@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * addons and/or affiliate services. |
5 | 5 | */ |
6 | 6 | |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -17,64 +17,64 @@ discard block |
||
17 | 17 | |
18 | 18 | public function run() |
19 | 19 | { |
20 | - if ( $this->enabled() ) { |
|
21 | - add_filter( 'autoptimize_filter_settingsscreen_tabs', array( $this, 'add_partner_tabs' ), 10, 1 ); |
|
20 | + if ($this->enabled()) { |
|
21 | + add_filter('autoptimize_filter_settingsscreen_tabs', array($this, 'add_partner_tabs'), 10, 1); |
|
22 | 22 | } |
23 | - add_action( 'admin_menu', array( $this, 'add_admin_menu' ) ); |
|
23 | + add_action('admin_menu', array($this, 'add_admin_menu')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | protected function enabled() |
27 | 27 | { |
28 | - return apply_filters( 'autoptimize_filter_show_partner_tabs', true ); |
|
28 | + return apply_filters('autoptimize_filter_show_partner_tabs', true); |
|
29 | 29 | } |
30 | 30 | |
31 | - public function add_partner_tabs( $in ) |
|
31 | + public function add_partner_tabs($in) |
|
32 | 32 | { |
33 | - $in = array_merge( $in, array( |
|
34 | - 'ao_partners' => __( 'Optimize More!', 'autoptimize' ), |
|
35 | - ) ); |
|
33 | + $in = array_merge($in, array( |
|
34 | + 'ao_partners' => __('Optimize More!', 'autoptimize'), |
|
35 | + )); |
|
36 | 36 | |
37 | 37 | return $in; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function add_admin_menu() |
41 | 41 | { |
42 | - if ( $this->enabled() ) { |
|
43 | - add_submenu_page( null, 'AO partner', 'AO partner', 'manage_options', 'ao_partners', array( $this, 'ao_partners_page' ) ); |
|
42 | + if ($this->enabled()) { |
|
43 | + add_submenu_page(null, 'AO partner', 'AO partner', 'manage_options', 'ao_partners', array($this, 'ao_partners_page')); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | 47 | protected function get_ao_partner_feed_markup() |
48 | 48 | { |
49 | - $no_feed_text = __( 'Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize' ); |
|
49 | + $no_feed_text = __('Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize'); |
|
50 | 50 | $output = ''; |
51 | - if ( apply_filters( 'autoptimize_settingsscreen_remotehttp', true ) ) { |
|
52 | - $rss = fetch_feed( 'http://feeds.feedburner.com/OptimizingMattersDownloads' ); |
|
51 | + if (apply_filters('autoptimize_settingsscreen_remotehttp', true)) { |
|
52 | + $rss = fetch_feed('http://feeds.feedburner.com/OptimizingMattersDownloads'); |
|
53 | 53 | $maxitems = 0; |
54 | 54 | |
55 | - if ( ! is_wp_error( $rss ) ) { |
|
56 | - $maxitems = $rss->get_item_quantity( 20 ); |
|
57 | - $rss_items = $rss->get_items( 0, $maxitems ); |
|
55 | + if (!is_wp_error($rss)) { |
|
56 | + $maxitems = $rss->get_item_quantity(20); |
|
57 | + $rss_items = $rss->get_items(0, $maxitems); |
|
58 | 58 | } |
59 | 59 | |
60 | - if ( 0 == $maxitems ) { |
|
60 | + if (0 == $maxitems) { |
|
61 | 61 | $output .= $no_feed_text; |
62 | 62 | } else { |
63 | 63 | $output .= '<ul>'; |
64 | - foreach ( $rss_items as $item ) { |
|
65 | - $item_url = esc_url( $item->get_permalink() ); |
|
64 | + foreach ($rss_items as $item) { |
|
65 | + $item_url = esc_url($item->get_permalink()); |
|
66 | 66 | $enclosure = $item->get_enclosure(); |
67 | 67 | |
68 | 68 | $output .= '<li class="itemDetail">'; |
69 | - $output .= '<h3 class="itemTitle"><a href="' . $item_url . '" target="_blank">' . esc_html( $item->get_title() ) . '</a></h3>'; |
|
69 | + $output .= '<h3 class="itemTitle"><a href="'.$item_url.'" target="_blank">'.esc_html($item->get_title()).'</a></h3>'; |
|
70 | 70 | |
71 | - if ( $enclosure && ( false !== strpos( $enclosure->get_type(), 'image' ) ) ) { |
|
72 | - $img_url = esc_url( $enclosure->get_link() ); |
|
73 | - $output .= '<div class="itemImage"><a href="' . $item_url . '" target="_blank"><img src="' . $img_url . '"></a></div>'; |
|
71 | + if ($enclosure && (false !== strpos($enclosure->get_type(), 'image'))) { |
|
72 | + $img_url = esc_url($enclosure->get_link()); |
|
73 | + $output .= '<div class="itemImage"><a href="'.$item_url.'" target="_blank"><img src="'.$img_url.'"></a></div>'; |
|
74 | 74 | } |
75 | 75 | |
76 | - $output .= '<div class="itemDescription">' . wp_kses_post( $item->get_description() ) . '</div>'; |
|
77 | - $output .= '<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="' . $item_url . '" target="_blank">' . __( 'More info', 'autoptimize' ) . '</a></div></div>'; |
|
76 | + $output .= '<div class="itemDescription">'.wp_kses_post($item->get_description()).'</div>'; |
|
77 | + $output .= '<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="'.$item_url.'" target="_blank">'.__('More info', 'autoptimize').'</a></div></div>'; |
|
78 | 78 | $output .= '</li>'; |
79 | 79 | } |
80 | 80 | $output .= '</ul>'; |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | } |
134 | 134 | </style> |
135 | 135 | <div class="wrap"> |
136 | - <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1> |
|
136 | + <h1><?php _e('Autoptimize Settings', 'autoptimize'); ?></h1> |
|
137 | 137 | <?php echo autoptimizeConfig::ao_admin_tabs(); ?> |
138 | - <?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?> |
|
138 | + <?php echo '<h2>'.__("These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize').'</h2>'; ?> |
|
139 | 139 | <div> |
140 | 140 | <?php echo $this->get_ao_partner_feed_markup(); ?> |
141 | 141 | </div> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Thin wrapper around css minifiers to avoid rewriting a bunch of existing code. |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param bool $raise_limits Whether to raise memory limits or not. Default true. |
23 | 23 | */ |
24 | - public function __construct( $raise_limits = true ) |
|
24 | + public function __construct($raise_limits = true) |
|
25 | 25 | { |
26 | - $this->minifier = new Autoptimize\tubalmartin\CssMin\Minifier( $raise_limits ); |
|
26 | + $this->minifier = new Autoptimize\tubalmartin\CssMin\Minifier($raise_limits); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - public function run( $css ) |
|
37 | + public function run($css) |
|
38 | 38 | { |
39 | - $result = $this->minifier->run( $css ); |
|
39 | + $result = $this->minifier->run($css); |
|
40 | 40 | |
41 | 41 | return $result; |
42 | 42 | } |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public static function minify( $css ) |
|
51 | + public static function minify($css) |
|
52 | 52 | { |
53 | 53 | $minifier = new self(); |
54 | 54 | |
55 | - return $minifier->run( $css ); |
|
55 | + return $minifier->run($css); |
|
56 | 56 | } |
57 | 57 | } |
@@ -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; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // No break, intentionally, so all upgrades are ran during a single request... |
49 | 49 | } |
50 | 50 | |
51 | - if ( true === $major_update ) { |
|
51 | + if (true === $major_update) { |
|
52 | 52 | $this->on_major_version_update(); |
53 | 53 | } |
54 | 54 | } |
@@ -60,19 +60,19 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $target Target version to check against (ie., the currently running one). |
62 | 62 | */ |
63 | - public static function check_installed_and_update( $target ) |
|
63 | + public static function check_installed_and_update($target) |
|
64 | 64 | { |
65 | - $db_version = get_option( 'autoptimize_version', 'none' ); |
|
66 | - if ( $db_version !== $target ) { |
|
67 | - if ( 'none' === $db_version ) { |
|
68 | - add_action( 'admin_notices', 'autoptimizeMain::notice_installed' ); |
|
65 | + $db_version = get_option('autoptimize_version', 'none'); |
|
66 | + if ($db_version !== $target) { |
|
67 | + if ('none' === $db_version) { |
|
68 | + add_action('admin_notices', 'autoptimizeMain::notice_installed'); |
|
69 | 69 | } else { |
70 | - $updater = new self( $db_version ); |
|
70 | + $updater = new self($db_version); |
|
71 | 71 | $updater->run_needed_major_upgrades(); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Versions differed, upgrades happened if needed, store the new version. |
75 | - update_option( 'autoptimize_version', $target ); |
|
75 | + update_option('autoptimize_version', $target); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | protected function on_major_version_update() |
84 | 84 | { |
85 | 85 | // The transients guard here prevents stale object caches from busting the cache on every request. |
86 | - if ( false == get_transient( 'autoptimize_stale_option_buster' ) ) { |
|
87 | - set_transient( 'autoptimize_stale_option_buster', 'Mamsie & Liessie zehhe: ZWIJH!', HOUR_IN_SECONDS ); |
|
86 | + if (false == get_transient('autoptimize_stale_option_buster')) { |
|
87 | + set_transient('autoptimize_stale_option_buster', 'Mamsie & Liessie zehhe: ZWIJH!', HOUR_IN_SECONDS); |
|
88 | 88 | autoptimizeCache::clearall(); |
89 | - add_action( 'admin_notices', 'autoptimizeMain::notice_updated' ); |
|
89 | + add_action('admin_notices', 'autoptimizeMain::notice_updated'); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | private function upgrade_from_1_6() |
97 | 97 | { |
98 | 98 | // If user was on version 1.6.x, force advanced options to be shown by default. |
99 | - update_option( 'autoptimize_show_adv', '1' ); |
|
99 | + update_option('autoptimize_show_adv', '1'); |
|
100 | 100 | |
101 | 101 | // And remove old options. |
102 | 102 | $to_delete_options = array( |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | 'autoptimize_cdn_img_url', |
109 | 109 | 'autoptimize_css_yui', |
110 | 110 | ); |
111 | - foreach ( $to_delete_options as $del_opt ) { |
|
112 | - delete_option( $del_opt ); |
|
111 | + foreach ($to_delete_options as $del_opt) { |
|
112 | + delete_option($del_opt); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | */ |
121 | 121 | private function upgrade_from_1_7() |
122 | 122 | { |
123 | - if ( ! is_multisite() ) { |
|
124 | - $css_exclude = get_option( 'autoptimize_css_exclude' ); |
|
125 | - if ( empty( $css_exclude ) ) { |
|
123 | + if (!is_multisite()) { |
|
124 | + $css_exclude = get_option('autoptimize_css_exclude'); |
|
125 | + if (empty($css_exclude)) { |
|
126 | 126 | $css_exclude = 'admin-bar.min.css, dashicons.min.css'; |
127 | - } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) { |
|
127 | + } elseif (false === strpos($css_exclude, 'dashicons.min.css')) { |
|
128 | 128 | $css_exclude .= ', dashicons.min.css'; |
129 | 129 | } |
130 | - update_option( 'autoptimize_css_exclude', $css_exclude ); |
|
130 | + update_option('autoptimize_css_exclude', $css_exclude); |
|
131 | 131 | } else { |
132 | 132 | global $wpdb; |
133 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
133 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
134 | 134 | $original_blog_id = get_current_blog_id(); |
135 | - foreach ( $blog_ids as $blog_id ) { |
|
136 | - switch_to_blog( $blog_id ); |
|
137 | - $css_exclude = get_option( 'autoptimize_css_exclude' ); |
|
138 | - if ( empty( $css_exclude ) ) { |
|
135 | + foreach ($blog_ids as $blog_id) { |
|
136 | + switch_to_blog($blog_id); |
|
137 | + $css_exclude = get_option('autoptimize_css_exclude'); |
|
138 | + if (empty($css_exclude)) { |
|
139 | 139 | $css_exclude = 'admin-bar.min.css, dashicons.min.css'; |
140 | - } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) { |
|
140 | + } elseif (false === strpos($css_exclude, 'dashicons.min.css')) { |
|
141 | 141 | $css_exclude .= ', dashicons.min.css'; |
142 | 142 | } |
143 | - update_option( 'autoptimize_css_exclude', $css_exclude ); |
|
143 | + update_option('autoptimize_css_exclude', $css_exclude); |
|
144 | 144 | } |
145 | - switch_to_blog( $original_blog_id ); |
|
145 | + switch_to_blog($original_blog_id); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | */ |
155 | 155 | private function upgrade_from_1_9() |
156 | 156 | { |
157 | - if ( ! is_multisite() ) { |
|
158 | - update_option( 'autoptimize_css_include_inline', 'on' ); |
|
159 | - update_option( 'autoptimize_js_include_inline', 'on' ); |
|
157 | + if (!is_multisite()) { |
|
158 | + update_option('autoptimize_css_include_inline', 'on'); |
|
159 | + update_option('autoptimize_js_include_inline', 'on'); |
|
160 | 160 | } else { |
161 | 161 | global $wpdb; |
162 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
162 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
163 | 163 | $original_blog_id = get_current_blog_id(); |
164 | - foreach ( $blog_ids as $blog_id ) { |
|
165 | - switch_to_blog( $blog_id ); |
|
166 | - update_option( 'autoptimize_css_include_inline', 'on' ); |
|
167 | - update_option( 'autoptimize_js_include_inline', 'on' ); |
|
164 | + foreach ($blog_ids as $blog_id) { |
|
165 | + switch_to_blog($blog_id); |
|
166 | + update_option('autoptimize_css_include_inline', 'on'); |
|
167 | + update_option('autoptimize_js_include_inline', 'on'); |
|
168 | 168 | } |
169 | - switch_to_blog( $original_blog_id ); |
|
169 | + switch_to_blog($original_blog_id); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -177,17 +177,17 @@ discard block |
||
177 | 177 | */ |
178 | 178 | private function upgrade_from_2_2() |
179 | 179 | { |
180 | - if ( ! is_multisite() ) { |
|
180 | + if (!is_multisite()) { |
|
181 | 181 | $this->do_2_2_settings_update(); |
182 | 182 | } else { |
183 | 183 | global $wpdb; |
184 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
184 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
185 | 185 | $original_blog_id = get_current_blog_id(); |
186 | - foreach ( $blog_ids as $blog_id ) { |
|
187 | - switch_to_blog( $blog_id ); |
|
186 | + foreach ($blog_ids as $blog_id) { |
|
187 | + switch_to_blog($blog_id); |
|
188 | 188 | $this->do_2_2_settings_update(); |
189 | 189 | } |
190 | - switch_to_blog( $original_blog_id ); |
|
190 | + switch_to_blog($original_blog_id); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | */ |
197 | 197 | private function do_2_2_settings_update() |
198 | 198 | { |
199 | - $nogooglefont = get_option( 'autoptimize_css_nogooglefont', '' ); |
|
200 | - $ao_extrasetting = get_option( 'autoptimize_extra_settings', '' ); |
|
201 | - if ( ( $nogooglefont ) && ( empty( $ao_extrasetting ) ) ) { |
|
202 | - update_option( 'autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options() ); |
|
199 | + $nogooglefont = get_option('autoptimize_css_nogooglefont', ''); |
|
200 | + $ao_extrasetting = get_option('autoptimize_extra_settings', ''); |
|
201 | + if (($nogooglefont) && (empty($ao_extrasetting))) { |
|
202 | + update_option('autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options()); |
|
203 | 203 | } |
204 | - delete_option( 'autoptimize_css_nogooglefont' ); |
|
204 | + delete_option('autoptimize_css_nogooglefont'); |
|
205 | 205 | } |
206 | 206 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * new in Autoptimize 2.2 |
5 | 5 | */ |
6 | 6 | |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -17,94 +17,94 @@ discard block |
||
17 | 17 | |
18 | 18 | public function add_hooks() |
19 | 19 | { |
20 | - if ( apply_filters( 'autoptimize_js_do_minify', true ) ) { |
|
21 | - add_filter( 'autoptimize_js_individual_script', array( $this, 'js_snippetcacher' ), 10, 2 ); |
|
22 | - add_filter( 'autoptimize_js_after_minify', array( $this, 'js_cleanup' ), 10, 1 ); |
|
20 | + if (apply_filters('autoptimize_js_do_minify', true)) { |
|
21 | + add_filter('autoptimize_js_individual_script', array($this, 'js_snippetcacher'), 10, 2); |
|
22 | + add_filter('autoptimize_js_after_minify', array($this, 'js_cleanup'), 10, 1); |
|
23 | 23 | } |
24 | - if ( apply_filters( 'autoptimize_css_do_minify', true ) ) { |
|
25 | - add_filter( 'autoptimize_css_individual_style', array( $this, 'css_snippetcacher' ), 10, 2 ); |
|
26 | - add_filter( 'autoptimize_css_after_minify', array( $this, 'css_cleanup' ), 10, 1 ); |
|
24 | + if (apply_filters('autoptimize_css_do_minify', true)) { |
|
25 | + add_filter('autoptimize_css_individual_style', array($this, 'css_snippetcacher'), 10, 2); |
|
26 | + add_filter('autoptimize_css_after_minify', array($this, 'css_cleanup'), 10, 1); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | - public function js_snippetcacher( $jsin, $jsfilename ) |
|
30 | + public function js_snippetcacher($jsin, $jsfilename) |
|
31 | 31 | { |
32 | - $md5hash = 'snippet_' . md5( $jsin ); |
|
33 | - $ccheck = new autoptimizeCache( $md5hash, 'js' ); |
|
34 | - if ( $ccheck->check() ) { |
|
32 | + $md5hash = 'snippet_'.md5($jsin); |
|
33 | + $ccheck = new autoptimizeCache($md5hash, 'js'); |
|
34 | + if ($ccheck->check()) { |
|
35 | 35 | $scriptsrc = $ccheck->retrieve(); |
36 | 36 | } else { |
37 | - if ( false === ( strpos( $jsfilename, 'min.js' ) ) && ( false === strpos( $jsfilename, 'js/jquery/jquery.js' ) ) && ( str_replace( apply_filters( 'autoptimize_filter_js_consider_minified', false ), '', $jsfilename ) === $jsfilename ) ) { |
|
38 | - $tmp_jscode = trim( JSMin::minify( $jsin ) ); |
|
39 | - if ( ! empty( $tmp_jscode ) ) { |
|
37 | + if (false === (strpos($jsfilename, 'min.js')) && (false === strpos($jsfilename, 'js/jquery/jquery.js')) && (str_replace(apply_filters('autoptimize_filter_js_consider_minified', false), '', $jsfilename) === $jsfilename)) { |
|
38 | + $tmp_jscode = trim(JSMin::minify($jsin)); |
|
39 | + if (!empty($tmp_jscode)) { |
|
40 | 40 | $scriptsrc = $tmp_jscode; |
41 | - unset( $tmp_jscode ); |
|
41 | + unset($tmp_jscode); |
|
42 | 42 | } else { |
43 | 43 | $scriptsrc = $jsin; |
44 | 44 | } |
45 | 45 | } else { |
46 | 46 | // Removing comments, linebreaks and stuff! |
47 | - $scriptsrc = preg_replace( '#^\s*\/\/.*$#Um', '', $jsin ); |
|
48 | - $scriptsrc = preg_replace( '#^\s*\/\*[^!].*\*\/\s?#Us', '', $scriptsrc ); |
|
49 | - $scriptsrc = preg_replace( "#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $scriptsrc ); |
|
47 | + $scriptsrc = preg_replace('#^\s*\/\/.*$#Um', '', $jsin); |
|
48 | + $scriptsrc = preg_replace('#^\s*\/\*[^!].*\*\/\s?#Us', '', $scriptsrc); |
|
49 | + $scriptsrc = preg_replace("#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $scriptsrc); |
|
50 | 50 | } |
51 | 51 | |
52 | - $last_char = substr( $scriptsrc, -1, 1 ); |
|
53 | - if ( ';' !== $last_char && '}' !== $last_char ) { |
|
52 | + $last_char = substr($scriptsrc, -1, 1); |
|
53 | + if (';' !== $last_char && '}' !== $last_char) { |
|
54 | 54 | $scriptsrc .= ';'; |
55 | 55 | } |
56 | 56 | |
57 | - if ( ! empty( $jsfilename ) && str_replace( apply_filters( 'autoptimize_filter_js_speedup_cache', false ), '', $jsfilename ) === $jsfilename ) { |
|
57 | + if (!empty($jsfilename) && str_replace(apply_filters('autoptimize_filter_js_speedup_cache', false), '', $jsfilename) === $jsfilename) { |
|
58 | 58 | // Don't cache inline CSS or if filter says no! |
59 | - $ccheck->cache( $scriptsrc, 'text/javascript' ); |
|
59 | + $ccheck->cache($scriptsrc, 'text/javascript'); |
|
60 | 60 | } |
61 | 61 | } |
62 | - unset( $ccheck ); |
|
62 | + unset($ccheck); |
|
63 | 63 | |
64 | 64 | return $scriptsrc; |
65 | 65 | } |
66 | 66 | |
67 | - public function css_snippetcacher( $cssin, $cssfilename ) |
|
67 | + public function css_snippetcacher($cssin, $cssfilename) |
|
68 | 68 | { |
69 | - $md5hash = 'snippet_' . md5( $cssin ); |
|
70 | - $ccheck = new autoptimizeCache( $md5hash, 'css' ); |
|
71 | - if ( $ccheck->check() ) { |
|
69 | + $md5hash = 'snippet_'.md5($cssin); |
|
70 | + $ccheck = new autoptimizeCache($md5hash, 'css'); |
|
71 | + if ($ccheck->check()) { |
|
72 | 72 | $stylesrc = $ccheck->retrieve(); |
73 | 73 | } else { |
74 | - if ( ( false === strpos( $cssfilename, 'min.css' ) ) && ( str_replace( apply_filters( 'autoptimize_filter_css_consider_minified', false ), '', $cssfilename ) === $cssfilename ) ) { |
|
74 | + if ((false === strpos($cssfilename, 'min.css')) && (str_replace(apply_filters('autoptimize_filter_css_consider_minified', false), '', $cssfilename) === $cssfilename)) { |
|
75 | 75 | $cssmin = new autoptimizeCSSmin(); |
76 | - $tmp_code = trim( $cssmin->run( $cssin ) ); |
|
76 | + $tmp_code = trim($cssmin->run($cssin)); |
|
77 | 77 | |
78 | - if ( ! empty( $tmp_code ) ) { |
|
78 | + if (!empty($tmp_code)) { |
|
79 | 79 | $stylesrc = $tmp_code; |
80 | - unset( $tmp_code ); |
|
80 | + unset($tmp_code); |
|
81 | 81 | } else { |
82 | 82 | $stylesrc = $cssin; |
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | // .min.css -> no heavy-lifting, just some cleanup! |
86 | - $stylesrc = preg_replace( '#^\s*\/\*[^!].*\*\/\s?#Us', '', $cssin ); |
|
87 | - $stylesrc = preg_replace( "#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $stylesrc ); |
|
88 | - $stylesrc = autoptimizeStyles::fixurls( $cssfilename, $stylesrc ); |
|
86 | + $stylesrc = preg_replace('#^\s*\/\*[^!].*\*\/\s?#Us', '', $cssin); |
|
87 | + $stylesrc = preg_replace("#(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+#", "\n", $stylesrc); |
|
88 | + $stylesrc = autoptimizeStyles::fixurls($cssfilename, $stylesrc); |
|
89 | 89 | } |
90 | - if ( ! empty( $cssfilename ) && ( str_replace( apply_filters( 'autoptimize_filter_css_speedup_cache', false ), '', $cssfilename ) === $cssfilename ) ) { |
|
90 | + if (!empty($cssfilename) && (str_replace(apply_filters('autoptimize_filter_css_speedup_cache', false), '', $cssfilename) === $cssfilename)) { |
|
91 | 91 | // Only caching CSS if it's not inline and is allowed by filter! |
92 | - $ccheck->cache( $stylesrc, 'text/css' ); |
|
92 | + $ccheck->cache($stylesrc, 'text/css'); |
|
93 | 93 | } |
94 | 94 | } |
95 | - unset( $ccheck ); |
|
95 | + unset($ccheck); |
|
96 | 96 | |
97 | 97 | return $stylesrc; |
98 | 98 | } |
99 | 99 | |
100 | - public function css_cleanup( $cssin ) |
|
100 | + public function css_cleanup($cssin) |
|
101 | 101 | { |
102 | 102 | // Speedupper results in aggregated CSS not being minified, so the filestart-marker AO adds when aggregating needs to be removed. |
103 | - return trim( str_replace( array( '/*FILESTART*/', '/*FILESTART2*/' ), '', $cssin ) ); |
|
103 | + return trim(str_replace(array('/*FILESTART*/', '/*FILESTART2*/'), '', $cssin)); |
|
104 | 104 | } |
105 | 105 | |
106 | - public function js_cleanup( $jsin ) |
|
106 | + public function js_cleanup($jsin) |
|
107 | 107 | { |
108 | - return trim( $jsin ); |
|
108 | + return trim($jsin); |
|
109 | 109 | } |
110 | 110 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Handles toolbar-related stuff. |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -12,32 +12,32 @@ discard block |
||
12 | 12 | public function __construct() |
13 | 13 | { |
14 | 14 | // If Cache is not available we don't add the toolbar. |
15 | - if ( ! autoptimizeCache::cacheavail() ) { |
|
15 | + if (!autoptimizeCache::cacheavail()) { |
|
16 | 16 | return; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Load admin toolbar feature once WordPress, all plugins, and the theme are fully loaded and instantiated. |
20 | - add_action( 'wp_loaded', array( $this, 'load_toolbar' ) ); |
|
20 | + add_action('wp_loaded', array($this, 'load_toolbar')); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function load_toolbar() |
24 | 24 | { |
25 | 25 | // Check permissions and that toolbar is not hidden via filter. |
26 | - if ( current_user_can( 'manage_options' ) && apply_filters( 'autoptimize_filter_toolbar_show', true ) ) { |
|
26 | + if (current_user_can('manage_options') && apply_filters('autoptimize_filter_toolbar_show', true)) { |
|
27 | 27 | |
28 | 28 | // Create a handler for the AJAX toolbar requests. |
29 | - add_action( 'wp_ajax_autoptimize_delete_cache', array( $this, 'delete_cache' ) ); |
|
29 | + add_action('wp_ajax_autoptimize_delete_cache', array($this, 'delete_cache')); |
|
30 | 30 | |
31 | 31 | // Load custom styles, scripts and menu only when needed. |
32 | - if ( is_admin_bar_showing() ) { |
|
33 | - if ( is_admin() ) { |
|
34 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
32 | + if (is_admin_bar_showing()) { |
|
33 | + if (is_admin()) { |
|
34 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
35 | 35 | } else { |
36 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
36 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Add the Autoptimize Toolbar to the Admin bar. |
40 | - add_action( 'admin_bar_menu', array( $this, 'add_toolbar' ), 100 ); |
|
40 | + add_action('admin_bar_menu', array($this, 'add_toolbar'), 100); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | $stats = autoptimizeCache::stats(); |
51 | 51 | |
52 | 52 | // Set the Max Size recommended for cache files. |
53 | - $max_size = apply_filters( 'autoptimize_filter_cachecheck_maxsize', 512 * 1024 * 1024 ); |
|
53 | + $max_size = apply_filters('autoptimize_filter_cachecheck_maxsize', 512*1024*1024); |
|
54 | 54 | |
55 | 55 | // Retrieve the current Total Files in cache. |
56 | 56 | $files = $stats[0]; |
57 | 57 | // Retrieve the current Total Size of the cache. |
58 | 58 | $bytes = $stats[1]; |
59 | - $size = $this->format_filesize( $bytes ); |
|
59 | + $size = $this->format_filesize($bytes); |
|
60 | 60 | |
61 | 61 | // Calculate the percentage of cache used. |
62 | - $percentage = ceil( $bytes / $max_size * 100 ); |
|
63 | - if ( $percentage > 100 ) { |
|
62 | + $percentage = ceil($bytes/$max_size*100); |
|
63 | + if ($percentage > 100) { |
|
64 | 64 | $percentage = 100; |
65 | 65 | } |
66 | 66 | |
@@ -70,81 +70,81 @@ discard block |
||
70 | 70 | * - "orange" if over 80%. |
71 | 71 | * - "red" if over 100%. |
72 | 72 | */ |
73 | - $color = ( 100 == $percentage ) ? 'red' : ( ( $percentage > 80 ) ? 'orange' : 'green' ); |
|
73 | + $color = (100 == $percentage) ? 'red' : (($percentage > 80) ? 'orange' : 'green'); |
|
74 | 74 | |
75 | 75 | // Create or add new items into the Admin Toolbar. |
76 | 76 | // Main "Autoptimize" node. |
77 | - $wp_admin_bar->add_node( array( |
|
77 | + $wp_admin_bar->add_node(array( |
|
78 | 78 | 'id' => 'autoptimize', |
79 | - 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Autoptimize', 'autoptimize' ) . '</span>', |
|
80 | - 'href' => admin_url( 'options-general.php?page=autoptimize' ), |
|
81 | - 'meta' => array( 'class' => 'bullet-' . $color ), |
|
79 | + 'title' => '<span class="ab-icon"></span><span class="ab-label">'.__('Autoptimize', 'autoptimize').'</span>', |
|
80 | + 'href' => admin_url('options-general.php?page=autoptimize'), |
|
81 | + 'meta' => array('class' => 'bullet-'.$color), |
|
82 | 82 | )); |
83 | 83 | |
84 | 84 | // "Cache Info" node. |
85 | - $wp_admin_bar->add_node( array( |
|
85 | + $wp_admin_bar->add_node(array( |
|
86 | 86 | 'id' => 'autoptimize-cache-info', |
87 | - 'title' => '<p>' . __( 'Cache Info', 'autoptimize' ) . '</p>' . |
|
88 | - '<div class="autoptimize-radial-bar" percentage="' . $percentage . '">' . |
|
89 | - '<div class="autoptimize-circle">' . |
|
90 | - '<div class="mask full"><div class="fill bg-' . $color . '"></div></div>' . |
|
91 | - '<div class="mask half"><div class="fill bg-' . $color . '"></div></div>' . |
|
92 | - '<div class="shadow"></div>' . |
|
93 | - '</div>' . |
|
94 | - '<div class="inset"><div class="percentage"><div class="numbers ' . $color . '">' . $percentage . '%</div></div></div>' . |
|
95 | - '</div>' . |
|
96 | - '<table>' . |
|
97 | - '<tr><td>' . __( 'Size', 'autoptimize' ) . ':</td><td class="size ' . $color . '">' . $size . '</td></tr>' . |
|
98 | - '<tr><td>' . __( 'Files', 'autoptimize' ) . ':</td><td class="files white">' . $files . '</td></tr>' . |
|
87 | + 'title' => '<p>'.__('Cache Info', 'autoptimize').'</p>'. |
|
88 | + '<div class="autoptimize-radial-bar" percentage="'.$percentage.'">'. |
|
89 | + '<div class="autoptimize-circle">'. |
|
90 | + '<div class="mask full"><div class="fill bg-'.$color.'"></div></div>'. |
|
91 | + '<div class="mask half"><div class="fill bg-'.$color.'"></div></div>'. |
|
92 | + '<div class="shadow"></div>'. |
|
93 | + '</div>'. |
|
94 | + '<div class="inset"><div class="percentage"><div class="numbers '.$color.'">'.$percentage.'%</div></div></div>'. |
|
95 | + '</div>'. |
|
96 | + '<table>'. |
|
97 | + '<tr><td>'.__('Size', 'autoptimize').':</td><td class="size '.$color.'">'.$size.'</td></tr>'. |
|
98 | + '<tr><td>'.__('Files', 'autoptimize').':</td><td class="files white">'.$files.'</td></tr>'. |
|
99 | 99 | '</table>', |
100 | 100 | 'parent' => 'autoptimize', |
101 | 101 | )); |
102 | 102 | |
103 | 103 | // "Delete Cache" node. |
104 | - $wp_admin_bar->add_node( array( |
|
104 | + $wp_admin_bar->add_node(array( |
|
105 | 105 | 'id' => 'autoptimize-delete-cache', |
106 | - 'title' => __( 'Delete Cache', 'autoptimize' ), |
|
106 | + 'title' => __('Delete Cache', 'autoptimize'), |
|
107 | 107 | 'parent' => 'autoptimize', |
108 | 108 | )); |
109 | 109 | } |
110 | 110 | |
111 | 111 | public function delete_cache() |
112 | 112 | { |
113 | - check_ajax_referer( 'ao_delcache_nonce', 'nonce' ); |
|
113 | + check_ajax_referer('ao_delcache_nonce', 'nonce'); |
|
114 | 114 | |
115 | 115 | $result = false; |
116 | - if ( current_user_can( 'manage_options' ) ) { |
|
116 | + if (current_user_can('manage_options')) { |
|
117 | 117 | // We call the function for cleaning the Autoptimize cache. |
118 | 118 | $result = autoptimizeCache::clearall(); |
119 | 119 | } |
120 | 120 | |
121 | - wp_send_json( $result ); |
|
121 | + wp_send_json($result); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | public function enqueue_scripts() |
125 | 125 | { |
126 | 126 | // Autoptimize Toolbar Styles. |
127 | - wp_enqueue_style( 'autoptimize-toolbar', plugins_url( '/static/toolbar.css', __FILE__ ), array(), AUTOPTIMIZE_PLUGIN_VERSION, 'all' ); |
|
127 | + wp_enqueue_style('autoptimize-toolbar', plugins_url('/static/toolbar.css', __FILE__), array(), AUTOPTIMIZE_PLUGIN_VERSION, 'all'); |
|
128 | 128 | |
129 | 129 | // Autoptimize Toolbar Javascript. |
130 | - wp_enqueue_script( 'autoptimize-toolbar', plugins_url( '/static/toolbar.js', __FILE__ ), array( 'jquery' ), AUTOPTIMIZE_PLUGIN_VERSION, true ); |
|
130 | + wp_enqueue_script('autoptimize-toolbar', plugins_url('/static/toolbar.js', __FILE__), array('jquery'), AUTOPTIMIZE_PLUGIN_VERSION, true); |
|
131 | 131 | |
132 | 132 | // Localizes a registered script with data for a JavaScript variable. |
133 | 133 | // Needed for the AJAX to work properly on the frontend. |
134 | - wp_localize_script( 'autoptimize-toolbar', 'autoptimize_ajax_object', array( |
|
135 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
136 | - 'error_msg' => sprintf( __( 'Your Autoptimize cache might not have been purged successfully, please check on the <a href=%s>Autoptimize settings page</a>.', 'autoptimize' ), admin_url( 'options-general.php?page=autoptimize' ) . ' style="white-space:nowrap;"' ), |
|
137 | - 'dismiss_msg' => __( 'Dismiss this notice.' ), |
|
138 | - 'nonce' => wp_create_nonce( 'ao_delcache_nonce' ), |
|
139 | - ) ); |
|
134 | + wp_localize_script('autoptimize-toolbar', 'autoptimize_ajax_object', array( |
|
135 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
136 | + 'error_msg' => sprintf(__('Your Autoptimize cache might not have been purged successfully, please check on the <a href=%s>Autoptimize settings page</a>.', 'autoptimize'), admin_url('options-general.php?page=autoptimize').' style="white-space:nowrap;"'), |
|
137 | + 'dismiss_msg' => __('Dismiss this notice.'), |
|
138 | + 'nonce' => wp_create_nonce('ao_delcache_nonce'), |
|
139 | + )); |
|
140 | 140 | } |
141 | 141 | |
142 | - public function format_filesize( $bytes, $decimals = 2 ) |
|
142 | + public function format_filesize($bytes, $decimals = 2) |
|
143 | 143 | { |
144 | - $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ); |
|
144 | + $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
|
145 | 145 | |
146 | - for ( $i = 0; ( $bytes / 1024) > 0.9; $i++, $bytes /= 1024 ) {} // @codingStandardsIgnoreLine |
|
146 | + for ($i = 0; ($bytes/1024) > 0.9; $i++, $bytes /= 1024) {} // @codingStandardsIgnoreLine |
|
147 | 147 | |
148 | - return sprintf( "%1.{$decimals}f %s", round( $bytes, $decimals ), $units[ $i ] ); |
|
148 | + return sprintf("%1.{$decimals}f %s", round($bytes, $decimals), $units[$i]); |
|
149 | 149 | } |
150 | 150 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
2 | +if (!defined('ABSPATH')) exit; // Exit if accessed directly. |
|
3 | 3 | |
4 | 4 | class autoptimizeConfig |
5 | 5 | { |
@@ -13,28 +13,28 @@ discard block |
||
13 | 13 | */ |
14 | 14 | private function __construct() |
15 | 15 | { |
16 | - if ( is_admin() ) { |
|
16 | + if (is_admin()) { |
|
17 | 17 | // Add the admin page and settings. |
18 | - add_action( 'admin_menu', array( $this, 'addmenu' ) ); |
|
19 | - add_action( 'admin_init', array( $this, 'registersettings' ) ); |
|
18 | + add_action('admin_menu', array($this, 'addmenu')); |
|
19 | + add_action('admin_init', array($this, 'registersettings')); |
|
20 | 20 | |
21 | 21 | // Set meta info. |
22 | - if ( function_exists( 'plugin_row_meta' ) ) { |
|
22 | + if (function_exists('plugin_row_meta')) { |
|
23 | 23 | // 2.8 and higher. |
24 | - add_filter( 'plugin_row_meta', array( $this, 'setmeta' ), 10, 2 ); |
|
25 | - } elseif ( function_exists( 'post_class' ) ) { |
|
24 | + add_filter('plugin_row_meta', array($this, 'setmeta'), 10, 2); |
|
25 | + } elseif (function_exists('post_class')) { |
|
26 | 26 | // 2.7 and lower. |
27 | - $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' ); |
|
28 | - add_filter( 'plugin_action_links_' . $plugin, array( $this, 'setmeta' ) ); |
|
27 | + $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php'); |
|
28 | + add_filter('plugin_action_links_'.$plugin, array($this, 'setmeta')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // Clean cache? |
32 | - if ( get_option( 'autoptimize_cache_clean' ) ) { |
|
32 | + if (get_option('autoptimize_cache_clean')) { |
|
33 | 33 | autoptimizeCache::clearall(); |
34 | - update_option( 'autoptimize_cache_clean', 0 ); |
|
34 | + update_option('autoptimize_cache_clean', 0); |
|
35 | 35 | } |
36 | 36 | |
37 | - $this->settings_screen_do_remote_http = apply_filters( 'autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http ); |
|
37 | + $this->settings_screen_do_remote_http = apply_filters('autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // Adds the Autoptimize Toolbar to the Admin bar. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | static public function instance() |
49 | 49 | { |
50 | 50 | // Only one instance. |
51 | - if ( null === self::$instance ) { |
|
51 | + if (null === self::$instance) { |
|
52 | 52 | self::$instance = new autoptimizeConfig(); |
53 | 53 | } |
54 | 54 | |
@@ -174,28 +174,28 @@ discard block |
||
174 | 174 | |
175 | 175 | <div class="wrap"> |
176 | 176 | |
177 | -<?php if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { ?> |
|
178 | -<div class="notice-error notice"><?php echo '<p>' . sprintf( __( '<strong>You are using a very old version of PHP</strong> (5.2.x or older) which has <a href=%s>serious security and performance issues</a>. Support for PHP 5.5 and below will be removed in one of the next AO released, please ask your hoster to provide you with an upgrade path to 7.x.', 'autoptimize' ), '"http://blog.futtta.be/2016/03/15/why-would-you-still-be-on-php-5-2/" target="_blank"' ) . '</p>'; ?></div> |
|
177 | +<?php if (version_compare(PHP_VERSION, '5.3.0') < 0) { ?> |
|
178 | +<div class="notice-error notice"><?php echo '<p>'.sprintf(__('<strong>You are using a very old version of PHP</strong> (5.2.x or older) which has <a href=%s>serious security and performance issues</a>. Support for PHP 5.5 and below will be removed in one of the next AO released, please ask your hoster to provide you with an upgrade path to 7.x.', 'autoptimize'), '"http://blog.futtta.be/2016/03/15/why-would-you-still-be-on-php-5-2/" target="_blank"').'</p>'; ?></div> |
|
179 | 179 | <?php } ?> |
180 | 180 | |
181 | -<?php if ( defined( 'AUTOPTIMIZE_LEGACY_MINIFIERS' ) ) { ?> |
|
181 | +<?php if (defined('AUTOPTIMIZE_LEGACY_MINIFIERS')) { ?> |
|
182 | 182 | <div class="notice-error notice"><p> |
183 | - <?php _e( "You are using the (no longer supported) AUTOPTIMIZE_LEGACY_MINIFIERS constant. Ensure your site is working properly and remove the constant, it doesn't do anything any more.", 'autoptimize' ); ?> |
|
183 | + <?php _e("You are using the (no longer supported) AUTOPTIMIZE_LEGACY_MINIFIERS constant. Ensure your site is working properly and remove the constant, it doesn't do anything any more.", 'autoptimize'); ?> |
|
184 | 184 | </p></div> |
185 | 185 | <?php } ?> |
186 | 186 | |
187 | 187 | <div id="autoptimize_main"> |
188 | 188 | <div id="ao_title_and_button"> |
189 | - <h1 id="ao_title"><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?> |
|
189 | + <h1 id="ao_title"><?php _e('Autoptimize Settings', 'autoptimize'); ?> |
|
190 | 190 | <span id="ao_adv_button"> |
191 | - <?php if ( get_option( 'autoptimize_show_adv', '0' ) == '1' ) { ?> |
|
192 | - <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><span><?php _e("Show advanced settings","autoptimize") ?></span></a> |
|
193 | - <a href="javascript:void(0);" id="ao_hide_adv" class="button"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a> |
|
191 | + <?php if (get_option('autoptimize_show_adv', '0') == '1') { ?> |
|
192 | + <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><span><?php _e("Show advanced settings", "autoptimize") ?></span></a> |
|
193 | + <a href="javascript:void(0);" id="ao_hide_adv" class="button"><span><?php _e("Hide advanced settings", "autoptimize") ?></span></a> |
|
194 | 194 | <style>tr.ao_adv{display:table-row;} li.ao_adv{display:list-item;}</style> |
195 | 195 | <?php $hiddenClass = ''; ?> |
196 | 196 | <?php } else { ?> |
197 | - <a href="javascript:void(0);" id="ao_show_adv" class="button"><span><?php _e("Show advanced settings","autoptimize") ?></span></a> |
|
198 | - <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a> |
|
197 | + <a href="javascript:void(0);" id="ao_show_adv" class="button"><span><?php _e("Show advanced settings", "autoptimize") ?></span></a> |
|
198 | + <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><span><?php _e("Hide advanced settings", "autoptimize") ?></span></a> |
|
199 | 199 | <?php $hiddenClass = 'hidden '; ?> |
200 | 200 | <?php } ?> |
201 | 201 | </span> |
@@ -205,185 +205,185 @@ discard block |
||
205 | 205 | <?php echo $this->ao_admin_tabs(); ?> |
206 | 206 | |
207 | 207 | <form method="post" action="options.php"> |
208 | -<?php settings_fields( 'autoptimize' ); ?> |
|
208 | +<?php settings_fields('autoptimize'); ?> |
|
209 | 209 | |
210 | 210 | <ul> |
211 | 211 | |
212 | 212 | <li class="itemDetail"> |
213 | -<h2 class="itemTitle"><?php _e('HTML Options','autoptimize'); ?></h2> |
|
213 | +<h2 class="itemTitle"><?php _e('HTML Options', 'autoptimize'); ?></h2> |
|
214 | 214 | <table class="form-table"> |
215 | 215 | <tr valign="top"> |
216 | -<th scope="row"><?php _e('Optimize HTML Code?','autoptimize'); ?></th> |
|
217 | -<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td> |
|
216 | +<th scope="row"><?php _e('Optimize HTML Code?', 'autoptimize'); ?></th> |
|
217 | +<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html') ? 'checked="checked" ' : ''; ?>/></td> |
|
218 | 218 | </tr> |
219 | -<tr class="<?php echo $hiddenClass;?>html_sub ao_adv" valign="top"> |
|
220 | -<th scope="row"><?php _e('Keep HTML comments?','autoptimize'); ?></th> |
|
221 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/> |
|
222 | -<?php _e('Enable this if you want HTML comments to remain in the page.','autoptimize'); ?></label></td> |
|
219 | +<tr class="<?php echo $hiddenClass; ?>html_sub ao_adv" valign="top"> |
|
220 | +<th scope="row"><?php _e('Keep HTML comments?', 'autoptimize'); ?></th> |
|
221 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments') ? 'checked="checked" ' : ''; ?>/> |
|
222 | +<?php _e('Enable this if you want HTML comments to remain in the page.', 'autoptimize'); ?></label></td> |
|
223 | 223 | </tr> |
224 | 224 | </table> |
225 | 225 | </li> |
226 | 226 | |
227 | 227 | <li class="itemDetail"> |
228 | -<h2 class="itemTitle"><?php _e('JavaScript Options','autoptimize'); ?></h2> |
|
228 | +<h2 class="itemTitle"><?php _e('JavaScript Options', 'autoptimize'); ?></h2> |
|
229 | 229 | <table class="form-table"> |
230 | 230 | <tr valign="top"> |
231 | -<th scope="row"><?php _e('Optimize JavaScript Code?','autoptimize'); ?></th> |
|
232 | -<td><input type="checkbox" id="autoptimize_js" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td> |
|
231 | +<th scope="row"><?php _e('Optimize JavaScript Code?', 'autoptimize'); ?></th> |
|
232 | +<td><input type="checkbox" id="autoptimize_js" name="autoptimize_js" <?php echo get_option('autoptimize_js') ? 'checked="checked" ' : ''; ?>/></td> |
|
233 | 233 | </tr> |
234 | -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv"> |
|
235 | -<th scope="row"><?php _e( 'Aggregate JS-files?', 'autoptimize' ); ?></th> |
|
236 | -<td><label class="cb_label"><input type="checkbox" id="autoptimize_js_aggregate" name="autoptimize_js_aggregate" <?php echo $conf->get( 'autoptimize_js_aggregate' ) ? 'checked="checked" ':''; ?>/> |
|
237 | -<?php _e( 'Aggregate all linked JS-files to have them loaded non-render blocking? If this option is off, the individual JS-files will remain in place but will be minified.', 'autoptimize' ); ?></label></td> |
|
234 | +<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv"> |
|
235 | +<th scope="row"><?php _e('Aggregate JS-files?', 'autoptimize'); ?></th> |
|
236 | +<td><label class="cb_label"><input type="checkbox" id="autoptimize_js_aggregate" name="autoptimize_js_aggregate" <?php echo $conf->get('autoptimize_js_aggregate') ? 'checked="checked" ' : ''; ?>/> |
|
237 | +<?php _e('Aggregate all linked JS-files to have them loaded non-render blocking? If this option is off, the individual JS-files will remain in place but will be minified.', 'autoptimize'); ?></label></td> |
|
238 | 238 | </tr> |
239 | -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate"> |
|
240 | -<th scope="row"><?php _e('Also aggregate inline JS?','autoptimize'); ?></th> |
|
241 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline')?'checked="checked" ':''; ?>/> |
|
242 | -<?php _e('Let Autoptimize also extract JS from the HTML. <strong>Warning</strong>: this can make Autoptimize\'s cache size grow quickly, so only enable this if you know what you\'re doing.','autoptimize'); ?></label></td> |
|
239 | +<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate"> |
|
240 | +<th scope="row"><?php _e('Also aggregate inline JS?', 'autoptimize'); ?></th> |
|
241 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline') ? 'checked="checked" ' : ''; ?>/> |
|
242 | +<?php _e('Let Autoptimize also extract JS from the HTML. <strong>Warning</strong>: this can make Autoptimize\'s cache size grow quickly, so only enable this if you know what you\'re doing.', 'autoptimize'); ?></label></td> |
|
243 | 243 | </tr> |
244 | -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate"> |
|
245 | -<th scope="row"><?php _e('Force JavaScript in <head>?','autoptimize'); ?></th> |
|
246 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead')?'checked="checked" ':''; ?>/> |
|
247 | -<?php _e('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.','autoptimize'); ?></label></td> |
|
244 | +<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate"> |
|
245 | +<th scope="row"><?php _e('Force JavaScript in <head>?', 'autoptimize'); ?></th> |
|
246 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead') ? 'checked="checked" ' : ''; ?>/> |
|
247 | +<?php _e('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.', 'autoptimize'); ?></label></td> |
|
248 | 248 | </tr> |
249 | 249 | <?php if (get_option('autoptimize_js_justhead')) { ?> |
250 | -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate"> |
|
251 | -<th scope="row"><?php _e('Look for scripts only in <head>?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th> |
|
252 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/> |
|
253 | -<?php _e('Mostly useful in combination with previous option when using jQuery-based templates, but might help keeping cache size under control.','autoptimize'); ?></label></td> |
|
250 | +<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate"> |
|
251 | +<th scope="row"><?php _e('Look for scripts only in <head>?', 'autoptimize'); echo ' <i>'.__('(deprecated)', 'autoptimize').'</i>'; ?></th> |
|
252 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead') ? 'checked="checked" ' : ''; ?>/> |
|
253 | +<?php _e('Mostly useful in combination with previous option when using jQuery-based templates, but might help keeping cache size under control.', 'autoptimize'); ?></label></td> |
|
254 | 254 | </tr> |
255 | 255 | <?php } ?> |
256 | -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate"> |
|
257 | -<th scope="row"><?php _e('Exclude scripts from Autoptimize:','autoptimize'); ?></th> |
|
258 | -<td><label><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude',"seal.js, js/jquery/jquery.js"); ?>"/><br /> |
|
259 | -<?php _e('A comma-separated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated by Autoptimize.','autoptimize'); ?></label></td> |
|
256 | +<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate"> |
|
257 | +<th scope="row"><?php _e('Exclude scripts from Autoptimize:', 'autoptimize'); ?></th> |
|
258 | +<td><label><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude', "seal.js, js/jquery/jquery.js"); ?>"/><br /> |
|
259 | +<?php _e('A comma-separated list of scripts you want to exclude from being optimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated by Autoptimize.', 'autoptimize'); ?></label></td> |
|
260 | 260 | </tr> |
261 | -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate"> |
|
262 | -<th scope="row"><?php _e('Add try-catch wrapping?','autoptimize'); ?></th> |
|
263 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch')?'checked="checked" ':''; ?>/> |
|
264 | -<?php _e('If your scripts break because of a JS-error, you might want to try this.','autoptimize'); ?></label></td> |
|
261 | +<tr valign="top" class="<?php echo $hiddenClass; ?>js_sub ao_adv js_aggregate"> |
|
262 | +<th scope="row"><?php _e('Add try-catch wrapping?', 'autoptimize'); ?></th> |
|
263 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch') ? 'checked="checked" ' : ''; ?>/> |
|
264 | +<?php _e('If your scripts break because of a JS-error, you might want to try this.', 'autoptimize'); ?></label></td> |
|
265 | 265 | </tr> |
266 | 266 | </table> |
267 | 267 | </li> |
268 | 268 | |
269 | 269 | <li class="itemDetail"> |
270 | -<h2 class="itemTitle"><?php _e('CSS Options','autoptimize'); ?></h2> |
|
270 | +<h2 class="itemTitle"><?php _e('CSS Options', 'autoptimize'); ?></h2> |
|
271 | 271 | <table class="form-table"> |
272 | 272 | <tr valign="top"> |
273 | -<th scope="row"><?php _e('Optimize CSS Code?','autoptimize'); ?></th> |
|
274 | -<td><input type="checkbox" id="autoptimize_css" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td> |
|
273 | +<th scope="row"><?php _e('Optimize CSS Code?', 'autoptimize'); ?></th> |
|
274 | +<td><input type="checkbox" id="autoptimize_css" name="autoptimize_css" <?php echo get_option('autoptimize_css') ? 'checked="checked" ' : ''; ?>/></td> |
|
275 | 275 | </tr> |
276 | -<tr class="<?php echo $hiddenClass;?>css_sub ao_adv" valign="top"> |
|
277 | -<th scope="row"><?php _e( 'Aggregate CSS-files?', 'autoptimize' ); ?></th> |
|
278 | -<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_aggregate" name="autoptimize_css_aggregate" <?php echo $conf->get( 'autoptimize_css_aggregate' ) ? 'checked="checked" ' : ''; ?>/> |
|
279 | -<?php _e('Aggregate all linked CSS-files? If this option is off, the individual CSS-files will remain in place but will be minified.', 'autoptimize' ); ?></label></td> |
|
276 | +<tr class="<?php echo $hiddenClass; ?>css_sub ao_adv" valign="top"> |
|
277 | +<th scope="row"><?php _e('Aggregate CSS-files?', 'autoptimize'); ?></th> |
|
278 | +<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_aggregate" name="autoptimize_css_aggregate" <?php echo $conf->get('autoptimize_css_aggregate') ? 'checked="checked" ' : ''; ?>/> |
|
279 | +<?php _e('Aggregate all linked CSS-files? If this option is off, the individual CSS-files will remain in place but will be minified.', 'autoptimize'); ?></label></td> |
|
280 | 280 | </tr> |
281 | -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate"> |
|
282 | -<th scope="row"><?php _e('Also aggregate inline CSS?','autoptimize'); ?></th> |
|
283 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline','1')?'checked="checked" ':''; ?>/> |
|
284 | -<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.','autoptimize'); ?></label></td> |
|
281 | +<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv css_aggregate"> |
|
282 | +<th scope="row"><?php _e('Also aggregate inline CSS?', 'autoptimize'); ?></th> |
|
283 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline', '1') ? 'checked="checked" ' : ''; ?>/> |
|
284 | +<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.', 'autoptimize'); ?></label></td> |
|
285 | 285 | </tr> |
286 | -<tr class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate" valign="top"> |
|
287 | -<th scope="row"><?php _e('Generate data: URIs for images?','autoptimize'); ?></th> |
|
288 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris')?'checked="checked" ':''; ?>/> |
|
289 | -<?php _e('Enable this to include small background-images in the CSS itself instead of as separate downloads.','autoptimize'); ?></label></td> |
|
286 | +<tr class="<?php echo $hiddenClass; ?>css_sub ao_adv css_aggregate" valign="top"> |
|
287 | +<th scope="row"><?php _e('Generate data: URIs for images?', 'autoptimize'); ?></th> |
|
288 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris') ? 'checked="checked" ' : ''; ?>/> |
|
289 | +<?php _e('Enable this to include small background-images in the CSS itself instead of as separate downloads.', 'autoptimize'); ?></label></td> |
|
290 | 290 | </tr> |
291 | 291 | <?php if (get_option('autoptimize_css_justhead')) { ?> |
292 | -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate"> |
|
293 | -<th scope="row"><?php _e('Look for styles only in <head>?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th> |
|
294 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/> |
|
295 | -<?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td> |
|
292 | +<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv css_aggregate"> |
|
293 | +<th scope="row"><?php _e('Look for styles only in <head>?', 'autoptimize'); echo ' <i>'.__('(deprecated)', 'autoptimize').'</i>'; ?></th> |
|
294 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead') ? 'checked="checked" ' : ''; ?>/> |
|
295 | +<?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.', 'autoptimize'); ?></label></td> |
|
296 | 296 | </tr> |
297 | 297 | <?php } ?> |
298 | -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv"> |
|
299 | -<th scope="row"><?php _e('Inline and Defer CSS?','autoptimize'); ?></th> |
|
300 | -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_defer" id="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer')?'checked="checked" ':''; ?>/> |
|
298 | +<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv"> |
|
299 | +<th scope="row"><?php _e('Inline and Defer CSS?', 'autoptimize'); ?></th> |
|
300 | +<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_defer" id="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer') ? 'checked="checked" ' : ''; ?>/> |
|
301 | 301 | <?php |
302 | -_e( 'Inline "above the fold CSS" while loading the main autoptimized CSS only after page load. <a href="http://wordpress.org/plugins/autoptimize/faq/" target="_blank">Check the FAQ</a> for more info.', 'autoptimize' ); |
|
303 | -if ( function_exists( 'is_plugin_active' ) && ! is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) { |
|
302 | +_e('Inline "above the fold CSS" while loading the main autoptimized CSS only after page load. <a href="http://wordpress.org/plugins/autoptimize/faq/" target="_blank">Check the FAQ</a> for more info.', 'autoptimize'); |
|
303 | +if (function_exists('is_plugin_active') && !is_plugin_active('autoptimize-criticalcss/ao_criticss_aas.php')) { |
|
304 | 304 | echo ' '; |
305 | - $critcss_install_url = network_admin_url() . 'plugin-install.php?s=autoptimize+criticalcss&tab=search&type=term'; |
|
306 | - echo sprintf( __( 'This can be fully automated for different types of pages with the %s.', 'autoptimize' ), '<a href="'.$critcss_install_url.'">Autoptimize CriticalCSS Power-Up</a>' ); |
|
305 | + $critcss_install_url = network_admin_url().'plugin-install.php?s=autoptimize+criticalcss&tab=search&type=term'; |
|
306 | + echo sprintf(__('This can be fully automated for different types of pages with the %s.', 'autoptimize'), '<a href="'.$critcss_install_url.'">Autoptimize CriticalCSS Power-Up</a>'); |
|
307 | 307 | } |
308 | 308 | ?> |
309 | 309 | </label></td> |
310 | 310 | </tr> |
311 | -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv" id="autoptimize_css_defer_inline"> |
|
311 | +<tr valign="top" class="<?php echo $hiddenClass; ?>css_sub ao_adv" id="autoptimize_css_defer_inline"> |
|
312 | 312 | <th scope="row"></th> |
313 | -<td><label><textarea rows="10" cols="10" style="width:100%;" placeholder="<?php _e('Paste the above the fold CSS here.','autoptimize'); ?>" name="autoptimize_css_defer_inline"><?php echo get_option('autoptimize_css_defer_inline'); ?></textarea></label></td> |
|
313 | +<td><label><textarea rows="10" cols="10" style="width:100%;" placeholder="<?php _e('Paste the above the fold CSS here.', 'autoptimize'); ?>" name="autoptimize_css_defer_inline"><?php echo get_option('autoptimize_css_defer_inline'); ?></textarea></label></td> |
|
314 | 314 | </tr> |
315 | -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub css_aggregate"> |
|
316 | -<th scope="row"><?php _e('Inline all CSS?','autoptimize'); ?></th> |
|
317 | -<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_inline" name="autoptimize_css_inline" <?php echo get_option('autoptimize_css_inline')?'checked="checked" ':''; ?>/> |
|
318 | -<?php _e('Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise.','autoptimize'); ?></label></td> |
|
315 | +<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv css_sub css_aggregate"> |
|
316 | +<th scope="row"><?php _e('Inline all CSS?', 'autoptimize'); ?></th> |
|
317 | +<td><label class="cb_label"><input type="checkbox" id="autoptimize_css_inline" name="autoptimize_css_inline" <?php echo get_option('autoptimize_css_inline') ? 'checked="checked" ' : ''; ?>/> |
|
318 | +<?php _e('Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise.', 'autoptimize'); ?></label></td> |
|
319 | 319 | </tr> |
320 | -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub css_aggregate"> |
|
321 | -<th scope="row"><?php _e('Exclude CSS from Autoptimize:','autoptimize'); ?></th> |
|
322 | -<td><label><input type="text" style="width:100%;" name="autoptimize_css_exclude" value="<?php echo get_option('autoptimize_css_exclude','wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css'); ?>"/><br /> |
|
323 | -<?php _e('A comma-separated list of CSS you want to exclude from being optimized.','autoptimize'); ?></label></td> |
|
320 | +<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv css_sub css_aggregate"> |
|
321 | +<th scope="row"><?php _e('Exclude CSS from Autoptimize:', 'autoptimize'); ?></th> |
|
322 | +<td><label><input type="text" style="width:100%;" name="autoptimize_css_exclude" value="<?php echo get_option('autoptimize_css_exclude', 'wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css'); ?>"/><br /> |
|
323 | +<?php _e('A comma-separated list of CSS you want to exclude from being optimized.', 'autoptimize'); ?></label></td> |
|
324 | 324 | </tr> |
325 | 325 | </table> |
326 | 326 | </li> |
327 | 327 | |
328 | 328 | <li class="itemDetail"> |
329 | -<h2 class="itemTitle"><?php _e('CDN Options','autoptimize'); ?></h2> |
|
329 | +<h2 class="itemTitle"><?php _e('CDN Options', 'autoptimize'); ?></h2> |
|
330 | 330 | <table class="form-table"> |
331 | 331 | <tr valign="top"> |
332 | -<th scope="row"><?php _e('CDN Base URL','autoptimize'); ?></th> |
|
333 | -<td><label><input id="cdn_url" type="text" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*(:\d{2,5})?\/?$" style="width:100%" value="<?php echo esc_url(get_option('autoptimize_cdn_url',''),array("http","https")); ?>" /><br /> |
|
334 | -<?php _e('Enter your CDN root URL to enable CDN for Autoptimized files. The URL can be http, https or protocol-relative (e.g. <code>//cdn.example.com/</code>). This is not needed for Cloudflare.','autoptimize'); ?></label></td> |
|
332 | +<th scope="row"><?php _e('CDN Base URL', 'autoptimize'); ?></th> |
|
333 | +<td><label><input id="cdn_url" type="text" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*(:\d{2,5})?\/?$" style="width:100%" value="<?php echo esc_url(get_option('autoptimize_cdn_url', ''), array("http", "https")); ?>" /><br /> |
|
334 | +<?php _e('Enter your CDN root URL to enable CDN for Autoptimized files. The URL can be http, https or protocol-relative (e.g. <code>//cdn.example.com/</code>). This is not needed for Cloudflare.', 'autoptimize'); ?></label></td> |
|
335 | 335 | </tr> |
336 | 336 | </table> |
337 | 337 | </li> |
338 | 338 | |
339 | -<li class="<?php echo $hiddenClass;?>itemDetail ao_adv"> |
|
340 | -<h2 class="itemTitle"><?php _e('Cache Info','autoptimize'); ?></h2> |
|
339 | +<li class="<?php echo $hiddenClass; ?>itemDetail ao_adv"> |
|
340 | +<h2 class="itemTitle"><?php _e('Cache Info', 'autoptimize'); ?></h2> |
|
341 | 341 | <table class="form-table" > |
342 | -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv"> |
|
343 | -<th scope="row"><?php _e('Cache folder','autoptimize'); ?></th> |
|
342 | +<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv"> |
|
343 | +<th scope="row"><?php _e('Cache folder', 'autoptimize'); ?></th> |
|
344 | 344 | <td><?php echo htmlentities(AUTOPTIMIZE_CACHE_DIR); ?></td> |
345 | 345 | </tr> |
346 | -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv"> |
|
347 | -<th scope="row"><?php _e('Can we write?','autoptimize'); ?></th> |
|
348 | -<td><?php echo (autoptimizeCache::cacheavail() ? __('Yes','autoptimize') : __('No','autoptimize')); ?></td> |
|
346 | +<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv"> |
|
347 | +<th scope="row"><?php _e('Can we write?', 'autoptimize'); ?></th> |
|
348 | +<td><?php echo (autoptimizeCache::cacheavail() ? __('Yes', 'autoptimize') : __('No', 'autoptimize')); ?></td> |
|
349 | 349 | </tr> |
350 | -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv"> |
|
351 | -<th scope="row"><?php _e('Cached styles and scripts','autoptimize'); ?></th> |
|
350 | +<tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv"> |
|
351 | +<th scope="row"><?php _e('Cached styles and scripts', 'autoptimize'); ?></th> |
|
352 | 352 | <td><?php |
353 | 353 | $AOstatArr = autoptimizeCache::stats(); |
354 | - if ( ! empty( $AOstatArr ) && is_array( $AOstatArr ) ) { |
|
355 | - $AOcacheSize = size_format( $AOstatArr[1], 2 ); |
|
354 | + if (!empty($AOstatArr) && is_array($AOstatArr)) { |
|
355 | + $AOcacheSize = size_format($AOstatArr[1], 2); |
|
356 | 356 | $details = ''; |
357 | - if ( $AOcacheSize > 0 ) { |
|
358 | - $details = ', ~' . $AOcacheSize . ' total'; |
|
357 | + if ($AOcacheSize > 0) { |
|
358 | + $details = ', ~'.$AOcacheSize.' total'; |
|
359 | 359 | } |
360 | - printf( __( '%1$s files, totalling %2$s Kbytes (calculated at %3$s)', 'autoptimize' ), $AOstatArr[0], $AOcacheSize, date( 'H:i e', $AOstatArr[2] ) ); |
|
360 | + printf(__('%1$s files, totalling %2$s Kbytes (calculated at %3$s)', 'autoptimize'), $AOstatArr[0], $AOcacheSize, date('H:i e', $AOstatArr[2])); |
|
361 | 361 | } |
362 | 362 | ?></td> |
363 | 363 | </tr> |
364 | 364 | </table> |
365 | 365 | </li> |
366 | 366 | |
367 | -<li class="<?php echo $hiddenClass;?>itemDetail ao_adv"> |
|
368 | -<h2 class="itemTitle"><?php _e('Misc Options','autoptimize'); ?></h2> |
|
367 | +<li class="<?php echo $hiddenClass; ?>itemDetail ao_adv"> |
|
368 | +<h2 class="itemTitle"><?php _e('Misc Options', 'autoptimize'); ?></h2> |
|
369 | 369 | <table class="form-table"> |
370 | - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv"> |
|
371 | - <th scope="row"><?php _e('Save aggregated script/css as static files?','autoptimize'); ?></th> |
|
372 | - <td><label class="cb_label"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip','1')?'checked="checked" ':''; ?>/> |
|
373 | - <?php _e('By default files saved are static css/js, uncheck this option if your webserver doesn\'t properly handle the compression and expiry.','autoptimize'); ?></label></td> |
|
370 | + <tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv"> |
|
371 | + <th scope="row"><?php _e('Save aggregated script/css as static files?', 'autoptimize'); ?></th> |
|
372 | + <td><label class="cb_label"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip', '1') ? 'checked="checked" ' : ''; ?>/> |
|
373 | + <?php _e('By default files saved are static css/js, uncheck this option if your webserver doesn\'t properly handle the compression and expiry.', 'autoptimize'); ?></label></td> |
|
374 | 374 | </tr> |
375 | - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv"> |
|
376 | - <th scope="row"><?php _e('Also optimize for logged in users?','autoptimize'); ?></th> |
|
377 | - <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_logged" <?php echo get_option('autoptimize_optimize_logged','1')?'checked="checked" ':''; ?>/> |
|
378 | - <?php _e('By default Autoptimize is also active for logged on users, uncheck not to optimize when logged in e.g. to use a pagebuilder.','autoptimize'); ?></label></td> |
|
375 | + <tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv"> |
|
376 | + <th scope="row"><?php _e('Also optimize for logged in users?', 'autoptimize'); ?></th> |
|
377 | + <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_logged" <?php echo get_option('autoptimize_optimize_logged', '1') ? 'checked="checked" ' : ''; ?>/> |
|
378 | + <?php _e('By default Autoptimize is also active for logged on users, uncheck not to optimize when logged in e.g. to use a pagebuilder.', 'autoptimize'); ?></label></td> |
|
379 | 379 | </tr> |
380 | 380 | <?php |
381 | - if ( function_exists("is_checkout") || function_exists("is_cart") || function_exists("edd_is_checkout") || function_exists("wpsc_is_cart") || function_exists("wpsc_is_checkout") ) { |
|
381 | + if (function_exists("is_checkout") || function_exists("is_cart") || function_exists("edd_is_checkout") || function_exists("wpsc_is_cart") || function_exists("wpsc_is_checkout")) { |
|
382 | 382 | ?> |
383 | - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv"> |
|
384 | - <th scope="row"><?php _e('Also optimize shop cart/ checkout?','autoptimize'); ?></th> |
|
385 | - <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_checkout" <?php echo get_option('autoptimize_optimize_checkout','1')?'checked="checked" ':''; ?>/> |
|
386 | - <?php _e('By default Autoptimize is also active on your shop\'s cart/ checkout, uncheck not to optimize those.','autoptimize'); ?></label> |
|
383 | + <tr valign="top" class="<?php echo $hiddenClass; ?>ao_adv"> |
|
384 | + <th scope="row"><?php _e('Also optimize shop cart/ checkout?', 'autoptimize'); ?></th> |
|
385 | + <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_checkout" <?php echo get_option('autoptimize_optimize_checkout', '1') ? 'checked="checked" ' : ''; ?>/> |
|
386 | + <?php _e('By default Autoptimize is also active on your shop\'s cart/ checkout, uncheck not to optimize those.', 'autoptimize'); ?></label> |
|
387 | 387 | </td> |
388 | 388 | </tr> |
389 | 389 | <?php } ?> |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | |
393 | 393 | </ul> |
394 | 394 | |
395 | -<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv','0'); ?>"> |
|
395 | +<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv', '0'); ?>"> |
|
396 | 396 | |
397 | 397 | <p class="submit"> |
398 | -<input type="submit" class="button-secondary" value="<?php _e('Save Changes','autoptimize') ?>" /> |
|
399 | -<input type="submit" class="button-primary" name="autoptimize_cache_clean" value="<?php _e('Save Changes and Empty Cache','autoptimize') ?>" /> |
|
398 | +<input type="submit" class="button-secondary" value="<?php _e('Save Changes', 'autoptimize') ?>" /> |
|
399 | +<input type="submit" class="button-primary" name="autoptimize_cache_clean" value="<?php _e('Save Changes and Empty Cache', 'autoptimize') ?>" /> |
|
400 | 400 | </p> |
401 | 401 | |
402 | 402 | </form> |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | <div class="autoptimize_banner hidden"> |
406 | 406 | <ul> |
407 | 407 | <?php |
408 | - if ( $this->settings_screen_do_remote_http ) { |
|
409 | - $AO_banner = get_transient( 'autoptimize_banner' ); |
|
410 | - if ( empty( $AO_banner ) ) { |
|
411 | - $banner_resp = wp_remote_get( 'https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION ); |
|
412 | - if ( ! is_wp_error( $banner_resp ) ) { |
|
413 | - if ( '200' == wp_remote_retrieve_response_code( $banner_resp ) ) { |
|
414 | - $AO_banner = wp_kses_post( wp_remote_retrieve_body( $banner_resp ) ); |
|
408 | + if ($this->settings_screen_do_remote_http) { |
|
409 | + $AO_banner = get_transient('autoptimize_banner'); |
|
410 | + if (empty($AO_banner)) { |
|
411 | + $banner_resp = wp_remote_get('https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION); |
|
412 | + if (!is_wp_error($banner_resp)) { |
|
413 | + if ('200' == wp_remote_retrieve_response_code($banner_resp)) { |
|
414 | + $AO_banner = wp_kses_post(wp_remote_retrieve_body($banner_resp)); |
|
415 | 415 | set_transient('autoptimize_banner', $AO_banner, DAY_IN_SECONDS); |
416 | 416 | } |
417 | 417 | } |
@@ -419,17 +419,17 @@ discard block |
||
419 | 419 | echo $AO_banner; |
420 | 420 | } |
421 | 421 | ?> |
422 | - <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.","autoptimize"); ?></li> |
|
423 | - <li><?php _e("Happy with Autoptimize?","autoptimize"); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e("Try my other plugins!","autoptimize"); ?></a></li> |
|
422 | + <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.", "autoptimize"); ?></li> |
|
423 | + <li><?php _e("Happy with Autoptimize?", "autoptimize"); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e("Try my other plugins!", "autoptimize"); ?></a></li> |
|
424 | 424 | </ul> |
425 | 425 | </div> |
426 | 426 | <div style="margin-left:10px;margin-top:-5px;"> |
427 | 427 | <h2> |
428 | - <?php _e("futtta about","autoptimize") ?> |
|
428 | + <?php _e("futtta about", "autoptimize") ?> |
|
429 | 429 | <select id="feed_dropdown" > |
430 | - <option value="1"><?php _e("Autoptimize","autoptimize") ?></option> |
|
431 | - <option value="2"><?php _e("WordPress","autoptimize") ?></option> |
|
432 | - <option value="3"><?php _e("Web Technology","autoptimize") ?></option> |
|
430 | + <option value="1"><?php _e("Autoptimize", "autoptimize") ?></option> |
|
431 | + <option value="2"><?php _e("WordPress", "autoptimize") ?></option> |
|
432 | + <option value="3"><?php _e("Web Technology", "autoptimize") ?></option> |
|
433 | 433 | </select> |
434 | 434 | </h2> |
435 | 435 | <div id="futtta_feed"> |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | </div> |
445 | 445 | </div> |
446 | 446 | </div> |
447 | - <div style="float:right;margin:50px 15px;"><a href="http://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url().'/'.plugin_basename(dirname(__FILE__)).'/external/do_not_donate_smallest.png'; ?>" title="<?php _e("Do not donate for this plugin!","autoptimize"); ?>"></a></div> |
|
447 | + <div style="float:right;margin:50px 15px;"><a href="http://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url().'/'.plugin_basename(dirname(__FILE__)).'/external/do_not_donate_smallest.png'; ?>" title="<?php _e("Do not donate for this plugin!", "autoptimize"); ?>"></a></div> |
|
448 | 448 | </div> |
449 | 449 | |
450 | 450 | <script type="text/javascript"> |
@@ -607,48 +607,48 @@ discard block |
||
607 | 607 | |
608 | 608 | public function addmenu() |
609 | 609 | { |
610 | - $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show' ) ); |
|
611 | - add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) ); |
|
612 | - add_action( 'admin_print_styles-' . $hook, array( $this, 'autoptimize_admin_styles' ) ); |
|
610 | + $hook = add_options_page(__('Autoptimize Options', 'autoptimize'), 'Autoptimize', 'manage_options', 'autoptimize', array($this, 'show')); |
|
611 | + add_action('admin_print_scripts-'.$hook, array($this, 'autoptimize_admin_scripts')); |
|
612 | + add_action('admin_print_styles-'.$hook, array($this, 'autoptimize_admin_styles')); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | public function autoptimize_admin_scripts() |
616 | 616 | { |
617 | - wp_enqueue_script( 'jqcookie', plugins_url( '/external/js/jquery.cookie.min.js', __FILE__ ), array( 'jquery' ), null, true ); |
|
618 | - wp_enqueue_script( 'unslider', plugins_url( '/external/js/unslider-min.js', __FILE__ ), array( 'jquery' ), null, true ); |
|
617 | + wp_enqueue_script('jqcookie', plugins_url('/external/js/jquery.cookie.min.js', __FILE__), array('jquery'), null, true); |
|
618 | + wp_enqueue_script('unslider', plugins_url('/external/js/unslider-min.js', __FILE__), array('jquery'), null, true); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | public function autoptimize_admin_styles() |
622 | 622 | { |
623 | - wp_enqueue_style( 'unslider', plugins_url( '/external/js/unslider.css', __FILE__ ) ); |
|
624 | - wp_enqueue_style( 'unslider-dots', plugins_url( '/external/js/unslider-dots.css', __FILE__ ) ); |
|
623 | + wp_enqueue_style('unslider', plugins_url('/external/js/unslider.css', __FILE__)); |
|
624 | + wp_enqueue_style('unslider-dots', plugins_url('/external/js/unslider-dots.css', __FILE__)); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | public function registersettings() { |
628 | - register_setting( 'autoptimize', 'autoptimize_html' ); |
|
629 | - register_setting( 'autoptimize', 'autoptimize_html_keepcomments' ); |
|
630 | - register_setting( 'autoptimize', 'autoptimize_js' ); |
|
631 | - register_setting( 'autoptimize', 'autoptimize_js_aggregate' ); |
|
632 | - register_setting( 'autoptimize', 'autoptimize_js_exclude' ); |
|
633 | - register_setting( 'autoptimize', 'autoptimize_js_trycatch' ); |
|
634 | - register_setting( 'autoptimize', 'autoptimize_js_justhead' ); |
|
635 | - register_setting( 'autoptimize', 'autoptimize_js_forcehead' ); |
|
636 | - register_setting( 'autoptimize', 'autoptimize_js_include_inline' ); |
|
637 | - register_setting( 'autoptimize', 'autoptimize_css' ); |
|
638 | - register_setting( 'autoptimize', 'autoptimize_css_aggregate' ); |
|
639 | - register_setting( 'autoptimize', 'autoptimize_css_exclude' ); |
|
640 | - register_setting( 'autoptimize', 'autoptimize_css_justhead' ); |
|
641 | - register_setting( 'autoptimize', 'autoptimize_css_datauris' ); |
|
642 | - register_setting( 'autoptimize', 'autoptimize_css_defer' ); |
|
643 | - register_setting( 'autoptimize', 'autoptimize_css_defer_inline' ); |
|
644 | - register_setting( 'autoptimize', 'autoptimize_css_inline' ); |
|
645 | - register_setting( 'autoptimize', 'autoptimize_css_include_inline' ); |
|
646 | - register_setting( 'autoptimize', 'autoptimize_cdn_url' ); |
|
647 | - register_setting( 'autoptimize', 'autoptimize_cache_clean' ); |
|
648 | - register_setting( 'autoptimize', 'autoptimize_cache_nogzip' ); |
|
649 | - register_setting( 'autoptimize', 'autoptimize_show_adv' ); |
|
650 | - register_setting( 'autoptimize', 'autoptimize_optimize_logged' ); |
|
651 | - register_setting( 'autoptimize', 'autoptimize_optimize_checkout' ); |
|
628 | + register_setting('autoptimize', 'autoptimize_html'); |
|
629 | + register_setting('autoptimize', 'autoptimize_html_keepcomments'); |
|
630 | + register_setting('autoptimize', 'autoptimize_js'); |
|
631 | + register_setting('autoptimize', 'autoptimize_js_aggregate'); |
|
632 | + register_setting('autoptimize', 'autoptimize_js_exclude'); |
|
633 | + register_setting('autoptimize', 'autoptimize_js_trycatch'); |
|
634 | + register_setting('autoptimize', 'autoptimize_js_justhead'); |
|
635 | + register_setting('autoptimize', 'autoptimize_js_forcehead'); |
|
636 | + register_setting('autoptimize', 'autoptimize_js_include_inline'); |
|
637 | + register_setting('autoptimize', 'autoptimize_css'); |
|
638 | + register_setting('autoptimize', 'autoptimize_css_aggregate'); |
|
639 | + register_setting('autoptimize', 'autoptimize_css_exclude'); |
|
640 | + register_setting('autoptimize', 'autoptimize_css_justhead'); |
|
641 | + register_setting('autoptimize', 'autoptimize_css_datauris'); |
|
642 | + register_setting('autoptimize', 'autoptimize_css_defer'); |
|
643 | + register_setting('autoptimize', 'autoptimize_css_defer_inline'); |
|
644 | + register_setting('autoptimize', 'autoptimize_css_inline'); |
|
645 | + register_setting('autoptimize', 'autoptimize_css_include_inline'); |
|
646 | + register_setting('autoptimize', 'autoptimize_cdn_url'); |
|
647 | + register_setting('autoptimize', 'autoptimize_cache_clean'); |
|
648 | + register_setting('autoptimize', 'autoptimize_cache_nogzip'); |
|
649 | + register_setting('autoptimize', 'autoptimize_show_adv'); |
|
650 | + register_setting('autoptimize', 'autoptimize_optimize_logged'); |
|
651 | + register_setting('autoptimize', 'autoptimize_optimize_checkout'); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | public function setmeta($links, $file = null) |
@@ -656,20 +656,20 @@ discard block |
||
656 | 656 | // Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/. |
657 | 657 | // Do it only once - saves time. |
658 | 658 | static $plugin; |
659 | - if ( empty( $plugin ) ) { |
|
660 | - $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' ); |
|
659 | + if (empty($plugin)) { |
|
660 | + $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php'); |
|
661 | 661 | } |
662 | 662 | |
663 | - if ( null === $file ) { |
|
663 | + if (null === $file) { |
|
664 | 664 | // 2.7 and lower. |
665 | - $settings_link = sprintf( '<a href="options-general.php?page=autoptimize">%s</a>', __( 'Settings' ) ); |
|
666 | - array_unshift( $links, $settings_link ); |
|
665 | + $settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings')); |
|
666 | + array_unshift($links, $settings_link); |
|
667 | 667 | } else { |
668 | 668 | // 2.8 and higher. |
669 | 669 | // If it's us, add the link. |
670 | - if ( $file === $plugin ) { |
|
671 | - $newlink = array( sprintf( '<a href="options-general.php?page=autoptimize">%s</a>', __( 'Settings' ) ) ); |
|
672 | - $links = array_merge( $links, $newlink ); |
|
670 | + if ($file === $plugin) { |
|
671 | + $newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'))); |
|
672 | + $links = array_merge($links, $newlink); |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | */ |
738 | 738 | public static function get_ao_css_preload_polyfill() |
739 | 739 | { |
740 | - $preload_poly = apply_filters('autoptimize_css_preload_polyfill','<script data-cfasync=\'false\'>!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={};if(e.support=function(){var e;try{e=t.document.createElement("link").relList.supports("preload")}catch(t){e=!1}return function(){return e}}(),e.bindMediaToggle=function(t){function e(){t.media=a}var a=t.media||"all";t.addEventListener?t.addEventListener("load",e):t.attachEvent&&t.attachEvent("onload",e),setTimeout(function(){t.rel="stylesheet",t.media="only x"}),setTimeout(e,3e3)},e.poly=function(){if(!e.support())for(var a=t.document.getElementsByTagName("link"),n=0;n<a.length;n++){var o=a[n];"preload"!==o.rel||"style"!==o.getAttribute("as")||o.getAttribute("data-loadcss")||(o.setAttribute("data-loadcss",!0),e.bindMediaToggle(o))}},!e.support()){e.poly();var a=t.setInterval(e.poly,500);t.addEventListener?t.addEventListener("load",function(){e.poly(),t.clearInterval(a)}):t.attachEvent&&t.attachEvent("onload",function(){e.poly(),t.clearInterval(a)})}"undefined"!=typeof exports?exports.loadCSS=loadCSS:t.loadCSS=loadCSS}("undefined"!=typeof global?global:this);</script>'); |
|
740 | + $preload_poly = apply_filters('autoptimize_css_preload_polyfill', '<script data-cfasync=\'false\'>!function(t){"use strict";t.loadCSS||(t.loadCSS=function(){});var e=loadCSS.relpreload={};if(e.support=function(){var e;try{e=t.document.createElement("link").relList.supports("preload")}catch(t){e=!1}return function(){return e}}(),e.bindMediaToggle=function(t){function e(){t.media=a}var a=t.media||"all";t.addEventListener?t.addEventListener("load",e):t.attachEvent&&t.attachEvent("onload",e),setTimeout(function(){t.rel="stylesheet",t.media="only x"}),setTimeout(e,3e3)},e.poly=function(){if(!e.support())for(var a=t.document.getElementsByTagName("link"),n=0;n<a.length;n++){var o=a[n];"preload"!==o.rel||"style"!==o.getAttribute("as")||o.getAttribute("data-loadcss")||(o.setAttribute("data-loadcss",!0),e.bindMediaToggle(o))}},!e.support()){e.poly();var a=t.setInterval(e.poly,500);t.addEventListener?t.addEventListener("load",function(){e.poly(),t.clearInterval(a)}):t.attachEvent&&t.attachEvent("onload",function(){e.poly(),t.clearInterval(a)})}"undefined"!=typeof exports?exports.loadCSS=loadCSS:t.loadCSS=loadCSS}("undefined"!=typeof global?global:this);</script>'); |
|
741 | 741 | return $preload_poly; |
742 | 742 | } |
743 | 743 | |
@@ -748,55 +748,55 @@ discard block |
||
748 | 748 | */ |
749 | 749 | public static function get_ao_css_preload_onload() |
750 | 750 | { |
751 | - $preload_onload = apply_filters('autoptimize_filter_css_preload_onload',"this.onload=null;this.rel='stylesheet'"); |
|
751 | + $preload_onload = apply_filters('autoptimize_filter_css_preload_onload', "this.onload=null;this.rel='stylesheet'"); |
|
752 | 752 | return $preload_onload; |
753 | 753 | } |
754 | 754 | |
755 | 755 | public function get($key) |
756 | 756 | { |
757 | - if ( ! is_array( $this->config ) ) { |
|
757 | + if (!is_array($this->config)) { |
|
758 | 758 | // Default config. |
759 | 759 | $config = self::get_defaults(); |
760 | 760 | |
761 | 761 | // Override with user settings. |
762 | - foreach ( array_keys( $config ) as $name ) { |
|
763 | - $conf = get_option( $name ); |
|
764 | - if ( false !== $conf ) { |
|
762 | + foreach (array_keys($config) as $name) { |
|
763 | + $conf = get_option($name); |
|
764 | + if (false !== $conf) { |
|
765 | 765 | // It was set before! |
766 | - $config[ $name ] = $conf; |
|
766 | + $config[$name] = $conf; |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | |
770 | 770 | // Save for next call. |
771 | - $this->config = apply_filters( 'autoptimize_filter_get_config', $config ); |
|
771 | + $this->config = apply_filters('autoptimize_filter_get_config', $config); |
|
772 | 772 | } |
773 | 773 | |
774 | - if ( isset( $this->config[ $key ] ) ) { |
|
775 | - return $this->config[ $key ]; |
|
774 | + if (isset($this->config[$key])) { |
|
775 | + return $this->config[$key]; |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | return false; |
779 | 779 | } |
780 | 780 | |
781 | 781 | private function getFutttaFeeds($url) { |
782 | - if ( $this->settings_screen_do_remote_http ) { |
|
783 | - $rss = fetch_feed( $url ); |
|
782 | + if ($this->settings_screen_do_remote_http) { |
|
783 | + $rss = fetch_feed($url); |
|
784 | 784 | $maxitems = 0; |
785 | 785 | |
786 | - if ( ! is_wp_error( $rss ) ) { |
|
787 | - $maxitems = $rss->get_item_quantity( 7 ); |
|
788 | - $rss_items = $rss->get_items( 0, $maxitems ); |
|
786 | + if (!is_wp_error($rss)) { |
|
787 | + $maxitems = $rss->get_item_quantity(7); |
|
788 | + $rss_items = $rss->get_items(0, $maxitems); |
|
789 | 789 | } |
790 | 790 | ?> |
791 | 791 | <ul> |
792 | - <?php if ( $maxitems == 0 ) : ?> |
|
793 | - <li><?php _e( 'No items', 'autoptimize' ); ?></li> |
|
792 | + <?php if ($maxitems == 0) : ?> |
|
793 | + <li><?php _e('No items', 'autoptimize'); ?></li> |
|
794 | 794 | <?php else : ?> |
795 | - <?php foreach ( $rss_items as $item ) : ?> |
|
795 | + <?php foreach ($rss_items as $item) : ?> |
|
796 | 796 | <li> |
797 | - <a href="<?php echo esc_url( $item->get_permalink() ); ?>" |
|
798 | - title="<?php printf( __( 'Posted %s', 'autoptimize' ), $item->get_date('j F Y | g:i a') ); ?>"> |
|
799 | - <?php echo esc_html( $item->get_title() ); ?> |
|
797 | + <a href="<?php echo esc_url($item->get_permalink()); ?>" |
|
798 | + title="<?php printf(__('Posted %s', 'autoptimize'), $item->get_date('j F Y | g:i a')); ?>"> |
|
799 | + <?php echo esc_html($item->get_title()); ?> |
|
800 | 800 | </a> |
801 | 801 | </li> |
802 | 802 | <?php endforeach; ?> |
@@ -809,23 +809,23 @@ discard block |
||
809 | 809 | // based on http://wordpress.stackexchange.com/a/58826 |
810 | 810 | static function ao_admin_tabs() |
811 | 811 | { |
812 | - $tabs = apply_filters( 'autoptimize_filter_settingsscreen_tabs' ,array( 'autoptimize' => __( 'Main', 'autoptimize' ) ) ); |
|
812 | + $tabs = apply_filters('autoptimize_filter_settingsscreen_tabs', array('autoptimize' => __('Main', 'autoptimize'))); |
|
813 | 813 | $tabContent = ''; |
814 | 814 | $tabs_count = count($tabs); |
815 | - if ( $tabs_count > 1 ) { |
|
816 | - if ( isset( $_GET['page'] ) ) { |
|
815 | + if ($tabs_count > 1) { |
|
816 | + if (isset($_GET['page'])) { |
|
817 | 817 | $currentId = $_GET['page']; |
818 | 818 | } else { |
819 | 819 | $currentId = "autoptimize"; |
820 | 820 | } |
821 | 821 | $tabContent .= '<h2 class="nav-tab-wrapper">'; |
822 | 822 | foreach ($tabs as $tabId => $tabName) { |
823 | - if ( $currentId == $tabId ) { |
|
823 | + if ($currentId == $tabId) { |
|
824 | 824 | $class = ' nav-tab-active'; |
825 | - } else{ |
|
825 | + } else { |
|
826 | 826 | $class = ''; |
827 | 827 | } |
828 | - $tabContent .= '<a class="nav-tab' . $class . '" href="?page=' . $tabId . '">' . $tabName . '</a>'; |
|
828 | + $tabContent .= '<a class="nav-tab'.$class.'" href="?page='.$tabId.'">'.$tabName.'</a>'; |
|
829 | 829 | } |
830 | 830 | $tabContent .= '</h2>'; |
831 | 831 | } else { |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public static function is_admin_and_not_ajax() |
844 | 844 | { |
845 | - return ( is_admin() && ! self::doing_ajax() ); |
|
845 | + return (is_admin() && !self::doing_ajax()); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -852,10 +852,10 @@ discard block |
||
852 | 852 | */ |
853 | 853 | protected static function doing_ajax() |
854 | 854 | { |
855 | - if ( function_exists( 'wp_doing_ajax' ) ) { |
|
855 | + if (function_exists('wp_doing_ajax')) { |
|
856 | 856 | return wp_doing_ajax(); |
857 | 857 | } else { |
858 | - return ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
858 | + return (defined('DOING_AJAX') && DOING_AJAX); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
@@ -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,48 +25,48 @@ 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', 'daily' ); |
|
40 | - if ( ! in_array( $frequency, array( 'hourly', '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', 'daily'); |
|
40 | + if (!in_array($frequency, array('hourly', 'daily', 'weekly', 'monthly'))) { |
|
41 | 41 | $frequency = 'daily'; |
42 | 42 | } |
43 | - if ( $do_cache_check && ( ! $schedule || $schedule !== $frequency ) ) { |
|
44 | - wp_schedule_event( time(), $frequency, self::SCHEDULE_HOOK ); |
|
45 | - } elseif ( $schedule && ! $do_cache_check ) { |
|
46 | - wp_clear_scheduled_hook( self::SCHEDULE_HOOK ); |
|
43 | + if ($do_cache_check && (!$schedule || $schedule !== $frequency)) { |
|
44 | + wp_schedule_event(time(), $frequency, self::SCHEDULE_HOOK); |
|
45 | + } elseif ($schedule && !$do_cache_check) { |
|
46 | + wp_clear_scheduled_hook(self::SCHEDULE_HOOK); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | 50 | public function cronjob() |
51 | 51 | { |
52 | 52 | // Check cachesize and act accordingly. |
53 | - $max_size = (int) apply_filters( 'autoptimize_filter_cachecheck_maxsize', 536870912 ); |
|
54 | - $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true ); |
|
53 | + $max_size = (int) apply_filters('autoptimize_filter_cachecheck_maxsize', 536870912); |
|
54 | + $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true); |
|
55 | 55 | $stat_array = autoptimizeCache::stats(); |
56 | - $cache_size = round( $stat_array[1] ); |
|
57 | - if ( ( $cache_size > $max_size ) && ( $do_cache_check ) ) { |
|
58 | - update_option( 'autoptimize_cachesize_notice', true ); |
|
59 | - if ( apply_filters( 'autoptimize_filter_cachecheck_sendmail', true ) ) { |
|
60 | - $site_url = esc_url( site_url() ); |
|
61 | - $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', get_option( 'admin_email', '' ) ); |
|
62 | - |
|
63 | - $ao_mailsubject = __( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $site_url . ')'; |
|
64 | - $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 . ')'; |
|
65 | - |
|
66 | - if ( ! empty( $ao_mailto ) ) { |
|
67 | - $ao_mailresult = wp_mail( $ao_mailto, $ao_mailsubject, $ao_mailbody ); |
|
68 | - if ( ! $ao_mailresult ) { |
|
69 | - error_log( 'Autoptimize could not send cache size warning mail.' ); |
|
56 | + $cache_size = round($stat_array[1]); |
|
57 | + if (($cache_size > $max_size) && ($do_cache_check)) { |
|
58 | + update_option('autoptimize_cachesize_notice', true); |
|
59 | + if (apply_filters('autoptimize_filter_cachecheck_sendmail', true)) { |
|
60 | + $site_url = esc_url(site_url()); |
|
61 | + $ao_mailto = apply_filters('autoptimize_filter_cachecheck_mailto', get_option('admin_email', '')); |
|
62 | + |
|
63 | + $ao_mailsubject = __('Autoptimize cache size warning', 'autoptimize').' ('.$site_url.')'; |
|
64 | + $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.')'; |
|
65 | + |
|
66 | + if (!empty($ao_mailto)) { |
|
67 | + $ao_mailresult = wp_mail($ao_mailto, $ao_mailsubject, $ao_mailbody); |
|
68 | + if (!$ao_mailresult) { |
|
69 | + error_log('Autoptimize could not send cache size warning mail.'); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | public function show_admin_notice() |
86 | 86 | { |
87 | 87 | // fixme: make notices dismissable. |
88 | - if ( (bool) get_option( 'autoptimize_cachesize_notice', false ) ) { |
|
88 | + if ((bool) get_option('autoptimize_cachesize_notice', false)) { |
|
89 | 89 | echo '<div class="notice notice-warning"><p>'; |
90 | - _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' ); |
|
90 | + _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'); |
|
91 | 91 | echo '</p></div>'; |
92 | - update_option( 'autoptimize_cachesize_notice', false ); |
|
92 | + update_option('autoptimize_cachesize_notice', false); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Notice for image proxy usage. |
96 | 96 | $_imgopt_notice = autoptimizeExtra::get_imgopt_status_notice_wrapper(); |
97 | - if ( is_array( $_imgopt_notice ) && array_key_exists( 'status', $_imgopt_notice ) && in_array( $_imgopt_notice['status'], array( 1, -1 ) ) ) { |
|
97 | + if (is_array($_imgopt_notice) && array_key_exists('status', $_imgopt_notice) && in_array($_imgopt_notice['status'], array(1, -1))) { |
|
98 | 98 | $_dismissible = 'ao-img-opt-notice-'; |
99 | 99 | $_hide_notice = '7'; |
100 | 100 | |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | $_hide_notice = '1'; |
103 | 103 | } |
104 | 104 | |
105 | - $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice ); |
|
105 | + $_imgopt_notice_dismissible = apply_filters('autoptimize_filter_imgopt_notice_dismissable', $_dismissible.$_hide_notice); |
|
106 | 106 | |
107 | - if ( $_imgopt_notice && PAnD::is_admin_notice_active( $_imgopt_notice_dismissible ) ) { |
|
108 | - echo '<div class="notice notice-warning is-dismissible" data-dismissible="' . $_imgopt_notice_dismissible . '"><p>' . $_imgopt_notice['notice'] . '</p></div>'; |
|
107 | + if ($_imgopt_notice && PAnD::is_admin_notice_active($_imgopt_notice_dismissible)) { |
|
108 | + echo '<div class="notice notice-warning is-dismissible" data-dismissible="'.$_imgopt_notice_dismissible.'"><p>'.$_imgopt_notice['notice'].'</p></div>'; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | public function __construct($raisePhpLimits = true) |
73 | 73 | { |
74 | 74 | $this->raisePhpLimits = (bool) $raisePhpLimits; |
75 | - $this->memoryLimit = 128 * 1048576; // 128MB in bytes |
|
76 | - $this->pcreBacktrackLimit = 1000 * 1000; |
|
77 | - $this->pcreRecursionLimit = 500 * 1000; |
|
75 | + $this->memoryLimit = 128*1048576; // 128MB in bytes |
|
76 | + $this->pcreBacktrackLimit = 1000*1000; |
|
77 | + $this->pcreRecursionLimit = 500*1000; |
|
78 | 78 | $this->hexToNamedColorsMap = Colors::getHexToNamedMap(); |
79 | 79 | $this->namedToHexColorsMap = Colors::getNamedToHexMap(); |
80 | 80 | $this->namedToHexColorsRegex = sprintf( |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function setShortenZeroValuesRegexes() |
178 | 178 | { |
179 | - $zeroRegex = '0'. $this->unitsGroupRegex; |
|
180 | - $numOrPosRegex = '('. $this->numRegex .'|top|left|bottom|right|center) '; |
|
179 | + $zeroRegex = '0'.$this->unitsGroupRegex; |
|
180 | + $numOrPosRegex = '('.$this->numRegex.'|top|left|bottom|right|center) '; |
|
181 | 181 | $oneZeroSafeProperties = array( |
182 | 182 | '(?:line-)?height', |
183 | 183 | '(?:(?:min|max)-)?width', |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | ); |
196 | 196 | |
197 | 197 | // First zero regex |
198 | - $regex = '/(^|;)('. implode('|', $oneZeroSafeProperties) .'):%s/Si'; |
|
198 | + $regex = '/(^|;)('.implode('|', $oneZeroSafeProperties).'):%s/Si'; |
|
199 | 199 | $this->shortenOneZeroesRegex = sprintf($regex, $zeroRegex); |
200 | 200 | |
201 | 201 | // Multiple zeroes regexes |
202 | 202 | $regex = '/(^|;)(margin|padding|border-(?:width|radius)|background-position):%s/Si'; |
203 | - $this->shortenTwoZeroesRegex = sprintf($regex, $numOrPosRegex . $zeroRegex); |
|
204 | - $this->shortenThreeZeroesRegex = sprintf($regex, $numOrPosRegex . $numOrPosRegex . $zeroRegex); |
|
205 | - $this->shortenFourZeroesRegex = sprintf($regex, $numOrPosRegex . $numOrPosRegex . $numOrPosRegex . $zeroRegex); |
|
203 | + $this->shortenTwoZeroesRegex = sprintf($regex, $numOrPosRegex.$zeroRegex); |
|
204 | + $this->shortenThreeZeroesRegex = sprintf($regex, $numOrPosRegex.$numOrPosRegex.$zeroRegex); |
|
205 | + $this->shortenFourZeroesRegex = sprintf($regex, $numOrPosRegex.$numOrPosRegex.$numOrPosRegex.$zeroRegex); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $dataStartIndex = $matchStartIndex + 4; // url( length |
390 | 390 | $searchOffset = $matchStartIndex + strlen($m[0][0]); |
391 | 391 | $terminator = $m[1][0]; // ', " or empty (not quoted) |
392 | - $terminatorRegex = '/(?<!\\\\)'. (strlen($terminator) === 0 ? '' : $terminator.'\s*') .'(\))/S'; |
|
392 | + $terminatorRegex = '/(?<!\\\\)'.(strlen($terminator) === 0 ? '' : $terminator.'\s*').'(\))/S'; |
|
393 | 393 | |
394 | 394 | $ret .= substr($css, $substrOffset, $matchStartIndex - $substrOffset); |
395 | 395 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $token = preg_replace('/\s+/S', '', $token); |
405 | 405 | } |
406 | 406 | |
407 | - $ret .= 'url('. $this->registerPreservedToken(trim($token)) .')'; |
|
407 | + $ret .= 'url('.$this->registerPreservedToken(trim($token)).')'; |
|
408 | 408 | // No end terminator found, re-add the whole match. Should we throw/warn here? |
409 | 409 | } else { |
410 | 410 | $ret .= substr($css, $matchStartIndex, $searchOffset - $matchStartIndex); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | private function processCommentsCallback($matches) |
427 | 427 | { |
428 | - return '/*'. $this->registerCommentToken($matches[1]) .'*/'; |
|
428 | + return '/*'.$this->registerCommentToken($matches[1]).'*/'; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | private function processOldIeSpecificMatrixDefinitionCallback($matches) |
437 | 437 | { |
438 | - return 'filter:progid:DXImageTransform.Microsoft.Matrix('. $this->registerPreservedToken($matches[1]) .')'; |
|
438 | + return 'filter:progid:DXImageTransform.Microsoft.Matrix('.$this->registerPreservedToken($matches[1]).')'; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | // minify alpha opacity in filter strings |
459 | 459 | $match = str_ireplace('progid:DXImageTransform.Microsoft.Alpha(Opacity=', 'alpha(opacity=', $match); |
460 | 460 | |
461 | - return $quote . $this->registerPreservedToken($match) . $quote; |
|
461 | + return $quote.$this->registerPreservedToken($match).$quote; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | private function processImportUnquotedUrlAtRulesCallback($matches) |
471 | 471 | { |
472 | - return '@import url('. $this->registerPreservedToken($matches[1]) .')'. $matches[2]; |
|
472 | + return '@import url('.$this->registerPreservedToken($matches[1]).')'.$matches[2]; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | private function processComments($css) |
481 | 481 | { |
482 | 482 | foreach ($this->comments as $commentId => $comment) { |
483 | - $commentIdString = '/*'. $commentId .'*/'; |
|
483 | + $commentIdString = '/*'.$commentId.'*/'; |
|
484 | 484 | |
485 | 485 | // ! in the first position of the comment means preserve |
486 | 486 | // so push to the preserved tokens keeping the ! |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | $blockEndPos = strpos($css, '}', $blockStartPos); |
532 | 532 | // When ending curly brace is missing, let's |
533 | 533 | // behave like there was one at the end of the block... |
534 | - if ( false === $blockEndPos ) { |
|
534 | + if (false === $blockEndPos) { |
|
535 | 535 | $blockEndPos = strlen($css) - 1; |
536 | 536 | } |
537 | 537 | $nextBlockStartPos = strpos($css, '{', $blockStartPos + 1); |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | } else { |
544 | 544 | $ruleBody = substr($css, $blockStartPos + 1, $blockEndPos - $blockStartPos - 1); |
545 | 545 | $ruleBodyToken = $this->registerRuleBodyToken($this->processRuleBody($ruleBody)); |
546 | - $ret .= '{'. $ruleBodyToken .'}'; |
|
546 | + $ret .= '{'.$ruleBodyToken.'}'; |
|
547 | 547 | $searchOffset = $blockEndPos + 1; |
548 | 548 | } |
549 | 549 | |
@@ -643,8 +643,8 @@ discard block |
||
643 | 643 | $body = preg_replace('/([ :,(])\+(\.?\d+)/S', '$1$2', $body); |
644 | 644 | |
645 | 645 | // shorten ms to s |
646 | - $body = preg_replace_callback('/([ :,(])(-?)(\d{3,})ms/Si', function ($matches) { |
|
647 | - return $matches[1] . $matches[2] . ((int) $matches[3] / 1000) .'s'; |
|
646 | + $body = preg_replace_callback('/([ :,(])(-?)(\d{3,})ms/Si', function($matches) { |
|
647 | + return $matches[1].$matches[2].((int) $matches[3]/1000).'s'; |
|
648 | 648 | }, $body); |
649 | 649 | |
650 | 650 | // Remove leading zeros from integer and float numbers. |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | $css = preg_replace('/::(before|after|first-(?:line|letter))(\{|,)/Si', ':$1$2', $css); |
757 | 757 | |
758 | 758 | // Retain space for special IE6 cases |
759 | - $css = preg_replace_callback('/:first-(line|letter)(\{|,)/Si', function ($matches) { |
|
760 | - return ':first-'. strtolower($matches[1]) .' '. $matches[2]; |
|
759 | + $css = preg_replace_callback('/:first-(line|letter)(\{|,)/Si', function($matches) { |
|
760 | + return ':first-'.strtolower($matches[1]).' '.$matches[2]; |
|
761 | 761 | }, $css); |
762 | 762 | |
763 | 763 | // Find a fraction that may used in some @media queries such as: (min-aspect-ratio: 1/1) |
764 | 764 | // Add token to add the "/" back in later |
765 | - $css = preg_replace('/\(([a-z-]+):([0-9]+)\/([0-9]+)\)/Si', '($1:$2'. self::QUERY_FRACTION .'$3)', $css); |
|
765 | + $css = preg_replace('/\(([a-z-]+):([0-9]+)\/([0-9]+)\)/Si', '($1:$2'.self::QUERY_FRACTION.'$3)', $css); |
|
766 | 766 | |
767 | 767 | // Remove empty rule blocks up to 2 levels deep. |
768 | 768 | $css = preg_replace(array_fill(0, 2, '/(\{)[^{};\/\n]+\{\}/S'), '$1', $css); |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | |
812 | 812 | // @import handling |
813 | - $css = preg_replace_callback($this->importRegex, function ($matches) use (&$imports) { |
|
813 | + $css = preg_replace_callback($this->importRegex, function($matches) use (&$imports) { |
|
814 | 814 | // Keep all @import at-rules found for later |
815 | 815 | $imports .= $matches[0]; |
816 | 816 | // Delete all @import at-rules |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | }, $css); |
819 | 819 | |
820 | 820 | // @namespace handling |
821 | - $css = preg_replace_callback($this->namespaceRegex, function ($matches) use (&$namespaces) { |
|
821 | + $css = preg_replace_callback($this->namespaceRegex, function($matches) use (&$namespaces) { |
|
822 | 822 | // Keep all @namespace at-rules found for later |
823 | 823 | $namespaces .= $matches[0]; |
824 | 824 | // Delete all @namespace at-rules |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | // 1. @charset first |
830 | 830 | // 2. @imports below @charset |
831 | 831 | // 3. @namespaces below @imports |
832 | - $css = $charset . $imports . $namespaces . $css; |
|
832 | + $css = $charset.$imports.$namespaces.$css; |
|
833 | 833 | |
834 | 834 | return $css; |
835 | 835 | } |
@@ -883,10 +883,10 @@ discard block |
||
883 | 883 | // Restore space after rgb() or hsl() function in some cases such as: |
884 | 884 | // background-image: linear-gradient(to bottom, rgb(210,180,140) 10%, rgb(255,0,0) 90%); |
885 | 885 | if (!empty($terminator) && !preg_match('/[ ,);]/S', $terminator)) { |
886 | - $terminator = ' '. $terminator; |
|
886 | + $terminator = ' '.$terminator; |
|
887 | 887 | } |
888 | 888 | |
889 | - return '#'. implode('', $hexColors) . $terminator; |
|
889 | + return '#'.implode('', $hexColors).$terminator; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | /** |
@@ -900,16 +900,16 @@ discard block |
||
900 | 900 | |
901 | 901 | // Shorten suitable 6 chars HEX colors |
902 | 902 | if (strlen($hex) === 6 && preg_match('/^([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3$/Si', $hex, $m)) { |
903 | - $hex = $m[1] . $m[2] . $m[3]; |
|
903 | + $hex = $m[1].$m[2].$m[3]; |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | // Lowercase |
907 | - $hex = '#'. strtolower($hex); |
|
907 | + $hex = '#'.strtolower($hex); |
|
908 | 908 | |
909 | 909 | // Replace Hex colors with shorter color names |
910 | 910 | $color = array_key_exists($hex, $this->hexToNamedColorsMap) ? $this->hexToNamedColorsMap[$hex] : $hex; |
911 | 911 | |
912 | - return $color . $matches[2]; |
|
912 | + return $color.$matches[2]; |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | /** |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | */ |
921 | 921 | private function shortenNamedColorsCallback($matches) |
922 | 922 | { |
923 | - return $matches[1] . $this->namedToHexColorsMap[strtolower($matches[2])] . $matches[3]; |
|
923 | + return $matches[1].$this->namedToHexColorsMap[strtolower($matches[2])].$matches[3]; |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * General helpers. |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return bool |
18 | 18 | */ |
19 | - public static function mbstring_available( $override = null ) |
|
19 | + public static function mbstring_available($override = null) |
|
20 | 20 | { |
21 | 21 | static $available = null; |
22 | 22 | |
23 | - if ( null === $available ) { |
|
24 | - $available = \extension_loaded( 'mbstring' ); |
|
23 | + if (null === $available) { |
|
24 | + $available = \extension_loaded('mbstring'); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( null !== $override ) { |
|
27 | + if (null !== $override) { |
|
28 | 28 | $available = $override; |
29 | 29 | } |
30 | 30 | |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return int|false |
44 | 44 | */ |
45 | - public static function strpos( $haystack, $needle, $offset = 0, $encoding = null ) |
|
45 | + public static function strpos($haystack, $needle, $offset = 0, $encoding = null) |
|
46 | 46 | { |
47 | - if ( self::mbstring_available() ) { |
|
48 | - return ( null === $encoding ) ? \mb_strpos( $haystack, $needle, $offset ) : \mb_strlen( $haystack, $needle, $offset, $encoding ); |
|
47 | + if (self::mbstring_available()) { |
|
48 | + return (null === $encoding) ? \mb_strpos($haystack, $needle, $offset) : \mb_strlen($haystack, $needle, $offset, $encoding); |
|
49 | 49 | } else { |
50 | - return \strpos( $haystack, $needle, $offset ); |
|
50 | + return \strpos($haystack, $needle, $offset); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | * @return int Number of charcters or bytes in given $string |
63 | 63 | * (characters if/when supported, bytes otherwise). |
64 | 64 | */ |
65 | - public static function strlen( $string, $encoding = null ) |
|
65 | + public static function strlen($string, $encoding = null) |
|
66 | 66 | { |
67 | - if ( self::mbstring_available() ) { |
|
68 | - return ( null === $encoding ) ? \mb_strlen( $string ) : \mb_strlen( $string, $encoding ); |
|
67 | + if (self::mbstring_available()) { |
|
68 | + return (null === $encoding) ? \mb_strlen($string) : \mb_strlen($string, $encoding); |
|
69 | 69 | } else { |
70 | - return \strlen( $string ); |
|
70 | + return \strlen($string); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -85,44 +85,44 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return string |
87 | 87 | */ |
88 | - public static function substr_replace( $string, $replacement, $start, $length = null, $encoding = null ) |
|
88 | + public static function substr_replace($string, $replacement, $start, $length = null, $encoding = null) |
|
89 | 89 | { |
90 | - if ( self::mbstring_available() ) { |
|
91 | - $strlen = self::strlen( $string, $encoding ); |
|
90 | + if (self::mbstring_available()) { |
|
91 | + $strlen = self::strlen($string, $encoding); |
|
92 | 92 | |
93 | - if ( $start < 0 ) { |
|
93 | + if ($start < 0) { |
|
94 | 94 | if ( -$start < $strlen ) { |
95 | 95 | $start = $strlen + $start; |
96 | 96 | } else { |
97 | 97 | $start = 0; |
98 | 98 | } |
99 | - } elseif ( $start > $strlen ) { |
|
99 | + } elseif ($start > $strlen) { |
|
100 | 100 | $start = $strlen; |
101 | 101 | } |
102 | 102 | |
103 | - if ( null === $length || '' === $length ) { |
|
103 | + if (null === $length || '' === $length) { |
|
104 | 104 | $start2 = $strlen; |
105 | - } elseif ( $length < 0 ) { |
|
105 | + } elseif ($length < 0) { |
|
106 | 106 | $start2 = $strlen + $length; |
107 | - if ( $start2 < $start ) { |
|
107 | + if ($start2 < $start) { |
|
108 | 108 | $start2 = $start; |
109 | 109 | } |
110 | 110 | } else { |
111 | 111 | $start2 = $start + $length; |
112 | 112 | } |
113 | 113 | |
114 | - if ( null === $encoding ) { |
|
115 | - $leader = $start ? \mb_substr( $string, 0, $start ) : ''; |
|
116 | - $trailer = ( $start2 < $strlen ) ? \mb_substr( $string, $start2, null ) : ''; |
|
114 | + if (null === $encoding) { |
|
115 | + $leader = $start ? \mb_substr($string, 0, $start) : ''; |
|
116 | + $trailer = ($start2 < $strlen) ? \mb_substr($string, $start2, null) : ''; |
|
117 | 117 | } else { |
118 | - $leader = $start ? \mb_substr( $string, 0, $start, $encoding ) : ''; |
|
119 | - $trailer = ( $start2 < $strlen ) ? \mb_substr( $string, $start2, null, $encoding ) : ''; |
|
118 | + $leader = $start ? \mb_substr($string, 0, $start, $encoding) : ''; |
|
119 | + $trailer = ($start2 < $strlen) ? \mb_substr($string, $start2, null, $encoding) : ''; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return "{$leader}{$replacement}{$trailer}"; |
123 | 123 | } |
124 | 124 | |
125 | - return ( null === $length ) ? \substr_replace( $string, $replacement, $start ) : \substr_replace( $string, $replacement, $start, $length ); |
|
125 | + return (null === $length) ? \substr_replace($string, $replacement, $start) : \substr_replace($string, $replacement, $start, $length); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return bool |
134 | 134 | */ |
135 | - public static function siteurl_not_root( $override = null ) |
|
135 | + public static function siteurl_not_root($override = null) |
|
136 | 136 | { |
137 | 137 | static $subdir = null; |
138 | 138 | |
139 | - if ( null === $subdir ) { |
|
139 | + if (null === $subdir) { |
|
140 | 140 | $parts = self::get_ao_wp_site_url_parts(); |
141 | - $subdir = ( isset( $parts['path'] ) && ( '/' !== $parts['path'] ) ); |
|
141 | + $subdir = (isset($parts['path']) && ('/' !== $parts['path'])); |
|
142 | 142 | } |
143 | 143 | |
144 | - if ( null !== $override ) { |
|
144 | + if (null !== $override) { |
|
145 | 145 | $subdir = $override; |
146 | 146 | } |
147 | 147 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | { |
159 | 159 | static $parts = array(); |
160 | 160 | |
161 | - if ( empty( $parts ) ) { |
|
162 | - $parts = \parse_url( AUTOPTIMIZE_WP_SITE_URL ); |
|
161 | + if (empty($parts)) { |
|
162 | + $parts = \parse_url(AUTOPTIMIZE_WP_SITE_URL); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $parts; |
@@ -174,33 +174,33 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - public static function tweak_cdn_url_if_needed( $cdn_url, $force_cache_miss = false ) |
|
177 | + public static function tweak_cdn_url_if_needed($cdn_url, $force_cache_miss = false) |
|
178 | 178 | { |
179 | 179 | static $results = array(); |
180 | 180 | |
181 | - if ( ! isset( $results[ $cdn_url ] ) || $force_cache_miss ) { |
|
181 | + if (!isset($results[$cdn_url]) || $force_cache_miss) { |
|
182 | 182 | |
183 | 183 | // In order to return unmodified input when there's no need to tweak. |
184 | - $results[ $cdn_url ] = $cdn_url; |
|
184 | + $results[$cdn_url] = $cdn_url; |
|
185 | 185 | |
186 | 186 | // Behind a default true filter for backcompat, and only for sites |
187 | 187 | // in a subfolder/subdirectory, but still easily turned off if |
188 | 188 | // not wanted/needed... |
189 | - if ( autoptimizeUtils::siteurl_not_root() ) { |
|
190 | - $check = apply_filters( 'autoptimize_filter_cdn_magic_path_check', true, $cdn_url ); |
|
191 | - if ( $check ) { |
|
189 | + if (autoptimizeUtils::siteurl_not_root()) { |
|
190 | + $check = apply_filters('autoptimize_filter_cdn_magic_path_check', true, $cdn_url); |
|
191 | + if ($check) { |
|
192 | 192 | $site_url_parts = autoptimizeUtils::get_ao_wp_site_url_parts(); |
193 | - $cdn_url_parts = \parse_url( $cdn_url ); |
|
194 | - $schemeless = self::is_protocol_relative( $cdn_url ); |
|
195 | - $cdn_url_parts = self::maybe_replace_cdn_path( $site_url_parts, $cdn_url_parts ); |
|
196 | - if ( false !== $cdn_url_parts ) { |
|
197 | - $results[ $cdn_url ] = self::assemble_parsed_url( $cdn_url_parts, $schemeless ); |
|
193 | + $cdn_url_parts = \parse_url($cdn_url); |
|
194 | + $schemeless = self::is_protocol_relative($cdn_url); |
|
195 | + $cdn_url_parts = self::maybe_replace_cdn_path($site_url_parts, $cdn_url_parts); |
|
196 | + if (false !== $cdn_url_parts) { |
|
197 | + $results[$cdn_url] = self::assemble_parsed_url($cdn_url_parts, $schemeless); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - return $results[ $cdn_url ]; |
|
203 | + return $results[$cdn_url]; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return array|false |
216 | 216 | */ |
217 | - public static function maybe_replace_cdn_path( array $site_url_parts, array $cdn_url_parts ) |
|
217 | + public static function maybe_replace_cdn_path(array $site_url_parts, array $cdn_url_parts) |
|
218 | 218 | { |
219 | - if ( isset( $site_url_parts['path'] ) && '/' !== $site_url_parts['path'] ) { |
|
220 | - if ( ! isset( $cdn_url_parts['path'] ) || '/' === $cdn_url_parts['path'] ) { |
|
219 | + if (isset($site_url_parts['path']) && '/' !== $site_url_parts['path']) { |
|
220 | + if (!isset($cdn_url_parts['path']) || '/' === $cdn_url_parts['path']) { |
|
221 | 221 | $cdn_url_parts['path'] = $site_url_parts['path']; |
222 | 222 | return $cdn_url_parts; |
223 | 223 | } |
@@ -237,20 +237,20 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public static function assemble_parsed_url( array $parsed_url, $schemeless = false ) |
|
240 | + public static function assemble_parsed_url(array $parsed_url, $schemeless = false) |
|
241 | 241 | { |
242 | - $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : ''; |
|
243 | - if ( $schemeless ) { |
|
242 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
243 | + if ($schemeless) { |
|
244 | 244 | $scheme = '//'; |
245 | 245 | } |
246 | - $host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : ''; |
|
247 | - $port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : ''; |
|
248 | - $user = isset( $parsed_url['user'] ) ? $parsed_url['user'] : ''; |
|
249 | - $pass = isset( $parsed_url['pass'] ) ? ':' . $parsed_url['pass'] : ''; |
|
250 | - $pass = ( $user || $pass ) ? "$pass@" : ''; |
|
251 | - $path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : ''; |
|
252 | - $query = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : ''; |
|
253 | - $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : ''; |
|
246 | + $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
|
247 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
248 | + $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; |
|
249 | + $pass = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : ''; |
|
250 | + $pass = ($user || $pass) ? "$pass@" : ''; |
|
251 | + $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; |
|
252 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
253 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
254 | 254 | |
255 | 255 | return "$scheme$user$pass$host$port$path$query$fragment"; |
256 | 256 | } |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return bool |
264 | 264 | */ |
265 | - public static function is_protocol_relative( $url ) |
|
265 | + public static function is_protocol_relative($url) |
|
266 | 266 | { |
267 | 267 | $result = false; |
268 | 268 | |
269 | - if ( ! empty( $url ) ) { |
|
270 | - $result = ( '/' === $url{1} ); // second char is `/`. |
|
269 | + if (!empty($url)) { |
|
270 | + $result = ('/' === $url{1} ); // second char is `/`. |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | return $result; |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - public static function path_canonicalize( $path ) |
|
283 | + public static function path_canonicalize($path) |
|
284 | 284 | { |
285 | - $patterns = array( |
|
285 | + $patterns = array( |
|
286 | 286 | '~/{2,}~', |
287 | 287 | '~/(\./)+~', |
288 | 288 | '~([^/\.]+/(?R)*\.{2,}/)~', |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | '', |
296 | 296 | ); |
297 | 297 | |
298 | - return preg_replace( $patterns, $replacements, $path ); |
|
298 | + return preg_replace($patterns, $replacements, $path); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @return none if $return_result is false (default), array if $return_result is true. |
307 | 307 | */ |
308 | - public static function check_service_availability( $return_result = false ) |
|
308 | + public static function check_service_availability($return_result = false) |
|
309 | 309 | { |
310 | - $service_availability_resp = wp_remote_get( 'https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=' . AUTOPTIMIZE_PLUGIN_VERSION ); |
|
311 | - if ( ! is_wp_error( $service_availability_resp ) ) { |
|
312 | - if ( '200' == wp_remote_retrieve_response_code( $service_availability_resp ) ) { |
|
313 | - $availabilities = json_decode( wp_remote_retrieve_body( $service_availability_resp ), true ); |
|
314 | - if ( is_array( $availabilities ) ) { |
|
315 | - update_option( 'autoptimize_service_availablity', $availabilities ); |
|
316 | - if ( $return_result ) { |
|
310 | + $service_availability_resp = wp_remote_get('https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver='.AUTOPTIMIZE_PLUGIN_VERSION); |
|
311 | + if (!is_wp_error($service_availability_resp)) { |
|
312 | + if ('200' == wp_remote_retrieve_response_code($service_availability_resp)) { |
|
313 | + $availabilities = json_decode(wp_remote_retrieve_body($service_availability_resp), true); |
|
314 | + if (is_array($availabilities)) { |
|
315 | + update_option('autoptimize_service_availablity', $availabilities); |
|
316 | + if ($return_result) { |
|
317 | 317 | return $availabilities; |
318 | 318 | } |
319 | 319 | } |
@@ -328,10 +328,10 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | - public static function str_is_valid_regex( $string ) |
|
331 | + public static function str_is_valid_regex($string) |
|
332 | 332 | { |
333 | - set_error_handler( function() {}, E_WARNING ); |
|
334 | - $is_regex = ( false !== preg_match( $string, '' ) ); |
|
333 | + set_error_handler(function() {}, E_WARNING); |
|
334 | + $is_regex = (false !== preg_match($string, '')); |
|
335 | 335 | restore_error_handler(); |
336 | 336 | |
337 | 337 | return $is_regex; |