@@ -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,70 +59,70 @@ 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"; |
|
62 | +$autoptimize_version = "2.3.0"; |
|
63 | 63 | |
64 | 64 | global $wpdb; |
65 | -$autoptimize_db_version = $wpdb->get_var( ' SELECT option_value FROM '.$wpdb->prefix.'options WHERE option_name = "autoptimize_version" ' ); |
|
65 | +$autoptimize_db_version = $wpdb->get_var(' SELECT option_value FROM '.$wpdb->prefix.'options WHERE option_name = "autoptimize_version" '); |
|
66 | 66 | if (!$autoptimize_db_version) { |
67 | - $autoptimize_db_version="none"; |
|
67 | + $autoptimize_db_version = "none"; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | if ($autoptimize_db_version !== $autoptimize_version) { |
71 | - if ($autoptimize_db_version==="none") { |
|
71 | + if ($autoptimize_db_version === "none") { |
|
72 | 72 | add_action('admin_notices', 'autoptimize_install_config_notice'); |
73 | 73 | } else { |
74 | 74 | // updating, include the update-code |
75 | 75 | include(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizeUpdateCode.php'); |
76 | 76 | } |
77 | 77 | |
78 | - update_option('autoptimize_version',$autoptimize_version); |
|
79 | - $autoptimize_db_version=$autoptimize_version; |
|
78 | + update_option('autoptimize_version', $autoptimize_version); |
|
79 | + $autoptimize_db_version = $autoptimize_version; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Load translations |
83 | 83 | function autoptimize_load_plugin_textdomain() { |
84 | - load_plugin_textdomain('autoptimize',false,plugin_basename(dirname( __FILE__ )).'/localization'); |
|
84 | + load_plugin_textdomain('autoptimize', false, plugin_basename(dirname(__FILE__)).'/localization'); |
|
85 | 85 | } |
86 | -add_action( 'init', 'autoptimize_load_plugin_textdomain' ); |
|
86 | +add_action('init', 'autoptimize_load_plugin_textdomain'); |
|
87 | 87 | |
88 | -function autoptimize_uninstall(){ |
|
88 | +function autoptimize_uninstall() { |
|
89 | 89 | autoptimizeCache::clearall(); |
90 | 90 | |
91 | - $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"); |
|
91 | + $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"); |
|
92 | 92 | |
93 | - if ( !is_multisite() ) { |
|
94 | - foreach ($delete_options as $del_opt) { delete_option( $del_opt ); } |
|
93 | + if (!is_multisite()) { |
|
94 | + foreach ($delete_options as $del_opt) { delete_option($del_opt); } |
|
95 | 95 | } else { |
96 | 96 | global $wpdb; |
97 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
97 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
98 | 98 | $original_blog_id = get_current_blog_id(); |
99 | - foreach ( $blog_ids as $blog_id ) { |
|
100 | - switch_to_blog( $blog_id ); |
|
101 | - foreach ($delete_options as $del_opt) { delete_option( $del_opt ); } |
|
99 | + foreach ($blog_ids as $blog_id) { |
|
100 | + switch_to_blog($blog_id); |
|
101 | + foreach ($delete_options as $del_opt) { delete_option($del_opt); } |
|
102 | 102 | } |
103 | - switch_to_blog( $original_blog_id ); |
|
103 | + switch_to_blog($original_blog_id); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( wp_get_schedule( 'ao_cachechecker' ) ) { |
|
107 | - wp_clear_scheduled_hook( 'ao_cachechecker' ); |
|
106 | + if (wp_get_schedule('ao_cachechecker')) { |
|
107 | + wp_clear_scheduled_hook('ao_cachechecker'); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | 111 | function autoptimize_install_config_notice() { |
112 | 112 | echo '<div class="updated"><p>'; |
113 | - _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize' ); |
|
113 | + _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize'); |
|
114 | 114 | echo '</p></div>'; |
115 | 115 | } |
116 | 116 | |
117 | 117 | function autoptimize_update_config_notice() { |
118 | 118 | echo '<div class="updated"><p>'; |
119 | - _e('Autoptimize has just been updated. Please <strong>test your site now</strong> and adapt Autoptimize config if needed.', 'autoptimize' ); |
|
119 | + _e('Autoptimize has just been updated. Please <strong>test your site now</strong> and adapt Autoptimize config if needed.', 'autoptimize'); |
|
120 | 120 | echo '</p></div>'; |
121 | 121 | } |
122 | 122 | |
123 | 123 | function autoptimize_cache_unavailable_notice() { |
124 | 124 | echo '<div class="error"><p>'; |
125 | - printf( __( 'Autoptimize cannot write to the cache directory (%s), please fix to enable CSS/ JS optimization!', 'autoptimize' ), AUTOPTIMIZE_CACHE_DIR ); |
|
125 | + printf(__('Autoptimize cannot write to the cache directory (%s), please fix to enable CSS/ JS optimization!', 'autoptimize'), AUTOPTIMIZE_CACHE_DIR); |
|
126 | 126 | echo '</p></div>'; |
127 | 127 | } |
128 | 128 | |
@@ -131,27 +131,27 @@ discard block |
||
131 | 131 | $ao_noptimize = false; |
132 | 132 | |
133 | 133 | // noptimize in qs to get non-optimized page for debugging |
134 | - if (array_key_exists("ao_noptimize",$_GET) || array_key_exists("ao_noptirocket",$_GET)) { |
|
135 | - if ( ( ($_GET["ao_noptimize"]==="1") || ($_GET["ao_noptirocket"]==="1") ) && (apply_filters('autoptimize_filter_honor_qs_noptimize',true)) ) { |
|
134 | + if (array_key_exists("ao_noptimize", $_GET) || array_key_exists("ao_noptirocket", $_GET)) { |
|
135 | + if ((($_GET["ao_noptimize"] === "1") || ($_GET["ao_noptirocket"] === "1")) && (apply_filters('autoptimize_filter_honor_qs_noptimize', true))) { |
|
136 | 136 | $ao_noptimize = true; |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | 140 | // check for DONOTMINIFY constant as used by e.g. WooCommerce POS |
141 | - if (defined('DONOTMINIFY') && (constant('DONOTMINIFY')===true || constant('DONOTMINIFY')==="true")) { |
|
141 | + if (defined('DONOTMINIFY') && (constant('DONOTMINIFY') === true || constant('DONOTMINIFY') === "true")) { |
|
142 | 142 | $ao_noptimize = true; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // if setting says not to optimize logged in user and user is logged in |
146 | - if ( get_option('autoptimize_optimize_logged','on') !== 'on' && is_user_logged_in() && current_user_can('edit_posts') ) { |
|
146 | + if (get_option('autoptimize_optimize_logged', 'on') !== 'on' && is_user_logged_in() && current_user_can('edit_posts')) { |
|
147 | 147 | $ao_noptimize = true; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // if setting says not to optimize cart/ checkout |
151 | - if ( get_option('autoptimize_optimize_checkout','on') !== 'on' ) { |
|
151 | + if (get_option('autoptimize_optimize_checkout', 'on') !== 'on') { |
|
152 | 152 | // checking for woocommerce, easy digital downloads and wp ecommerce |
153 | - foreach ( array("is_checkout","is_cart","edd_is_checkout","wpsc_is_cart","wpsc_is_checkout") as $shopCond ) { |
|
154 | - if ( function_exists($shopCond) && $shopCond() ) { |
|
153 | + foreach (array("is_checkout", "is_cart", "edd_is_checkout", "wpsc_is_cart", "wpsc_is_checkout") as $shopCond) { |
|
154 | + if (function_exists($shopCond) && $shopCond()) { |
|
155 | 155 | $ao_noptimize = true; |
156 | 156 | break; |
157 | 157 | } |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | // filter you can use to block autoptimization on your own terms |
162 | - $ao_noptimize = (bool) apply_filters( 'autoptimize_filter_noptimize', $ao_noptimize ); |
|
162 | + $ao_noptimize = (bool) apply_filters('autoptimize_filter_noptimize', $ao_noptimize); |
|
163 | 163 | |
164 | - if (!is_feed() && !$ao_noptimize && !is_admin() && ( !function_exists('is_customize_preview') || !is_customize_preview() ) ) { |
|
164 | + if (!is_feed() && !$ao_noptimize && !is_admin() && (!function_exists('is_customize_preview') || !is_customize_preview())) { |
|
165 | 165 | // load speedupper conditionally (true by default?) |
166 | - if ( apply_filters('autoptimize_filter_speedupper', true) ) { |
|
166 | + if (apply_filters('autoptimize_filter_speedupper', true)) { |
|
167 | 167 | include(AUTOPTIMIZE_PLUGIN_DIR.'classlesses/autoptimizeSpeedupper.php'); |
168 | 168 | } |
169 | 169 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeBase.php'); |
175 | 175 | |
176 | 176 | // Load extra classes and set some vars |
177 | - if($conf->get('autoptimize_html')) { |
|
177 | + if ($conf->get('autoptimize_html')) { |
|
178 | 178 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeHTML.php'); |
179 | 179 | // BUG: new minify-html does not support keeping HTML comments, skipping for now |
180 | 180 | // if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | // } |
185 | 185 | } |
186 | 186 | |
187 | - if($conf->get('autoptimize_js')) { |
|
187 | + if ($conf->get('autoptimize_js')) { |
|
188 | 188 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeScripts.php'); |
189 | 189 | if (!class_exists('JSMin')) { |
190 | 190 | if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | @include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/minify-2.3.1-jsmin.php'); |
194 | 194 | } |
195 | 195 | } |
196 | - if ( ! defined( 'CONCATENATE_SCRIPTS' )) { |
|
197 | - define('CONCATENATE_SCRIPTS',false); |
|
196 | + if (!defined('CONCATENATE_SCRIPTS')) { |
|
197 | + define('CONCATENATE_SCRIPTS', false); |
|
198 | 198 | } |
199 | - if ( ! defined( 'COMPRESS_SCRIPTS' )) { |
|
200 | - define('COMPRESS_SCRIPTS',false); |
|
199 | + if (!defined('COMPRESS_SCRIPTS')) { |
|
200 | + define('COMPRESS_SCRIPTS', false); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if($conf->get('autoptimize_css')) { |
|
204 | + if ($conf->get('autoptimize_css')) { |
|
205 | 205 | include(AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeStyles.php'); |
206 | 206 | if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { |
207 | 207 | if (!class_exists('Minify_CSS_Compressor')) { |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | @include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/yui-php-cssmin-2.4.8-4_fgo.php'); |
213 | 213 | } |
214 | 214 | } |
215 | - if ( ! defined( 'COMPRESS_CSS' )) { |
|
216 | - define('COMPRESS_CSS',false); |
|
215 | + if (!defined('COMPRESS_CSS')) { |
|
216 | + define('COMPRESS_CSS', false); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | // filter to be used with care, kills all output buffers when true. use with extreme caution. you have been warned! |
221 | - if (apply_filters('autoptimize_filter_obkiller',false)) { |
|
221 | + if (apply_filters('autoptimize_filter_obkiller', false)) { |
|
222 | 222 | while (ob_get_level() > 0) { |
223 | 223 | ob_end_clean(); |
224 | 224 | } |
@@ -230,36 +230,36 @@ discard block |
||
230 | 230 | |
231 | 231 | // Action on end, this is where the magic happens |
232 | 232 | function autoptimize_end_buffering($content) { |
233 | - if ( ((stripos($content,"<html") === false) && (stripos($content,"<!DOCTYPE html") === false)) || preg_match('/<html[^>]*(?:amp|⚡)/',$content) === 1 || stripos($content,"<xsl:stylesheet") !== false ) { return $content; } |
|
233 | + if (((stripos($content, "<html") === false) && (stripos($content, "<!DOCTYPE html") === false)) || preg_match('/<html[^>]*(?:amp|⚡)/', $content) === 1 || stripos($content, "<xsl:stylesheet") !== false) { return $content; } |
|
234 | 234 | |
235 | 235 | // load URL constants as late as possible to allow domain mapper to kick in |
236 | 236 | if (function_exists("domain_mapping_siteurl")) { |
237 | - define('AUTOPTIMIZE_WP_SITE_URL',domain_mapping_siteurl(get_current_blog_id())); |
|
238 | - define('AUTOPTIMIZE_WP_CONTENT_URL',str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL),AUTOPTIMIZE_WP_SITE_URL,content_url())); |
|
237 | + define('AUTOPTIMIZE_WP_SITE_URL', domain_mapping_siteurl(get_current_blog_id())); |
|
238 | + define('AUTOPTIMIZE_WP_CONTENT_URL', str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL), AUTOPTIMIZE_WP_SITE_URL, content_url())); |
|
239 | 239 | } else { |
240 | - define('AUTOPTIMIZE_WP_SITE_URL',site_url()); |
|
241 | - define('AUTOPTIMIZE_WP_CONTENT_URL',content_url()); |
|
240 | + define('AUTOPTIMIZE_WP_SITE_URL', site_url()); |
|
241 | + define('AUTOPTIMIZE_WP_CONTENT_URL', content_url()); |
|
242 | 242 | } |
243 | 243 | |
244 | - if ( is_multisite() && apply_filters( 'autoptimize_separate_blog_caches' , true ) ) { |
|
244 | + if (is_multisite() && apply_filters('autoptimize_separate_blog_caches', true)) { |
|
245 | 245 | $blog_id = get_current_blog_id(); |
246 | - define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/' ); |
|
246 | + define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR.$blog_id.'/'); |
|
247 | 247 | } else { |
248 | - define('AUTOPTIMIZE_CACHE_URL',AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR); |
|
248 | + define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL.AUTOPTIMIZE_CACHE_CHILD_DIR); |
|
249 | 249 | } |
250 | - define('AUTOPTIMIZE_WP_ROOT_URL',str_replace(AUTOPTIMIZE_WP_CONTENT_NAME,'',AUTOPTIMIZE_WP_CONTENT_URL)); |
|
251 | - define('AUTOPTIMIZE_HASH',wp_hash(AUTOPTIMIZE_CACHE_DIR)); |
|
250 | + define('AUTOPTIMIZE_WP_ROOT_URL', str_replace(AUTOPTIMIZE_WP_CONTENT_NAME, '', AUTOPTIMIZE_WP_CONTENT_URL)); |
|
251 | + define('AUTOPTIMIZE_HASH', wp_hash(AUTOPTIMIZE_CACHE_DIR)); |
|
252 | 252 | |
253 | 253 | // Config element |
254 | 254 | $conf = autoptimizeConfig::instance(); |
255 | 255 | |
256 | 256 | // Choose the classes |
257 | 257 | $classes = array(); |
258 | - if($conf->get('autoptimize_js')) |
|
258 | + if ($conf->get('autoptimize_js')) |
|
259 | 259 | $classes[] = 'autoptimizeScripts'; |
260 | - if($conf->get('autoptimize_css')) |
|
260 | + if ($conf->get('autoptimize_css')) |
|
261 | 261 | $classes[] = 'autoptimizeStyles'; |
262 | - if($conf->get('autoptimize_html')) |
|
262 | + if ($conf->get('autoptimize_html')) |
|
263 | 263 | $classes[] = 'autoptimizeHTML'; |
264 | 264 | |
265 | 265 | // Set some options |
@@ -288,12 +288,12 @@ discard block |
||
288 | 288 | ) |
289 | 289 | ); |
290 | 290 | |
291 | - $content = apply_filters( 'autoptimize_filter_html_before_minify', $content ); |
|
291 | + $content = apply_filters('autoptimize_filter_html_before_minify', $content); |
|
292 | 292 | |
293 | 293 | // Run the classes |
294 | - foreach($classes as $name) { |
|
294 | + foreach ($classes as $name) { |
|
295 | 295 | $instance = new $name($content); |
296 | - if($instance->read($classoptions[$name])) { |
|
296 | + if ($instance->read($classoptions[$name])) { |
|
297 | 297 | $instance->minify(); |
298 | 298 | $instance->cache(); |
299 | 299 | $content = $instance->getcontent(); |
@@ -301,19 +301,19 @@ discard block |
||
301 | 301 | unset($instance); |
302 | 302 | } |
303 | 303 | |
304 | - $content = apply_filters( 'autoptimize_html_after_minify', $content ); |
|
304 | + $content = apply_filters('autoptimize_html_after_minify', $content); |
|
305 | 305 | return $content; |
306 | 306 | } |
307 | 307 | |
308 | -if ( autoptimizeCache::cacheavail() ) { |
|
308 | +if (autoptimizeCache::cacheavail()) { |
|
309 | 309 | $conf = autoptimizeConfig::instance(); |
310 | - if( $conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css') ) { |
|
310 | + if ($conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css')) { |
|
311 | 311 | // Hook to wordpress |
312 | 312 | if (defined('AUTOPTIMIZE_INIT_EARLIER')) { |
313 | - add_action('init','autoptimize_start_buffering',-1); |
|
313 | + add_action('init', 'autoptimize_start_buffering', -1); |
|
314 | 314 | } else { |
315 | 315 | if (!defined('AUTOPTIMIZE_HOOK_INTO')) { define('AUTOPTIMIZE_HOOK_INTO', 'template_redirect'); } |
316 | - add_action(constant("AUTOPTIMIZE_HOOK_INTO"),'autoptimize_start_buffering',2); |
|
316 | + add_action(constant("AUTOPTIMIZE_HOOK_INTO"), 'autoptimize_start_buffering', 2); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | } else { |
@@ -321,15 +321,15 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | function autoptimize_activate() { |
324 | - register_uninstall_hook( __FILE__, 'autoptimize_uninstall' ); |
|
324 | + register_uninstall_hook(__FILE__, 'autoptimize_uninstall'); |
|
325 | 325 | } |
326 | -register_activation_hook( __FILE__, 'autoptimize_activate' ); |
|
326 | +register_activation_hook(__FILE__, 'autoptimize_activate'); |
|
327 | 327 | |
328 | 328 | include_once('classlesses/autoptimizeCacheChecker.php'); |
329 | 329 | |
330 | -add_action('plugins_loaded','includeAutoptimizeExtra'); |
|
330 | +add_action('plugins_loaded', 'includeAutoptimizeExtra'); |
|
331 | 331 | function includeAutoptimizeExtra() { |
332 | - if ( apply_filters('autoptimize_filter_extra_activate',true) ) { |
|
332 | + if (apply_filters('autoptimize_filter_extra_activate', true)) { |
|
333 | 333 | include_once('classlesses/autoptimizeExtra.php'); |
334 | 334 | } |
335 | 335 | } |