Last active
January 6, 2016 05:42
-
-
Save BurlesonBrad/b7d3a72cf590cbe403ff to your computer and use it in GitHub Desktop.
for Jonathan
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 | |
/** | |
* Plugin Name: Jonathan's Speed Plugin | |
* Plugin URI: https://bradgriffin.me | |
* Description: | |
* Version: 1 | |
* Author: Brad | |
* Author URI: https://bradgriffin.me | |
* Requires at least: 4.5 | |
* Tested up to: 4.5 | |
**/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
// BEGIN stop storing post revisions // | |
define( 'WP_POST_REVISIONS', -1 ); | |
// END stop storing post revisions // | |
// Move Proceed to Checkout button on cart page // | |
add_action( 'woocommerce_cart_actions', 'move_proceed_button' ); | |
function move_proceed_button( $checkout ) { | |
echo '<a href="' . esc_url( WC()->cart->get_checkout_url() ) . '" class="checkout-button button alt wc-forward" >' . __( 'Proceed to Checkout', 'woocommerce' ) . '</a>'; | |
} | |
// END Move Proceed to Checkout button on cart page // | |
/* Bye Emoji :-( */ | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
/* ...so sad */ | |
/** | |
* Optimize WooCommerce Scripts | |
* This will stop any WooCommerce from loading and running when your NOT on a WooCommerce page or product post type. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 ); | |
function child_manage_woocommerce_styles() { | |
//remove generator meta tag | |
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); | |
//first check that woo exists to prevent fatal errors | |
if ( function_exists( 'is_woocommerce' ) ) { | |
//dequeue scripts and styles | |
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { | |
wp_dequeue_style( 'woocommerce_frontend_styles' ); | |
wp_dequeue_style( 'woocommerce_fancybox_styles' ); | |
wp_dequeue_style( 'woocommerce_chosen_styles' ); | |
wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); | |
wp_dequeue_style( 'woocommerce-general' ); | |
wp_dequeue_style( 'woocommerce-layout' ); | |
wp_dequeue_style( 'woocommerce-smallscreen' ); | |
wp_dequeue_script( 'wc_price_slider' ); | |
wp_dequeue_script( 'wc-single-product' ); | |
wp_dequeue_script( 'wc-add-to-cart' ); | |
wp_dequeue_script( 'wc-cart-fragments' ); | |
wp_dequeue_script( 'wc-checkout' ); | |
wp_dequeue_script( 'wc-add-to-cart-variation' ); | |
wp_dequeue_script( 'wc-single-product' ); | |
wp_dequeue_script( 'wc-cart' ); | |
wp_dequeue_script( 'wc-chosen' ); | |
wp_dequeue_script( 'woocommerce' ); | |
wp_dequeue_script( 'prettyPhoto' ); | |
wp_dequeue_script( 'prettyPhoto-init' ); | |
wp_dequeue_script( 'jquery-blockui' ); | |
wp_dequeue_script( 'jquery-placeholder' ); | |
wp_dequeue_script( 'fancybox' ); | |
wp_dequeue_script( 'jqueryui' ); | |
} | |
} | |
} | |
// End WooCommerce Scripts Wonderful Code // | |
//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' ); | |
// End Cleaning up the head // | |
// 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 ); | |
// End script version number removal // | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment