Version Description
Release Date: 10 July 2019
- Fixed: Set the plugin URL as relative, to comply with SSL enabling plugins.
- Updated: Moved the Local (Google) Analytics script to the /wp-content/cache/ directory.
- Updated: Rewrote some code to comply with WordPress & PHP coding standards.
- Updated: The plugin's readme file has now only 5 tags, because the WordPress plugin directory only minds the first 5 tags. Heh.
Download this release
Release Info
| Developer | optimocha |
| Plugin | |
| Version | 3.8.3 |
| Comparing to | |
| See all releases | |
Code changes from version 3.8.2.1 to 3.8.3
- inc/core.php +218 -177
- inc/template/options.php +14 -2
- readme.txt +11 -2
- speed-booster-pack.php +3 -3
inc/core.php
CHANGED
|
@@ -12,55 +12,91 @@ if( !defined( 'ABSPATH' ) ) {
|
|
| 12 |
if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
| 13 |
|
| 14 |
class Speed_Booster_Pack_Core {
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
public function __construct() {
|
| 17 |
|
| 18 |
global $sbp_options;
|
| 19 |
|
|
|
|
|
|
|
| 20 |
add_action( 'wp_enqueue_scripts', array( $this, 'sbp_move_scripts_to_footer' ) );
|
| 21 |
-
|
|
|
|
| 22 |
add_action( 'wp_head', array( $this, 'sbp_scripts_to_head' ) );
|
| 23 |
}
|
| 24 |
|
| 25 |
add_action( 'after_setup_theme', array( $this, 'sbp_junk_header_tags' ) );
|
| 26 |
add_action( 'init', array( $this, 'sbp_init' ) );
|
|
|
|
| 27 |
//enable cdn rewrite
|
| 28 |
-
if(
|
| 29 |
-
add_action('template_redirect', array($this,'sbp_cdn_rewrite'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
// Start GA
|
| 33 |
-
if(
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
-
if(
|
| 39 |
-
add_filter('monsterinsights_frontend_output_analytics_src',
|
| 40 |
}
|
| 41 |
else {
|
| 42 |
-
|
|
|
|
| 43 |
$tracking_code_position = 'wp_footer';
|
| 44 |
}
|
| 45 |
else {
|
| 46 |
$tracking_code_position = 'wp_head';
|
| 47 |
}
|
| 48 |
-
add_action($tracking_code_position, array($this,'sbp_print_ga'), 0);
|
| 49 |
}
|
| 50 |
}
|
| 51 |
else {
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
-
add_action('sbp_update_ga', array($this,'sbp_update_ga'));
|
| 58 |
// End GA
|
| 59 |
|
| 60 |
$this->sbp_css_optimizer(); // CSS Optimizer functions
|
| 61 |
|
| 62 |
// Minifier
|
| 63 |
-
if ( ! is_admin() and isset( $sbp_options['minify_html_js'] ) ) {
|
| 64 |
$this->sbp_minifier();
|
| 65 |
}
|
| 66 |
|
|
@@ -70,7 +106,7 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 70 |
}
|
| 71 |
|
| 72 |
// Remove query strings from static resources
|
| 73 |
-
if ( ! is_admin() and isset( $sbp_options['query_strings'] ) ) {
|
| 74 |
add_filter( 'script_loader_src', array( $this, 'sbp_remove_query_strings' ), 15, 1 );
|
| 75 |
add_filter( 'style_loader_src', array( $this, 'sbp_remove_query_strings' ), 15, 1 );
|
| 76 |
}
|
|
@@ -79,18 +115,10 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 79 |
* @since 3.7
|
| 80 |
*/
|
| 81 |
// Disable emojis
|
| 82 |
-
if ( ! is_admin() && isset( $sbp_options['remove_emojis'] ) ) {
|
| 83 |
add_action( 'init', array( $this, 'sbp_disable_emojis' ) );
|
| 84 |
}
|
| 85 |
|
| 86 |
-
/**
|
| 87 |
-
* @since 3.8
|
| 88 |
-
*/
|
| 89 |
-
// Disable Cart Fragments
|
| 90 |
-
if( isset( $sbp_options[ 'disable_cart_fragments' ] ) && class_exists( 'woocommerce' ) ) {
|
| 91 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'sbp_disable_cart_fragments' ), 999 );
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
/**
|
| 95 |
* @since 3.8
|
| 96 |
*/
|
|
@@ -118,10 +146,6 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 118 |
add_action( 'wp_loaded', array( $this, 'sbp_disable_google_maps' ) );
|
| 119 |
}
|
| 120 |
|
| 121 |
-
if ( isset( $sbp_options['disable_password_strength_meter'] ) ) {
|
| 122 |
-
add_action( 'wp_print_scripts', array( $this, 'sbp_disable_password_strength_meter' ), 100 );
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
if ( isset( $sbp_options['disable_heartbeat'] ) ) {
|
| 126 |
add_action( 'init', array( $this, 'sbp_disable_heartbeat' ), 1 );
|
| 127 |
}
|
|
@@ -147,6 +171,41 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 147 |
|
| 148 |
} // END public public function __construct
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
/**
|
| 151 |
* @since 3.8.1
|
| 152 |
*/
|
|
@@ -215,7 +274,7 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 215 |
|
| 216 |
$wp_check = isset( $wp->query_vars['lost-password'] ) || ( isset( $_GET['action'] ) && $_GET['action'] === 'lostpassword' ) || is_page( 'lost_password' );
|
| 217 |
|
| 218 |
-
$wc_check = (
|
| 219 |
|
| 220 |
if ( ! $wp_check && ! $wc_check ) {
|
| 221 |
if ( wp_script_is( 'zxcvbn-async', 'enqueued' ) ) {
|
|
@@ -345,12 +404,12 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 345 |
|
| 346 |
} // END function sbp_move_scripts_to_footer
|
| 347 |
|
| 348 |
-
|
| 349 |
/*--------------------------------------------------------------------------------------------------------
|
| 350 |
Put scripts back to the head
|
| 351 |
---------------------------------------------------------------------------------------------------------*/
|
| 352 |
|
| 353 |
public function sbp_scripts_to_head() {
|
|
|
|
| 354 |
/**
|
| 355 |
* Default: add jQuery to header always
|
| 356 |
*
|
|
@@ -736,179 +795,161 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
| 736 |
} // END public function sbp_junk_header_tags
|
| 737 |
|
| 738 |
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
function sbp_cdn_rewriter($html) {
|
| 748 |
-
global $sbp_options;
|
| 749 |
-
$sbp_cdn_directories = $sbp_options['sbp_cdn_included_directories'];
|
| 750 |
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 761 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 762 |
}
|
| 763 |
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
if(!empty($sbp_cdn_excluded)) {
|
| 780 |
-
$exclusions = array_map('trim', explode(',', $sbp_cdn_excluded));
|
| 781 |
-
foreach($exclusions as $exclusion) {
|
| 782 |
-
if(!empty($exclusion) && stristr($url[0], $exclusion) != false) {
|
| 783 |
-
return $url[0];
|
| 784 |
}
|
| 785 |
}
|
| 786 |
-
}
|
| 787 |
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
//Prep Site URL
|
| 794 |
-
$siteURL = get_option('home');
|
| 795 |
-
$siteURL = substr($siteURL, strpos($siteURL, '//'));
|
| 796 |
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
}
|
| 801 |
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
//Replace Relative URL
|
| 807 |
-
return $sbp_cdn_url . $url[0];
|
| 808 |
-
}
|
| 809 |
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
/*--------------------------------------------
|
| 815 |
-
Google Analytics
|
| 816 |
-
--------------------------------------------*/
|
| 817 |
-
|
| 818 |
-
//update analytics.js
|
| 819 |
-
function sbp_update_ga() {
|
| 820 |
-
//paths
|
| 821 |
-
$local_file = SPEED_BOOSTER_PACK_URL. 'inc/js/analytics.js';
|
| 822 |
-
$host = 'www.google-analytics.com';
|
| 823 |
-
$path = '/analytics.js';
|
| 824 |
-
|
| 825 |
-
//open connection
|
| 826 |
-
$fp = @fsockopen($host, '80', $errno, $errstr, 10);
|
| 827 |
-
|
| 828 |
-
if($fp){
|
| 829 |
-
//send headers
|
| 830 |
-
$header = "GET $path HTTP/1.0\r\n";
|
| 831 |
-
$header.= "Host: $host\r\n";
|
| 832 |
-
$header.= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6\r\n";
|
| 833 |
-
$header.= "Accept: */*\r\n";
|
| 834 |
-
$header.= "Accept-Language: en-us,en;q=0.5\r\n";
|
| 835 |
-
$header.= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
|
| 836 |
-
$header.= "Keep-Alive: 300\r\n";
|
| 837 |
-
$header.= "Connection: keep-alive\r\n";
|
| 838 |
-
$header.= "Referer: https://$host\r\n\r\n";
|
| 839 |
-
fwrite($fp, $header);
|
| 840 |
-
$response = '';
|
| 841 |
-
|
| 842 |
-
//get response
|
| 843 |
-
while($line = fread($fp, 4096)) {
|
| 844 |
-
$response.= $line;
|
| 845 |
-
}
|
| 846 |
-
|
| 847 |
-
//close connection
|
| 848 |
-
fclose($fp);
|
| 849 |
-
|
| 850 |
-
//remove headers
|
| 851 |
-
$position = strpos($response, "\r\n\r\n");
|
| 852 |
-
$response = substr($response, $position + 4);
|
| 853 |
-
|
| 854 |
-
//create file if needed
|
| 855 |
-
if(!file_exists($local_file)) {
|
| 856 |
-
fopen($local_file, 'w');
|
| 857 |
-
}
|
| 858 |
-
|
| 859 |
-
//write response to file
|
| 860 |
-
if(is_writable($local_file)) {
|
| 861 |
-
if($fp = fopen($local_file, 'w')) {
|
| 862 |
-
fwrite($fp, $response);
|
| 863 |
-
fclose($fp);
|
| 864 |
}
|
|
|
|
|
|
|
| 865 |
}
|
|
|
|
|
|
|
|
|
|
| 866 |
}
|
| 867 |
-
}
|
| 868 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
global $sbp_options;
|
| 873 |
|
| 874 |
-
|
| 875 |
-
if(current_user_can('manage_options') && empty($sbp_options['sbp_track_loggedin_admins'])) {
|
| 876 |
-
return;
|
| 877 |
}
|
| 878 |
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
echo "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','" . SPEED_BOOSTER_PACK_URL . "inc/js/analytics.js','ga');\n";
|
| 883 |
-
echo "ga('create', '" . $sbp_options['sbp_ga_tracking_id'] . "', 'auto');\n";
|
| 884 |
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
}
|
| 889 |
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
}
|
| 894 |
|
| 895 |
-
|
| 896 |
|
| 897 |
-
|
| 898 |
-
if(!empty($sbp_options['sbp_bounce_rate'])) {
|
| 899 |
-
echo 'setTimeout("ga(' . "'send','event','adjusted bounce rate','" . $sbp_options['sbp_bounce_rate'] . " seconds')" . '"' . "," . $sbp_options['sbp_bounce_rate'] * 1000 . ");\n";
|
| 900 |
-
}
|
| 901 |
|
| 902 |
-
|
| 903 |
-
echo "<!-- End of Local Analytics. -->\n\n";
|
| 904 |
}
|
| 905 |
-
}
|
| 906 |
|
| 907 |
-
//return local anlytics url for Monster Insights
|
| 908 |
-
function sbp_monster_ga($url) {
|
| 909 |
-
return SPEED_BOOSTER_PACK_URL . "/inc/js/analytics.js";
|
| 910 |
-
}
|
| 911 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 912 |
|
| 913 |
-
}
|
| 914 |
-
}
|
| 12 |
if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
| 13 |
|
| 14 |
class Speed_Booster_Pack_Core {
|
| 15 |
+
private $local_cache_dir = '/cache/';
|
| 16 |
+
private $remote_ga_script = 'https://www.google-analytics.com/analytics.js';
|
| 17 |
+
private $local_ga_script;
|
| 18 |
|
| 19 |
public function __construct() {
|
| 20 |
|
| 21 |
global $sbp_options;
|
| 22 |
|
| 23 |
+
$this->local_ga_script = $this->local_cache_dir . 'speed-booster/analytics.js';
|
| 24 |
+
|
| 25 |
add_action( 'wp_enqueue_scripts', array( $this, 'sbp_move_scripts_to_footer' ) );
|
| 26 |
+
|
| 27 |
+
if ( ! is_admin() and isset( $sbp_options[ 'jquery_to_footer' ] ) ) {
|
| 28 |
add_action( 'wp_head', array( $this, 'sbp_scripts_to_head' ) );
|
| 29 |
}
|
| 30 |
|
| 31 |
add_action( 'after_setup_theme', array( $this, 'sbp_junk_header_tags' ) );
|
| 32 |
add_action( 'init', array( $this, 'sbp_init' ) );
|
| 33 |
+
|
| 34 |
//enable cdn rewrite
|
| 35 |
+
if( isset( $sbp_options[ 'sbp_enable_cdn' ] ) && $sbp_options[ 'sbp_enable_cdn' ] == "1" && isset( $sbp_options[ 'sbp_cdn_url' ] ) ) {
|
| 36 |
+
add_action( 'template_redirect', array( $this, 'sbp_cdn_rewrite' ) );
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// WooCommerce optimizing features
|
| 40 |
+
if( $this->sbp_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
| 41 |
+
/**
|
| 42 |
+
* @since 3.8.3
|
| 43 |
+
*/
|
| 44 |
+
if( isset( $sbp_options[ 'dequeue_wc_scripts' ] ) ) {
|
| 45 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'sbp_dequeue_wc_scripts' ) );
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @since 3.8
|
| 50 |
+
*/
|
| 51 |
+
// Disable Cart Fragments
|
| 52 |
+
if( isset( $sbp_options[ 'disable_cart_fragments' ] ) ) {
|
| 53 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'sbp_disable_cart_fragments' ), 999 );
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Disable password strength meter
|
| 58 |
+
* @since 3.8.3
|
| 59 |
+
*/
|
| 60 |
+
if( isset( $sbp_options[ 'disable_password_strength_meter' ] ) ) {
|
| 61 |
+
add_action( 'wp_print_scripts', array( $this, 'sbp_disable_password_strength_meter' ), 100 );
|
| 62 |
+
}
|
| 63 |
}
|
| 64 |
|
| 65 |
// Start GA
|
| 66 |
+
if( isset( $sbp_options[ 'sbp_enable_local_analytics' ] ) && $sbp_options[ 'sbp_enable_local_analytics' ] == "1" ) {
|
| 67 |
+
|
| 68 |
+
if( !wp_next_scheduled( 'sbp_update_ga' ) ) {
|
| 69 |
+
wp_schedule_event( time(), 'daily', 'sbp_update_ga' );
|
| 70 |
}
|
| 71 |
|
| 72 |
+
if( isset( $sbp_options[ 'sbp_monsterinsights' ] ) && $sbp_options[ 'sbp_monsterinsights' ] == "1" ) {
|
| 73 |
+
add_filter( 'monsterinsights_frontend_output_analytics_src', WP_CONTENT_URL . $this->local_ga_script, 1000 );
|
| 74 |
}
|
| 75 |
else {
|
| 76 |
+
|
| 77 |
+
if( isset( $sbp_options[ 'sbp_tracking_position' ] ) && $sbp_options[ 'sbp_tracking_position' ] == 'footer' ) {
|
| 78 |
$tracking_code_position = 'wp_footer';
|
| 79 |
}
|
| 80 |
else {
|
| 81 |
$tracking_code_position = 'wp_head';
|
| 82 |
}
|
| 83 |
+
add_action( $tracking_code_position, array( $this, 'sbp_print_ga' ), 0 );
|
| 84 |
}
|
| 85 |
}
|
| 86 |
else {
|
| 87 |
+
|
| 88 |
+
if( wp_next_scheduled( 'sbp_update_ga' ) ) {
|
| 89 |
+
wp_clear_scheduled_hook( 'sbp_update_ga' );
|
| 90 |
}
|
| 91 |
}
|
| 92 |
|
| 93 |
+
add_action( 'sbp_update_ga', array( $this, 'sbp_update_ga' ) );
|
| 94 |
// End GA
|
| 95 |
|
| 96 |
$this->sbp_css_optimizer(); // CSS Optimizer functions
|
| 97 |
|
| 98 |
// Minifier
|
| 99 |
+
if ( ! is_admin() and isset( $sbp_options[ 'minify_html_js' ] ) ) {
|
| 100 |
$this->sbp_minifier();
|
| 101 |
}
|
| 102 |
|
| 106 |
}
|
| 107 |
|
| 108 |
// Remove query strings from static resources
|
| 109 |
+
if ( ! is_admin() and isset( $sbp_options[ 'query_strings' ] ) ) {
|
| 110 |
add_filter( 'script_loader_src', array( $this, 'sbp_remove_query_strings' ), 15, 1 );
|
| 111 |
add_filter( 'style_loader_src', array( $this, 'sbp_remove_query_strings' ), 15, 1 );
|
| 112 |
}
|
| 115 |
* @since 3.7
|
| 116 |
*/
|
| 117 |
// Disable emojis
|
| 118 |
+
if ( ! is_admin() && isset( $sbp_options[ 'remove_emojis' ] ) ) {
|
| 119 |
add_action( 'init', array( $this, 'sbp_disable_emojis' ) );
|
| 120 |
}
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
/**
|
| 123 |
* @since 3.8
|
| 124 |
*/
|
| 146 |
add_action( 'wp_loaded', array( $this, 'sbp_disable_google_maps' ) );
|
| 147 |
}
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
if ( isset( $sbp_options['disable_heartbeat'] ) ) {
|
| 150 |
add_action( 'init', array( $this, 'sbp_disable_heartbeat' ), 1 );
|
| 151 |
}
|
| 171 |
|
| 172 |
} // END public public function __construct
|
| 173 |
|
| 174 |
+
/**
|
| 175 |
+
* Check if a plugin is active or not.
|
| 176 |
+
* @since 3.8.3
|
| 177 |
+
*/
|
| 178 |
+
function sbp_is_plugin_active( $path ) {
|
| 179 |
+
return in_array( $path, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Dequeue WooCommerce scripts on non-WC pages.
|
| 184 |
+
* @since 3.8.3
|
| 185 |
+
*/
|
| 186 |
+
function sbp_dequeue_wc_scripts() {
|
| 187 |
+
// check for woocommerce is currently inactive
|
| 188 |
+
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
|
| 189 |
+
// dequeue WooCommerce styles
|
| 190 |
+
wp_dequeue_style( 'woocommerce_chosen_styles' );
|
| 191 |
+
wp_dequeue_style( 'woocommerce_fancybox_styles' );
|
| 192 |
+
wp_dequeue_style( 'woocommerce_frontend_styles' );
|
| 193 |
+
wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
|
| 194 |
+
|
| 195 |
+
// dequeue WooCommerce scripts
|
| 196 |
+
wp_dequeue_script( 'wc-add-to-cart' );
|
| 197 |
+
wp_dequeue_script( 'wc-add-to-cart-variation' );
|
| 198 |
+
wp_dequeue_script( 'wc-cart' );
|
| 199 |
+
wp_dequeue_script( 'wc-cart-fragments' );
|
| 200 |
+
wp_dequeue_script( 'wc-checkout' );
|
| 201 |
+
wp_dequeue_script( 'wc-chosen' );
|
| 202 |
+
wp_dequeue_script( 'wc-single-product' );
|
| 203 |
+
wp_dequeue_script( 'wc-single-product' );
|
| 204 |
+
wp_dequeue_script( 'wc_price_slider' );
|
| 205 |
+
wp_dequeue_script( 'woocommerce' );
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
/**
|
| 210 |
* @since 3.8.1
|
| 211 |
*/
|
| 274 |
|
| 275 |
$wp_check = isset( $wp->query_vars['lost-password'] ) || ( isset( $_GET['action'] ) && $_GET['action'] === 'lostpassword' ) || is_page( 'lost_password' );
|
| 276 |
|
| 277 |
+
$wc_check = ( ( is_account_page() || is_checkout() ) );
|
| 278 |
|
| 279 |
if ( ! $wp_check && ! $wc_check ) {
|
| 280 |
if ( wp_script_is( 'zxcvbn-async', 'enqueued' ) ) {
|
| 404 |
|
| 405 |
} // END function sbp_move_scripts_to_footer
|
| 406 |
|
|
|
|
| 407 |
/*--------------------------------------------------------------------------------------------------------
|
| 408 |
Put scripts back to the head
|
| 409 |
---------------------------------------------------------------------------------------------------------*/
|
| 410 |
|
| 411 |
public function sbp_scripts_to_head() {
|
| 412 |
+
|
| 413 |
/**
|
| 414 |
* Default: add jQuery to header always
|
| 415 |
*
|
| 795 |
} // END public function sbp_junk_header_tags
|
| 796 |
|
| 797 |
|
| 798 |
+
/*--------------------------------
|
| 799 |
+
CDN Rewrite URLs
|
| 800 |
+
---------------------------------*/
|
| 801 |
+
|
| 802 |
+
function sbp_cdn_rewrite() {
|
| 803 |
+
ob_start(array($this,'sbp_cdn_rewriter'));
|
| 804 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 805 |
|
| 806 |
+
function sbp_cdn_rewriter($html) {
|
| 807 |
+
global $sbp_options;
|
| 808 |
+
$sbp_cdn_directories = $sbp_options['sbp_cdn_included_directories'];
|
| 809 |
|
| 810 |
+
//Prep Site URL
|
| 811 |
+
$escapedSiteURL = quotemeta(get_option('home'));
|
| 812 |
+
$regExURL = '(https?:|)' . substr($escapedSiteURL, strpos($escapedSiteURL, '//'));
|
| 813 |
+
|
| 814 |
+
//Prep Included Directories
|
| 815 |
+
$directories = 'wp\-content|wp\-includes';
|
| 816 |
+
if(!empty($sbp_cdn_directories)) {
|
| 817 |
+
$directoriesArray = array_map('trim', explode(',', $sbp_cdn_directories));
|
| 818 |
+
if(count($directoriesArray) > 0) {
|
| 819 |
+
$directories = implode('|', array_map('quotemeta', array_filter($directoriesArray)));
|
| 820 |
+
}
|
| 821 |
}
|
| 822 |
+
|
| 823 |
+
//Rewrite URLs + Return
|
| 824 |
+
$regEx = '#(?<=[(\"\'])(?:' . $regExURL . ')?/(?:((?:' . $directories . ')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
|
| 825 |
+
$cdnHTML = preg_replace_callback($regEx, array($this,'sbp_cdn_rewrite_url'), $html);
|
| 826 |
+
return $cdnHTML;
|
| 827 |
}
|
| 828 |
|
| 829 |
+
function sbp_cdn_rewrite_url($url) {
|
| 830 |
+
global $sbp_options;
|
| 831 |
+
$sbp_cdn_url = $sbp_options['sbp_cdn_url'];
|
| 832 |
+
$sbp_cdn_excluded = $sbp_options['sbp_cdn_exclusions'];
|
| 833 |
+
|
| 834 |
+
//Make Sure CDN URL is Set
|
| 835 |
+
if(!empty($sbp_cdn_url)) {
|
| 836 |
+
|
| 837 |
+
//Don't Rewrite if Excluded
|
| 838 |
+
if(!empty($sbp_cdn_excluded)) {
|
| 839 |
+
$exclusions = array_map('trim', explode(',', $sbp_cdn_excluded));
|
| 840 |
+
foreach($exclusions as $exclusion) {
|
| 841 |
+
if(!empty($exclusion) && stristr($url[0], $exclusion) != false) {
|
| 842 |
+
return $url[0];
|
| 843 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 844 |
}
|
| 845 |
}
|
|
|
|
| 846 |
|
| 847 |
+
//Don't Rewrite if Previewing
|
| 848 |
+
if(is_admin_bar_showing() && isset($_GET['preview']) && $_GET['preview'] == 'true') {
|
| 849 |
+
return $url[0];
|
| 850 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
|
| 852 |
+
//Prep Site URL
|
| 853 |
+
$siteURL = get_option('home');
|
| 854 |
+
$siteURL = substr($siteURL, strpos($siteURL, '//'));
|
|
|
|
| 855 |
|
| 856 |
+
//Replace URL w/ No HTTP/S Prefix
|
| 857 |
+
if(strpos($url[0], '//') === 0) {
|
| 858 |
+
return str_replace($siteURL, $sbp_cdn_url, $url[0]);
|
| 859 |
+
}
|
|
|
|
|
|
|
|
|
|
| 860 |
|
| 861 |
+
//Found Site URL, Replace Non Relative URL w/ HTTP/S Prefix
|
| 862 |
+
if(strstr($url[0], $siteURL)) {
|
| 863 |
+
return str_replace(array('http:' . $siteURL, 'https:' . $siteURL), $sbp_cdn_url, $url[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 864 |
}
|
| 865 |
+
//Replace Relative URL
|
| 866 |
+
return $sbp_cdn_url . $url[0];
|
| 867 |
}
|
| 868 |
+
|
| 869 |
+
//Return Original URL
|
| 870 |
+
return $url[0];
|
| 871 |
}
|
|
|
|
| 872 |
|
| 873 |
+
/*--------------------------------------------
|
| 874 |
+
File processor
|
| 875 |
+
--------------------------------------------*/
|
| 876 |
+
|
| 877 |
+
function file_process() {
|
| 878 |
+
global $wp_filesystem;
|
| 879 |
|
| 880 |
+
require_once ( ABSPATH . '/wp-admin/includes/file.php' );
|
| 881 |
+
WP_Filesystem();
|
|
|
|
| 882 |
|
| 883 |
+
return $wp_filesystem;
|
|
|
|
|
|
|
| 884 |
}
|
| 885 |
|
| 886 |
+
/*--------------------------------------------
|
| 887 |
+
Google Analytics
|
| 888 |
+
--------------------------------------------*/
|
|
|
|
|
|
|
| 889 |
|
| 890 |
+
//update analytics.js
|
| 891 |
+
function sbp_update_ga() {
|
| 892 |
+
$wp_filesystem = $this->file_process();
|
|
|
|
| 893 |
|
| 894 |
+
if( !$wp_filesystem->exists( WP_CONTENT_DIR . $this->local_cache_dir . 'speed-booster/' ) ) {
|
| 895 |
+
$wp_filesystem->mkdir( WP_CONTENT_DIR . $this->local_cache_dir, FS_CHMOD_DIR );
|
| 896 |
+
$wp_filesystem->mkdir( WP_CONTENT_DIR . $this->local_cache_dir . 'speed-booster/', FS_CHMOD_DIR );
|
| 897 |
}
|
| 898 |
|
| 899 |
+
$file_content = $wp_filesystem->get_contents( $this->remote_ga_script );
|
| 900 |
|
| 901 |
+
if( $wp_filesystem->put_contents( WP_CONTENT_DIR . $this->local_ga_script, $file_content, FS_CHMOD_FILE ) ) return true;
|
|
|
|
|
|
|
|
|
|
| 902 |
|
| 903 |
+
return false;
|
|
|
|
| 904 |
}
|
|
|
|
| 905 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 906 |
|
| 907 |
+
//print analytics script
|
| 908 |
+
function sbp_print_ga() {
|
| 909 |
+
global $sbp_options;
|
| 910 |
+
|
| 911 |
+
//dont print for logged in admins
|
| 912 |
+
if( current_user_can( 'manage_options' ) && empty( $sbp_options[ 'sbp_track_loggedin_admins' ] ) ) {
|
| 913 |
+
return;
|
| 914 |
+
}
|
| 915 |
+
|
| 916 |
+
if( isset( $sbp_options[ 'sbp_ga_tracking_id' ] ) && !empty( $sbp_options[ 'sbp_ga_tracking_id' ] ) ) {
|
| 917 |
+
$wp_filesystem = $this->file_process();
|
| 918 |
+
$ga_script = WP_CONTENT_URL . $this->local_ga_script;
|
| 919 |
+
|
| 920 |
+
if( !$wp_filesystem->exists( WP_CONTENT_DIR . $this->local_ga_script ) ) {
|
| 921 |
+
|
| 922 |
+
if( !$this->sbp_update_ga() ) {
|
| 923 |
+
$ga_script = $this->remote_ga_script;
|
| 924 |
+
}
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
echo "\n\n<!-- Local Analytics generated with Speed Booster Pack by Optimocha. -->\n";
|
| 928 |
+
echo "<script>\n";
|
| 929 |
+
echo "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','" . $ga_script . "','ga');\n";
|
| 930 |
+
echo "ga('create', '" . $sbp_options[ 'sbp_ga_tracking_id' ] . "', 'auto');\n";
|
| 931 |
+
|
| 932 |
+
//disable display features
|
| 933 |
+
if( !empty( $sbp_options[ 'sbp_disable_display_features' ] ) && $sbp_options[ 'sbp_disable_display_features' ] == "1") {
|
| 934 |
+
echo "ga('set', 'allowAdFeatures', false);\n";
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
//anonymize ip
|
| 938 |
+
if( !empty( $sbp_options[ 'sbp_anonymize_ip' ] ) && $sbp_options[ 'sbp_anonymize_ip' ] == "1" ) {
|
| 939 |
+
echo "ga('set', 'anonymizeIp', true);\n";
|
| 940 |
+
}
|
| 941 |
+
|
| 942 |
+
echo "ga('send', 'pageview');\n";
|
| 943 |
+
|
| 944 |
+
//adjusted bounce rate
|
| 945 |
+
if( !empty( $sbp_options[ 'sbp_bounce_rate' ] ) ) {
|
| 946 |
+
echo 'setTimeout("ga(' . "'send','event','adjusted bounce rate','" . $sbp_options[ 'sbp_bounce_rate' ] . " seconds')" . '"' . "," . $sbp_options[ 'sbp_bounce_rate' ] * 1000 . ");\n";
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
echo "</script>\n";
|
| 950 |
+
echo "<!-- End of Local Analytics. -->\n\n";
|
| 951 |
+
}
|
| 952 |
+
}
|
| 953 |
|
| 954 |
+
} // END class Speed_Booster_Pack_Core
|
| 955 |
+
} // END if(!class_exists('Speed_Booster_Pack_Core'))
|
inc/template/options.php
CHANGED
|
@@ -173,16 +173,28 @@ if ( is_array( $option_arr ) && in_array( 'defer-from-footer', $option_arr ) ) {
|
|
| 173 |
'items' => array(
|
| 174 |
'enable_instant_page' => array(
|
| 175 |
'type' => 'checkbox',
|
| 176 |
-
'label' => __( 'Enable instant.page
|
| 177 |
'tooltip' => __( 'Check this option if you want to use the instant.page link preloader. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.', 'speed-booster-pack' ),
|
| 178 |
'options_group' => 'sbp_settings',
|
| 179 |
),
|
| 180 |
'disable_cart_fragments' => array(
|
| 181 |
'type' => 'checkbox',
|
| 182 |
-
'label' => __( 'Disable cart fragments
|
| 183 |
'tooltip' => __( 'Check this option to disable WooCommerce's "cart fragments" script, which overrides all caching function to update cart totals on each page load in your theme header. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.', 'speed-booster-pack' ),
|
| 184 |
'options_group' => 'sbp_settings',
|
| 185 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
'disable_google_maps' => array(
|
| 187 |
'type' => 'checkbox',
|
| 188 |
'label' => __( 'Remove Google Maps', 'speed-booster-pack' ),
|
| 173 |
'items' => array(
|
| 174 |
'enable_instant_page' => array(
|
| 175 |
'type' => 'checkbox',
|
| 176 |
+
'label' => __( 'Enable instant.page', 'speed-booster-pack' ),
|
| 177 |
'tooltip' => __( 'Check this option if you want to use the instant.page link preloader. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.', 'speed-booster-pack' ),
|
| 178 |
'options_group' => 'sbp_settings',
|
| 179 |
),
|
| 180 |
'disable_cart_fragments' => array(
|
| 181 |
'type' => 'checkbox',
|
| 182 |
+
'label' => __( 'WooCommerce: Disable cart fragments', 'speed-booster-pack' ),
|
| 183 |
'tooltip' => __( 'Check this option to disable WooCommerce's "cart fragments" script, which overrides all caching function to update cart totals on each page load in your theme header. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.', 'speed-booster-pack' ),
|
| 184 |
'options_group' => 'sbp_settings',
|
| 185 |
),
|
| 186 |
+
'dequeue_wc_scripts' => array(
|
| 187 |
+
'type' => 'checkbox',
|
| 188 |
+
'label' => __( '(BETA) Remove WooCommerce scripts in non-WC pages', 'speed-booster-pack' ),
|
| 189 |
+
'tooltip' => __( 'Check this option if you want to remove WooCommerce scripts in non-WooCommerce pages. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.', 'speed-booster-pack' ),
|
| 190 |
+
'options_group' => 'sbp_settings',
|
| 191 |
+
),
|
| 192 |
+
'disable_password_strength_meter' => array(
|
| 193 |
+
'type' => 'checkbox',
|
| 194 |
+
'label' => __( '(BETA) WooCommerce: Disable password strength meter', 'speed-booster-pack' ),
|
| 195 |
+
'tooltip' => __( 'Check this option if you want to disable WooCommerce password strength meter. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.', 'speed-booster-pack' ),
|
| 196 |
+
'options_group' => 'sbp_settings',
|
| 197 |
+
),
|
| 198 |
'disable_google_maps' => array(
|
| 199 |
'type' => 'checkbox',
|
| 200 |
'label' => __( 'Remove Google Maps', 'speed-booster-pack' ),
|
readme.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
=== Speed Booster Pack ===
|
| 2 |
Contributors: optimocha
|
| 3 |
-
Tags: speed,
|
| 4 |
Requires at least: 4.6
|
| 5 |
Tested up to: 5.2.1
|
| 6 |
Requires PHP: 5.6
|
| 7 |
-
Stable tag: 3.8.
|
| 8 |
License: GPLv3 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 10 |
|
|
@@ -53,6 +53,15 @@ Speed Booster Pack is a plugin that can help you speed up your website by tweaki
|
|
| 53 |
|
| 54 |
== Changelog ==
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
= 3.8.2.1 =
|
| 57 |
|
| 58 |
*Release Date: 04 June 2019*
|
| 1 |
=== Speed Booster Pack ===
|
| 2 |
Contributors: optimocha
|
| 3 |
+
Tags: speed, performance, javascript optimization, css optimization, google pagespeed
|
| 4 |
Requires at least: 4.6
|
| 5 |
Tested up to: 5.2.1
|
| 6 |
Requires PHP: 5.6
|
| 7 |
+
Stable tag: 3.8.3
|
| 8 |
License: GPLv3 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 10 |
|
| 53 |
|
| 54 |
== Changelog ==
|
| 55 |
|
| 56 |
+
= 3.8.3 =
|
| 57 |
+
|
| 58 |
+
*Release Date: 10 July 2019*
|
| 59 |
+
|
| 60 |
+
* **Fixed**: Set the plugin URL as relative, to comply with SSL enabling plugins.
|
| 61 |
+
* **Updated**: Moved the Local (Google) Analytics script to the /wp-content/cache/ directory.
|
| 62 |
+
* **Updated**: Rewrote some code to comply with WordPress & PHP coding standards.
|
| 63 |
+
* **Updated**: The plugin's readme file has now only 5 tags, because the WordPress plugin directory only minds the first 5 tags. Heh.
|
| 64 |
+
|
| 65 |
= 3.8.2.1 =
|
| 66 |
|
| 67 |
*Release Date: 04 June 2019*
|
speed-booster-pack.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* Plugin URI: http://wordpress.org/plugins/speed-booster-pack/
|
| 5 |
* Description: Speed Booster Pack helps you improve your page loading speed and get higher scores on speed test services like GTmetrix, Google PageSpeed or WebPageTest.
|
| 6 |
* Author: Optimocha
|
| 7 |
-
* Version: 3.8.
|
| 8 |
* Author URI: https://optimocha.com
|
| 9 |
* License: GPLv3 or later
|
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
|
@@ -46,8 +46,8 @@ if( !defined( 'ABSPATH' ) ) {
|
|
| 46 |
-----------------------------------------------------------------------------------------------------------*/
|
| 47 |
|
| 48 |
define( 'SPEED_BOOSTER_PACK_PATH', plugin_dir_path( __FILE__ ) );
|
| 49 |
-
define( 'SPEED_BOOSTER_PACK_URL', plugin_dir_url( __FILE__ ) );
|
| 50 |
-
define( 'SPEED_BOOSTER_PACK_VERSION', '3.8.
|
| 51 |
// Defining css position
|
| 52 |
define( 'SBP_FOOTER', 10 );
|
| 53 |
// Defining css last position
|
| 4 |
* Plugin URI: http://wordpress.org/plugins/speed-booster-pack/
|
| 5 |
* Description: Speed Booster Pack helps you improve your page loading speed and get higher scores on speed test services like GTmetrix, Google PageSpeed or WebPageTest.
|
| 6 |
* Author: Optimocha
|
| 7 |
+
* Version: 3.8.3
|
| 8 |
* Author URI: https://optimocha.com
|
| 9 |
* License: GPLv3 or later
|
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 46 |
-----------------------------------------------------------------------------------------------------------*/
|
| 47 |
|
| 48 |
define( 'SPEED_BOOSTER_PACK_PATH', plugin_dir_path( __FILE__ ) );
|
| 49 |
+
define( 'SPEED_BOOSTER_PACK_URL', preg_replace('#^https?:#', '', plugin_dir_url( __FILE__ ) ) );
|
| 50 |
+
define( 'SPEED_BOOSTER_PACK_VERSION', '3.8.3' );
|
| 51 |
// Defining css position
|
| 52 |
define( 'SBP_FOOTER', 10 );
|
| 53 |
// Defining css last position
|
