Skip to content

Instantly share code, notes, and snippets.

View mattkeys's full-sized avatar

Matt Keys mattkeys

View GitHub Profile
<?php
/*
* Are You My Mother? by: Matt Keys
* Function: Pass an array of Prospective Page IDs along with the current Page ID.
* Return true if the current page is a child of any of the Prospective Page IDs.
* Optional: Set third parameter to TRUE if you want to check if the current page is a direct match to a Prospective Page ID
*/
function are_you_my_mother(array $prospective_page_ids, $current_page_id, $match_parent = false) {
// If match_parent is true, see if current page is a direct match before trying ancestors
$menu = wp_nav_plus(array('menu' => $instance['menu_term_id'], 'echo' => false, 'container' => false, 'items_wrap' => '%3$s', 'start_depth' => $instance['start_depth'], 'depth' => $instance['depth']));
if(!empty($menu)) {
echo 'your container html';
echo $menu;
echo 'end your container html here';
}
@mattkeys
mattkeys / gist:8135256
Created December 26, 2013 15:47
Gravity Forms business
// GRAVITY FORMS SUBMIT BUTTON STYLING
function form_submit_button($button, $form){
return "<input type='submit' id='gform_submit_button_{$form["id"]}' class='btn' value='Send Email'>";
}
add_filter("gform_submit_button_1", "form_submit_button", 10, 2);
// REMOVING GRAVITY FORMS FIELD LABELS
function form_required_label($content, $field, $value, $lead_id, $form_id){
$types = array('radio','checkbox','textarea','hidden');
@mattkeys
mattkeys / gist:3cd83f3ff9ca5f62ce4c
Last active August 29, 2015 14:15
Syntax Error
<?php
if ( is_active_nav_menu( 'primary' ) ) {
$divider_html = '';
wp_nav_menu( array(
'theme_location' => 'primary', // Setting up the location for the main-menu, Main Navigation.
'menu_class' => 'dropdown', //Adding the class for dropdowns
'divider_html' => $divider_html,
'container_id' => 'navwrap', //Add CSS ID to the containter that wraps the menu.
'fallback_cb' => 'wp_page_menu', //if wp_nav_menu is unavailable, WordPress displays wp_page_menu function, which displays the pages of your blog.
)
/**
* Get the Font Awesome CSS.
*
* @since 1.0.0
*
* @param string $url URL of the remote stylesheet.
* @param string $version Version of Font Awesome to fetch.
*
* @return string $response Font Awesome CSS, from either:
* 1. transient,
@mattkeys
mattkeys / acf_form_head_variant.php
Last active September 7, 2016 17:06
acf_form_head variant
public function new_submission()
{
acf_enqueue_scripts();
if ( ! acf_verify_nonce( 'acf_form' ) || ! acf_validate_save_post( true ) ) {
return;
}
add_filter('acf/pre_save_post', '_acf_pre_save_post', 5, 2);
Array
(
[list] => Array
(
[] =>
[fa-500px] => &#xf26e; 500px
[fa-address-book] => &#xf2b9; address-book
[fa-address-book-o] => &#xf2ba; address-book-o
[fa-address-card] => &#xf2bb; address-card
[fa-address-card-o] => &#xf2bc; address-card-o
@mattkeys
mattkeys / Fix WPML + ACF Parent Page Location Issues
Last active March 1, 2022 18:24
WPML doesn't properly handle field groups that are assigned to page parents. This filter fixes that.
// Make WPML compatible with ACF field groups with location set to 'page parent'
function filter_acf_location_rule_match_param( $result, $rule, $screen, $field_group ) {
$default_lang = apply_filters( 'wpml_default_language', NULL );
if ( ! isset( $screen['lang'] ) || $default_lang == $screen['lang'] ) {
return $result;
}
if ( ! isset( $screen['post_id'] ) || empty( $screen['post_id'] ) ) {
return $result;