Completed
Push — master ( 4a80b9...a1e7b8 )
by frank
06:58
created
classlesses/autoptimizePageCacheFlush.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,55 +2,55 @@
 block discarded – undo
2 2
 // flush as many page cache plugin's caches as possible
3 3
 // hyper cache and gator cache hook into AO, so we don't need to :-)
4 4
 
5
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
+if (!defined('ABSPATH')) exit; // Exit if accessed directly
6 6
 
7 7
 function autoptimize_flush_pagecache() {
8
-    if(function_exists('wp_cache_clear_cache')) {
8
+    if (function_exists('wp_cache_clear_cache')) {
9 9
         if (is_multisite()) {
10 10
             $blog_id = get_current_blog_id();
11 11
             wp_cache_clear_cache($blog_id);
12 12
         } else {
13 13
             wp_cache_clear_cache();
14 14
         }
15
-    } else if ( has_action('cachify_flush_cache') ) {
15
+    } else if (has_action('cachify_flush_cache')) {
16 16
         do_action('cachify_flush_cache');
17
-    } else if ( function_exists('w3tc_pgcache_flush') ) {
17
+    } else if (function_exists('w3tc_pgcache_flush')) {
18 18
         w3tc_pgcache_flush();
19
-    } else if ( function_exists('wp_fast_cache_bulk_delete_all') ) {
19
+    } else if (function_exists('wp_fast_cache_bulk_delete_all')) {
20 20
         wp_fast_cache_bulk_delete_all(); // still to retest
21 21
     } else if (class_exists("WpFastestCache")) {
22 22
         $wpfc = new WpFastestCache();
23 23
         $wpfc -> deleteCache();
24
-    } else if ( class_exists("c_ws_plugin__qcache_purging_routines") ) {
24
+    } else if (class_exists("c_ws_plugin__qcache_purging_routines")) {
25 25
         c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache, still to retest
26
-    } else if ( class_exists("zencache") ) {
26
+    } else if (class_exists("zencache")) {
27 27
         zencache::clear();
28
-    } else if ( class_exists("comet_cache") ) {
28
+    } else if (class_exists("comet_cache")) {
29 29
         comet_cache::clear();
30
-    } else if ( class_exists("WpeCommon") ) {
31
-        if ( apply_filters('autoptimize_flush_wpengine_aggressive', false) ) {
32
-            if ( method_exists( "WpeCommon", "purge_memcached" ) ) {
30
+    } else if (class_exists("WpeCommon")) {
31
+        if (apply_filters('autoptimize_flush_wpengine_aggressive', false)) {
32
+            if (method_exists("WpeCommon", "purge_memcached")) {
33 33
                 WpeCommon::purge_memcached();
34 34
             }
35
-            if ( method_exists( "WpeCommon", "clear_maxcdn_cache" ) ) {  
35
+            if (method_exists("WpeCommon", "clear_maxcdn_cache")) {  
36 36
                 WpeCommon::clear_maxcdn_cache();
37 37
             }
38 38
         }
39
-        if ( method_exists( "WpeCommon", "purge_varnish_cache" ) ) {
39
+        if (method_exists("WpeCommon", "purge_varnish_cache")) {
40 40
             WpeCommon::purge_varnish_cache();   
41 41
         }
42
-    } else if ( function_exists('sg_cachepress_purge_cache') ) {
42
+    } else if (function_exists('sg_cachepress_purge_cache')) {
43 43
         sg_cachepress_purge_cache();
44
-    } else if(file_exists(WP_CONTENT_DIR.'/wp-cache-config.php') && function_exists('prune_super_cache')){
44
+    } else if (file_exists(WP_CONTENT_DIR.'/wp-cache-config.php') && function_exists('prune_super_cache')) {
45 45
         // fallback for WP-Super-Cache
46 46
         global $cache_path;
47 47
         if (is_multisite()) {
48 48
             $blog_id = get_current_blog_id();
49
-            prune_super_cache( get_supercache_dir( $blog_id ), true );
50
-            prune_super_cache( $cache_path . 'blogs/', true );
49
+            prune_super_cache(get_supercache_dir($blog_id), true);
50
+            prune_super_cache($cache_path.'blogs/', true);
51 51
         } else {
52
-            prune_super_cache($cache_path.'supercache/',true);
53
-            prune_super_cache($cache_path,true);
52
+            prune_super_cache($cache_path.'supercache/', true);
53
+            prune_super_cache($cache_path, true);
54 54
         }
55 55
     }
56 56
 }
57 57
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,10 @@
 block discarded – undo
2 2
 // flush as many page cache plugin's caches as possible
3 3
 // hyper cache and gator cache hook into AO, so we don't need to :-)
4 4
 
5
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
+if ( ! defined( 'ABSPATH' ) ) {
6
+    exit;
7
+}
8
+// Exit if accessed directly
6 9
 
7 10
 function autoptimize_flush_pagecache() {
8 11
     if(function_exists('wp_cache_clear_cache')) {
Please login to merge, or discard this patch.
classlesses/autoptimizeSpeedupper.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,13 +88,13 @@
 block discarded – undo
88 88
 }
89 89
 
90 90
 function ao_css_speedup_cleanup($cssin) {
91
-	// speedupper results in aggregated CSS not being minified, so the filestart-marker AO adds when aggregating need to be removed
92
-	return trim(str_replace(array('/*FILESTART*/','/*FILESTART2*/'),'',$cssin));
91
+    // speedupper results in aggregated CSS not being minified, so the filestart-marker AO adds when aggregating need to be removed
92
+    return trim(str_replace(array('/*FILESTART*/','/*FILESTART2*/'),'',$cssin));
93 93
 }
94 94
 
95 95
 function ao_js_speedup_cleanup($jsin) {
96
-	// cleanup
97
-	return trim($jsin);
96
+    // cleanup
97
+    return trim($jsin);
98 98
 }
99 99
 
100 100
 add_filter('autoptimize_css_individual_style','ao_css_snippetcacher',10,2);
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,64 +4,64 @@  discard block
 block discarded – undo
4 4
 * new in Autoptimize 2.2
5 5
 */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7
+if (!defined('ABSPATH')) exit; // Exit if accessed directly
8 8
 
9
-function ao_js_snippetcacher($jsin,$jsfilename) {
9
+function ao_js_snippetcacher($jsin, $jsfilename) {
10 10
     $md5hash = "snippet_".md5($jsin);
11
-    $ccheck = new autoptimizeCache($md5hash,'js');
12
-    if($ccheck->check()) {
11
+    $ccheck = new autoptimizeCache($md5hash, 'js');
12
+    if ($ccheck->check()) {
13 13
         $scriptsrc = $ccheck->retrieve();
14 14
     } else {
15
-        if ( (strpos($jsfilename,"min.js") === false) && ( strpos($jsfilename,"js/jquery/jquery.js") === false ) && ( str_replace(apply_filters('autoptimize_filter_js_consider_minified',false), '', $jsfilename) === $jsfilename ) ) {
16
-            if(class_exists('JSMin')) {
15
+        if ((strpos($jsfilename, "min.js") === false) && (strpos($jsfilename, "js/jquery/jquery.js") === false) && (str_replace(apply_filters('autoptimize_filter_js_consider_minified', false), '', $jsfilename) === $jsfilename)) {
16
+            if (class_exists('JSMin')) {
17 17
                 $tmp_jscode = trim(JSMin::minify($jsin));
18 18
                 if (!empty($tmp_jscode)) {
19 19
                         $scriptsrc = $tmp_jscode;
20 20
                         unset($tmp_jscode);
21 21
                 } else {
22
-                        $scriptsrc=$jsin;
22
+                        $scriptsrc = $jsin;
23 23
                 }
24 24
             } else {
25
-                $scriptsrc=$jsin;
25
+                $scriptsrc = $jsin;
26 26
             }
27 27
         } else {
28 28
             // do some housekeeping here to remove comments & linebreaks and stuff
29
-            $scriptsrc=preg_replace("#^\s*\/\/.*$#Um","",$jsin);
30
-            $scriptsrc=preg_replace("#^\s*\/\*[^!].*\*\/\s?#Us","",$scriptsrc);
31
-            $scriptsrc=preg_replace("#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $scriptsrc);
29
+            $scriptsrc = preg_replace("#^\s*\/\/.*$#Um", "", $jsin);
30
+            $scriptsrc = preg_replace("#^\s*\/\*[^!].*\*\/\s?#Us", "", $scriptsrc);
31
+            $scriptsrc = preg_replace("#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $scriptsrc);
32 32
 
33
-            if ((substr($scriptsrc,-1,1)!==";")&&(substr($scriptsrc,-1,1)!=="}")) {
34
-                $scriptsrc.=";";
33
+            if ((substr($scriptsrc, -1, 1) !== ";") && (substr($scriptsrc, -1, 1) !== "}")) {
34
+                $scriptsrc .= ";";
35 35
             }
36 36
         }
37
-        if ( !empty($jsfilename) && str_replace( apply_filters('autoptimize_filter_js_speedup_cache',false), '', $jsfilename ) === $jsfilename ) {
37
+        if (!empty($jsfilename) && str_replace(apply_filters('autoptimize_filter_js_speedup_cache', false), '', $jsfilename) === $jsfilename) {
38 38
             // don't cache inline CSS or if filter says no
39
-            $ccheck->cache($scriptsrc,'text/javascript');
39
+            $ccheck->cache($scriptsrc, 'text/javascript');
40 40
         }
41 41
     }
42 42
     unset($ccheck);
43 43
 
44
-    if (get_option("autoptimize_js_trycatch")==="on") {
45
-        $scriptsrc="try{".$scriptsrc."}catch(e){}";
44
+    if (get_option("autoptimize_js_trycatch") === "on") {
45
+        $scriptsrc = "try{".$scriptsrc."}catch(e){}";
46 46
     }
47 47
 
48 48
     return $scriptsrc;
49 49
 }
50 50
 
51
-function ao_css_snippetcacher($cssin,$cssfilename) {
51
+function ao_css_snippetcacher($cssin, $cssfilename) {
52 52
     $md5hash = "snippet_".md5($cssin);
53
-    $ccheck = new autoptimizeCache($md5hash,'css');
54
-    if($ccheck->check()) {
53
+    $ccheck = new autoptimizeCache($md5hash, 'css');
54
+    if ($ccheck->check()) {
55 55
         $stylesrc = $ccheck->retrieve();
56 56
     } else {
57
-        if ( ( strpos($cssfilename,"min.css") === false ) && ( str_replace( apply_filters('autoptimize_filter_css_consider_minified',false), '', $cssfilename ) === $cssfilename ) ) {
57
+        if ((strpos($cssfilename, "min.css") === false) && (str_replace(apply_filters('autoptimize_filter_css_consider_minified', false), '', $cssfilename) === $cssfilename)) {
58 58
             if (class_exists('Minify_CSS_Compressor')) {
59 59
                 $tmp_code = trim(Minify_CSS_Compressor::process($cssin));
60
-            } else if(class_exists('CSSmin')) {
60
+            } else if (class_exists('CSSmin')) {
61 61
                 $cssmin = new CSSmin();
62
-                if (method_exists($cssmin,"run")) {
62
+                if (method_exists($cssmin, "run")) {
63 63
                     $tmp_code = trim($cssmin->run($cssin));
64
-                } elseif (@is_callable(array($cssmin,"minify"))) {
64
+                } elseif (@is_callable(array($cssmin, "minify"))) {
65 65
                     $tmp_code = trim(CssMin::minify($cssin));
66 66
                 }
67 67
             }
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
             }
75 75
         } else {
76 76
             // .min.css -> no heavy-lifting, just some cleanup
77
-            $stylesrc=preg_replace("#^\s*\/\*[^!].*\*\/\s?#Us","",$cssin);
78
-            $stylesrc=preg_replace("#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $stylesrc);
79
-            $stylesrc=autoptimizeStyles::fixurls($cssfilename,$stylesrc);
77
+            $stylesrc = preg_replace("#^\s*\/\*[^!].*\*\/\s?#Us", "", $cssin);
78
+            $stylesrc = preg_replace("#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $stylesrc);
79
+            $stylesrc = autoptimizeStyles::fixurls($cssfilename, $stylesrc);
80 80
         }
81
-        if ( !empty($cssfilename) && ( str_replace( apply_filters('autoptimize_filter_css_speedup_cache',false), '', $cssfilename ) === $cssfilename ) ) {
81
+        if (!empty($cssfilename) && (str_replace(apply_filters('autoptimize_filter_css_speedup_cache', false), '', $cssfilename) === $cssfilename)) {
82 82
             // only cache CSS if not inline and allowed by filter
83
-            $ccheck->cache($stylesrc,'text/css');
83
+            $ccheck->cache($stylesrc, 'text/css');
84 84
         }
85 85
     }
86 86
     unset($ccheck);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 function ao_css_speedup_cleanup($cssin) {
91 91
 	// speedupper results in aggregated CSS not being minified, so the filestart-marker AO adds when aggregating need to be removed
92
-	return trim(str_replace(array('/*FILESTART*/','/*FILESTART2*/'),'',$cssin));
92
+	return trim(str_replace(array('/*FILESTART*/', '/*FILESTART2*/'), '', $cssin));
93 93
 }
94 94
 
95 95
 function ao_js_speedup_cleanup($jsin) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	return trim($jsin);
98 98
 }
99 99
 
100
-add_filter('autoptimize_css_individual_style','ao_css_snippetcacher',10,2);
101
-add_filter('autoptimize_js_individual_script','ao_js_snippetcacher',10,2);
102
-add_filter('autoptimize_css_after_minify','ao_css_speedup_cleanup',10,1);
103
-add_filter('autoptimize_js_after_minify','ao_js_speedup_cleanup',10,1);
100
+add_filter('autoptimize_css_individual_style', 'ao_css_snippetcacher', 10, 2);
101
+add_filter('autoptimize_js_individual_script', 'ao_js_snippetcacher', 10, 2);
102
+add_filter('autoptimize_css_after_minify', 'ao_css_speedup_cleanup', 10, 1);
103
+add_filter('autoptimize_js_after_minify', 'ao_js_speedup_cleanup', 10, 1);
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,10 @@
 block discarded – undo
4 4
 * new in Autoptimize 2.2
5 5
 */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7
+if ( ! defined( 'ABSPATH' ) ) {
8
+    exit;
9
+}
10
+// Exit if accessed directly
8 11
 
9 12
 function ao_js_snippetcacher($jsin,$jsfilename) {
10 13
     $md5hash = "snippet_".md5($jsin);
Please login to merge, or discard this patch.
classes/autoptimizeCLI.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 class autoptimizeCLI extends WP_CLI_Command {
8 8
 
9
-	/**
10
-	 * Clears the cache.
11
-	 *
12
-	 * @subcommand clear
13
-	 */
14
-	public function clear( $args, $args_assoc ) {
15
-		WP_CLI::line( esc_html__( 'Flushing the cache...', 'autoptimize' ) );
16
-		autoptimizeCache::clearall();
17
-		WP_CLI::success( esc_html__( 'Cache flushed.', 'autoptimize' ) );
18
-	}
9
+    /**
10
+     * Clears the cache.
11
+     *
12
+     * @subcommand clear
13
+     */
14
+    public function clear( $args, $args_assoc ) {
15
+        WP_CLI::line( esc_html__( 'Flushing the cache...', 'autoptimize' ) );
16
+        autoptimizeCache::clearall();
17
+        WP_CLI::success( esc_html__( 'Cache flushed.', 'autoptimize' ) );
18
+    }
19 19
 
20 20
 }
21 21
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	 *
12 12
 	 * @subcommand clear
13 13
 	 */
14
-	public function clear( $args, $args_assoc ) {
15
-		WP_CLI::line( esc_html__( 'Flushing the cache...', 'autoptimize' ) );
14
+	public function clear($args, $args_assoc) {
15
+		WP_CLI::line(esc_html__('Flushing the cache...', 'autoptimize'));
16 16
 		autoptimizeCache::clearall();
17
-		WP_CLI::success( esc_html__( 'Cache flushed.', 'autoptimize' ) );
17
+		WP_CLI::success(esc_html__('Cache flushed.', 'autoptimize'));
18 18
 	}
19 19
 
20 20
 }
21 21
 
22
-WP_CLI::add_command( 'autoptimize', 'autoptimizeCLI' );
22
+WP_CLI::add_command('autoptimize', 'autoptimizeCLI');
Please login to merge, or discard this patch.
classlesses/autoptimizeCacheChecker.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /* 
5 8
  * cachechecker code
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /* 
5 5
  * cachechecker code
@@ -13,39 +13,39 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 if (is_admin()) {
16
-    add_action('plugins_loaded','ao_cachechecker_setup');
16
+    add_action('plugins_loaded', 'ao_cachechecker_setup');
17 17
 }
18 18
 
19 19
 function ao_cachechecker_setup() {
20
-    $doCacheCheck = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true);
21
-    $cacheCheckSchedule = wp_get_schedule( 'ao_cachechecker' );
22
-    $AOCCfreq = apply_filters('autoptimize_filter_cachecheck_frequency','daily');
23
-    if (!in_array($AOCCfreq,array('hourly','daily','monthly'))) {
24
-        $AOCCfreq='daily';
20
+    $doCacheCheck = (bool) apply_filters('autoptimize_filter_cachecheck_do', true);
21
+    $cacheCheckSchedule = wp_get_schedule('ao_cachechecker');
22
+    $AOCCfreq = apply_filters('autoptimize_filter_cachecheck_frequency', 'daily');
23
+    if (!in_array($AOCCfreq, array('hourly', 'daily', 'monthly'))) {
24
+        $AOCCfreq = 'daily';
25 25
     }
26
-    if ( $doCacheCheck && ( !$cacheCheckSchedule || $cacheCheckSchedule !== $AOCCfreq ) ) {
26
+    if ($doCacheCheck && (!$cacheCheckSchedule || $cacheCheckSchedule !== $AOCCfreq)) {
27 27
         wp_schedule_event(time(), $AOCCfreq, 'ao_cachechecker');
28
-    } else if ( $cacheCheckSchedule && !$doCacheCheck ) {
29
-        wp_clear_scheduled_hook( 'ao_cachechecker' );
28
+    } else if ($cacheCheckSchedule && !$doCacheCheck) {
29
+        wp_clear_scheduled_hook('ao_cachechecker');
30 30
     }
31 31
 }
32 32
 
33 33
 add_action('ao_cachechecker', 'ao_cachechecker_cronjob');
34 34
 function ao_cachechecker_cronjob() {
35
-    $maxSize = (int) apply_filters( "autoptimize_filter_cachecheck_maxsize", 536870912);
36
-    $doCacheCheck = (bool) apply_filters( "autoptimize_filter_cachecheck_do", true);
37
-    $statArr=autoptimizeCache::stats(); 
38
-    $cacheSize=round($statArr[1]);
39
-    if (($cacheSize>$maxSize) && ($doCacheCheck)) {
40
-        update_option("autoptimize_cachesize_notice",true);
41
-        if (apply_filters('autoptimize_filter_cachecheck_sendmail',true)) {
42
-            $saniSiteUrl=esc_url(site_url());
43
-            $ao_mailto=apply_filters('autoptimize_filter_cachecheck_mailto',get_option('admin_email',''));
44
-            $ao_mailsubject=__('Autoptimize cache size warning','autoptimize')." (".$saniSiteUrl.")";
45
-            $ao_mailbody=__('Autoptimize\'s cache size is getting big, consider purging the cache. Have a look at https://wordpress.org/plugins/autoptimize/faq/ to see how you can keep the cache size under control.', 'autoptimize')." (site: ".$saniSiteUrl.")";
35
+    $maxSize = (int) apply_filters("autoptimize_filter_cachecheck_maxsize", 536870912);
36
+    $doCacheCheck = (bool) apply_filters("autoptimize_filter_cachecheck_do", true);
37
+    $statArr = autoptimizeCache::stats(); 
38
+    $cacheSize = round($statArr[1]);
39
+    if (($cacheSize > $maxSize) && ($doCacheCheck)) {
40
+        update_option("autoptimize_cachesize_notice", true);
41
+        if (apply_filters('autoptimize_filter_cachecheck_sendmail', true)) {
42
+            $saniSiteUrl = esc_url(site_url());
43
+            $ao_mailto = apply_filters('autoptimize_filter_cachecheck_mailto', get_option('admin_email', ''));
44
+            $ao_mailsubject = __('Autoptimize cache size warning', 'autoptimize')." (".$saniSiteUrl.")";
45
+            $ao_mailbody = __('Autoptimize\'s cache size is getting big, consider purging the cache. Have a look at https://wordpress.org/plugins/autoptimize/faq/ to see how you can keep the cache size under control.', 'autoptimize')." (site: ".$saniSiteUrl.")";
46 46
 
47 47
             if (!empty($ao_mailto)) {
48
-                $ao_mailresult=wp_mail($ao_mailto,$ao_mailsubject,$ao_mailbody);
48
+                $ao_mailresult = wp_mail($ao_mailto, $ao_mailsubject, $ao_mailbody);
49 49
                 if (!$ao_mailresult) {
50 50
                     error_log("Autoptimize could not send cache size warning mail.");
51 51
                 }
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 
57 57
 add_action('admin_notices', 'autoptimize_cachechecker_notice');
58 58
 function autoptimize_cachechecker_notice() {
59
-    if ((bool) get_option("autoptimize_cachesize_notice",false)) {
59
+    if ((bool) get_option("autoptimize_cachesize_notice", false)) {
60 60
         echo '<div class="notice notice-warning"><p>';
61
-        _e('<strong>Autoptimize\'s cache size is getting big</strong>, consider purging the cache. Have a look at <a href="https://wordpress.org/plugins/autoptimize/faq/" target="_blank">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize' );
61
+        _e('<strong>Autoptimize\'s cache size is getting big</strong>, consider purging the cache. Have a look at <a href="https://wordpress.org/plugins/autoptimize/faq/" target="_blank">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize');
62 62
         echo '</p></div>';
63
-        update_option("autoptimize_cachesize_notice",false);
63
+        update_option("autoptimize_cachesize_notice", false);
64 64
     }
65 65
 }
Please login to merge, or discard this patch.
classlesses/autoptimizeExtra.php 2 patches
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 // initialize
5 8
 if ( is_admin() ) {
@@ -281,13 +284,19 @@  discard block
 block discarded – undo
281 284
             <tr>
282 285
                 <th scope="row"><?php _e('Remove emojis','autoptimize'); ?></th>
283 286
                 <td>
284
-                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_1]' <?php if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) echo 'checked="checked"'; ?> value='1'><?php _e('Removes WordPress\' core emojis\' inline CSS, inline JavaScript, and an otherwise un-autoptimized JavaScript file.','autoptimize'); ?></label>
287
+                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_1]' <?php if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) {
288
+    echo 'checked="checked"';
289
+}
290
+?> value='1'><?php _e('Removes WordPress\' core emojis\' inline CSS, inline JavaScript, and an otherwise un-autoptimized JavaScript file.','autoptimize'); ?></label>
285 291
                 </td>
286 292
             </tr>
287 293
             <tr>
288 294
                 <th scope="row"><?php _e('Remove query strings from static resources','autoptimize'); ?></th>
289 295
                 <td>
290
-                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_0]' <?php if (!empty( $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) echo 'checked="checked"'; ?> value='1'><?php _e('Removing query strings (or more specificaly the <code>ver</code> parameter) will not improve load time, but might improve performance scores.','autoptimize'); ?></label>
296
+                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_0]' <?php if (!empty( $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) {
297
+    echo 'checked="checked"';
298
+}
299
+?> value='1'><?php _e('Removing query strings (or more specificaly the <code>ver</code> parameter) will not improve load time, but might improve performance scores.','autoptimize'); ?></label>
291 300
                 </td>
292 301
             </tr>
293 302
             <tr>
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 // initialize
5
-if ( is_admin() ) {
6
-    add_action( 'admin_menu', 'autoptimize_extra_admin' );
7
-    add_filter( 'autoptimize_filter_settingsscreen_tabs','add_autoptimize_extra_tab' );
5
+if (is_admin()) {
6
+    add_action('admin_menu', 'autoptimize_extra_admin');
7
+    add_filter('autoptimize_filter_settingsscreen_tabs', 'add_autoptimize_extra_tab');
8 8
 } else {
9 9
     autoptimize_extra_init();
10 10
 }
11 11
 
12 12
 // get option
13 13
 function autoptimize_extra_get_options() {
14
-    $_default_val = array("autoptimize_extra_checkbox_field_1"=>"0","autoptimize_extra_checkbox_field_0"=>"0","autoptimize_extra_radio_field_4"=>"1","autoptimize_extra_text_field_2"=>"","autoptimize_extra_text_field_3"=>"");
15
-    $_option_val = get_option( 'autoptimize_extra_settings' );
14
+    $_default_val = array("autoptimize_extra_checkbox_field_1"=>"0", "autoptimize_extra_checkbox_field_0"=>"0", "autoptimize_extra_radio_field_4"=>"1", "autoptimize_extra_text_field_2"=>"", "autoptimize_extra_text_field_3"=>"");
15
+    $_option_val = get_option('autoptimize_extra_settings');
16 16
     if (empty($_option_val)) {
17 17
         $_option_val = $_default_val;
18 18
     }
@@ -24,74 +24,74 @@  discard block
 block discarded – undo
24 24
     $autoptimize_extra_options = autoptimize_extra_get_options();
25 25
 
26 26
     /* disable emojis */
27
-    if ( !empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) ) {
27
+    if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_1'])) {
28 28
         autoptimize_extra_disable_emojis();
29 29
     }
30 30
     
31 31
     /* remove version from query string */
32
-    if ( !empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) ) {
33
-        add_filter( 'script_loader_src', 'autoptimize_extra_remove_qs', 15, 1 );
34
-        add_filter( 'style_loader_src', 'autoptimize_extra_remove_qs', 15, 1 );
32
+    if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_0'])) {
33
+        add_filter('script_loader_src', 'autoptimize_extra_remove_qs', 15, 1);
34
+        add_filter('style_loader_src', 'autoptimize_extra_remove_qs', 15, 1);
35 35
     }
36 36
 
37 37
     /* async JS */
38 38
     if (!empty($autoptimize_extra_options['autoptimize_extra_text_field_3'])) {
39
-        add_filter('autoptimize_filter_js_exclude','autoptimize_extra_async_js',10,1);
39
+        add_filter('autoptimize_filter_js_exclude', 'autoptimize_extra_async_js', 10, 1);
40 40
     }
41 41
 
42 42
     /* optimize google fonts */
43
-    if ( !empty( $autoptimize_extra_options['autoptimize_extra_radio_field_4'] ) && ( $autoptimize_extra_options['autoptimize_extra_radio_field_4'] != "1" ) ) {
44
-        add_filter( 'wp_resource_hints', 'autoptimize_extra_gfonts_remove_dnsprefetch', 10, 2 );        
45
-        if ( $autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "2" ) {
46
-            add_filter('autoptimize_filter_css_removables','autoptimize_extra_remove_gfonts',10,1);
43
+    if (!empty($autoptimize_extra_options['autoptimize_extra_radio_field_4']) && ($autoptimize_extra_options['autoptimize_extra_radio_field_4'] != "1")) {
44
+        add_filter('wp_resource_hints', 'autoptimize_extra_gfonts_remove_dnsprefetch', 10, 2);        
45
+        if ($autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "2") {
46
+            add_filter('autoptimize_filter_css_removables', 'autoptimize_extra_remove_gfonts', 10, 1);
47 47
         } else {
48
-            add_filter('autoptimize_html_after_minify','autoptimize_extra_gfonts',10,1);
49
-            add_filter('autoptimize_extra_filter_tobepreconn','autoptimize_extra_preconnectgooglefonts',10,1);
48
+            add_filter('autoptimize_html_after_minify', 'autoptimize_extra_gfonts', 10, 1);
49
+            add_filter('autoptimize_extra_filter_tobepreconn', 'autoptimize_extra_preconnectgooglefonts', 10, 1);
50 50
         }
51 51
     }
52 52
     
53 53
     /* preconnect */
54
-    if ( !empty($autoptimize_extra_options['autoptimize_extra_text_field_2']) || has_filter('autoptimize_extra_filter_tobepreconn') ) {
55
-        add_filter( 'wp_resource_hints', 'autoptimize_extra_preconnect', 10, 2 );
54
+    if (!empty($autoptimize_extra_options['autoptimize_extra_text_field_2']) || has_filter('autoptimize_extra_filter_tobepreconn')) {
55
+        add_filter('wp_resource_hints', 'autoptimize_extra_preconnect', 10, 2);
56 56
     }
57 57
 }
58 58
 
59 59
 // disable emoji's functions
60 60
 function autoptimize_extra_disable_emojis() {
61 61
     // all actions related to emojis
62
-    remove_action( 'admin_print_styles', 'print_emoji_styles' );
63
-    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
64
-    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
65
-    remove_action( 'wp_print_styles', 'print_emoji_styles' );
66
-    remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
67
-    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
68
-    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
62
+    remove_action('admin_print_styles', 'print_emoji_styles');
63
+    remove_action('wp_head', 'print_emoji_detection_script', 7);
64
+    remove_action('admin_print_scripts', 'print_emoji_detection_script');
65
+    remove_action('wp_print_styles', 'print_emoji_styles');
66
+    remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
67
+    remove_filter('the_content_feed', 'wp_staticize_emoji');
68
+    remove_filter('comment_text_rss', 'wp_staticize_emoji');
69 69
 
70 70
     // filter to remove TinyMCE emojis
71
-    add_filter( 'tiny_mce_plugins', 'autoptimize_extra_disable_emojis_tinymce' );
71
+    add_filter('tiny_mce_plugins', 'autoptimize_extra_disable_emojis_tinymce');
72 72
 
73 73
     // and remove dns-prefetch for emoji
74
-    add_filter( 'wp_resource_hints', 'autoptimize_extra_emojis_remove_dns_prefetch', 10, 2 );
74
+    add_filter('wp_resource_hints', 'autoptimize_extra_emojis_remove_dns_prefetch', 10, 2);
75 75
 }
76 76
 
77
-function autoptimize_extra_disable_emojis_tinymce( $plugins ) {
78
-    if ( is_array( $plugins ) ) {
79
-        return array_diff( $plugins, array( 'wpemoji' ) );
77
+function autoptimize_extra_disable_emojis_tinymce($plugins) {
78
+    if (is_array($plugins)) {
79
+        return array_diff($plugins, array('wpemoji'));
80 80
     } else {
81 81
         return array();
82 82
     }
83 83
 }
84 84
 
85
-function autoptimize_extra_emojis_remove_dns_prefetch( $urls, $relation_type ) {
86
-    $_emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/' );
85
+function autoptimize_extra_emojis_remove_dns_prefetch($urls, $relation_type) {
86
+    $_emoji_svg_url = apply_filters('emoji_svg_url', 'https://s.w.org/images/core/emoji/');
87 87
 
88
-    return autoptimize_extra_remove_dns_prefetch( $urls, $relation_type, $_emoji_svg_url );
88
+    return autoptimize_extra_remove_dns_prefetch($urls, $relation_type, $_emoji_svg_url);
89 89
 }
90 90
 
91 91
 // remove query string function
92
-function autoptimize_extra_remove_qs( $src ) {
93
-    if ( strpos($src, '?ver=') ) {
94
-            $src = remove_query_arg( 'ver', $src );
92
+function autoptimize_extra_remove_qs($src) {
93
+    if (strpos($src, '?ver=')) {
94
+            $src = remove_query_arg('ver', $src);
95 95
     }
96 96
     return $src;
97 97
 }
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
     // get exclusions
104 104
     $AO_JSexclArrayIn = array();
105 105
     if (!empty($in)) {
106
-        $AO_JSexclArrayIn = array_fill_keys(array_filter(array_map('trim',explode(",",$in))),"");
106
+        $AO_JSexclArrayIn = array_fill_keys(array_filter(array_map('trim', explode(",", $in))), "");
107 107
     }
108 108
     
109 109
     // get asyncs
110 110
     $_fromSetting = $autoptimize_extra_options['autoptimize_extra_text_field_3'];
111
-    $AO_asynced_JS = array_fill_keys(array_filter(array_map('trim',explode(",",$_fromSetting))),"");
111
+    $AO_asynced_JS = array_fill_keys(array_filter(array_map('trim', explode(",", $_fromSetting))), "");
112 112
     foreach ($AO_asynced_JS as $JSkey => $JSvalue) {
113 113
         $AO_asynced_JS[$JSkey] = "async";
114 114
     }
115 115
     
116 116
     // merge exclusions & asyncs in one array and return to AO API
117
-    $AO_excl_w_async = array_merge( $AO_JSexclArrayIn, $AO_asynced_JS );
117
+    $AO_excl_w_async = array_merge($AO_JSexclArrayIn, $AO_asynced_JS);
118 118
     return $AO_excl_w_async;
119 119
 }
120 120
 
@@ -123,25 +123,25 @@  discard block
 block discarded – undo
123 123
     $autoptimize_extra_options = autoptimize_extra_get_options();
124 124
     
125 125
     // get setting and store in array
126
-    $_to_be_preconnected = array_filter(array_map('trim',explode(",",$autoptimize_extra_options['autoptimize_extra_text_field_2'])));
127
-    $_to_be_preconnected = apply_filters( 'autoptimize_extra_filter_tobepreconn', $_to_be_preconnected );
126
+    $_to_be_preconnected = array_filter(array_map('trim', explode(",", $autoptimize_extra_options['autoptimize_extra_text_field_2'])));
127
+    $_to_be_preconnected = apply_filters('autoptimize_extra_filter_tobepreconn', $_to_be_preconnected);
128 128
 
129 129
     // walk array, extract domain and add to new array with crossorigin attribute
130 130
     foreach ($_to_be_preconnected as $_preconn_single) {
131 131
         $_preconn_parsed = parse_url($_preconn_single);
132 132
         
133
-        if ( is_array($_preconn_parsed) && empty($_preconn_parsed['scheme']) ) {
133
+        if (is_array($_preconn_parsed) && empty($_preconn_parsed['scheme'])) {
134 134
             $_preconn_domain = "//".$_preconn_parsed['host'];
135
-        } else if ( is_array($_preconn_parsed) ) {
135
+        } else if (is_array($_preconn_parsed)) {
136 136
             $_preconn_domain = $_preconn_parsed['scheme']."://".$_preconn_parsed['host'];
137 137
         }
138 138
         
139
-        if ( !empty($_preconn_domain) ) {
139
+        if (!empty($_preconn_domain)) {
140 140
             $_preconn_hint = array('href' => $_preconn_domain);
141 141
             // fonts don't get preconnected unless crossorigin flag is set, non-fonts don't get preconnected if origin flag is set
142 142
             // so hardcode fonts.gstatic.com to come with crossorigin and have filter to add other domains if needed
143
-            $_preconn_crossorigin = apply_filters( 'autoptimize_extra_filter_preconn_crossorigin', array('https://fonts.gstatic.com') );
144
-            if ( in_array( $_preconn_domain, $_preconn_crossorigin ) ) {
143
+            $_preconn_crossorigin = apply_filters('autoptimize_extra_filter_preconn_crossorigin', array('https://fonts.gstatic.com'));
144
+            if (in_array($_preconn_domain, $_preconn_crossorigin)) {
145 145
                 $_preconn_hint['crossorigin'] = 'anonymous';
146 146
             }
147 147
             $_new_hints[] = $_preconn_hint;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
     // merge in wordpress' preconnect hints
152
-    if ( 'preconnect' === $relation_type && !empty($_new_hints) ) {
152
+    if ('preconnect' === $relation_type && !empty($_new_hints)) {
153 153
         $hints = array_merge($hints, $_new_hints);      
154 154
     }
155 155
     
@@ -157,10 +157,10 @@  discard block
 block discarded – undo
157 157
 }
158 158
 
159 159
 // google font functions
160
-function autoptimize_extra_gfonts_remove_dnsprefetch ( $urls, $relation_type ) {
160
+function autoptimize_extra_gfonts_remove_dnsprefetch($urls, $relation_type) {
161 161
     $_gfonts_url = "fonts.googleapis.com";
162 162
     
163
-    return autoptimize_extra_remove_dns_prefetch( $urls, $relation_type, $_gfonts_url );
163
+    return autoptimize_extra_remove_dns_prefetch($urls, $relation_type, $_gfonts_url);
164 164
 }
165 165
 
166 166
 function autoptimize_extra_remove_gfonts($in) { 
@@ -172,48 +172,48 @@  discard block
 block discarded – undo
172 172
     $autoptimize_extra_options = autoptimize_extra_get_options();
173 173
     
174 174
     // extract fonts, partly based on wp rocket's extraction code
175
-    $_without_comments = preg_replace( '/<!--(.*)-->/Uis', '', $in );
176
-    preg_match_all( '#<link(?:\s+(?:(?!href\s*=\s*)[^>])+)?(?:\s+href\s*=\s*([\'"])((?:https?:)?\/\/fonts\.googleapis\.com\/css(?:(?!\1).)+)\1)(?:\s+[^>]*)?>#iU', $_without_comments, $matches );
175
+    $_without_comments = preg_replace('/<!--(.*)-->/Uis', '', $in);
176
+    preg_match_all('#<link(?:\s+(?:(?!href\s*=\s*)[^>])+)?(?:\s+href\s*=\s*([\'"])((?:https?:)?\/\/fonts\.googleapis\.com\/css(?:(?!\1).)+)\1)(?:\s+[^>]*)?>#iU', $_without_comments, $matches);
177 177
 
178 178
     $i = 0;
179 179
     $fontsCollection = array();
180
-    if ( ! $matches[2] ) {
180
+    if (!$matches[2]) {
181 181
         return $in;
182 182
     }
183 183
     
184 184
     // store them in $fonts array
185
-    foreach ( $matches[2] as $font ) {
186
-        if ( ! preg_match( '/rel=["\']dns-prefetch["\']/', $matches[0][ $i ] ) ) {
185
+    foreach ($matches[2] as $font) {
186
+        if (!preg_match('/rel=["\']dns-prefetch["\']/', $matches[0][$i])) {
187 187
             // Get fonts name.
188
-            $font = str_replace( array( '%7C', '%7c' ) , '|', $font );
189
-            $font = explode( 'family=', $font );
190
-            $font = ( isset( $font[1] ) ) ? explode( '&', $font[1] ) : array();
188
+            $font = str_replace(array('%7C', '%7c'), '|', $font);
189
+            $font = explode('family=', $font);
190
+            $font = (isset($font[1])) ? explode('&', $font[1]) : array();
191 191
             // Add font to $fonts[$i] but make sure not to pollute with an empty family
192
-            $_thisfont = array_values( array_filter( explode( '|', reset( $font ) ) ) );
193
-            if ( !empty($_thisfont) ) {
192
+            $_thisfont = array_values(array_filter(explode('|', reset($font))));
193
+            if (!empty($_thisfont)) {
194 194
                 $fontsCollection[$i]["fonts"] = $_thisfont;
195 195
                 // And add subset if any
196
-                $subset = ( is_array( $font ) ) ? end( $font ) : '';
197
-                if ( false !== strpos( $subset, 'subset=' ) ) {
198
-                    $subset = explode( 'subset=', $subset );
199
-                    $fontsCollection[$i]["subsets"] = explode( ',', $subset[1] );
196
+                $subset = (is_array($font)) ? end($font) : '';
197
+                if (false !== strpos($subset, 'subset=')) {
198
+                    $subset = explode('subset=', $subset);
199
+                    $fontsCollection[$i]["subsets"] = explode(',', $subset[1]);
200 200
                 }
201 201
             }
202 202
             // And remove Google Fonts.
203
-            $in = str_replace( $matches[0][ $i ], '', $in );
203
+            $in = str_replace($matches[0][$i], '', $in);
204 204
         }
205 205
         $i++;
206 206
     }
207 207
 
208
-    $_fontsOut="";
209
-    if ( $autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "3" ) {
208
+    $_fontsOut = "";
209
+    if ($autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "3") {
210 210
         // aggregate & link
211
-        $_fontsString="";
212
-        $_subsetString="";
211
+        $_fontsString = "";
212
+        $_subsetString = "";
213 213
         foreach ($fontsCollection as $font) {
214
-            $_fontsString .= '|'.trim( implode( '|' , $font["fonts"] ), '|' );
215
-            if ( !empty( $font["subsets"] ) ) {
216
-                $_subsetString .= implode( ',', $font["subsets"] ); 
214
+            $_fontsString .= '|'.trim(implode('|', $font["fonts"]), '|');
215
+            if (!empty($font["subsets"])) {
216
+                $_subsetString .= implode(',', $font["subsets"]); 
217 217
             }
218 218
         }
219 219
                     
@@ -221,17 +221,17 @@  discard block
 block discarded – undo
221 221
             $_fontsString = $_fontsString."#038;subset=".$_subsetString;
222 222
         }
223 223
 
224
-        $_fontsString = str_replace( '|', '%7C', ltrim($_fontsString,'|') );
224
+        $_fontsString = str_replace('|', '%7C', ltrim($_fontsString, '|'));
225 225
         
226
-        if ( ! empty( $_fontsString ) ) {
227
-            $_fontsOut = '<link rel="stylesheet" id="ao_optimized_gfonts" href="https://fonts.googleapis.com/css?family=' . $_fontsString . '" />';
226
+        if (!empty($_fontsString)) {
227
+            $_fontsOut = '<link rel="stylesheet" id="ao_optimized_gfonts" href="https://fonts.googleapis.com/css?family='.$_fontsString.'" />';
228 228
         }
229
-    } else if ( $autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "4" ) {
229
+    } else if ($autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "4") {
230 230
         // aggregate & load async (webfont.js impl.)
231 231
         $_fontsArray = array();
232 232
         foreach ($fontsCollection as $_fonts) {
233
-            if ( !empty( $_fonts["subsets"] ) ) {
234
-                $_subset = implode(",",$_fonts["subsets"]);
233
+            if (!empty($_fonts["subsets"])) {
234
+                $_subset = implode(",", $_fonts["subsets"]);
235 235
                 foreach ($_fonts["fonts"] as $key => $_one_font) {
236 236
                     $_one_font = $_one_font.":".$_subset;
237 237
                     $_fonts["fonts"][$key] = $_one_font;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         foreach ($_fontsArray as $_font) {
245 245
             $_fontsOut .= $_font."','";
246 246
         }
247
-        $_fontsOut = trim(trim($_fontsOut,"'"),",");
247
+        $_fontsOut = trim(trim($_fontsOut, "'"), ",");
248 248
         $_fontsOut .= '] },classes:false, events:false, timeout:1500};(function() {var wf = document.createElement(\'script\');wf.src=\'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js\';wf.type=\'text/javascript\';wf.async=\'true\';var s=document.getElementsByTagName(\'script\')[0];s.parentNode.insertBefore(wf, s);})();</script>';
249 249
     }
250 250
  
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
     // preconnect to fonts.gstatic.com speed up download of static font-files
260 260
     $in[] = "https://fonts.gstatic.com";
261
-    if ( $autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "4" ) {
261
+    if ($autoptimize_extra_options['autoptimize_extra_radio_field_4'] == "4") {
262 262
         // and more preconnects for webfont.js
263 263
         $in[] = "https://ajax.googleapis.com";
264 264
         $in[] = "https://fonts.googleapis.com";
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
     return $in;
267 267
 }
268 268
 
269
-function autoptimize_extra_remove_dns_prefetch( $urls, $relation_type, $_remove_url ) {
270
-        if ( 'dns-prefetch' == $relation_type ) {
271
-        $_count=0;
269
+function autoptimize_extra_remove_dns_prefetch($urls, $relation_type, $_remove_url) {
270
+        if ('dns-prefetch' == $relation_type) {
271
+        $_count = 0;
272 272
         foreach ($urls as $_url) {
273
-            if ( strpos($_url, $_remove_url) !== false ) {
273
+            if (strpos($_url, $_remove_url) !== false) {
274 274
                 unset($urls[$_count]);
275 275
             }
276 276
             $_count++;
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 
283 283
 /* admin page functions */
284 284
 function autoptimize_extra_admin() { 
285
-    add_submenu_page( null, 'autoptimize_extra', 'autoptimize_extra', 'manage_options', 'autoptimize_extra', 'autoptimize_extra_options_page' );
286
-    register_setting( 'autoptimize_extra_settings', 'autoptimize_extra_settings' );
285
+    add_submenu_page(null, 'autoptimize_extra', 'autoptimize_extra', 'manage_options', 'autoptimize_extra', 'autoptimize_extra_options_page');
286
+    register_setting('autoptimize_extra_settings', 'autoptimize_extra_settings');
287 287
 }
288 288
 
289 289
 function add_autoptimize_extra_tab($in) {
290
-    $in=array_merge($in,array('autoptimize_extra' => __('Extra','autoptimize')));
290
+    $in = array_merge($in, array('autoptimize_extra' => __('Extra', 'autoptimize')));
291 291
     return $in;
292 292
 }
293 293
 
@@ -301,46 +301,46 @@  discard block
 block discarded – undo
301 301
         #autoptimize_extra_descr{font-size: 120%;}
302 302
     </style>
303 303
     <div class="wrap">
304
-    <h1><?php _e('Autoptimize Settings','autoptimize'); ?></h1>
304
+    <h1><?php _e('Autoptimize Settings', 'autoptimize'); ?></h1>
305 305
     <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
306 306
     <form id='ao_settings_form' action='options.php' method='post'>
307 307
         <?php settings_fields('autoptimize_extra_settings'); ?>
308
-        <h2><?php _e('Extra Auto-Optimizations','autoptimize'); ?></h2>
309
-        <span id='autoptimize_extra_descr'><?php _e('The following settings can improve your site\'s performance even more.','autoptimize'); ?></span>
308
+        <h2><?php _e('Extra Auto-Optimizations', 'autoptimize'); ?></h2>
309
+        <span id='autoptimize_extra_descr'><?php _e('The following settings can improve your site\'s performance even more.', 'autoptimize'); ?></span>
310 310
         <table class="form-table">
311 311
             <tr>
312
-                <th scope="row"><?php _e('Remove emojis','autoptimize'); ?></th>
312
+                <th scope="row"><?php _e('Remove emojis', 'autoptimize'); ?></th>
313 313
                 <td>
314
-                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_1]' <?php if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) echo 'checked="checked"'; ?> value='1'><?php _e('Removes WordPress\' core emojis\' inline CSS, inline JavaScript, and an otherwise un-autoptimized JavaScript file.','autoptimize'); ?></label>
314
+                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_1]' <?php if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_1']) echo 'checked="checked"'; ?> value='1'><?php _e('Removes WordPress\' core emojis\' inline CSS, inline JavaScript, and an otherwise un-autoptimized JavaScript file.', 'autoptimize'); ?></label>
315 315
                 </td>
316 316
             </tr>
317 317
             <tr>
318
-                <th scope="row"><?php _e('Remove query strings from static resources','autoptimize'); ?></th>
318
+                <th scope="row"><?php _e('Remove query strings from static resources', 'autoptimize'); ?></th>
319 319
                 <td>
320
-                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_0]' <?php if (!empty( $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) echo 'checked="checked"'; ?> value='1'><?php _e('Removing query strings (or more specificaly the <code>ver</code> parameter) will not improve load time, but might improve performance scores.','autoptimize'); ?></label>
320
+                    <label><input type='checkbox' name='autoptimize_extra_settings[autoptimize_extra_checkbox_field_0]' <?php if (!empty($autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) && 1 == $autoptimize_extra_options['autoptimize_extra_checkbox_field_0']) echo 'checked="checked"'; ?> value='1'><?php _e('Removing query strings (or more specificaly the <code>ver</code> parameter) will not improve load time, but might improve performance scores.', 'autoptimize'); ?></label>
321 321
                 </td>
322 322
             </tr>
323 323
             <tr>
324
-                <th scope="row"><?php _e('Google Fonts','autoptimize'); ?></th>
324
+                <th scope="row"><?php _e('Google Fonts', 'autoptimize'); ?></th>
325 325
                 <td>
326
-                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="1" <?php if (!in_array($_googlef,array(2,3,4))) {echo "checked"; } ?> ><?php _e('Leave as is','autoptimize'); ?><br/>
327
-                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="2" <?php checked(2, $_googlef, true); ?> ><?php _e('Remove Google Fonts','autoptimize'); ?><br/>
328
-                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="3" <?php checked(3, $_googlef, true); ?> ><?php _e('Combine and link in head','autoptimize'); ?><br/>
329
-                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="4" <?php checked(4, $_googlef, true); ?> ><?php _e('Combine and load fonts asynchronously with <a href="https://github.com/typekit/webfontloader#readme" target="_blank">webfont.js</a>','autoptimize'); ?><br/>
326
+                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="1" <?php if (!in_array($_googlef, array(2, 3, 4))) {echo "checked"; } ?> ><?php _e('Leave as is', 'autoptimize'); ?><br/>
327
+                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="2" <?php checked(2, $_googlef, true); ?> ><?php _e('Remove Google Fonts', 'autoptimize'); ?><br/>
328
+                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="3" <?php checked(3, $_googlef, true); ?> ><?php _e('Combine and link in head', 'autoptimize'); ?><br/>
329
+                    <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="4" <?php checked(4, $_googlef, true); ?> ><?php _e('Combine and load fonts asynchronously with <a href="https://github.com/typekit/webfontloader#readme" target="_blank">webfont.js</a>', 'autoptimize'); ?><br/>
330 330
                 </td>
331 331
             </tr>
332 332
             <tr>
333
-                <th scope="row"><?php _e('Preconnect to 3rd party domains <em>(advanced users)</em>','autoptimize'); ?></th>
333
+                <th scope="row"><?php _e('Preconnect to 3rd party domains <em>(advanced users)</em>', 'autoptimize'); ?></th>
334 334
                 <td>
335
-                    <label><input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_2]' value='<?php echo $autoptimize_extra_options['autoptimize_extra_text_field_2']; ?>'><br /><?php _e('Add 3rd party domains you want the browser to <a href="https://www.keycdn.com/support/preconnect/#primary" target="_blank">preconnect</a> to, separated by comma\'s. Make sure to include the correct protocol (HTTP or HTTPS).','autoptimize'); ?></label>
335
+                    <label><input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_2]' value='<?php echo $autoptimize_extra_options['autoptimize_extra_text_field_2']; ?>'><br /><?php _e('Add 3rd party domains you want the browser to <a href="https://www.keycdn.com/support/preconnect/#primary" target="_blank">preconnect</a> to, separated by comma\'s. Make sure to include the correct protocol (HTTP or HTTPS).', 'autoptimize'); ?></label>
336 336
                 </td>
337 337
             </tr>
338 338
             <tr>
339
-                <th scope="row"><?php _e('Async Javascript-files <em>(advanced users)</em>','autoptimize'); ?></th>
339
+                <th scope="row"><?php _e('Async Javascript-files <em>(advanced users)</em>', 'autoptimize'); ?></th>
340 340
                 <td>
341 341
                     <input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_3]' value='<?php echo $autoptimize_extra_options['autoptimize_extra_text_field_3']; ?>'>
342 342
                     <br />
343
-                    <?php _e('Comma-separated list of local or 3rd party JS-files that should loaded with the <code>async</code> flag. JS-files from your own site will be automatically excluded if added here.','autoptimize'); ?>
343
+                    <?php _e('Comma-separated list of local or 3rd party JS-files that should loaded with the <code>async</code> flag. JS-files from your own site will be automatically excluded if added here.', 'autoptimize'); ?>
344 344
                 </td>
345 345
             </tr>
346 346
         </table>
Please login to merge, or discard this patch.