Skip to content

Instantly share code, notes, and snippets.

@nathaningram
nathaningram / gist:3675d231574174810909
Created May 11, 2015 13:35
The Incredible Shrinking Header - jQuery
jQuery(function( $ ){
$(window).scroll(function () {
if ($(document).scrollTop() > 200 ) {
$('.builder-module-1-background-wrapper').addClass('shrink');
} else {
$('.builder-module-1-background-wrapper').removeClass('shrink');
}
});
@nathaningram
nathaningram / gist:f1ac3f88a357a05d321d
Last active August 29, 2015 14:20
The Incredible Shrinking Header - PHP Function
//* Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'ni_shrinking_header_script' );
function ni_shrinking_header_script() {
wp_enqueue_script( 'shrinking-header', get_bloginfo( 'stylesheet_directory' ) . '/js/shrinking-header.js', array( 'jquery' ), '1.0.0', true );
}
@nathaningram
nathaningram / gist:3daedafa11bfc72a6a77
Created May 11, 2015 15:40
The Incredible Shrinking Header - CSS
/*********************************************
Incredible Shrinking Header CSS
*********************************************/
/* Sticky Top Module */
.builder-module-1-background-wrapper {
background: #15384E;
position: fixed;
width: 100%;
@nathaningram
nathaningram / gist:965628501dff4eb241e3
Created June 8, 2015 15:36
Prefill Gravity Form with User Data
// Prefill Gravity Form with User Data
function populate_usermeta($meta_key){ global $current_user;
return $current_user->__get($meta_key);
}
add_filter('gform_field_value_userfirstname', create_function("", '$value = populate_usermeta(\'user_firstname\'); return $value;' ));
add_filter('gform_field_value_userlastname', create_function("", '$value = populate_usermeta(\'user_lastname\'); return $value;' ));
add_filter('gform_field_value_useremail', create_function("", '$value = populate_usermeta(\'user_email\'); return $value;' ));
add_filter('gform_field_value_userwebsite', create_function("", '$value = populate_usermeta(\'user_url\'); return $value;' ));
@nathaningram
nathaningram / gist:43ef5b3b1882e0412cbe
Created June 8, 2015 15:42
User First Name Shortcode
// First Name of Logged In User Shortcode
function ni_firstname() {
$user = wp_get_current_user();
$firstname = $user->user_firstname;
return $firstname;
}
add_shortcode('firstname', 'ni_firstname');
@nathaningram
nathaningram / gist:234d1063553cafd9be7a
Created June 8, 2015 15:56
Remove Login from Theme My Login Login
// Change the Theme My Login Login Template Header
function tml_title_filter( $title, $action ) {
if ( 'login' == $action ) return '';
return $title;
}
add_filter( 'tml_title', 'tml_title_filter', 10, 2 );
@nathaningram
nathaningram / gist:41b45ace1959bb9b9683
Created August 10, 2015 14:08
Remove Visual Composer Nag
// Remove Visual Composer Nag
add_action('admin_init', function()
{
setcookie('vchideactivationmsg', '1', strtotime('+3 years'), '/');
});
@nathaningram
nathaningram / gist:53b60b1286c3948669a1
Created August 10, 2015 14:12
Remove Visual Compose Meta Data
//Remove Visual Composer Meta Data
add_action('init', 'myoverride', 100);
function myoverride() {
remove_action('wp_head', array(visual_composer(), 'addMetaData'));
}
@nathaningram
nathaningram / gist:e4223705b0efb5fb86da
Created November 13, 2015 20:55
Design to Builder Shortcodes for functions.php
//Anti-Spam Email Shortcode
//Use this shortcode [emailme]nathan@brilliantly.net[/emailme]
function protect_email_address( $atts , $content=null ) {
for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>';
}
add_shortcode('emailme', 'protect_email_address');
add_theme_support( 'builder-responsive', array('tablet-width' => '1023px', 'mobile-width' => '767px' ));