Last active
October 16, 2016 22:34
-
-
Save BurlesonBrad/b4f29b80d1c81c0e2729 to your computer and use it in GitHub Desktop.
Yvan's functions.php file for the child theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Yvan's child theme functions.php file. You can "move" this child function.php into ANY (<---pretty cool, right?) child theme that you want. | |
* | |
* @package storefront-child | |
*/ | |
// DO NOT REMOVE THIS FUNCTION AS IT LOADS THE PARENT THEME STYLESHEET | |
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' ); | |
function enqueue_parent_theme_style() { | |
wp_enqueue_style( 'parent-style', get_stylesheet_directory_uri().'/style.css' ); | |
} | |
/* Add any custom PHP below this line of text */ | |
/** Add shortcode to widget */ | |
add_filter('widget_text', 'do_shortcode'); | |
/** Remove WooCommerce Update Nag */ | |
remove_action( 'admin_notices', 'woothemes_updater_notice' ); | |
/** Remove Storefront Footer Credit */ | |
add_action( 'init', 'custom_remove_footer_credit', 10 ); | |
function custom_remove_footer_credit () { | |
remove_action( 'storefront_footer', 'storefront_credit', 20 ); | |
add_action( 'storefront_footer', 'custom_storefront_credit', 20 ); | |
} | |
function custom_storefront_credit() { | |
?> | |
<div class="site-info"> | |
© <?php echo get_bloginfo( 'name' ) . ' ' . get_the_date( 'Y' ); ?> | |
</div><!-- .site-info --> | |
<?php | |
} | |
/** I want to get to ALL the settings in my dashboard! */ | |
function all_settings_link() { | |
add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php'); | |
} | |
add_action('admin_menu', 'all_settings_link'); | |
/**Remove Superfluous info In The Head! */ | |
function remove_header_info() { | |
remove_action( 'wp_head', 'rsd_link' ); | |
remove_action( 'wp_head', 'wlwmanifest_link' ); | |
remove_action( 'wp_head', 'wp_generator' ); | |
remove_action( 'wp_head', 'start_post_rel_link' ); | |
remove_action( 'wp_head', 'index_rel_link' ); | |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); // for WordPress >= 3.0 | |
} | |
add_action( 'init', 'remove_header_info' ); | |
/** Let's remove those pesky script version numbers! */ | |
function wpex_remove_script_version( $src ) { | |
if ( strpos( $src, 'ver=' ) ) { | |
$src = remove_query_arg( 'ver', $src ); | |
} | |
return $src; | |
} | |
add_filter( 'script_loader_src', 'wpex_remove_script_version', 15, 1 ); | |
add_filter( 'style_loader_src', 'wpex_remove_script_version', 15, 1 ); | |
/** Disable self-ping on internal links */ | |
function no_self_ping( &$links ) { | |
$home = get_option( 'home' ); | |
foreach ( $links as $l => $link ) | |
if ( 0 === strpos( $link, $home ) ) | |
unset($links[$l]); | |
} | |
add_action( 'pre_ping', 'no_self_ping' ); | |
/** Auto Complete all WooCommerce orders */ | |
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); | |
function custom_woocommerce_auto_complete_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
$order = wc_get_order( $order_id ); | |
$order->update_status( 'completed' ); | |
} | |
/** And, that's about all their is to it :-) Add whatever 'function' related items you want into this file. And if you ever decide to get a different child theme, simply pick this file up outta your old child thmes /folder and put it into your new child theme /folder. Pretty cool, right?!?!?!? **/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment