Skip to content

Instantly share code, notes, and snippets.

View danielmcclure's full-sized avatar

Daniel McClure danielmcclure

View GitHub Profile
@danielmcclure
danielmcclure / robots.txt
Created December 10, 2014 00:38
Block search engines from accessing WordPress system files.
User-Agent: *
Disallow: /cgi-bin/
Disallow: /wp-admin/
Disallow: /wp-content/plugins/
Disallow: /wp-content/cache/
Disallow: /wp-content/themes/
Disallow: /wp-includes/
@danielmcclure
danielmcclure / custom_functions.php
Created December 10, 2014 03:54
Move the Thesis Navigation bar below the header
<?php
/* Move Thesis Navigation Below Header */
remove_action('thesis_hook_before_header' , 'thesis_nav_menu');
add_action('thesis_hook_after_header', 'thesis_nav_menu');
<?php
//* Do NOT include the opening php tag
//* Unregister primary sidebar
unregister_sidebar( 'sidebar' );
<?php
//* Do NOT include the opening php tag
//* Force content-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
//* Force sidebar-content layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' );
//* Force content-sidebar-sidebar layout setting
@danielmcclure
danielmcclure / functions.php
Created December 23, 2014 04:28
Adds an is_tree(''); function to check is page is a specific ID or ancestor of that ID in WordPress
<?php
//* Do NOT include the opening php tag
function is_tree( $pid ) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( is_page($pid) )
return true; // we're at the page or at a sub page
$anc = get_post_ancestors( $post->ID );
@danielmcclure
danielmcclure / functions.php
Created March 9, 2015 07:44
Responsive Viewport for WordPress
<?php
/**
* Viewport Meta Tag for Mobile Browsers
*
* @author Daniel McClure
*/
function tme_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
@danielmcclure
danielmcclure / functions.php
Created March 27, 2015 07:29
Auto-Login After Registration on Gravity Forms for WordPress
/*Auto-login After Gravity Forms Registration */
add_action( 'gform_user_registered', 'tme_gravity_registration_autologin', 10, 4 );
function tme_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {
$user = get_userdata( $user_id );
$user_login = $user->user_login;
$user_password = $password;
wp_signon( array(
'user_login' => $user_login,
'user_password' => $user_password,
@danielmcclure
danielmcclure / functions.php
Created April 5, 2015 09:07
Remove & Customise Gravity Forms Validation Messages
<?php
//* Change The Default Gravity Forms Validation Message
add_filter('gform_validation_message', 'change_validation_message', 10, 2);
function change_validation_message($message, $form) {
return "<div class='valuation-form-error'>Please entered your details below...</div>";
}
//* Remove The Gravity Forms Error Styling
add_filter( 'gform_field_css_class', function ( $css_class, $field ) {
@danielmcclure
danielmcclure / functions.php
Last active August 29, 2015 14:18
Shortcode To Only Display Content When User Is Logged In / Out
//* Add logged in content shortcode
function tme_is_logged_in ($params, $content = null) {
if ( is_user_logged_in() ){
return $content;
} else {
return;
}
}
add_shortcode('isloggedin', 'tme_is_logged_in' );
@danielmcclure
danielmcclure / functions.php
Created June 9, 2015 03:30
Add DuracellTomi's Google Tag Manager Plugin Code After Body Tag for Genesis Theme Framework
<?php
// Do not include the PHP tag above.
/* Add DuracellTomi's Google Tag Manager for WordPress Plugin Code After Body Tag */
add_action('genesis_before', 'google_tag_manager');
function google_tag_manager() { ?>
<!-- Google Tag Manager -->
<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>
<!-- End Google Tag Manager -->