@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | http://www.gnu.org/licenses/gpl.txt |
13 | 13 | */ |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
15 | +if (!defined('ABSPATH')) exit; // Exit if accessed directly |
|
16 | 16 | |
17 | -define('AUTOPTIMIZE_PLUGIN_DIR',plugin_dir_path(__FILE__)); |
|
17 | +define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
18 | 18 | |
19 | 19 | // Load config class |
20 | 20 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeConfig.php'); |
21 | 21 | |
22 | 22 | // Load toolbar class |
23 | -include( AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeToolbar.php' ); |
|
23 | +include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeToolbar.php'); |
|
24 | 24 | |
25 | 25 | // Load partners tab if admin |
26 | 26 | if (is_admin()) { |
@@ -28,29 +28,29 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // Do we gzip when caching (needed early to load autoptimizeCache.php) |
31 | -define('AUTOPTIMIZE_CACHE_NOGZIP',(bool) get_option('autoptimize_cache_nogzip')); |
|
31 | +define('AUTOPTIMIZE_CACHE_NOGZIP', (bool) get_option('autoptimize_cache_nogzip')); |
|
32 | 32 | |
33 | 33 | // Load cache class |
34 | 34 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCache.php'); |
35 | 35 | |
36 | 36 | // wp-content dir name (automagically set, should not be needed), dirname of AO cache dir and AO-prefix can be overridden in wp-config.php |
37 | -if (!defined('AUTOPTIMIZE_WP_CONTENT_NAME')) { define('AUTOPTIMIZE_WP_CONTENT_NAME','/'.wp_basename( WP_CONTENT_DIR )); } |
|
38 | -if (!defined('AUTOPTIMIZE_CACHE_CHILD_DIR')) { define('AUTOPTIMIZE_CACHE_CHILD_DIR','/cache/autoptimize/'); } |
|
37 | +if (!defined('AUTOPTIMIZE_WP_CONTENT_NAME')) { define('AUTOPTIMIZE_WP_CONTENT_NAME', '/'.wp_basename(WP_CONTENT_DIR)); } |
|
38 | +if (!defined('AUTOPTIMIZE_CACHE_CHILD_DIR')) { define('AUTOPTIMIZE_CACHE_CHILD_DIR', '/cache/autoptimize/'); } |
|
39 | 39 | if (!defined('AUTOPTIMIZE_CACHEFILE_PREFIX')) { define('AUTOPTIMIZE_CACHEFILE_PREFIX', 'autoptimize_'); } |
40 | 40 | |
41 | 41 | // Plugin dir constants (plugin url's defined later to accomodate domain mapped sites) |
42 | -if (is_multisite() && apply_filters( 'autoptimize_separate_blog_caches' , true )) { |
|
42 | +if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) { |
|
43 | 43 | $blog_id = get_current_blog_id(); |
44 | - define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/' ); |
|
44 | + define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/'); |
|
45 | 45 | } else { |
46 | 46 | define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR.AUTOPTIMIZE_CACHE_CHILD_DIR); |
47 | 47 | } |
48 | -define('AUTOPTIMIZE_CACHE_DELAY',true); |
|
49 | -define('WP_ROOT_DIR',substr(WP_CONTENT_DIR, 0, strlen(WP_CONTENT_DIR)-strlen(AUTOPTIMIZE_WP_CONTENT_NAME))); |
|
48 | +define('AUTOPTIMIZE_CACHE_DELAY', true); |
|
49 | +define('WP_ROOT_DIR', substr(WP_CONTENT_DIR, 0, strlen(WP_CONTENT_DIR) - strlen(AUTOPTIMIZE_WP_CONTENT_NAME))); |
|
50 | 50 | |
51 | 51 | // WP CLI |
52 | -if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
53 | - require_once AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php'; |
|
52 | +if (defined('WP_CLI') && WP_CLI) { |
|
53 | + require_once AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCLI.php'; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // Initialize the cache at least once |
@@ -59,65 +59,65 @@ discard block |
||
59 | 59 | /* Check if we're updating, in which case we might need to do stuff and flush the cache |
60 | 60 | to avoid old versions of aggregated files lingering around */ |
61 | 61 | |
62 | -$autoptimize_version="2.3.0"; |
|
63 | -$autoptimize_db_version=get_option('autoptimize_version','none'); |
|
62 | +$autoptimize_version = "2.3.0"; |
|
63 | +$autoptimize_db_version = get_option('autoptimize_version', 'none'); |
|
64 | 64 | |
65 | 65 | if ($autoptimize_db_version !== $autoptimize_version) { |
66 | - if ($autoptimize_db_version==="none") { |
|
66 | + if ($autoptimize_db_version === "none") { |
|
67 | 67 | add_action('admin_notices', 'autoptimize_install_config_notice'); |
68 | 68 | } else { |
69 | 69 | // updating, include the update-code |
70 | 70 | include(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizeUpdateCode.php'); |
71 | 71 | } |
72 | 72 | |
73 | - update_option('autoptimize_version',$autoptimize_version); |
|
74 | - $autoptimize_db_version=$autoptimize_version; |
|
73 | + update_option('autoptimize_version', $autoptimize_version); |
|
74 | + $autoptimize_db_version = $autoptimize_version; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Load translations |
78 | 78 | function autoptimize_load_plugin_textdomain() { |
79 | - load_plugin_textdomain('autoptimize',false,plugin_basename(dirname( __FILE__ )).'/localization'); |
|
79 | + load_plugin_textdomain('autoptimize', false, plugin_basename(dirname(__FILE__)).'/localization'); |
|
80 | 80 | } |
81 | -add_action( 'init', 'autoptimize_load_plugin_textdomain' ); |
|
81 | +add_action('init', 'autoptimize_load_plugin_textdomain'); |
|
82 | 82 | |
83 | -function autoptimize_uninstall(){ |
|
83 | +function autoptimize_uninstall() { |
|
84 | 84 | autoptimizeCache::clearall(); |
85 | 85 | |
86 | - $delete_options=array("autoptimize_cache_clean", "autoptimize_cache_nogzip", "autoptimize_css", "autoptimize_css_datauris", "autoptimize_css_justhead", "autoptimize_css_defer", "autoptimize_css_defer_inline", "autoptimize_css_inline", "autoptimize_css_exclude", "autoptimize_html", "autoptimize_html_keepcomments", "autoptimize_js", "autoptimize_js_exclude", "autoptimize_js_forcehead", "autoptimize_js_justhead", "autoptimize_js_trycatch", "autoptimize_version", "autoptimize_show_adv", "autoptimize_cdn_url", "autoptimize_cachesize_notice","autoptimize_css_include_inline","autoptimize_js_include_inline","autoptimize_optimize_logged","autoptimize_optimize_checkout","autoptimize_extra_settings"); |
|
86 | + $delete_options = array("autoptimize_cache_clean", "autoptimize_cache_nogzip", "autoptimize_css", "autoptimize_css_datauris", "autoptimize_css_justhead", "autoptimize_css_defer", "autoptimize_css_defer_inline", "autoptimize_css_inline", "autoptimize_css_exclude", "autoptimize_html", "autoptimize_html_keepcomments", "autoptimize_js", "autoptimize_js_exclude", "autoptimize_js_forcehead", "autoptimize_js_justhead", "autoptimize_js_trycatch", "autoptimize_version", "autoptimize_show_adv", "autoptimize_cdn_url", "autoptimize_cachesize_notice", "autoptimize_css_include_inline", "autoptimize_js_include_inline", "autoptimize_optimize_logged", "autoptimize_optimize_checkout", "autoptimize_extra_settings"); |
|
87 | 87 | |
88 | - if ( !is_multisite() ) { |
|
89 | - foreach ($delete_options as $del_opt) { delete_option( $del_opt ); } |
|
88 | + if (!is_multisite()) { |
|
89 | + foreach ($delete_options as $del_opt) { delete_option($del_opt); } |
|
90 | 90 | } else { |
91 | 91 | global $wpdb; |
92 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
92 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
93 | 93 | $original_blog_id = get_current_blog_id(); |
94 | - foreach ( $blog_ids as $blog_id ) { |
|
95 | - switch_to_blog( $blog_id ); |
|
96 | - foreach ($delete_options as $del_opt) { delete_option( $del_opt ); } |
|
94 | + foreach ($blog_ids as $blog_id) { |
|
95 | + switch_to_blog($blog_id); |
|
96 | + foreach ($delete_options as $del_opt) { delete_option($del_opt); } |
|
97 | 97 | } |
98 | - switch_to_blog( $original_blog_id ); |
|
98 | + switch_to_blog($original_blog_id); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( wp_get_schedule( 'ao_cachechecker' ) ) { |
|
102 | - wp_clear_scheduled_hook( 'ao_cachechecker' ); |
|
101 | + if (wp_get_schedule('ao_cachechecker')) { |
|
102 | + wp_clear_scheduled_hook('ao_cachechecker'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | function autoptimize_install_config_notice() { |
107 | 107 | echo '<div class="updated"><p>'; |
108 | - _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize' ); |
|
108 | + _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize'); |
|
109 | 109 | echo '</p></div>'; |
110 | 110 | } |
111 | 111 | |
112 | 112 | function autoptimize_update_config_notice() { |
113 | 113 | echo '<div class="updated"><p>'; |
114 | - _e('Autoptimize has just been updated. Please <strong>test your site now</strong> and adapt Autoptimize config if needed.', 'autoptimize' ); |
|
114 | + _e('Autoptimize has just been updated. Please <strong>test your site now</strong> and adapt Autoptimize config if needed.', 'autoptimize'); |
|
115 | 115 | echo '</p></div>'; |
116 | 116 | } |
117 | 117 | |
118 | 118 | function autoptimize_cache_unavailable_notice() { |
119 | 119 | echo '<div class="error"><p>'; |
120 | - printf( __( 'Autoptimize cannot write to the cache directory (%s), please fix to enable CSS/ JS optimization!', 'autoptimize' ), AUTOPTIMIZE_CACHE_DIR ); |
|
120 | + printf(__('Autoptimize cannot write to the cache directory (%s), please fix to enable CSS/ JS optimization!', 'autoptimize'), AUTOPTIMIZE_CACHE_DIR); |
|
121 | 121 | echo '</p></div>'; |
122 | 122 | } |
123 | 123 | |
@@ -126,27 +126,27 @@ discard block |
||
126 | 126 | $ao_noptimize = false; |
127 | 127 | |
128 | 128 | // noptimize in qs to get non-optimized page for debugging |
129 | - if (array_key_exists("ao_noptimize",$_GET) || array_key_exists("ao_noptirocket",$_GET)) { |
|
130 | - if ( ( ($_GET["ao_noptimize"]==="1") || ($_GET["ao_noptirocket"]==="1") ) && (apply_filters('autoptimize_filter_honor_qs_noptimize',true)) ) { |
|
129 | + if (array_key_exists("ao_noptimize", $_GET) || array_key_exists("ao_noptirocket", $_GET)) { |
|
130 | + if ((($_GET["ao_noptimize"] === "1") || ($_GET["ao_noptirocket"] === "1")) && (apply_filters('autoptimize_filter_honor_qs_noptimize', true))) { |
|
131 | 131 | $ao_noptimize = true; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | // check for DONOTMINIFY constant as used by e.g. WooCommerce POS |
136 | - if (defined('DONOTMINIFY') && (constant('DONOTMINIFY')===true || constant('DONOTMINIFY')==="true")) { |
|
136 | + if (defined('DONOTMINIFY') && (constant('DONOTMINIFY') === true || constant('DONOTMINIFY') === "true")) { |
|
137 | 137 | $ao_noptimize = true; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // if setting says not to optimize logged in user and user is logged in |
141 | - if ( get_option('autoptimize_optimize_logged','on') !== 'on' && is_user_logged_in() && current_user_can('edit_posts') ) { |
|
141 | + if (get_option('autoptimize_optimize_logged', 'on') !== 'on' && is_user_logged_in() && current_user_can('edit_posts')) { |
|
142 | 142 | $ao_noptimize = true; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // if setting says not to optimize cart/ checkout |
146 | - if ( get_option('autoptimize_optimize_checkout','on') !== 'on' ) { |
|
146 | + if (get_option('autoptimize_optimize_checkout', 'on') !== 'on') { |
|
147 | 147 | // checking for woocommerce, easy digital downloads and wp ecommerce |
148 | - foreach ( array("is_checkout","is_cart","edd_is_checkout","wpsc_is_cart","wpsc_is_checkout") as $shopCond ) { |
|
149 | - if ( function_exists($shopCond) && $shopCond() ) { |
|
148 | + foreach (array("is_checkout", "is_cart", "edd_is_checkout", "wpsc_is_cart", "wpsc_is_checkout") as $shopCond) { |
|
149 | + if (function_exists($shopCond) && $shopCond()) { |
|
150 | 150 | $ao_noptimize = true; |
151 | 151 | break; |
152 | 152 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // filter you can use to block autoptimization on your own terms |
157 | - $ao_noptimize = (bool) apply_filters( 'autoptimize_filter_noptimize', $ao_noptimize ); |
|
157 | + $ao_noptimize = (bool) apply_filters('autoptimize_filter_noptimize', $ao_noptimize); |
|
158 | 158 | |
159 | - if (!is_feed() && !$ao_noptimize && !is_admin() && ( !function_exists('is_customize_preview') || !is_customize_preview() ) ) { |
|
159 | + if (!is_feed() && !$ao_noptimize && !is_admin() && (!function_exists('is_customize_preview') || !is_customize_preview())) { |
|
160 | 160 | // load speedupper conditionally (true by default?) |
161 | - if ( apply_filters('autoptimize_filter_speedupper', true) ) { |
|
161 | + if (apply_filters('autoptimize_filter_speedupper', true)) { |
|
162 | 162 | include(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizeSpeedupper.php'); |
163 | 163 | } |
164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeBase.php'); |
170 | 170 | |
171 | 171 | // Load extra classes and set some vars |
172 | - if($conf->get('autoptimize_html')) { |
|
172 | + if ($conf->get('autoptimize_html')) { |
|
173 | 173 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeHTML.php'); |
174 | 174 | // BUG: new minify-html does not support keeping HTML comments, skipping for now |
175 | 175 | // if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | // } |
180 | 180 | } |
181 | 181 | |
182 | - if($conf->get('autoptimize_js')) { |
|
182 | + if ($conf->get('autoptimize_js')) { |
|
183 | 183 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeScripts.php'); |
184 | 184 | if (!class_exists('JSMin')) { |
185 | 185 | if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | @include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/minify-2.3.1-jsmin.php'); |
189 | 189 | } |
190 | 190 | } |
191 | - if ( ! defined( 'CONCATENATE_SCRIPTS' )) { |
|
192 | - define('CONCATENATE_SCRIPTS',false); |
|
191 | + if (!defined('CONCATENATE_SCRIPTS')) { |
|
192 | + define('CONCATENATE_SCRIPTS', false); |
|
193 | 193 | } |
194 | - if ( ! defined( 'COMPRESS_SCRIPTS' )) { |
|
195 | - define('COMPRESS_SCRIPTS',false); |
|
194 | + if (!defined('COMPRESS_SCRIPTS')) { |
|
195 | + define('COMPRESS_SCRIPTS', false); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - if($conf->get('autoptimize_css')) { |
|
199 | + if ($conf->get('autoptimize_css')) { |
|
200 | 200 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeStyles.php'); |
201 | 201 | if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
202 | 202 | if (!class_exists('Minify_CSS_Compressor')) { |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | @include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/yui-php-cssmin-2.4.8-4_fgo.php'); |
208 | 208 | } |
209 | 209 | } |
210 | - if ( ! defined( 'COMPRESS_CSS' )) { |
|
211 | - define('COMPRESS_CSS',false); |
|
210 | + if (!defined('COMPRESS_CSS')) { |
|
211 | + define('COMPRESS_CSS', false); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | 215 | // filter to be used with care, kills all output buffers when true. use with extreme caution. you have been warned! |
216 | - if (apply_filters('autoptimize_filter_obkiller',false)) { |
|
216 | + if (apply_filters('autoptimize_filter_obkiller', false)) { |
|
217 | 217 | while (ob_get_level() > 0) { |
218 | 218 | ob_end_clean(); |
219 | 219 | } |
@@ -225,36 +225,36 @@ discard block |
||
225 | 225 | |
226 | 226 | // Action on end, this is where the magic happens |
227 | 227 | function autoptimize_end_buffering($content) { |
228 | - if ( ((stripos($content,"<html") === false) && (stripos($content,"<!DOCTYPE html") === false)) || preg_match('/<html[^>]*(?:amp|⚡)/',$content) === 1 || stripos($content,"<xsl:stylesheet") !== false ) { return $content; } |
|
228 | + if (((stripos($content, "<html") === false) && (stripos($content, "<!DOCTYPE html") === false)) || preg_match('/<html[^>]*(?:amp|⚡)/', $content) === 1 || stripos($content, "<xsl:stylesheet") !== false) { return $content; } |
|
229 | 229 | |
230 | 230 | // load URL constants as late as possible to allow domain mapper to kick in |
231 | 231 | if (function_exists("domain_mapping_siteurl")) { |
232 | - define('AUTOPTIMIZE_WP_SITE_URL',domain_mapping_siteurl(get_current_blog_id())); |
|
233 | - define('AUTOPTIMIZE_WP_CONTENT_URL',str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL),AUTOPTIMIZE_WP_SITE_URL,content_url())); |
|
232 | + define('AUTOPTIMIZE_WP_SITE_URL', domain_mapping_siteurl(get_current_blog_id())); |
|
233 | + define('AUTOPTIMIZE_WP_CONTENT_URL', str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL), AUTOPTIMIZE_WP_SITE_URL, content_url())); |
|
234 | 234 | } else { |
235 | - define('AUTOPTIMIZE_WP_SITE_URL',site_url()); |
|
236 | - define('AUTOPTIMIZE_WP_CONTENT_URL',content_url()); |
|
235 | + define('AUTOPTIMIZE_WP_SITE_URL', site_url()); |
|
236 | + define('AUTOPTIMIZE_WP_CONTENT_URL', content_url()); |
|
237 | 237 | } |
238 | 238 | |
239 | - if ( is_multisite() && apply_filters( 'autoptimize_separate_blog_caches' , true ) ) { |
|
239 | + if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) { |
|
240 | 240 | $blog_id = get_current_blog_id(); |
241 | - define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/' ); |
|
241 | + define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/'); |
|
242 | 242 | } else { |
243 | - define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR); |
|
243 | + define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR); |
|
244 | 244 | } |
245 | - define('AUTOPTIMIZE_WP_ROOT_URL',str_replace(AUTOPTIMIZE_WP_CONTENT_NAME,'',AUTOPTIMIZE_WP_CONTENT_URL)); |
|
246 | - define('AUTOPTIMIZE_HASH',wp_hash(AUTOPTIMIZE_CACHE_DIR)); |
|
245 | + define('AUTOPTIMIZE_WP_ROOT_URL', str_replace(AUTOPTIMIZE_WP_CONTENT_NAME, '', AUTOPTIMIZE_WP_CONTENT_URL)); |
|
246 | + define('AUTOPTIMIZE_HASH', wp_hash(AUTOPTIMIZE_CACHE_DIR)); |
|
247 | 247 | |
248 | 248 | // Config element |
249 | 249 | $conf = autoptimizeConfig::instance(); |
250 | 250 | |
251 | 251 | // Choose the classes |
252 | 252 | $classes = array(); |
253 | - if($conf->get('autoptimize_js')) |
|
253 | + if ($conf->get('autoptimize_js')) |
|
254 | 254 | $classes[] = 'autoptimizeScripts'; |
255 | - if($conf->get('autoptimize_css')) |
|
255 | + if ($conf->get('autoptimize_css')) |
|
256 | 256 | $classes[] = 'autoptimizeStyles'; |
257 | - if($conf->get('autoptimize_html')) |
|
257 | + if ($conf->get('autoptimize_html')) |
|
258 | 258 | $classes[] = 'autoptimizeHTML'; |
259 | 259 | |
260 | 260 | // Set some options |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | ) |
284 | 284 | ); |
285 | 285 | |
286 | - $content = apply_filters( 'autoptimize_filter_html_before_minify', $content ); |
|
286 | + $content = apply_filters('autoptimize_filter_html_before_minify', $content); |
|
287 | 287 | |
288 | 288 | // Run the classes |
289 | - foreach($classes as $name) { |
|
289 | + foreach ($classes as $name) { |
|
290 | 290 | $instance = new $name($content); |
291 | - if($instance->read($classoptions[$name])) { |
|
291 | + if ($instance->read($classoptions[$name])) { |
|
292 | 292 | $instance->minify(); |
293 | 293 | $instance->cache(); |
294 | 294 | $content = $instance->getcontent(); |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | unset($instance); |
297 | 297 | } |
298 | 298 | |
299 | - $content = apply_filters( 'autoptimize_html_after_minify', $content ); |
|
299 | + $content = apply_filters('autoptimize_html_after_minify', $content); |
|
300 | 300 | return $content; |
301 | 301 | } |
302 | 302 | |
303 | -if ( autoptimizeCache::cacheavail() ) { |
|
303 | +if (autoptimizeCache::cacheavail()) { |
|
304 | 304 | $conf = autoptimizeConfig::instance(); |
305 | - if( $conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') ) { |
|
305 | + if ($conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css')) { |
|
306 | 306 | // Hook to wordpress |
307 | 307 | if (defined('AUTOPTIMIZE_INIT_EARLIER')) { |
308 | - add_action('init','autoptimize_start_buffering',-1); |
|
308 | + add_action('init', 'autoptimize_start_buffering', -1); |
|
309 | 309 | } else { |
310 | 310 | if (!defined('AUTOPTIMIZE_HOOK_INTO')) { define('AUTOPTIMIZE_HOOK_INTO', 'template_redirect'); } |
311 | - add_action(constant("AUTOPTIMIZE_HOOK_INTO"),'autoptimize_start_buffering',2); |
|
311 | + add_action(constant("AUTOPTIMIZE_HOOK_INTO"), 'autoptimize_start_buffering', 2); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } else { |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | } |
317 | 317 | |
318 | 318 | function autoptimize_activate() { |
319 | - register_uninstall_hook( __FILE__, 'autoptimize_uninstall' ); |
|
319 | + register_uninstall_hook(__FILE__, 'autoptimize_uninstall'); |
|
320 | 320 | } |
321 | -register_activation_hook( __FILE__, 'autoptimize_activate' ); |
|
321 | +register_activation_hook(__FILE__, 'autoptimize_activate'); |
|
322 | 322 | |
323 | 323 | include_once('classlesses/autoptimizeCacheChecker.php'); |
324 | 324 | |
325 | -add_action('plugins_loaded','includeAutoptimizeExtra'); |
|
325 | +add_action('plugins_loaded', 'includeAutoptimizeExtra'); |
|
326 | 326 | function includeAutoptimizeExtra() { |
327 | - if ( apply_filters('autoptimize_filter_extra_activate',true) ) { |
|
327 | + if (apply_filters('autoptimize_filter_extra_activate', true)) { |
|
328 | 328 | include_once('classlesses/autoptimizeExtra.php'); |
329 | 329 | } |
330 | 330 | } |