@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | protected $inputLength = 0; |
71 | 71 | protected $lookAhead = null; |
72 | 72 | protected $output = ''; |
73 | - protected $lastByteOut = ''; |
|
73 | + protected $lastByteOut = ''; |
|
74 | 74 | protected $keptComment = ''; |
75 | 75 | |
76 | 76 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | $mbIntEnc = null; |
109 | - if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) { |
|
109 | + if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) { |
|
110 | 110 | $mbIntEnc = mb_internal_encoding(); |
111 | 111 | mb_internal_encoding('8bit'); |
112 | 112 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | && ($this->b === $this->lastByteOut)) { |
129 | 129 | // Don't delete this space. If we do, the addition/subtraction |
130 | 130 | // could be parsed as a post-increment |
131 | - } elseif (! $this->isAlphaNum($this->b)) { |
|
131 | + } elseif (!$this->isAlphaNum($this->b)) { |
|
132 | 132 | $command = self::ACTION_DELETE_A; |
133 | 133 | } |
134 | 134 | } elseif ($this->a === "\n") { |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | // otherwise mb_strpos will give WARNING |
140 | 140 | } elseif ($this->b === null |
141 | 141 | || (false === strpos('{[(+-!~', $this->b) |
142 | - && ! $this->isAlphaNum($this->b))) { |
|
142 | + && !$this->isAlphaNum($this->b))) { |
|
143 | 143 | $command = self::ACTION_DELETE_A; |
144 | 144 | } |
145 | - } elseif (! $this->isAlphaNum($this->a)) { |
|
145 | + } elseif (!$this->isAlphaNum($this->a)) { |
|
146 | 146 | if ($this->b === ' ' |
147 | 147 | || ($this->b === "\n" |
148 | 148 | && (false === strpos('}])+-"\'', $this->a)))) { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | if ($this->a === "'" || $this->a === '"' || $this->a === '`') { // string/template literal |
200 | 200 | $delimiter = $this->a; |
201 | 201 | $str = $this->a; // in case needed for exception |
202 | - for(;;) { |
|
202 | + for (;;) { |
|
203 | 203 | $this->output .= $this->a; |
204 | 204 | $this->lastByteOut = $this->a; |
205 | 205 | |
@@ -229,13 +229,13 @@ discard block |
||
229 | 229 | case self::ACTION_DELETE_A_B: // 3 |
230 | 230 | $this->b = $this->next(); |
231 | 231 | if ($this->b === '/' && $this->isRegexpLiteral()) { |
232 | - $this->output .= $this->a . $this->b; |
|
232 | + $this->output .= $this->a.$this->b; |
|
233 | 233 | $pattern = '/'; // keep entire pattern in case we need to report it in the exception |
234 | - for(;;) { |
|
234 | + for (;;) { |
|
235 | 235 | $this->a = $this->get(); |
236 | 236 | $pattern .= $this->a; |
237 | 237 | if ($this->a === '[') { |
238 | - for(;;) { |
|
238 | + for (;;) { |
|
239 | 239 | $this->output .= $this->a; |
240 | 240 | $this->a = $this->get(); |
241 | 241 | $pattern .= $this->a; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | if ($this->isEOF($this->a)) { |
251 | 251 | throw new JSMin_UnterminatedRegExpException( |
252 | 252 | "JSMin: Unterminated set in RegExp at byte " |
253 | - . $this->inputIndex .": {$pattern}"); |
|
253 | + . $this->inputIndex.": {$pattern}"); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | // if the "/" follows a keyword, it must be a regexp, otherwise it's best to assume division |
297 | 297 | |
298 | - $subject = $this->output . trim($this->a); |
|
298 | + $subject = $this->output.trim($this->a); |
|
299 | 299 | if (!preg_match('/(?:case|else|in|return|typeof)$/', $subject, $m)) { |
300 | 300 | // not a keyword |
301 | 301 | return false; |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | { |
407 | 407 | $this->get(); |
408 | 408 | $comment = ''; |
409 | - for(;;) { |
|
409 | + for (;;) { |
|
410 | 410 | $get = $this->get(); |
411 | 411 | if ($get === '*') { |
412 | 412 | if ($this->peek() === '/') { // end of comment reached |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | // don't prepend a newline if two comments right after one another |
418 | 418 | $this->keptComment = "\n"; |
419 | 419 | } |
420 | - $this->keptComment .= "/*!" . substr($comment, 1) . "*/\n"; |
|
420 | + $this->keptComment .= "/*!".substr($comment, 1)."*/\n"; |
|
421 | 421 | } else if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) { |
422 | 422 | // IE conditional |
423 | 423 | $this->keptComment .= "/*{$comment}*/"; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * Checks if cachesize is > 0.5GB (size is filterable), if so, an option is set which controls showing an admin notice. |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
@@ -25,51 +25,51 @@ discard block |
||
25 | 25 | |
26 | 26 | public function add_hooks() |
27 | 27 | { |
28 | - if ( is_admin() ) { |
|
29 | - add_action( 'plugins_loaded', array( $this, 'setup' ) ); |
|
28 | + if (is_admin()) { |
|
29 | + add_action('plugins_loaded', array($this, 'setup')); |
|
30 | 30 | } |
31 | - add_action( self::SCHEDULE_HOOK, array( $this, 'cronjob' ) ); |
|
32 | - add_action( 'admin_notices', array( $this, 'show_admin_notice' ) ); |
|
31 | + add_action(self::SCHEDULE_HOOK, array($this, 'cronjob')); |
|
32 | + add_action('admin_notices', array($this, 'show_admin_notice')); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setup() |
36 | 36 | { |
37 | - $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true ); |
|
38 | - $schedule = wp_get_schedule( self::SCHEDULE_HOOK ); |
|
39 | - $frequency = apply_filters( 'autoptimize_filter_cachecheck_frequency', 'twicedaily' ); |
|
40 | - if ( ! in_array( $frequency, array( 'hourly', 'twicedaily', 'daily', 'weekly', 'monthly' ) ) ) { |
|
37 | + $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true); |
|
38 | + $schedule = wp_get_schedule(self::SCHEDULE_HOOK); |
|
39 | + $frequency = apply_filters('autoptimize_filter_cachecheck_frequency', 'twicedaily'); |
|
40 | + if (!in_array($frequency, array('hourly', 'twicedaily', 'daily', 'weekly', 'monthly'))) { |
|
41 | 41 | $frequency = 'twicedaily'; |
42 | 42 | } |
43 | - if ( $do_cache_check && ( ! $schedule || $schedule !== $frequency ) ) { |
|
44 | - if ( $schedule ) { |
|
45 | - wp_clear_scheduled_hook( self::SCHEDULE_HOOK ); |
|
43 | + if ($do_cache_check && (!$schedule || $schedule !== $frequency)) { |
|
44 | + if ($schedule) { |
|
45 | + wp_clear_scheduled_hook(self::SCHEDULE_HOOK); |
|
46 | 46 | } |
47 | - wp_schedule_event( time(), $frequency, self::SCHEDULE_HOOK ); |
|
48 | - } elseif ( $schedule && ! $do_cache_check ) { |
|
49 | - wp_clear_scheduled_hook( self::SCHEDULE_HOOK ); |
|
47 | + wp_schedule_event(time(), $frequency, self::SCHEDULE_HOOK); |
|
48 | + } elseif ($schedule && !$do_cache_check) { |
|
49 | + wp_clear_scheduled_hook(self::SCHEDULE_HOOK); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | public function cronjob() |
54 | 54 | { |
55 | 55 | // Check cachesize and act accordingly. |
56 | - $max_size = (int) apply_filters( 'autoptimize_filter_cachecheck_maxsize', 536870912 ); |
|
57 | - $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true ); |
|
56 | + $max_size = (int) apply_filters('autoptimize_filter_cachecheck_maxsize', 536870912); |
|
57 | + $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true); |
|
58 | 58 | $stat_array = autoptimizeCache::stats(); |
59 | - $cache_size = round( $stat_array[1] ); |
|
60 | - if ( ( $cache_size > $max_size ) && ( $do_cache_check ) ) { |
|
61 | - update_option( 'autoptimize_cachesize_notice', true ); |
|
62 | - if ( apply_filters( 'autoptimize_filter_cachecheck_sendmail', true ) ) { |
|
63 | - $site_url = esc_url( site_url() ); |
|
64 | - $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', get_option( 'admin_email', '' ) ); |
|
65 | - |
|
66 | - $ao_mailsubject = __( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $site_url . ')'; |
|
67 | - $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: ' . $site_url . ')'; |
|
68 | - |
|
69 | - if ( ! empty( $ao_mailto ) ) { |
|
70 | - $ao_mailresult = wp_mail( $ao_mailto, $ao_mailsubject, $ao_mailbody ); |
|
71 | - if ( ! $ao_mailresult ) { |
|
72 | - error_log( 'Autoptimize could not send cache size warning mail.' ); |
|
59 | + $cache_size = round($stat_array[1]); |
|
60 | + if (($cache_size > $max_size) && ($do_cache_check)) { |
|
61 | + update_option('autoptimize_cachesize_notice', true); |
|
62 | + if (apply_filters('autoptimize_filter_cachecheck_sendmail', true)) { |
|
63 | + $site_url = esc_url(site_url()); |
|
64 | + $ao_mailto = apply_filters('autoptimize_filter_cachecheck_mailto', get_option('admin_email', '')); |
|
65 | + |
|
66 | + $ao_mailsubject = __('Autoptimize cache size warning', 'autoptimize').' ('.$site_url.')'; |
|
67 | + $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: '.$site_url.')'; |
|
68 | + |
|
69 | + if (!empty($ao_mailto)) { |
|
70 | + $ao_mailresult = wp_mail($ao_mailto, $ao_mailsubject, $ao_mailbody); |
|
71 | + if (!$ao_mailresult) { |
|
72 | + error_log('Autoptimize could not send cache size warning mail.'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | |
88 | 88 | public function show_admin_notice() |
89 | 89 | { |
90 | - if ( (bool) get_option( 'autoptimize_cachesize_notice', false ) && current_user_can( 'manage_options' ) ) { |
|
90 | + if ((bool) get_option('autoptimize_cachesize_notice', false) && current_user_can('manage_options')) { |
|
91 | 91 | echo '<div class="notice notice-warning"><p>'; |
92 | - _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" rel="noopener noreferrer">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize' ); |
|
92 | + _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" rel="noopener noreferrer">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize'); |
|
93 | 93 | echo '</p></div>'; |
94 | - update_option( 'autoptimize_cachesize_notice', false ); |
|
94 | + update_option('autoptimize_cachesize_notice', false); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | // Notice for image proxy usage. |
98 | 98 | $_imgopt_notice = autoptimizeExtra::get_imgopt_status_notice_wrapper(); |
99 | - if ( current_user_can( 'manage_options' ) && is_array( $_imgopt_notice ) && array_key_exists( 'status', $_imgopt_notice ) && in_array( $_imgopt_notice['status'], array( 1, -1, -2 ) ) ) { |
|
99 | + if (current_user_can('manage_options') && is_array($_imgopt_notice) && array_key_exists('status', $_imgopt_notice) && in_array($_imgopt_notice['status'], array(1, -1, -2))) { |
|
100 | 100 | $_dismissible = 'ao-img-opt-notice-'; |
101 | 101 | $_hide_notice = '7'; |
102 | 102 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | $_hide_notice = '1'; |
105 | 105 | } |
106 | 106 | |
107 | - $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice ); |
|
107 | + $_imgopt_notice_dismissible = apply_filters('autoptimize_filter_imgopt_notice_dismissable', $_dismissible.$_hide_notice); |
|
108 | 108 | |
109 | - if ( $_imgopt_notice && PAnD::is_admin_notice_active( $_imgopt_notice_dismissible ) ) { |
|
110 | - echo '<div class="notice notice-warning is-dismissible" data-dismissible="' . $_imgopt_notice_dismissible . '"><p>' . $_imgopt_notice['notice'] . '</p></div>'; |
|
109 | + if ($_imgopt_notice && PAnD::is_admin_notice_active($_imgopt_notice_dismissible)) { |
|
110 | + echo '<div class="notice notice-warning is-dismissible" data-dismissible="'.$_imgopt_notice_dismissible.'"><p>'.$_imgopt_notice['notice'].'</p></div>'; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Handles version updates and should only be instantiated in autoptimize.php if/when needed. |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected $current_major_version = null; |
18 | 18 | |
19 | - public function __construct( $current_version ) |
|
19 | + public function __construct($current_version) |
|
20 | 20 | { |
21 | - $this->current_major_version = substr( $current_version, 0, 3 ); |
|
21 | + $this->current_major_version = substr($current_version, 0, 3); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $major_update = false; |
31 | 31 | |
32 | - switch ( $this->current_major_version ) { |
|
32 | + switch ($this->current_major_version) { |
|
33 | 33 | case '1.6': |
34 | 34 | $this->upgrade_from_1_6(); |
35 | 35 | $major_update = true; |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | $major_update = true; |
48 | 48 | // No break, intentionally, so all upgrades are ran during a single request... |
49 | 49 | case '2.4': |
50 | - if ( get_option( 'autoptimize_version', 'none' ) == '2.4.2' ) { |
|
50 | + if (get_option('autoptimize_version', 'none') == '2.4.2') { |
|
51 | 51 | $this->upgrade_from_2_4_2(); |
52 | 52 | } |
53 | 53 | $major_update = false; |
54 | 54 | // No break, intentionally, so all upgrades are ran during a single request... |
55 | 55 | } |
56 | 56 | |
57 | - if ( true === $major_update ) { |
|
57 | + if (true === $major_update) { |
|
58 | 58 | $this->on_major_version_update(); |
59 | 59 | } |
60 | 60 | } |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param string $target Target version to check against (ie., the currently running one). |
68 | 68 | */ |
69 | - public static function check_installed_and_update( $target ) |
|
69 | + public static function check_installed_and_update($target) |
|
70 | 70 | { |
71 | - $db_version = get_option( 'autoptimize_version', 'none' ); |
|
72 | - if ( $db_version !== $target ) { |
|
73 | - if ( 'none' === $db_version ) { |
|
74 | - add_action( 'admin_notices', 'autoptimizeMain::notice_installed' ); |
|
71 | + $db_version = get_option('autoptimize_version', 'none'); |
|
72 | + if ($db_version !== $target) { |
|
73 | + if ('none' === $db_version) { |
|
74 | + add_action('admin_notices', 'autoptimizeMain::notice_installed'); |
|
75 | 75 | } else { |
76 | - $updater = new self( $db_version ); |
|
76 | + $updater = new self($db_version); |
|
77 | 77 | $updater->run_needed_major_upgrades(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Versions differed, upgrades happened if needed, store the new version. |
81 | - update_option( 'autoptimize_version', $target ); |
|
81 | + update_option('autoptimize_version', $target); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | protected function on_major_version_update() |
90 | 90 | { |
91 | 91 | // The transients guard here prevents stale object caches from busting the cache on every request. |
92 | - if ( false == get_transient( 'autoptimize_stale_option_buster' ) ) { |
|
93 | - set_transient( 'autoptimize_stale_option_buster', 'Mamsie & Liessie zehhe: ZWIJH!', HOUR_IN_SECONDS ); |
|
92 | + if (false == get_transient('autoptimize_stale_option_buster')) { |
|
93 | + set_transient('autoptimize_stale_option_buster', 'Mamsie & Liessie zehhe: ZWIJH!', HOUR_IN_SECONDS); |
|
94 | 94 | autoptimizeCache::clearall(); |
95 | - add_action( 'admin_notices', 'autoptimizeMain::notice_updated' ); |
|
95 | + add_action('admin_notices', 'autoptimizeMain::notice_updated'); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | private function upgrade_from_1_6() |
103 | 103 | { |
104 | 104 | // If user was on version 1.6.x, force advanced options to be shown by default. |
105 | - update_option( 'autoptimize_show_adv', '1' ); |
|
105 | + update_option('autoptimize_show_adv', '1'); |
|
106 | 106 | |
107 | 107 | // And remove old options. |
108 | 108 | $to_delete_options = array( |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | 'autoptimize_cdn_img_url', |
115 | 115 | 'autoptimize_css_yui', |
116 | 116 | ); |
117 | - foreach ( $to_delete_options as $del_opt ) { |
|
118 | - delete_option( $del_opt ); |
|
117 | + foreach ($to_delete_options as $del_opt) { |
|
118 | + delete_option($del_opt); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -126,29 +126,29 @@ discard block |
||
126 | 126 | */ |
127 | 127 | private function upgrade_from_1_7() |
128 | 128 | { |
129 | - if ( ! is_multisite() ) { |
|
130 | - $css_exclude = get_option( 'autoptimize_css_exclude' ); |
|
131 | - if ( empty( $css_exclude ) ) { |
|
129 | + if (!is_multisite()) { |
|
130 | + $css_exclude = get_option('autoptimize_css_exclude'); |
|
131 | + if (empty($css_exclude)) { |
|
132 | 132 | $css_exclude = 'admin-bar.min.css, dashicons.min.css'; |
133 | - } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) { |
|
133 | + } elseif (false === strpos($css_exclude, 'dashicons.min.css')) { |
|
134 | 134 | $css_exclude .= ', dashicons.min.css'; |
135 | 135 | } |
136 | - update_option( 'autoptimize_css_exclude', $css_exclude ); |
|
136 | + update_option('autoptimize_css_exclude', $css_exclude); |
|
137 | 137 | } else { |
138 | 138 | global $wpdb; |
139 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
139 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
140 | 140 | $original_blog_id = get_current_blog_id(); |
141 | - foreach ( $blog_ids as $blog_id ) { |
|
142 | - switch_to_blog( $blog_id ); |
|
143 | - $css_exclude = get_option( 'autoptimize_css_exclude' ); |
|
144 | - if ( empty( $css_exclude ) ) { |
|
141 | + foreach ($blog_ids as $blog_id) { |
|
142 | + switch_to_blog($blog_id); |
|
143 | + $css_exclude = get_option('autoptimize_css_exclude'); |
|
144 | + if (empty($css_exclude)) { |
|
145 | 145 | $css_exclude = 'admin-bar.min.css, dashicons.min.css'; |
146 | - } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) { |
|
146 | + } elseif (false === strpos($css_exclude, 'dashicons.min.css')) { |
|
147 | 147 | $css_exclude .= ', dashicons.min.css'; |
148 | 148 | } |
149 | - update_option( 'autoptimize_css_exclude', $css_exclude ); |
|
149 | + update_option('autoptimize_css_exclude', $css_exclude); |
|
150 | 150 | } |
151 | - switch_to_blog( $original_blog_id ); |
|
151 | + switch_to_blog($original_blog_id); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -160,19 +160,19 @@ discard block |
||
160 | 160 | */ |
161 | 161 | private function upgrade_from_1_9() |
162 | 162 | { |
163 | - if ( ! is_multisite() ) { |
|
164 | - update_option( 'autoptimize_css_include_inline', 'on' ); |
|
165 | - update_option( 'autoptimize_js_include_inline', 'on' ); |
|
163 | + if (!is_multisite()) { |
|
164 | + update_option('autoptimize_css_include_inline', 'on'); |
|
165 | + update_option('autoptimize_js_include_inline', 'on'); |
|
166 | 166 | } else { |
167 | 167 | global $wpdb; |
168 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
168 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
169 | 169 | $original_blog_id = get_current_blog_id(); |
170 | - foreach ( $blog_ids as $blog_id ) { |
|
171 | - switch_to_blog( $blog_id ); |
|
172 | - update_option( 'autoptimize_css_include_inline', 'on' ); |
|
173 | - update_option( 'autoptimize_js_include_inline', 'on' ); |
|
170 | + foreach ($blog_ids as $blog_id) { |
|
171 | + switch_to_blog($blog_id); |
|
172 | + update_option('autoptimize_css_include_inline', 'on'); |
|
173 | + update_option('autoptimize_js_include_inline', 'on'); |
|
174 | 174 | } |
175 | - switch_to_blog( $original_blog_id ); |
|
175 | + switch_to_blog($original_blog_id); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | */ |
184 | 184 | private function upgrade_from_2_2() |
185 | 185 | { |
186 | - if ( ! is_multisite() ) { |
|
186 | + if (!is_multisite()) { |
|
187 | 187 | $this->do_2_2_settings_update(); |
188 | 188 | } else { |
189 | 189 | global $wpdb; |
190 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
190 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
191 | 191 | $original_blog_id = get_current_blog_id(); |
192 | - foreach ( $blog_ids as $blog_id ) { |
|
193 | - switch_to_blog( $blog_id ); |
|
192 | + foreach ($blog_ids as $blog_id) { |
|
193 | + switch_to_blog($blog_id); |
|
194 | 194 | $this->do_2_2_settings_update(); |
195 | 195 | } |
196 | - switch_to_blog( $original_blog_id ); |
|
196 | + switch_to_blog($original_blog_id); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | */ |
203 | 203 | private function do_2_2_settings_update() |
204 | 204 | { |
205 | - $nogooglefont = get_option( 'autoptimize_css_nogooglefont', '' ); |
|
206 | - $ao_extrasetting = get_option( 'autoptimize_extra_settings', '' ); |
|
207 | - if ( ( $nogooglefont ) && ( empty( $ao_extrasetting ) ) ) { |
|
208 | - update_option( 'autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options() ); |
|
205 | + $nogooglefont = get_option('autoptimize_css_nogooglefont', ''); |
|
206 | + $ao_extrasetting = get_option('autoptimize_extra_settings', ''); |
|
207 | + if (($nogooglefont) && (empty($ao_extrasetting))) { |
|
208 | + update_option('autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options()); |
|
209 | 209 | } |
210 | - delete_option( 'autoptimize_css_nogooglefont' ); |
|
210 | + delete_option('autoptimize_css_nogooglefont'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | $jobs = _get_cron_array(); |
220 | 220 | |
221 | 221 | // Remove all ao_cachechecker cron jobs (for now). |
222 | - foreach ( $jobs as $when => $job ) { |
|
223 | - $name = key( $job ); |
|
222 | + foreach ($jobs as $when => $job) { |
|
223 | + $name = key($job); |
|
224 | 224 | |
225 | - if ( false !== strpos( $name, 'ao_cachechecker' ) ) { |
|
226 | - unset( $jobs[ $when ] ); |
|
225 | + if (false !== strpos($name, 'ao_cachechecker')) { |
|
226 | + unset($jobs[$when]); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Save the data. |
231 | - _set_cron_array( $jobs ); |
|
231 | + _set_cron_array($jobs); |
|
232 | 232 | } |
233 | 233 | } |
@@ -16,66 +16,66 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | |
19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
19 | +if (!defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
23 | -define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.4.4' ); |
|
23 | +define('AUTOPTIMIZE_PLUGIN_VERSION', '2.4.4'); |
|
24 | 24 | |
25 | 25 | // plugin_dir_path() returns the trailing slash! |
26 | -define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
27 | -define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ ); |
|
26 | +define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
27 | +define('AUTOPTIMIZE_PLUGIN_FILE', __FILE__); |
|
28 | 28 | |
29 | 29 | // Bail early if attempting to run on non-supported php versions. |
30 | -if ( version_compare( PHP_VERSION, '5.3', '<' ) ) { |
|
30 | +if (version_compare(PHP_VERSION, '5.3', '<')) { |
|
31 | 31 | function autoptimize_incompatible_admin_notice() { |
32 | - echo '<div class="error"><p>' . __( 'Autoptimize requires PHP 5.3 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>'; |
|
33 | - if ( isset( $_GET['activate'] ) ) { |
|
34 | - unset( $_GET['activate'] ); |
|
32 | + echo '<div class="error"><p>'.__('Autoptimize requires PHP 5.3 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize').'</p></div>'; |
|
33 | + if (isset($_GET['activate'])) { |
|
34 | + unset($_GET['activate']); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | function autoptimize_deactivate_self() { |
38 | - deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) ); |
|
38 | + deactivate_plugins(plugin_basename(AUTOPTIMIZE_PLUGIN_FILE)); |
|
39 | 39 | } |
40 | - add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' ); |
|
41 | - add_action( 'admin_init', 'autoptimize_deactivate_self' ); |
|
40 | + add_action('admin_notices', 'autoptimize_incompatible_admin_notice'); |
|
41 | + add_action('admin_init', 'autoptimize_deactivate_self'); |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | -function autoptimize_autoload( $class_name ) { |
|
46 | - if ( in_array( $class_name, array( 'Minify_HTML', 'JSMin' ) ) ) { |
|
47 | - $file = strtolower( $class_name ); |
|
48 | - $file = str_replace( '_', '-', $file ); |
|
49 | - $path = dirname( __FILE__ ) . '/classes/external/php/'; |
|
50 | - $filepath = $path . $file . '.php'; |
|
51 | - } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) { |
|
52 | - $file = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name ); |
|
53 | - $path = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/'; |
|
54 | - $filepath = $path . $file . '.php'; |
|
55 | - } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) { |
|
45 | +function autoptimize_autoload($class_name) { |
|
46 | + if (in_array($class_name, array('Minify_HTML', 'JSMin'))) { |
|
47 | + $file = strtolower($class_name); |
|
48 | + $file = str_replace('_', '-', $file); |
|
49 | + $path = dirname(__FILE__).'/classes/external/php/'; |
|
50 | + $filepath = $path.$file.'.php'; |
|
51 | + } elseif (false !== strpos($class_name, 'Autoptimize\\tubalmartin\\CssMin')) { |
|
52 | + $file = str_replace('Autoptimize\\tubalmartin\\CssMin\\', '', $class_name); |
|
53 | + $path = dirname(__FILE__).'/classes/external/php/yui-php-cssmin-bundled/'; |
|
54 | + $filepath = $path.$file.'.php'; |
|
55 | + } elseif ('autoptimize' === substr($class_name, 0, 11)) { |
|
56 | 56 | // One of our "old" classes. |
57 | 57 | $file = $class_name; |
58 | - $path = dirname( __FILE__ ) . '/classes/'; |
|
59 | - $filepath = $path . $file . '.php'; |
|
60 | - } elseif ( 'PAnD' === $class_name ) { |
|
58 | + $path = dirname(__FILE__).'/classes/'; |
|
59 | + $filepath = $path.$file.'.php'; |
|
60 | + } elseif ('PAnD' === $class_name) { |
|
61 | 61 | $file = 'persist-admin-notices-dismissal'; |
62 | - $path = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/'; |
|
63 | - $filepath = $path . $file . '.php'; |
|
62 | + $path = dirname(__FILE__).'/classes/external/php/persist-admin-notices-dismissal/'; |
|
63 | + $filepath = $path.$file.'.php'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // If we didn't match one of our rules, bail! |
67 | - if ( ! isset( $filepath ) ) { |
|
67 | + if (!isset($filepath)) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | 71 | require $filepath; |
72 | 72 | } |
73 | 73 | |
74 | -spl_autoload_register( 'autoptimize_autoload' ); |
|
74 | +spl_autoload_register('autoptimize_autoload'); |
|
75 | 75 | |
76 | 76 | // Load WP CLI command(s) on demand. |
77 | -if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
78 | - require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php'; |
|
77 | +if (defined('WP_CLI') && WP_CLI) { |
|
78 | + require AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCLI.php'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | function autoptimize() { |
87 | 87 | static $plugin = null; |
88 | 88 | |
89 | - if ( null === $plugin ) { |
|
90 | - $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE ); |
|
89 | + if (null === $plugin) { |
|
90 | + $plugin = new autoptimizeMain(AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $plugin; |
@@ -414,6 +414,10 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | // Checks against the white- and blacklists |
417 | + |
|
418 | + /** |
|
419 | + * @param string $tag |
|
420 | + */ |
|
417 | 421 | private function ismergeable($tag) |
418 | 422 | { |
419 | 423 | if ( ! $this->aggregate ) { |
@@ -534,7 +538,7 @@ discard block |
||
534 | 538 | * @param string $filepath Filepath. |
535 | 539 | * @param bool $cache_miss Optional. Force a cache miss. Default false. |
536 | 540 | * |
537 | - * @return bool|string Url pointing to the minified js file or false. |
|
541 | + * @return false|string Url pointing to the minified js file or false. |
|
538 | 542 | */ |
539 | 543 | public function minify_single( $filepath, $cache_miss = false ) |
540 | 544 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | ); |
14 | 14 | |
15 | 15 | private $dontmove = array( |
16 | - 'document.write','html5.js','show_ads.js','google_ad','histats.com/js','statcounter.com/counter/counter.js', |
|
17 | - 'ws.amazon.com/widgets','media.fastclick.net','/ads/','comment-form-quicktags/quicktags.php','edToolbar', |
|
18 | - 'intensedebate.com','scripts.chitika.net/','_gaq.push','jotform.com/','admin-bar.min.js','GoogleAnalyticsObject', |
|
19 | - 'plupload.full.min.js','syntaxhighlighter','adsbygoogle','gist.github.com','_stq','nonce','post_id','data-noptimize' |
|
16 | + 'document.write', 'html5.js', 'show_ads.js', 'google_ad', 'histats.com/js', 'statcounter.com/counter/counter.js', |
|
17 | + 'ws.amazon.com/widgets', 'media.fastclick.net', '/ads/', 'comment-form-quicktags/quicktags.php', 'edToolbar', |
|
18 | + 'intensedebate.com', 'scripts.chitika.net/', '_gaq.push', 'jotform.com/', 'admin-bar.min.js', 'GoogleAnalyticsObject', |
|
19 | + 'plupload.full.min.js', 'syntaxhighlighter', 'adsbygoogle', 'gist.github.com', '_stq', 'nonce', 'post_id', 'data-noptimize' |
|
20 | 20 | ,'logHuman' |
21 | 21 | ); |
22 | 22 | private $domove = array( |
23 | - 'gaJsHost','load_cmc','jd.gallery.transitions.js','swfobject.embedSWF(','tiny_mce.js','tinyMCEPreInit.go' |
|
23 | + 'gaJsHost', 'load_cmc', 'jd.gallery.transitions.js', 'swfobject.embedSWF(', 'tiny_mce.js', 'tinyMCEPreInit.go' |
|
24 | 24 | ); |
25 | 25 | private $domovelast = array( |
26 | - 'addthis.com','/afsonline/show_afs_search.js','disqus.js','networkedblogs.com/getnetworkwidget','infolinks.com/js/', |
|
27 | - 'jd.gallery.js.php','jd.gallery.transitions.js','swfobject.embedSWF(','linkwithin.com/widget.js','tiny_mce.js','tinyMCEPreInit.go' |
|
26 | + 'addthis.com', '/afsonline/show_afs_search.js', 'disqus.js', 'networkedblogs.com/getnetworkwidget', 'infolinks.com/js/', |
|
27 | + 'jd.gallery.js.php', 'jd.gallery.transitions.js', 'swfobject.embedSWF(', 'linkwithin.com/widget.js', 'tiny_mce.js', 'tinyMCEPreInit.go' |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | private $aggregate = true; |
@@ -43,84 +43,84 @@ discard block |
||
43 | 43 | // Reads the page and collects script tags |
44 | 44 | public function read($options) |
45 | 45 | { |
46 | - $noptimizeJS = apply_filters( 'autoptimize_filter_js_noptimize', false, $this->content ); |
|
47 | - if ( $noptimizeJS ) { |
|
46 | + $noptimizeJS = apply_filters('autoptimize_filter_js_noptimize', false, $this->content); |
|
47 | + if ($noptimizeJS) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
51 | 51 | // only optimize known good JS? |
52 | - $whitelistJS = apply_filters( 'autoptimize_filter_js_whitelist', '', $this->content ); |
|
53 | - if ( ! empty( $whitelistJS ) ) { |
|
54 | - $this->whitelist = array_filter( array_map( 'trim', explode( ',', $whitelistJS ) ) ); |
|
52 | + $whitelistJS = apply_filters('autoptimize_filter_js_whitelist', '', $this->content); |
|
53 | + if (!empty($whitelistJS)) { |
|
54 | + $this->whitelist = array_filter(array_map('trim', explode(',', $whitelistJS))); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // is there JS we should simply remove |
58 | - $removableJS = apply_filters( 'autoptimize_filter_js_removables', '', $this->content ); |
|
58 | + $removableJS = apply_filters('autoptimize_filter_js_removables', '', $this->content); |
|
59 | 59 | if (!empty($removableJS)) { |
60 | - $this->jsremovables = array_filter( array_map( 'trim', explode( ',', $removableJS ) ) ); |
|
60 | + $this->jsremovables = array_filter(array_map('trim', explode(',', $removableJS))); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // only header? |
64 | - if ( apply_filters( 'autoptimize_filter_js_justhead', $options['justhead'] ) ) { |
|
65 | - $content = explode( '</head>', $this->content, 2 ); |
|
66 | - $this->content = $content[0] . '</head>'; |
|
64 | + if (apply_filters('autoptimize_filter_js_justhead', $options['justhead'])) { |
|
65 | + $content = explode('</head>', $this->content, 2); |
|
66 | + $this->content = $content[0].'</head>'; |
|
67 | 67 | $this->restofcontent = $content[1]; |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Determine whether we're doing JS-files aggregation or not. |
71 | - if ( ! $options['aggregate'] ) { |
|
71 | + if (!$options['aggregate']) { |
|
72 | 72 | $this->aggregate = false; |
73 | 73 | } |
74 | 74 | // Returning true for "dontaggregate" turns off aggregation. |
75 | - if ( $this->aggregate && apply_filters( 'autoptimize_filter_js_dontaggregate', false ) ) { |
|
75 | + if ($this->aggregate && apply_filters('autoptimize_filter_js_dontaggregate', false)) { |
|
76 | 76 | $this->aggregate = false; |
77 | 77 | } |
78 | 78 | |
79 | 79 | // include inline? |
80 | - if ( apply_filters( 'autoptimize_js_include_inline', $options['include_inline'] ) ) { |
|
80 | + if (apply_filters('autoptimize_js_include_inline', $options['include_inline'])) { |
|
81 | 81 | $this->include_inline = true; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // filter to "late inject minified JS", default to true for now (it is faster) |
85 | - $this->inject_min_late = apply_filters( 'autoptimize_filter_js_inject_min_late', true ); |
|
85 | + $this->inject_min_late = apply_filters('autoptimize_filter_js_inject_min_late', true); |
|
86 | 86 | |
87 | 87 | // filters to override hardcoded do(nt)move(last) array contents (array in, array out!) |
88 | - $this->dontmove = apply_filters( 'autoptimize_filter_js_dontmove', $this->dontmove ); |
|
89 | - $this->domovelast = apply_filters( 'autoptimize_filter_js_movelast', $this->domovelast ); |
|
90 | - $this->domove = apply_filters( 'autoptimize_filter_js_domove', $this->domove ); |
|
88 | + $this->dontmove = apply_filters('autoptimize_filter_js_dontmove', $this->dontmove); |
|
89 | + $this->domovelast = apply_filters('autoptimize_filter_js_movelast', $this->domovelast); |
|
90 | + $this->domove = apply_filters('autoptimize_filter_js_domove', $this->domove); |
|
91 | 91 | |
92 | 92 | // get extra exclusions settings or filter |
93 | 93 | $excludeJS = $options['js_exclude']; |
94 | - $excludeJS = apply_filters( 'autoptimize_filter_js_exclude', $excludeJS, $this->content ); |
|
94 | + $excludeJS = apply_filters('autoptimize_filter_js_exclude', $excludeJS, $this->content); |
|
95 | 95 | |
96 | - if ( '' !== $excludeJS ) { |
|
97 | - if ( is_array( $excludeJS ) ) { |
|
98 | - if ( ( $removeKeys = array_keys( $excludeJS, 'remove' ) ) !== false ) { |
|
99 | - foreach ( $removeKeys as $removeKey ) { |
|
100 | - unset( $excludeJS[$removeKey] ); |
|
96 | + if ('' !== $excludeJS) { |
|
97 | + if (is_array($excludeJS)) { |
|
98 | + if (($removeKeys = array_keys($excludeJS, 'remove')) !== false) { |
|
99 | + foreach ($removeKeys as $removeKey) { |
|
100 | + unset($excludeJS[$removeKey]); |
|
101 | 101 | $this->jsremovables[] = $removeKey; |
102 | 102 | } |
103 | 103 | } |
104 | - $exclJSArr = array_keys( $excludeJS ); |
|
104 | + $exclJSArr = array_keys($excludeJS); |
|
105 | 105 | } else { |
106 | - $exclJSArr = array_filter( array_map( 'trim', explode( ',', $excludeJS ) ) ); |
|
106 | + $exclJSArr = array_filter(array_map('trim', explode(',', $excludeJS))); |
|
107 | 107 | } |
108 | - $this->dontmove = array_merge( $exclJSArr, $this->dontmove ); |
|
108 | + $this->dontmove = array_merge($exclJSArr, $this->dontmove); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Should we add try-catch? |
112 | - if ( $options['trycatch'] ) { |
|
112 | + if ($options['trycatch']) { |
|
113 | 113 | $this->trycatch = true; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // force js in head? |
117 | - if ( $options['forcehead'] ) { |
|
117 | + if ($options['forcehead']) { |
|
118 | 118 | $this->forcehead = true; |
119 | 119 | } else { |
120 | 120 | $this->forcehead = false; |
121 | 121 | } |
122 | 122 | |
123 | - $this->forcehead = apply_filters( 'autoptimize_filter_js_forcehead', $this->forcehead ); |
|
123 | + $this->forcehead = apply_filters('autoptimize_filter_js_forcehead', $this->forcehead); |
|
124 | 124 | |
125 | 125 | // get cdn url |
126 | 126 | $this->cdn_url = $options['cdn_url']; |
@@ -135,26 +135,26 @@ discard block |
||
135 | 135 | $this->content = $this->hide_comments($this->content); |
136 | 136 | |
137 | 137 | // Get script files |
138 | - if ( preg_match_all( '#<script.*</script>#Usmi', $this->content, $matches ) ) { |
|
139 | - foreach( $matches[0] as $tag ) { |
|
138 | + if (preg_match_all('#<script.*</script>#Usmi', $this->content, $matches)) { |
|
139 | + foreach ($matches[0] as $tag) { |
|
140 | 140 | // only consider script aggregation for types whitelisted in should_aggregate-function |
141 | 141 | $should_aggregate = $this->should_aggregate($tag); |
142 | - if ( ! $should_aggregate ) { |
|
142 | + if (!$should_aggregate) { |
|
143 | 143 | $tag = ''; |
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | - if ( preg_match( '#<script[^>]*src=("|\')([^>]*)("|\')#Usmi', $tag, $source ) ) { |
|
147 | + if (preg_match('#<script[^>]*src=("|\')([^>]*)("|\')#Usmi', $tag, $source)) { |
|
148 | 148 | // non-inline script |
149 | - if ( $this->isremovable($tag, $this->jsremovables) ) { |
|
150 | - $this->content = str_replace( $tag, '', $this->content ); |
|
149 | + if ($this->isremovable($tag, $this->jsremovables)) { |
|
150 | + $this->content = str_replace($tag, '', $this->content); |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
154 | 154 | $origTag = null; |
155 | - $url = current( explode( '?', $source[2], 2 ) ); |
|
155 | + $url = current(explode('?', $source[2], 2)); |
|
156 | 156 | $path = $this->getpath($url); |
157 | - if ( false !== $path && preg_match( '#\.js$#', $path ) && $this->ismergeable($tag) ) { |
|
157 | + if (false !== $path && preg_match('#\.js$#', $path) && $this->ismergeable($tag)) { |
|
158 | 158 | // ok to optimize, add to array |
159 | 159 | $this->scripts[] = $path; |
160 | 160 | } else { |
@@ -162,35 +162,35 @@ discard block |
||
162 | 162 | $newTag = $tag; |
163 | 163 | |
164 | 164 | // non-mergeable script (excluded or dynamic or external) |
165 | - if ( is_array( $excludeJS ) ) { |
|
165 | + if (is_array($excludeJS)) { |
|
166 | 166 | // should we add flags? |
167 | - foreach ( $excludeJS as $exclTag => $exclFlags) { |
|
168 | - if ( false !== strpos( $origTag, $exclTag ) && in_array( $exclFlags, array( 'async', 'defer' ) ) ) { |
|
169 | - $newTag = str_replace( '<script ', '<script ' . $exclFlags . ' ', $newTag ); |
|
167 | + foreach ($excludeJS as $exclTag => $exclFlags) { |
|
168 | + if (false !== strpos($origTag, $exclTag) && in_array($exclFlags, array('async', 'defer'))) { |
|
169 | + $newTag = str_replace('<script ', '<script '.$exclFlags.' ', $newTag); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Should we minify the non-aggregated script? |
175 | - if ( $path && apply_filters( 'autoptimize_filter_js_minify_excluded', true, $url ) ) { |
|
176 | - $minified_url = $this->minify_single( $path ); |
|
175 | + if ($path && apply_filters('autoptimize_filter_js_minify_excluded', true, $url)) { |
|
176 | + $minified_url = $this->minify_single($path); |
|
177 | 177 | // replace orig URL with minified URL from cache if so |
178 | - if ( ! empty( $minified_url ) ) { |
|
179 | - $newTag = str_replace( $url, $minified_url, $newTag ); |
|
178 | + if (!empty($minified_url)) { |
|
179 | + $newTag = str_replace($url, $minified_url, $newTag); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - if ( $this->ismovable($newTag) ) { |
|
183 | + if ($this->ismovable($newTag)) { |
|
184 | 184 | // can be moved, flags and all |
185 | - if ( $this->movetolast($newTag) ) { |
|
185 | + if ($this->movetolast($newTag)) { |
|
186 | 186 | $this->move['last'][] = $newTag; |
187 | 187 | } else { |
188 | 188 | $this->move['first'][] = $newTag; |
189 | 189 | } |
190 | 190 | } else { |
191 | 191 | // cannot be moved, so if flag was added re-inject altered tag immediately |
192 | - if ( $origTag !== $newTag ) { |
|
193 | - $this->content = str_replace( $origTag, $newTag, $this->content ); |
|
192 | + if ($origTag !== $newTag) { |
|
193 | + $this->content = str_replace($origTag, $newTag, $this->content); |
|
194 | 194 | $origTag = ''; |
195 | 195 | } |
196 | 196 | // and forget about the $tag (not to be touched any more) |
@@ -199,24 +199,24 @@ discard block |
||
199 | 199 | } |
200 | 200 | } else { |
201 | 201 | // Inline script |
202 | - if ( $this->isremovable($tag, $this->jsremovables) ) { |
|
203 | - $this->content = str_replace( $tag, '', $this->content ); |
|
202 | + if ($this->isremovable($tag, $this->jsremovables)) { |
|
203 | + $this->content = str_replace($tag, '', $this->content); |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // unhide comments, as javascript may be wrapped in comment-tags for old times' sake |
208 | 208 | $tag = $this->restore_comments($tag); |
209 | - if ( $this->ismergeable($tag) && $this->include_inline ) { |
|
210 | - preg_match( '#<script.*>(.*)</script>#Usmi', $tag , $code ); |
|
211 | - $code = preg_replace('#.*<!\[CDATA\[(?:\s*\*/)?(.*)(?://|/\*)\s*?\]\]>.*#sm', '$1', $code[1] ); |
|
212 | - $code = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $code ); |
|
213 | - $this->scripts[] = 'INLINE;' . $code; |
|
209 | + if ($this->ismergeable($tag) && $this->include_inline) { |
|
210 | + preg_match('#<script.*>(.*)</script>#Usmi', $tag, $code); |
|
211 | + $code = preg_replace('#.*<!\[CDATA\[(?:\s*\*/)?(.*)(?://|/\*)\s*?\]\]>.*#sm', '$1', $code[1]); |
|
212 | + $code = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $code); |
|
213 | + $this->scripts[] = 'INLINE;'.$code; |
|
214 | 214 | } else { |
215 | 215 | // Can we move this? |
216 | - $changedTag = apply_filters( 'autoptimize_inline_js_tag', $tag ); |
|
217 | - $autoptimize_js_moveable = apply_filters( 'autoptimize_js_moveable', '', $changedTag ); |
|
218 | - if ( $this->ismovable($changedTag) || '' !== $autoptimize_js_moveable ) { |
|
219 | - if ( $this->movetolast($changedTag) || 'last' === $autoptimize_js_moveable ) { |
|
216 | + $changedTag = apply_filters('autoptimize_inline_js_tag', $tag); |
|
217 | + $autoptimize_js_moveable = apply_filters('autoptimize_js_moveable', '', $changedTag); |
|
218 | + if ($this->ismovable($changedTag) || '' !== $autoptimize_js_moveable) { |
|
219 | + if ($this->movetolast($changedTag) || 'last' === $autoptimize_js_moveable) { |
|
220 | 220 | $this->move['last'][] = $changedTag; |
221 | 221 | } else { |
222 | 222 | $this->move['first'][] = $changedTag; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | //Remove the original script tag |
234 | - $this->content = str_replace( $tag, '', $this->content ); |
|
234 | + $this->content = str_replace($tag, '', $this->content); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return true; |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | // We're only interested in the type attribute of the <script> tag itself, not any possible |
262 | 262 | // inline code that might just contain the 'type=' string... |
263 | 263 | $tag_parts = array(); |
264 | - preg_match( '#<(script[^>]*)>#i', $tag, $tag_parts); |
|
264 | + preg_match('#<(script[^>]*)>#i', $tag, $tag_parts); |
|
265 | 265 | $tag_without_contents = null; |
266 | - if ( ! empty( $tag_parts[1] ) ) { |
|
266 | + if (!empty($tag_parts[1])) { |
|
267 | 267 | $tag_without_contents = $tag_parts[1]; |
268 | 268 | } |
269 | 269 | |
270 | - $has_type = ( strpos( $tag_without_contents, 'type' ) !== false ); |
|
270 | + $has_type = (strpos($tag_without_contents, 'type') !== false); |
|
271 | 271 | |
272 | 272 | $type_valid = false; |
273 | - if ( $has_type ) { |
|
274 | - $type_valid = (bool) preg_match( '/type\s*=\s*[\'"]?(?:text|application)\/(?:javascript|ecmascript)[\'"]?/i', $tag_without_contents ); |
|
273 | + if ($has_type) { |
|
274 | + $type_valid = (bool) preg_match('/type\s*=\s*[\'"]?(?:text|application)\/(?:javascript|ecmascript)[\'"]?/i', $tag_without_contents); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | $should_aggregate = false; |
278 | - if ( ! $has_type || $type_valid ) { |
|
278 | + if (!$has_type || $type_valid) { |
|
279 | 279 | $should_aggregate = true; |
280 | 280 | } |
281 | 281 | |
@@ -285,40 +285,40 @@ discard block |
||
285 | 285 | //Joins and optimizes JS |
286 | 286 | public function minify() |
287 | 287 | { |
288 | - foreach ( $this->scripts as $script ) { |
|
288 | + foreach ($this->scripts as $script) { |
|
289 | 289 | // TODO/FIXME: some duplicate code here, can be reduced/simplified |
290 | - if ( preg_match( '#^INLINE;#', $script ) ) { |
|
290 | + if (preg_match('#^INLINE;#', $script)) { |
|
291 | 291 | // Inline script |
292 | - $script = preg_replace( '#^INLINE;#', '', $script ); |
|
293 | - $script = rtrim( $script, ";\n\t\r" ) . ';'; |
|
292 | + $script = preg_replace('#^INLINE;#', '', $script); |
|
293 | + $script = rtrim($script, ";\n\t\r").';'; |
|
294 | 294 | // Add try-catch? |
295 | - if ( $this->trycatch ) { |
|
296 | - $script = 'try{' . $script . '}catch(e){}'; |
|
295 | + if ($this->trycatch) { |
|
296 | + $script = 'try{'.$script.'}catch(e){}'; |
|
297 | 297 | } |
298 | - $tmpscript = apply_filters( 'autoptimize_js_individual_script', $script, '' ); |
|
299 | - if ( has_filter( 'autoptimize_js_individual_script' ) && ! empty( $tmpscript ) ) { |
|
298 | + $tmpscript = apply_filters('autoptimize_js_individual_script', $script, ''); |
|
299 | + if (has_filter('autoptimize_js_individual_script') && !empty($tmpscript)) { |
|
300 | 300 | $script = $tmpscript; |
301 | 301 | $this->alreadyminified = true; |
302 | 302 | } |
303 | - $this->jscode .= "\n" . $script; |
|
303 | + $this->jscode .= "\n".$script; |
|
304 | 304 | } else { |
305 | 305 | // External script |
306 | - if ( false !== $script && file_exists( $script ) && is_readable( $script ) ) { |
|
307 | - $scriptsrc = file_get_contents( $script ); |
|
308 | - $scriptsrc = preg_replace( '/\x{EF}\x{BB}\x{BF}/', '', $scriptsrc ); |
|
309 | - $scriptsrc = rtrim( $scriptsrc, ";\n\t\r" ) . ';'; |
|
306 | + if (false !== $script && file_exists($script) && is_readable($script)) { |
|
307 | + $scriptsrc = file_get_contents($script); |
|
308 | + $scriptsrc = preg_replace('/\x{EF}\x{BB}\x{BF}/', '', $scriptsrc); |
|
309 | + $scriptsrc = rtrim($scriptsrc, ";\n\t\r").';'; |
|
310 | 310 | // Add try-catch? |
311 | - if ( $this->trycatch ) { |
|
312 | - $scriptsrc = 'try{' . $scriptsrc . '}catch(e){}'; |
|
311 | + if ($this->trycatch) { |
|
312 | + $scriptsrc = 'try{'.$scriptsrc.'}catch(e){}'; |
|
313 | 313 | } |
314 | - $tmpscriptsrc = apply_filters( 'autoptimize_js_individual_script', $scriptsrc, $script ); |
|
315 | - if ( has_filter( 'autoptimize_js_individual_script' ) && ! empty( $tmpscriptsrc ) ) { |
|
314 | + $tmpscriptsrc = apply_filters('autoptimize_js_individual_script', $scriptsrc, $script); |
|
315 | + if (has_filter('autoptimize_js_individual_script') && !empty($tmpscriptsrc)) { |
|
316 | 316 | $scriptsrc = $tmpscriptsrc; |
317 | 317 | $this->alreadyminified = true; |
318 | - } else if ( $this->can_inject_late($script) ) { |
|
318 | + } else if ($this->can_inject_late($script)) { |
|
319 | 319 | $scriptsrc = self::build_injectlater_marker($script, md5($scriptsrc)); |
320 | 320 | } |
321 | - $this->jscode .= "\n" . $scriptsrc; |
|
321 | + $this->jscode .= "\n".$scriptsrc; |
|
322 | 322 | }/*else{ |
323 | 323 | //Couldn't read JS. Maybe getpath isn't working? |
324 | 324 | }*/ |
@@ -326,32 +326,32 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | // Check for already-minified code |
329 | - $this->md5hash = md5( $this->jscode ); |
|
329 | + $this->md5hash = md5($this->jscode); |
|
330 | 330 | $ccheck = new autoptimizeCache($this->md5hash, 'js'); |
331 | - if ( $ccheck->check() ) { |
|
331 | + if ($ccheck->check()) { |
|
332 | 332 | $this->jscode = $ccheck->retrieve(); |
333 | 333 | return true; |
334 | 334 | } |
335 | - unset( $ccheck ); |
|
335 | + unset($ccheck); |
|
336 | 336 | |
337 | 337 | // $this->jscode has all the uncompressed code now. |
338 | - if ( true !== $this->alreadyminified ) { |
|
339 | - if ( apply_filters( 'autoptimize_js_do_minify', true ) ) { |
|
340 | - $tmp_jscode = trim( JSMin::minify( $this->jscode ) ); |
|
341 | - if ( ! empty( $tmp_jscode ) ) { |
|
338 | + if (true !== $this->alreadyminified) { |
|
339 | + if (apply_filters('autoptimize_js_do_minify', true)) { |
|
340 | + $tmp_jscode = trim(JSMin::minify($this->jscode)); |
|
341 | + if (!empty($tmp_jscode)) { |
|
342 | 342 | $this->jscode = $tmp_jscode; |
343 | - unset( $tmp_jscode ); |
|
343 | + unset($tmp_jscode); |
|
344 | 344 | } |
345 | - $this->jscode = $this->inject_minified( $this->jscode ); |
|
346 | - $this->jscode = apply_filters( 'autoptimize_js_after_minify', $this->jscode ); |
|
345 | + $this->jscode = $this->inject_minified($this->jscode); |
|
346 | + $this->jscode = apply_filters('autoptimize_js_after_minify', $this->jscode); |
|
347 | 347 | return true; |
348 | 348 | } else { |
349 | - $this->jscode = $this->inject_minified( $this->jscode ); |
|
349 | + $this->jscode = $this->inject_minified($this->jscode); |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - $this->jscode = apply_filters( 'autoptimize_js_after_minify', $this->jscode ); |
|
354 | + $this->jscode = apply_filters('autoptimize_js_after_minify', $this->jscode); |
|
355 | 355 | return true; |
356 | 356 | } |
357 | 357 | |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | public function cache() |
360 | 360 | { |
361 | 361 | $cache = new autoptimizeCache($this->md5hash, 'js'); |
362 | - if ( ! $cache->check() ) { |
|
362 | + if (!$cache->check()) { |
|
363 | 363 | // Cache our code |
364 | 364 | $cache->cache($this->jscode, 'text/javascript'); |
365 | 365 | } |
366 | - $this->url = AUTOPTIMIZE_CACHE_URL . $cache->getname(); |
|
366 | + $this->url = AUTOPTIMIZE_CACHE_URL.$cache->getname(); |
|
367 | 367 | $this->url = $this->url_replace_cdn($this->url); |
368 | 368 | } |
369 | 369 | |
@@ -371,43 +371,43 @@ discard block |
||
371 | 371 | public function getcontent() |
372 | 372 | { |
373 | 373 | // Restore the full content |
374 | - if ( ! empty( $this->restofcontent ) ) { |
|
374 | + if (!empty($this->restofcontent)) { |
|
375 | 375 | $this->content .= $this->restofcontent; |
376 | 376 | $this->restofcontent = ''; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Add the scripts taking forcehead/ deferred (default) into account |
380 | - if ( $this->forcehead ) { |
|
381 | - $replaceTag = array( '</head>', 'before' ); |
|
380 | + if ($this->forcehead) { |
|
381 | + $replaceTag = array('</head>', 'before'); |
|
382 | 382 | $defer = ''; |
383 | 383 | } else { |
384 | - $replaceTag = array( '</body>', 'before' ); |
|
384 | + $replaceTag = array('</body>', 'before'); |
|
385 | 385 | $defer = 'defer '; |
386 | 386 | } |
387 | 387 | |
388 | - $defer = apply_filters( 'autoptimize_filter_js_defer', $defer ); |
|
388 | + $defer = apply_filters('autoptimize_filter_js_defer', $defer); |
|
389 | 389 | |
390 | - $bodyreplacementpayload = '<script type="text/javascript" ' . $defer . 'src="' . $this->url . '"></script>'; |
|
391 | - $bodyreplacementpayload = apply_filters( 'autoptimize_filter_js_bodyreplacementpayload', $bodyreplacementpayload ); |
|
390 | + $bodyreplacementpayload = '<script type="text/javascript" '.$defer.'src="'.$this->url.'"></script>'; |
|
391 | + $bodyreplacementpayload = apply_filters('autoptimize_filter_js_bodyreplacementpayload', $bodyreplacementpayload); |
|
392 | 392 | |
393 | - $bodyreplacement = implode( '', $this->move['first'] ); |
|
393 | + $bodyreplacement = implode('', $this->move['first']); |
|
394 | 394 | $bodyreplacement .= $bodyreplacementpayload; |
395 | - $bodyreplacement .= implode( '', $this->move['last'] ); |
|
395 | + $bodyreplacement .= implode('', $this->move['last']); |
|
396 | 396 | |
397 | - $replaceTag = apply_filters( 'autoptimize_filter_js_replacetag', $replaceTag ); |
|
397 | + $replaceTag = apply_filters('autoptimize_filter_js_replacetag', $replaceTag); |
|
398 | 398 | |
399 | - if ( strlen( $this->jscode ) > 0 ) { |
|
400 | - $this->inject_in_html( $bodyreplacement, $replaceTag ); |
|
399 | + if (strlen($this->jscode) > 0) { |
|
400 | + $this->inject_in_html($bodyreplacement, $replaceTag); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | // Restore comments. |
404 | - $this->content = $this->restore_comments( $this->content ); |
|
404 | + $this->content = $this->restore_comments($this->content); |
|
405 | 405 | |
406 | 406 | // Restore IE hacks. |
407 | - $this->content = $this->restore_iehacks( $this->content ); |
|
407 | + $this->content = $this->restore_iehacks($this->content); |
|
408 | 408 | |
409 | 409 | // Restore noptimize. |
410 | - $this->content = $this->restore_noptimize( $this->content ); |
|
410 | + $this->content = $this->restore_noptimize($this->content); |
|
411 | 411 | |
412 | 412 | // Return the modified HTML. |
413 | 413 | return $this->content; |
@@ -416,32 +416,32 @@ discard block |
||
416 | 416 | // Checks against the white- and blacklists |
417 | 417 | private function ismergeable($tag) |
418 | 418 | { |
419 | - if ( ! $this->aggregate ) { |
|
419 | + if (!$this->aggregate) { |
|
420 | 420 | return false; |
421 | 421 | } |
422 | 422 | |
423 | - if ( ! empty( $this->whitelist ) ) { |
|
424 | - foreach ( $this->whitelist as $match ) { |
|
425 | - if (false !== strpos( $tag, $match ) ) { |
|
423 | + if (!empty($this->whitelist)) { |
|
424 | + foreach ($this->whitelist as $match) { |
|
425 | + if (false !== strpos($tag, $match)) { |
|
426 | 426 | return true; |
427 | 427 | } |
428 | 428 | } |
429 | 429 | // no match with whitelist |
430 | 430 | return false; |
431 | 431 | } else { |
432 | - foreach($this->domove as $match) { |
|
433 | - if ( false !== strpos( $tag, $match ) ) { |
|
432 | + foreach ($this->domove as $match) { |
|
433 | + if (false !== strpos($tag, $match)) { |
|
434 | 434 | // Matched something |
435 | 435 | return false; |
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
439 | - if ( $this->movetolast($tag) ) { |
|
439 | + if ($this->movetolast($tag)) { |
|
440 | 440 | return false; |
441 | 441 | } |
442 | 442 | |
443 | - foreach( $this->dontmove as $match ) { |
|
444 | - if ( false !== strpos( $tag, $match ) ) { |
|
443 | + foreach ($this->dontmove as $match) { |
|
444 | + if (false !== strpos($tag, $match)) { |
|
445 | 445 | // Matched something |
446 | 446 | return false; |
447 | 447 | } |
@@ -455,23 +455,23 @@ discard block |
||
455 | 455 | // Checks agains the blacklist |
456 | 456 | private function ismovable($tag) |
457 | 457 | { |
458 | - if ( true !== $this->include_inline || apply_filters( 'autoptimize_filter_js_unmovable', true ) ) { |
|
458 | + if (true !== $this->include_inline || apply_filters('autoptimize_filter_js_unmovable', true)) { |
|
459 | 459 | return false; |
460 | 460 | } |
461 | 461 | |
462 | - foreach ( $this->domove as $match ) { |
|
463 | - if ( false !== strpos( $tag, $match ) ) { |
|
462 | + foreach ($this->domove as $match) { |
|
463 | + if (false !== strpos($tag, $match)) { |
|
464 | 464 | // Matched something |
465 | 465 | return true; |
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
469 | - if ( $this->movetolast($tag) ) { |
|
469 | + if ($this->movetolast($tag)) { |
|
470 | 470 | return true; |
471 | 471 | } |
472 | 472 | |
473 | - foreach ( $this->dontmove as $match ) { |
|
474 | - if ( false !== strpos( $tag, $match ) ) { |
|
473 | + foreach ($this->dontmove as $match) { |
|
474 | + if (false !== strpos($tag, $match)) { |
|
475 | 475 | // Matched something |
476 | 476 | return false; |
477 | 477 | } |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | |
484 | 484 | private function movetolast($tag) |
485 | 485 | { |
486 | - foreach ( $this->domovelast as $match ) { |
|
487 | - if ( false !== strpos( $tag, $match ) ) { |
|
486 | + foreach ($this->domovelast as $match) { |
|
487 | + if (false !== strpos($tag, $match)) { |
|
488 | 488 | // Matched, return true |
489 | 489 | return true; |
490 | 490 | } |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | * @return bool |
506 | 506 | */ |
507 | 507 | private function can_inject_late($jsPath) { |
508 | - $consider_minified_array = apply_filters( 'autoptimize_filter_js_consider_minified', false ); |
|
509 | - if ( true !== $this->inject_min_late ) { |
|
508 | + $consider_minified_array = apply_filters('autoptimize_filter_js_consider_minified', false); |
|
509 | + if (true !== $this->inject_min_late) { |
|
510 | 510 | // late-inject turned off |
511 | 511 | return false; |
512 | - } else if ( ( false === strpos( $jsPath, 'min.js' ) ) && ( false === strpos( $jsPath, 'wp-includes/js/jquery/jquery.js' ) ) && ( str_replace( $consider_minified_array, '', $jsPath ) === $jsPath ) ) { |
|
512 | + } else if ((false === strpos($jsPath, 'min.js')) && (false === strpos($jsPath, 'wp-includes/js/jquery/jquery.js')) && (str_replace($consider_minified_array, '', $jsPath) === $jsPath)) { |
|
513 | 513 | // file not minified based on filename & filter |
514 | 514 | return false; |
515 | 515 | } else { |
@@ -536,26 +536,26 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return bool|string Url pointing to the minified js file or false. |
538 | 538 | */ |
539 | - public function minify_single( $filepath, $cache_miss = false ) |
|
539 | + public function minify_single($filepath, $cache_miss = false) |
|
540 | 540 | { |
541 | - $contents = $this->prepare_minify_single( $filepath ); |
|
541 | + $contents = $this->prepare_minify_single($filepath); |
|
542 | 542 | |
543 | - if ( empty( $contents ) ) { |
|
543 | + if (empty($contents)) { |
|
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | |
547 | 547 | // Check cache. |
548 | - $hash = 'single_' . md5( $contents ); |
|
549 | - $cache = new autoptimizeCache( $hash, 'js' ); |
|
548 | + $hash = 'single_'.md5($contents); |
|
549 | + $cache = new autoptimizeCache($hash, 'js'); |
|
550 | 550 | |
551 | 551 | // If not in cache already, minify... |
552 | - if ( ! $cache->check() || $cache_miss ) { |
|
553 | - $contents = trim( JSMin::minify( $contents ) ); |
|
552 | + if (!$cache->check() || $cache_miss) { |
|
553 | + $contents = trim(JSMin::minify($contents)); |
|
554 | 554 | // Store in cache. |
555 | - $cache->cache( $contents, 'text/javascript' ); |
|
555 | + $cache->cache($contents, 'text/javascript'); |
|
556 | 556 | } |
557 | 557 | |
558 | - $url = $this->build_minify_single_url( $cache ); |
|
558 | + $url = $this->build_minify_single_url($cache); |
|
559 | 559 | |
560 | 560 | return $url; |
561 | 561 | } |