PluginProbe
Autoptimize / 2.1.2
Autoptimize v2.1.2
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
← All changes | classes/autoptimizeConfig.php +229 -443 2.5.12.1.2 View file →
@@ -1,64 +1,50 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2 +if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 3
4 -class autoptimizeConfig
5 -{
6 - private $config = null;
4 +class autoptimizeConfig {
5 + private $config = null;
7 6 static private $instance = null;
8 7
9 - private $settings_screen_do_remote_http = true;
8 + //Singleton: private construct
9 + private function __construct() {
10 + if( is_admin() ) {
11 + //Add the admin page and settings
12 + add_action('admin_menu',array($this,'addmenu'));
13 + add_action('admin_init',array($this,'registersettings'));
10 14
11 - /**
12 - * Singleton.
13 - */
14 - private function __construct()
15 - {
16 - if ( is_admin() ) {
17 - // Add the admin page and settings.
18 - add_action( 'admin_menu', array( $this, 'addmenu' ) );
19 - add_action( 'admin_init', array( $this, 'registersettings' ) );
20 -
21 - // Set meta info.
22 - if ( function_exists( 'plugin_row_meta' ) ) {
23 - // 2.8 and higher.
24 - add_filter( 'plugin_row_meta', array( $this, 'setmeta' ), 10, 2 );
25 - } elseif ( function_exists( 'post_class' ) ) {
26 - // 2.7 and lower.
27 - $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' );
28 - add_filter( 'plugin_action_links_' . $plugin, array( $this, 'setmeta' ) );
15 + //Set meta info
16 + if(function_exists('plugin_row_meta')) {
17 + //2.8+
18 + add_filter('plugin_row_meta',array($this,'setmeta'),10,2);
19 + } elseif(function_exists('post_class')) {
20 + //2.7
21 + $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php');
22 + add_filter('plugin_action_links_'.$plugin,array($this,'setmeta'));
29 23 }
30 24
31 - // Clean cache?
32 - if ( get_option( 'autoptimize_cache_clean' ) ) {
25 + //Clean cache?
26 + if(get_option('autoptimize_cache_clean')) {
33 27 autoptimizeCache::clearall();
34 - update_option( 'autoptimize_cache_clean', 0 );
28 + update_option('autoptimize_cache_clean',0);
35 29 }
36 -
37 - $this->settings_screen_do_remote_http = apply_filters( 'autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http );
38 30 }
39 31
40 - // Adds the Autoptimize Toolbar to the Admin bar.
41 - // (we load outside the is_admin check so it's also displayed on the frontend toolbar).
32 + //Add the Autoptimize Toolbar to the Admin bar
33 + //(we loaded outside the verification of is_admin to also be displayed on the frontend toolbar)
42 34 $toolbar = new autoptimizeToolbar();
43 35 }
44 -
45 - /**
46 - * @return autoptimizeConfig
47 - */
48 - static public function instance()
49 - {
50 - // Only one instance.
51 - if ( null === self::$instance ) {
36 +
37 + static public function instance() {
38 + //Only one instance
39 + if (self::$instance == null) {
52 40 self::$instance = new autoptimizeConfig();
53 41 }
54 -
42 +
55 43 return self::$instance;
56 - }
57 -
58 - public function show()
59 - {
60 - $conf = self::instance();
44 + }
45 +
46 + public function show() {
61 47 ?>
62 48 <style>
63 49 /* title and button */
64 50 #ao_title_and_button:after {content:''; display:block; clear:both;}
@@ -83,16 +69,8 @@
83 69 #ao_show_adv:before {
84 70 content: "\f108 \f140";
85 71 }
86 72
87 -/* animate "show adv" button */
88 -#ao_show_adv { animation: watchmenow 3s linear 5s 10; }
89 -#ao_show_adv:hover { animation: none; }
90 -@keyframes watchmenow {
91 - 0% { box-shadow: unset; }
92 - 100% { box-shadow: 0px 0px 20px yellow; }
93 -}
94 -
95 73 /* form */
96 74 .itemDetail {
97 75 background: #fff;
98 76 border: 1px solid #ccc;
@@ -101,15 +79,14 @@
101 79 }
102 80 .itemTitle {
103 81 margin-top: 0;
104 82 }
105 -
106 -input[type=url]:invalid {color: red; border-color:red;} .form-table th{font-weight:normal;}
83 +input[type=url]:invalid {color: red; border-color:red;} .form-table th{font-weight:100;}
107 84 #autoptimize_main .cb_label {display: block; padding-left: 25px; text-indent: -25px;}
108 85
109 86 /* rss block */
110 87 #futtta_feed ul{list-style:outside;}
111 -#futtta_feed {font-size:medium; margin:0px 20px;}
88 +#futtta_feed {font-size:medium; margin:0px 20px;}
112 89
113 90 /* banner + unslider */
114 91 .autoptimize_banner {
115 92 margin: 0 38px;
@@ -152,9 +129,8 @@
152 129 }
153 130 .unslider-arrow.next::before {
154 131 content: "\f345";
155 132 }
156 -
157 133 /* responsive stuff: hide admin-feed on smaller screens */
158 134 @media (min-width: 961px) {
159 135 #autoptimize_main {float:left;width:69%;}
160 136 #autoptimize_admin_feed{float:right;width:30%;display:block !important;}
@@ -173,78 +149,88 @@
173 149 </style>
174 150
175 151 <div class="wrap">
176 152
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>
153 +<?php if (version_compare(PHP_VERSION, '5.3.0') < 0) { ?>
154 +<div class="notice-error notice"><?php _e('<p><strong>You are using a very old version of PHP</strong> (5.2.x or older) which has <a href="http://blog.futtta.be/2016/03/15/why-would-you-still-be-on-php-5-2/" target="_blank">serious security and performance issues</a>. Please ask your hoster to provide you with an upgrade path to 5.6 or 7.0</p>','autoptimize'); ?></div>
179 155 <?php } ?>
180 156
181 -<?php if ( defined( 'AUTOPTIMIZE_LEGACY_MINIFIERS' ) ) { ?>
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' ); ?>
184 - </p></div>
185 -<?php } ?>
186 -
187 157 <div id="autoptimize_main">
188 - <div id="ao_title_and_button">
189 - <h1 id="ao_title"><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?>
190 - <span id="ao_adv_button">
191 - <?php if ( get_option( 'autoptimize_show_adv', '1' ) == '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 - <style>tr.ao_adv{display:table-row;} li.ao_adv{display:list-item;}</style>
195 - <?php $hiddenClass = ''; ?>
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>
199 - <?php $hiddenClass = 'hidden '; ?>
200 - <?php } ?>
201 - </span>
202 - </h1>
203 - </div>
158 +<div id="ao_title_and_button">
159 + <h1 id="ao_title"><?php _e('Autoptimize Settings','autoptimize'); ?>
160 + <span id="ao_adv_button">
161 + <?php
162 + if (get_option('autoptimize_show_adv','0')=='1') {
163 + ?>
164 + <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><span><?php _e("Show advanced settings","autoptimize") ?></span></a>
165 + <a href="javascript:void(0);" id="ao_hide_adv" class="button"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a>
166 + <style>tr.ao_adv{display:table-row;} li.ao_adv{display:list-item;}</style>
167 + <?php
168 + $hiddenClass="";
169 + } else {
170 + ?>
171 + <a href="javascript:void(0);" id="ao_show_adv" class="button"><span><?php _e("Show advanced settings","autoptimize") ?></span></a>
172 + <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a>
173 + <?php
174 + $hiddenClass="hidden ";
175 + }
176 + ?>
177 + </span>
178 + </h1>
179 +</div>
204 180
205 - <?php echo $this->ao_admin_tabs(); ?>
181 +<?php echo $this->ao_admin_tabs(); ?>
206 182
207 183 <form method="post" action="options.php">
208 -<?php settings_fields( 'autoptimize' ); ?>
184 +<?php settings_fields('autoptimize'); ?>
209 185
210 186 <ul>
211 187
212 188 <li class="itemDetail">
189 +<h2 class="itemTitle"><?php _e('HTML Options','autoptimize'); ?></h2>
190 +<table class="form-table">
191 +<tr valign="top">
192 +<th scope="row"><?php _e('Optimize HTML Code?','autoptimize'); ?></th>
193 +<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
194 +</tr>
195 +<tr class="<?php echo $hiddenClass;?>html_sub ao_adv" valign="top">
196 +<th scope="row"><?php _e('Keep HTML comments?','autoptimize'); ?></th>
197 +<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/>
198 +<?php _e('Enable this if you want HTML comments to remain in the page.','autoptimize'); ?></label></td>
199 +</tr>
200 +</table>
201 +</li>
202 +
203 +<li class="itemDetail">
213 204 <h2 class="itemTitle"><?php _e('JavaScript Options','autoptimize'); ?></h2>
214 -<table class="form-table">
205 +<table class="form-table">
215 206 <tr valign="top">
216 207 <th scope="row"><?php _e('Optimize JavaScript Code?','autoptimize'); ?></th>
217 208 <td><input type="checkbox" id="autoptimize_js" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
218 209 </tr>
219 210 <tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
220 -<th scope="row"><?php _e( 'Aggregate JS-files?', 'autoptimize' ); ?></th>
221 -<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" ':''; ?>/>
222 -<?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>
223 -</tr>
224 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
225 -<th scope="row"><?php _e('Also aggregate inline JS?','autoptimize'); ?></th>
226 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline')?'checked="checked" ':''; ?>/>
227 -<?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>
228 -</tr>
229 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
230 211 <th scope="row"><?php _e('Force JavaScript in &lt;head&gt;?','autoptimize'); ?></th>
231 212 <td><label class="cb_label"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead')?'checked="checked" ':''; ?>/>
232 -<?php _e('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.','autoptimize'); ?></label></td>
213 +<?php _e('Load JavaScript early, reducing the chance of JS-errors but making it render blocking. You can disable this if you\'re not aggregating inline JS and you want JS to be deferred.','autoptimize'); ?></label></td>
233 214 </tr>
234 215 <?php if (get_option('autoptimize_js_justhead')) { ?>
235 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
236 -<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th>
216 +<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
217 +<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?','autoptimize'); _e(' <i>(deprecated)</i>','autoptimize'); ?></th>
237 218 <td><label class="cb_label"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
238 219 <?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>
239 220 </tr>
240 221 <?php } ?>
241 222 <tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
223 +<th scope="row"><?php _e('Also aggregate inline JS?','autoptimize'); ?></th>
224 +<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline')?'checked="checked" ':''; ?>/>
225 +<?php _e('Check this option for Autoptimize to also aggregate JS in the HTML. If this option is not enabled, you might have to "force JavaScript in head".','autoptimize'); ?></label></td>
226 +</tr>
227 +<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
242 228 <th scope="row"><?php _e('Exclude scripts from Autoptimize:','autoptimize'); ?></th>
243 -<td><label><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude',"wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js"); ?>"/><br />
244 -<?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>
229 +<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 />
230 +<?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 and minimized by Autoptimize.','autoptimize'); ?></label></td>
245 231 </tr>
246 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
232 +<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
247 233 <th scope="row"><?php _e('Add try-catch wrapping?','autoptimize'); ?></th>
248 234 <td><label class="cb_label"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch')?'checked="checked" ':''; ?>/>
249 235 <?php _e('If your scripts break because of a JS-error, you might want to try this.','autoptimize'); ?></label></td>
250 236 </tr>
@@ -252,53 +238,45 @@
252 238 </li>
253 239
254 240 <li class="itemDetail">
255 241 <h2 class="itemTitle"><?php _e('CSS Options','autoptimize'); ?></h2>
256 -<table class="form-table">
242 +<table class="form-table">
257 243 <tr valign="top">
258 244 <th scope="row"><?php _e('Optimize CSS Code?','autoptimize'); ?></th>
259 245 <td><input type="checkbox" id="autoptimize_css" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
260 246 </tr>
261 247 <tr class="<?php echo $hiddenClass;?>css_sub ao_adv" valign="top">
262 -<th scope="row"><?php _e( 'Aggregate CSS-files?', 'autoptimize' ); ?></th>
263 -<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" ' : ''; ?>/>
264 -<?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>
265 -</tr>
266 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate">
267 -<th scope="row"><?php _e('Also aggregate inline CSS?','autoptimize'); ?></th>
268 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline','1')?'checked="checked" ':''; ?>/>
269 -<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.','autoptimize'); ?></label></td>
270 -</tr>
271 -<tr class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate" valign="top">
272 248 <th scope="row"><?php _e('Generate data: URIs for images?','autoptimize'); ?></th>
273 249 <td><label class="cb_label"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris')?'checked="checked" ':''; ?>/>
274 250 <?php _e('Enable this to include small background-images in the CSS itself instead of as separate downloads.','autoptimize'); ?></label></td>
275 251 </tr>
252 +<tr class="<?php echo $hiddenClass;?>css_sub ao_adv" valign="top">
253 +<th scope="row"><?php _e('Remove Google Fonts?','autoptimize'); ?></th>
254 +<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_nogooglefont" <?php echo get_option('autoptimize_css_nogooglefont')?'checked="checked" ':''; ?>/>
255 +<?php _e('Check this if you don\'t need or want Google Fonts being loaded.','autoptimize'); ?></label></td>
256 +</tr>
276 257 <?php if (get_option('autoptimize_css_justhead')) { ?>
277 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv css_aggregate">
278 -<th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th>
258 +<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
259 +<th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); _e(' <i>(deprecated)</i>','autoptimize'); ?></th>
279 260 <td><label class="cb_label"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
280 261 <?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
281 262 </tr>
282 263 <?php } ?>
283 264 <tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
265 +<th scope="row"><?php _e('Also aggregate inline CSS?','autoptimize'); ?></th>
266 +<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline','1')?'checked="checked" ':''; ?>/>
267 +<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.','autoptimize'); ?></label></td>
268 +</tr>
269 +<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
284 270 <th scope="row"><?php _e('Inline and Defer CSS?','autoptimize'); ?></th>
285 271 <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" ':''; ?>/>
286 -<?php
287 -_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' );
288 -if ( function_exists( 'is_plugin_active' ) && ! is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) {
289 - echo ' ';
290 - $critcss_install_url = network_admin_url() . 'plugin-install.php?s=autoptimize+criticalcss&tab=search&type=term';
291 - 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>' );
292 -}
293 -?>
294 -</label></td>
272 +<?php _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> before activating this option!','autoptimize'); ?></label></td>
295 273 </tr>
296 274 <tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv" id="autoptimize_css_defer_inline">
297 275 <th scope="row"></th>
298 276 <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>
299 277 </tr>
300 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub css_aggregate">
278 +<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub">
301 279 <th scope="row"><?php _e('Inline all CSS?','autoptimize'); ?></th>
302 280 <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" ':''; ?>/>
303 281 <?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>
304 282 </tr>
@@ -303,9 +281,9 @@
303 281 <?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>
304 282 </tr>
305 283 <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub">
306 284 <th scope="row"><?php _e('Exclude CSS from Autoptimize:','autoptimize'); ?></th>
307 -<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 />
285 +<td><label><input type="text" style="width:100%;" name="autoptimize_css_exclude" value="<?php echo get_option('autoptimize_css_exclude','admin-bar.min.css, dashicons.min.css'); ?>"/><br />
308 286 <?php _e('A comma-separated list of CSS you want to exclude from being optimized.','autoptimize'); ?></label></td>
309 287 </tr>
310 288 </table>
311 289 </li>
@@ -310,29 +288,14 @@
310 288 </table>
311 289 </li>
312 290
313 291 <li class="itemDetail">
314 -<h2 class="itemTitle"><?php _e('HTML Options','autoptimize'); ?></h2>
315 -<table class="form-table">
316 -<tr valign="top">
317 -<th scope="row"><?php _e('Optimize HTML Code?','autoptimize'); ?></th>
318 -<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
319 -</tr>
320 -<tr class="<?php echo $hiddenClass;?>html_sub ao_adv" valign="top">
321 -<th scope="row"><?php _e('Keep HTML comments?','autoptimize'); ?></th>
322 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/>
323 -<?php _e('Enable this if you want HTML comments to remain in the page.','autoptimize'); ?></label></td>
324 -</tr>
325 -</table>
326 -</li>
327 -
328 -<li class="itemDetail">
329 292 <h2 class="itemTitle"><?php _e('CDN Options','autoptimize'); ?></h2>
330 -<table class="form-table">
293 +<table class="form-table">
331 294 <tr valign="top">
332 295 <th scope="row"><?php _e('CDN Base URL','autoptimize'); ?></th>
333 296 <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>
297 +<?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>).','autoptimize'); ?></label></td>
335 298 </tr>
336 299 </table>
337 300 </li>
338 301
@@ -337,9 +300,9 @@
337 300 </li>
338 301
339 302 <li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
340 303 <h2 class="itemTitle"><?php _e('Cache Info','autoptimize'); ?></h2>
341 -<table class="form-table" >
304 +<table class="form-table" >
342 305 <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
343 306 <th scope="row"><?php _e('Cache folder','autoptimize'); ?></th>
344 307 <td><?php echo htmlentities(AUTOPTIMIZE_CACHE_DIR); ?></td>
345 308 </tr>
@@ -349,62 +312,24 @@
349 312 </tr>
350 313 <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
351 314 <th scope="row"><?php _e('Cached styles and scripts','autoptimize'); ?></th>
352 315 <td><?php
353 - $AOstatArr = autoptimizeCache::stats();
354 - if ( ! empty( $AOstatArr ) && is_array( $AOstatArr ) ) {
355 - $AOcacheSize = size_format( $AOstatArr[1], 2 );
356 - $details = '';
357 - if ( $AOcacheSize > 0 ) {
358 - $details = ', ~' . $AOcacheSize . ' total';
359 - }
360 - printf( __( '%1$s files, totalling %2$s Kbytes (calculated at %3$s)', 'autoptimize' ), $AOstatArr[0], $AOcacheSize, date( 'H:i e', $AOstatArr[2] ) );
361 - }
316 + $AOstatArr=autoptimizeCache::stats();
317 + $AOcacheSize=round($AOstatArr[1]/1024);
318 + echo $AOstatArr[0].__(' files, totalling ','autoptimize').$AOcacheSize.__(' Kbytes (calculated at ','autoptimize').date("H:i e", $AOstatArr[2]).')';
362 319 ?></td>
363 320 </tr>
321 +<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
322 +<th scope="row"><?php _e('Save aggregated script/css as static files?','autoptimize'); ?></th>
323 +<td><label class="cb_label"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip','1')?'checked="checked" ':''; ?>/>
324 +<?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>
325 +</tr>
364 326 </table>
365 327 </li>
366 328
367 -<li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
368 -<h2 class="itemTitle"><?php _e('Misc Options','autoptimize'); ?></h2>
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>
374 - </tr>
375 - <?php
376 - $_min_excl_class = 'ao_adv';
377 - if ( !$conf->get( 'autoptimize_css_aggregate' ) && !$conf->get( 'autoptimize_js_aggregate' ) ) {
378 - $_min_excl_class = ' hidden';
379 - }
380 - ?>
381 - <tr valign="top" id="min_excl_row" class="<?php echo $hiddenClass.$_min_excl_class; ?>">
382 - <th scope="row"><?php _e('Minify excluded CSS and JS files?','autoptimize'); ?></th>
383 - <td><label class="cb_label"><input type="checkbox" name="autoptimize_minify_excluded" <?php echo get_option('autoptimize_minify_excluded','1')?'checked="checked" ':''; ?>/>
384 - <?php _e('When aggregating JS or CSS, excluded files that are not minified (based on filename) are by default minified by Autoptimize despite being excluded. Uncheck this option if anything breaks despite excluding.','autoptimize'); ?></label></td>
385 - </tr>
386 - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
387 - <th scope="row"><?php _e('Also optimize for logged in users?','autoptimize'); ?></th>
388 - <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_logged" <?php echo get_option('autoptimize_optimize_logged','1')?'checked="checked" ':''; ?>/>
389 - <?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>
390 - </tr>
391 - <?php
392 - if ( function_exists("is_checkout") || function_exists("is_cart") || function_exists("edd_is_checkout") || function_exists("wpsc_is_cart") || function_exists("wpsc_is_checkout") ) {
393 - ?>
394 - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
395 - <th scope="row"><?php _e('Also optimize shop cart/ checkout?','autoptimize'); ?></th>
396 - <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_checkout" <?php echo get_option('autoptimize_optimize_checkout','1')?'checked="checked" ':''; ?>/>
397 - <?php _e('By default Autoptimize is also active on your shop\'s cart/ checkout, uncheck not to optimize those.','autoptimize'); ?></label>
398 - </td>
399 - </tr>
400 - <?php } ?>
401 -</table>
402 -</li>
403 -
404 329 </ul>
405 330
406 -<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv','1'); ?>">
331 +<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv','0'); ?>">
407 332
408 333 <p class="submit">
409 334 <input type="submit" class="button-secondary" value="<?php _e('Save Changes','autoptimize') ?>" />
410 335 <input type="submit" class="button-primary" name="autoptimize_cache_clean" value="<?php _e('Save Changes and Empty Cache','autoptimize') ?>" />
@@ -413,27 +338,27 @@
413 338 </form>
414 339 </div>
415 340 <div id="autoptimize_admin_feed" class="hidden">
416 341 <div class="autoptimize_banner hidden">
417 - <ul>
418 - <?php
419 - if ( $this->settings_screen_do_remote_http ) {
420 - $AO_banner = get_transient( 'autoptimize_banner' );
421 - if ( empty( $AO_banner ) ) {
422 - $banner_resp = wp_remote_get( 'https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver='.AUTOPTIMIZE_PLUGIN_VERSION );
423 - if ( ! is_wp_error( $banner_resp ) ) {
424 - if ( '200' == wp_remote_retrieve_response_code( $banner_resp ) ) {
425 - $AO_banner = wp_kses_post( wp_remote_retrieve_body( $banner_resp ) );
426 - set_transient('autoptimize_banner', $AO_banner, DAY_IN_SECONDS);
342 + <ul>
343 + <?php
344 + if (apply_filters('autoptimize_settingsscreen_remotehttp',true)) {
345 + $AO_banner=get_transient("autoptimize_banner");
346 + if (empty($AO_banner)) {
347 + $banner_resp = wp_remote_get("http://misc.optimizingmatters.com/autoptimize_news.html");
348 + if (!is_wp_error($banner_resp)) {
349 + if (wp_remote_retrieve_response_code($banner_resp)=="200") {
350 + $AO_banner = wp_kses_post(wp_remote_retrieve_body($banner_resp));
351 + set_transient("autoptimize_banner",$AO_banner,DAY_IN_SECONDS);
352 + }
427 353 }
428 354 }
355 + echo $AO_banner;
429 356 }
430 - echo $AO_banner;
431 - }
432 - ?>
433 - <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.","autoptimize"); ?></li>
357 + ?>
358 + <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ</a> or post your question on <a href='http://wordpress.org/support/plugin/autoptimize'>the support-forum</a>.","autoptimize"); ?></li>
434 359 <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>
435 - </ul>
360 + </ul>
436 361 </div>
437 362 <div style="margin-left:10px;margin-top:-5px;">
438 363 <h2>
439 364 <?php _e("futtta about","autoptimize") ?>
@@ -454,9 +379,9 @@
454 379 <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_webtech"); ?>
455 380 </div>
456 381 </div>
457 382 </div>
458 - <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>
383 + <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!"); ?>"></a></div>
459 384 </div>
460 385
461 386 <script type="text/javascript">
462 387 var feed = new Array;
@@ -466,10 +391,9 @@
466 391 cookiename="autoptimize_feed";
467 392
468 393 jQuery(document).ready(function() {
469 394 check_ini_state();
470 -
471 - jQuery('#autoptimize_admin_feed').fadeTo("slow",1).show();
395 + jQuery('#autoptimize_admin_feed').fadeTo("slow",1).show();
472 396 jQuery('.autoptimize_banner').unslider({autoplay:true, delay:3500, infinite: false, arrows:{prev:'<a class="unslider-arrow prev"></a>', next:'<a class="unslider-arrow next"></a>'}}).fadeTo("slow",1).show();
473 397
474 398 jQuery( "#feed_dropdown" ).change(function() {
475 399 jQuery("#futtta_feed").fadeTo(0,0);
@@ -489,9 +413,9 @@
489 413 }
490 414 if (jQuery("#autoptimize_js").attr('checked')) {
491 415 jQuery(".js_sub:visible").fadeTo("fast",1);
492 416 }
493 - check_ini_state();
417 + check_ini_state()
494 418 jQuery( "input#autoptimize_show_adv" ).val("1");
495 419 });
496 420
497 421 jQuery( "#ao_hide_adv" ).click(function() {
@@ -504,9 +428,9 @@
504 428 }
505 429 if (!jQuery("#autoptimize_js").attr('checked')) {
506 430 jQuery(".js_sub:visible").fadeTo("fast",.33);
507 431 }
508 - check_ini_state();
432 + check_ini_state()
509 433 jQuery( "input#autoptimize_show_adv" ).val("0");
510 434 });
511 435
512 436 jQuery( "#autoptimize_html" ).change(function() {
@@ -524,20 +448,8 @@
524 448 jQuery(".js_sub:visible").fadeTo("fast",.33);
525 449 }
526 450 });
527 451
528 - jQuery( "#autoptimize_js_aggregate" ).change(function() {
529 - if (this.checked && jQuery("#autoptimize_js").attr('checked')) {
530 - jQuery(".js_aggregate:visible").fadeTo("fast",1);
531 - jQuery( "#min_excl_row" ).show();
532 - } else {
533 - jQuery(".js_aggregate:visible").fadeTo("fast",.33);
534 - if ( jQuery( "#autoptimize_css_aggregate" ).prop('checked') == false ) {
535 - jQuery( "#min_excl_row" ).hide();
536 - }
537 - }
538 - });
539 -
540 452 jQuery( "#autoptimize_css" ).change(function() {
541 453 if (this.checked) {
542 454 jQuery(".css_sub:visible").fadeTo("fast",1);
543 455 } else {
@@ -544,20 +456,8 @@
544 456 jQuery(".css_sub:visible").fadeTo("fast",.33);
545 457 }
546 458 });
547 459
548 - jQuery( "#autoptimize_css_aggregate" ).change(function() {
549 - if (this.checked && jQuery("#autoptimize_css").attr('checked')) {
550 - jQuery(".css_aggregate:visible").fadeTo("fast",1);
551 - jQuery( "#min_excl_row" ).show();
552 - } else {
553 - jQuery(".css_aggregate:visible").fadeTo("fast",.33);
554 - if ( jQuery( "#autoptimize_js_aggregate" ).prop('checked') == false ) {
555 - jQuery( "#min_excl_row" ).hide();
556 - }
557 - }
558 - });
559 -
560 460 jQuery( "#autoptimize_css_inline" ).change(function() {
561 461 if (this.checked) {
562 462 jQuery("#autoptimize_css_defer").prop("checked",false);
563 463 jQuery("#autoptimize_css_defer_inline").hide("slow");
@@ -578,9 +478,9 @@
578 478 if(typeof(feedid) !== "string") feedid=1;
579 479 show_feed(feedid);
580 480 })
581 481
582 - // validate cdn_url.
482 + // validate cdn_url
583 483 var cdn_url=document.getElementById("cdn_url");
584 484 cdn_url_baseCSS=cdn_url.style.cssText;
585 485 if ("validity" in cdn_url) {
586 486 jQuery("#cdn_url").focusout(function (event) {
@@ -600,17 +500,11 @@
600 500 }
601 501 if (!jQuery("#autoptimize_css").attr('checked')) {
602 502 jQuery(".css_sub:visible").fadeTo('fast',.33);
603 503 }
604 - if (!jQuery("#autoptimize_css_aggregate").attr('checked')) {
605 - jQuery(".css_aggregate:visible").fadeTo('fast',.33);
606 - }
607 504 if (!jQuery("#autoptimize_js").attr('checked')) {
608 505 jQuery(".js_sub:visible").fadeTo('fast',.33);
609 506 }
610 - if (!jQuery("#autoptimize_js_aggregate").attr('checked')) {
611 - jQuery(".js_aggregate:visible").fadeTo('fast',.33);
612 - }
613 507 }
614 508
615 509 function show_feed(id) {
616 510 jQuery('#futtta_feed').children().hide();
@@ -623,74 +517,65 @@
623 517
624 518 <?php
625 519 }
626 520
627 - public function addmenu()
628 - {
629 - $hook = add_options_page( __( 'Autoptimize Options', 'autoptimize' ), 'Autoptimize', 'manage_options', 'autoptimize', array( $this, 'show' ) );
630 - add_action( 'admin_print_scripts-' . $hook, array( $this, 'autoptimize_admin_scripts' ) );
631 - add_action( 'admin_print_styles-' . $hook, array( $this, 'autoptimize_admin_styles' ) );
521 + public function addmenu() {
522 + $hook=add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize','manage_options','autoptimize',array($this,'show'));
523 + add_action( 'admin_print_scripts-'.$hook,array($this,'autoptimize_admin_scripts'));
524 + add_action( 'admin_print_styles-'.$hook,array($this,'autoptimize_admin_styles'));
632 525 }
633 526
634 - public function autoptimize_admin_scripts()
635 - {
636 - wp_enqueue_script( 'jqcookie', plugins_url( '/external/js/jquery.cookie.min.js', __FILE__ ), array( 'jquery' ), null, true );
637 - wp_enqueue_script( 'unslider', plugins_url( '/external/js/unslider-min.js', __FILE__ ), array( 'jquery' ), null, true );
527 + public function autoptimize_admin_scripts() {
528 + wp_enqueue_script('jqcookie', plugins_url('/external/js/jquery.cookie.min.js', __FILE__), array('jquery'),null,true);
529 + wp_enqueue_script('unslider', plugins_url('/external/js/unslider-min.js', __FILE__), array('jquery'),null,true);
638 530 }
639 531
640 - public function autoptimize_admin_styles()
641 - {
642 - wp_enqueue_style( 'unslider', plugins_url( '/external/js/unslider.css', __FILE__ ) );
643 - wp_enqueue_style( 'unslider-dots', plugins_url( '/external/js/unslider-dots.css', __FILE__ ) );
532 + public function autoptimize_admin_styles() {
533 + wp_enqueue_style('unslider', plugins_url('/external/js/unslider.css', __FILE__));
534 + wp_enqueue_style('unslider-dots', plugins_url('/external/js/unslider-dots.css', __FILE__));
644 535 }
645 536
646 537 public function registersettings() {
647 - register_setting( 'autoptimize', 'autoptimize_html' );
648 - register_setting( 'autoptimize', 'autoptimize_html_keepcomments' );
649 - register_setting( 'autoptimize', 'autoptimize_js' );
650 - register_setting( 'autoptimize', 'autoptimize_js_aggregate' );
651 - register_setting( 'autoptimize', 'autoptimize_js_exclude' );
652 - register_setting( 'autoptimize', 'autoptimize_js_trycatch' );
653 - register_setting( 'autoptimize', 'autoptimize_js_justhead' );
654 - register_setting( 'autoptimize', 'autoptimize_js_forcehead' );
655 - register_setting( 'autoptimize', 'autoptimize_js_include_inline' );
656 - register_setting( 'autoptimize', 'autoptimize_css' );
657 - register_setting( 'autoptimize', 'autoptimize_css_aggregate' );
658 - register_setting( 'autoptimize', 'autoptimize_css_exclude' );
659 - register_setting( 'autoptimize', 'autoptimize_css_justhead' );
660 - register_setting( 'autoptimize', 'autoptimize_css_datauris' );
661 - register_setting( 'autoptimize', 'autoptimize_css_defer' );
662 - register_setting( 'autoptimize', 'autoptimize_css_defer_inline' );
663 - register_setting( 'autoptimize', 'autoptimize_css_inline' );
664 - register_setting( 'autoptimize', 'autoptimize_css_include_inline' );
665 - register_setting( 'autoptimize', 'autoptimize_cdn_url' );
666 - register_setting( 'autoptimize', 'autoptimize_cache_clean' );
667 - register_setting( 'autoptimize', 'autoptimize_cache_nogzip' );
668 - register_setting( 'autoptimize', 'autoptimize_show_adv' );
669 - register_setting( 'autoptimize', 'autoptimize_optimize_logged' );
670 - register_setting( 'autoptimize', 'autoptimize_optimize_checkout' );
671 - register_setting( 'autoptimize', 'autoptimize_minify_excluded' );
538 + register_setting('autoptimize','autoptimize_html');
539 + register_setting('autoptimize','autoptimize_html_keepcomments');
540 + register_setting('autoptimize','autoptimize_js');
541 + register_setting('autoptimize','autoptimize_js_exclude');
542 + register_setting('autoptimize','autoptimize_js_trycatch');
543 + register_setting('autoptimize','autoptimize_js_justhead');
544 + register_setting('autoptimize','autoptimize_js_forcehead');
545 + register_setting('autoptimize','autoptimize_js_include_inline');
546 + register_setting('autoptimize','autoptimize_css');
547 + register_setting('autoptimize','autoptimize_css_exclude');
548 + register_setting('autoptimize','autoptimize_css_justhead');
549 + register_setting('autoptimize','autoptimize_css_datauris');
550 + register_setting('autoptimize','autoptimize_css_defer');
551 + register_setting('autoptimize','autoptimize_css_defer_inline');
552 + register_setting('autoptimize','autoptimize_css_inline');
553 + register_setting('autoptimize','autoptimize_css_include_inline');
554 + register_setting('autoptimize','autoptimize_css_nogooglefont');
555 + register_setting('autoptimize','autoptimize_cdn_url');
556 + register_setting('autoptimize','autoptimize_cache_clean');
557 + register_setting('autoptimize','autoptimize_cache_nogzip');
558 + register_setting('autoptimize','autoptimize_show_adv');
672 559 }
673 560
674 - public function setmeta($links, $file = null)
675 - {
676 - // Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/.
677 - // Do it only once - saves time.
561 + public function setmeta($links,$file=null) {
562 + //Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/
563 + //Do it only once - saves time
678 564 static $plugin;
679 - if ( empty( $plugin ) ) {
680 - $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' );
681 - }
682 -
683 - if ( null === $file ) {
684 - // 2.7 and lower.
685 - $settings_link = sprintf( '<a href="options-general.php?page=autoptimize">%s</a>', __( 'Settings' ) );
686 - array_unshift( $links, $settings_link );
565 + if(empty($plugin))
566 + $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php');
567 +
568 + if($file===null) {
569 + //2.7
570 + $settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'));
571 + array_unshift($links,$settings_link);
687 572 } else {
688 - // 2.8 and higher.
689 - // If it's us, add the link.
690 - if ( $file === $plugin ) {
691 - $newlink = array( sprintf( '<a href="options-general.php?page=autoptimize">%s</a>', __( 'Settings' ) ) );
692 - $links = array_merge( $links, $newlink );
573 + //2.8
574 + //If it's us, add the link
575 + if($file === $plugin) {
576 + $newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>',__('Settings')));
577 + $links = array_merge($links,$newlink);
693 578 }
694 579 }
695 580
696 581 return $links;
@@ -695,133 +580,59 @@
695 580
696 581 return $links;
697 582 }
698 583
699 - /**
700 - * @return array
701 - */
702 - public static function get_defaults()
703 - {
704 - static $config = array(
705 - 'autoptimize_html' => 0,
706 - 'autoptimize_html_keepcomments' => 0,
707 - 'autoptimize_js' => 0,
708 - 'autoptimize_js_aggregate' => 1,
709 - 'autoptimize_js_exclude' => 'wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js',
710 - 'autoptimize_js_trycatch' => 0,
711 - 'autoptimize_js_justhead' => 0,
712 - 'autoptimize_js_include_inline' => 0,
713 - 'autoptimize_js_forcehead' => 0,
714 - 'autoptimize_css' => 0,
715 - 'autoptimize_css_aggregate' => 1,
716 - 'autoptimize_css_exclude' => 'admin-bar.min.css, dashicons.min.css, wp-content/cache/, wp-content/uploads/',
717 - 'autoptimize_css_justhead' => 0,
718 - 'autoptimize_css_include_inline' => 1,
719 - 'autoptimize_css_defer' => 0,
720 - 'autoptimize_css_defer_inline' => '',
721 - 'autoptimize_css_inline' => 0,
722 - 'autoptimize_css_datauris' => 0,
723 - 'autoptimize_cdn_url' => '',
724 - 'autoptimize_cache_nogzip' => 1,
725 - 'autoptimize_show_adv' => 1,
726 - 'autoptimize_optimize_logged' => 1,
727 - 'autoptimize_optimize_checkout' => 1,
728 - 'autoptimize_minify_excluded' => 1,
729 - );
584 + public function get($key) {
585 + if(!is_array($this->config)) {
586 + //Default config
587 + $config = array('autoptimize_html' => 0,
588 + 'autoptimize_html_keepcomments' => 0,
589 + 'autoptimize_js' => 0,
590 + 'autoptimize_js_exclude' => "seal.js, js/jquery/jquery.js",
591 + 'autoptimize_js_trycatch' => 0,
592 + 'autoptimize_js_justhead' => 0,
593 + 'autoptimize_js_include_inline' => 0,
594 + 'autoptimize_js_forcehead' => 0,
595 + 'autoptimize_css' => 0,
596 + 'autoptimize_css_exclude' => "admin-bar.min.css, dashicons.min.css",
597 + 'autoptimize_css_justhead' => 0,
598 + 'autoptimize_css_include_inline' => 1,
599 + 'autoptimize_css_defer' => 0,
600 + 'autoptimize_css_defer_inline' => "",
601 + 'autoptimize_css_inline' => 0,
602 + 'autoptimize_css_datauris' => 0,
603 + 'autoptimize_css_nogooglefont' => 0,
604 + 'autoptimize_cdn_url' => "",
605 + 'autoptimize_cache_nogzip' => 1,
606 + 'autoptimize_show_adv' => 0
607 + );
730 608
731 - return $config;
732 - }
733 -
734 - /**
735 - * Returns default option values for autoptimizeExtra.
736 - *
737 - * @return array
738 - */
739 - public static function get_ao_extra_default_options()
740 - {
741 - $defaults = array(
742 - 'autoptimize_extra_checkbox_field_1' => '0',
743 - 'autoptimize_extra_checkbox_field_0' => '0',
744 - 'autoptimize_extra_radio_field_4' => '1',
745 - 'autoptimize_extra_text_field_2' => '',
746 - 'autoptimize_extra_text_field_3' => '',
747 - );
748 -
749 - return $defaults;
750 - }
751 -
752 - /**
753 - * Returns default option values for autoptimizeExtra.
754 - *
755 - * @return array
756 - */
757 - public static function get_ao_imgopt_default_options()
758 - {
759 - $defaults = array(
760 - 'autoptimize_imgopt_checkbox_field_1' => '0', // imgopt off.
761 - 'autoptimize_imgopt_select_field_2' => '2', // quality glossy.
762 - 'autoptimize_imgopt_checkbox_field_3' => '0', // lazy load off.
763 - 'autoptimize_imgopt_checkbox_field_4' => '0', // webp off (might be removed).
764 - 'autoptimize_imgopt_text_field_5' => '', // lazy load exclusions empty.
765 - );
766 - return $defaults;
767 - }
768 -
769 - /**
770 - * Returns preload polyfill JS.
771 - *
772 - * @return string
773 - */
774 - public static function get_ao_css_preload_polyfill()
775 - {
776 - $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>');
777 - return $preload_poly;
778 - }
779 -
780 - /**
781 - * Returns preload JS onload handler.
782 - *
783 - * @return string
784 - */
785 - public static function get_ao_css_preload_onload()
786 - {
787 - $preload_onload = apply_filters('autoptimize_filter_css_preload_onload',"this.onload=null;this.rel='stylesheet'");
788 - return $preload_onload;
789 - }
790 -
791 - public function get($key)
792 - {
793 - if ( ! is_array( $this->config ) ) {
794 - // Default config.
795 - $config = self::get_defaults();
796 -
797 - // Override with user settings.
798 - foreach ( array_keys( $config ) as $name ) {
799 - $conf = get_option( $name );
800 - if ( false !== $conf ) {
801 - // It was set before!
802 - $config[ $name ] = $conf;
609 + //Override with user settings
610 + foreach(array_keys($config) as $name) {
611 + $conf = get_option($name);
612 + if($conf!==false) {
613 + //It was set before!
614 + $config[$name] = $conf;
803 615 }
804 616 }
805 617
806 - // Save for next call.
807 - $this->config = apply_filters( 'autoptimize_filter_get_config', $config );
618 + //Save for next question
619 + $this->config = $config;
808 620 }
809 621
810 - if ( isset( $this->config[ $key ] ) ) {
811 - return $this->config[ $key ];
812 - }
622 + if(isset($this->config[$key]))
623 + return $this->config[$key];
813 624
814 625 return false;
815 626 }
816 627
817 628 private function getFutttaFeeds($url) {
818 - if ( $this->settings_screen_do_remote_http ) {
629 + if (apply_filters('autoptimize_settingsscreen_remotehttp',true)) {
819 630 $rss = fetch_feed( $url );
820 631 $maxitems = 0;
821 632
822 633 if ( ! is_wp_error( $rss ) ) {
823 - $maxitems = $rss->get_item_quantity( 7 );
634 + $maxitems = $rss->get_item_quantity( 7 );
824 635 $rss_items = $rss->get_items( 0, $maxitems );
825 636 }
826 637 ?>
827 638 <ul>
@@ -837,60 +648,35 @@
837 648 </li>
838 649 <?php endforeach; ?>
839 650 <?php endif; ?>
840 651 </ul>
841 - <?php
652 + <?php
842 653 }
843 654 }
844 655
845 656 // based on http://wordpress.stackexchange.com/a/58826
846 - static function ao_admin_tabs()
847 - {
848 - $tabs = apply_filters( 'autoptimize_filter_settingsscreen_tabs' ,array( 'autoptimize' => __( 'JS, CSS &amp; HTML', 'autoptimize' ) ) );
849 - $tabContent = '';
850 - $tabs_count = count($tabs);
851 - if ( $tabs_count > 1 ) {
852 - if ( isset( $_GET['page'] ) ) {
657 + static function ao_admin_tabs(){
658 + $tabs = apply_filters('autoptimize_filter_settingsscreen_tabs',array('autoptimize' => __('Main','autoptimize')));
659 + $tabContent="";
660 + if (count($tabs)>1) {
661 + if(isset($_GET['page'])){
853 662 $currentId = $_GET['page'];
854 663 } else {
855 664 $currentId = "autoptimize";
856 665 }
857 - $tabContent .= '<h2 class="nav-tab-wrapper">';
858 - foreach ($tabs as $tabId => $tabName) {
859 - if ( $currentId == $tabId ) {
860 - $class = ' nav-tab-active';
666 + $tabContent .= "<h2 class=\"nav-tab-wrapper\">";
667 + foreach($tabs as $tabId => $tabName){
668 + if($currentId == $tabId){
669 + $class = " nav-tab-active";
861 670 } else{
862 - $class = '';
671 + $class = "";
863 672 }
864 - $tabContent .= '<a class="nav-tab' . $class . '" href="?page=' . $tabId . '">' . $tabName . '</a>';
673 + $tabContent .= '<a class="nav-tab'.$class.'" href="?page='.$tabId.'">'.$tabName.'</a>';
865 674 }
866 - $tabContent .= '</h2>';
675 + $tabContent .= "</h2>";
867 676 } else {
868 - $tabContent = '<hr/>';
677 + $tabContent = "<hr/>";
869 678 }
870 679
871 680 return $tabContent;
872 - }
873 -
874 - /**
875 - * Returns true if in admin (and not in admin-ajax.php!)
876 - *
877 - * @return bool
878 - */
879 - public static function is_admin_and_not_ajax()
880 - {
881 - return ( is_admin() && ! self::doing_ajax() );
882 - }
883 -
884 - /**
885 - * Returns true if doing ajax.
886 - *
887 - * @return bool
888 - */
889 - protected static function doing_ajax()
890 - {
891 - if ( function_exists( 'wp_doing_ajax' ) ) {
892 - return wp_doing_ajax();
893 - }
894 - return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
895 681 }
896 682 }