PluginProbe
Autoptimize / 1.6.5
Autoptimize v1.6.5
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 +273 -783 2.4.01.6.5 View file →
@@ -1,861 +1,351 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
3 2
4 3 class autoptimizeConfig
5 4 {
6 - private $config = null;
7 - static private $instance = null;
5 + private $config = null;
6 + static private $instance = null;
7 +
8 + //Singleton: private construct
9 + private function __construct()
10 + {
11 + if( is_admin() )
12 + {
13 + //Add the admin page and settings
14 + add_action('admin_menu',array($this,'addmenu'));
15 + add_action('admin_init',array($this,'registersettings'));
8 16
9 - private $settings_screen_do_remote_http = true;
17 + //Set meta info
18 + if(function_exists('plugin_row_meta'))
19 + {
20 + //2.8+
21 + add_filter('plugin_row_meta',array($this,'setmeta'),10,2);
22 + } elseif(function_exists('post_class')) {
23 + //2.7
24 + $plugin = plugin_basename(WP_PLUGIN_DIR.'/autoptimize/autoptimize.php');
25 + add_filter('plugin_action_links_'.$plugin,array($this,'setmeta'));
26 + }
10 27
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' ) );
29 - }
30 -
31 - // Clean cache?
32 - if ( get_option( 'autoptimize_cache_clean' ) ) {
33 - autoptimizeCache::clearall();
34 - update_option( 'autoptimize_cache_clean', 0 );
35 - }
36 -
37 - $this->settings_screen_do_remote_http = apply_filters( 'autoptimize_settingsscreen_remotehttp', $this->settings_screen_do_remote_http );
38 - }
39 -
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).
42 - $toolbar = new autoptimizeToolbar();
28 + //Clean cache?
29 + if(get_option('autoptimize_cache_clean'))
30 + {
31 + autoptimizeCache::clearall();
32 + update_option('autoptimize_cache_clean',0);
33 + }
34 + }
35 + }
36 +
37 + static public function instance()
38 + {
39 + //Only one instance
40 + if (self::$instance == null)
41 + {
42 + self::$instance = new autoptimizeConfig();
43 + }
44 +
45 + return self::$instance;
43 46 }
44 -
45 - /**
46 - * @return autoptimizeConfig
47 - */
48 - static public function instance()
49 - {
50 - // Only one instance.
51 - if ( null === self::$instance ) {
52 - self::$instance = new autoptimizeConfig();
53 - }
54 -
55 - return self::$instance;
56 - }
57 -
58 - public function show()
59 - {
60 - $conf = self::instance();
47 +
48 + public function show()
49 + {
61 50 ?>
62 -<style>
63 -/* title and button */
64 -#ao_title_and_button:after {content:''; display:block; clear:both;}
65 -#ao_adv_button{float:right;}
66 -#ao_hide_adv:before, #ao_show_adv:before {
67 - display: inline-block;
68 - float: left;
69 - height: 20px;
70 - width: 35px;
71 - background: none;
72 - color: #b4b9be;
73 - font: normal 20px/26px dashicons;
74 - letter-spacing: -4px;
75 - text-align: left;
76 - speak: none;
77 - -webkit-font-smoothing: antialiased;
78 - -moz-osx-font-smoothing: grayscale;
79 -}
80 -#ao_hide_adv:before {
81 - content: "\f108 \f142";
82 -}
83 -#ao_show_adv:before {
84 - content: "\f108 \f140";
85 -}
86 -
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 -/* form */
96 -.itemDetail {
97 - background: #fff;
98 - border: 1px solid #ccc;
99 - padding: 15px;
100 - margin: 15px 10px 10px 0;
101 -}
102 -.itemTitle {
103 - margin-top: 0;
104 -}
105 -
106 -input[type=url]:invalid {color: red; border-color:red;} .form-table th{font-weight:normal;}
107 -#autoptimize_main .cb_label {display: block; padding-left: 25px; text-indent: -25px;}
108 -
109 -/* rss block */
110 -#futtta_feed ul{list-style:outside;}
111 -#futtta_feed {font-size:medium; margin:0px 20px;}
112 -
113 -/* banner + unslider */
114 -.autoptimize_banner {
115 - margin: 0 38px;
116 - padding-bottom: 5px;
117 -}
118 -.autoptimize_banner ul li {
119 - font-size:medium;
120 - text-align:center;
121 -}
122 -.unslider {
123 - position:relative;
124 -}
125 -.unslider-arrow {
126 - display: block;
127 - left: unset;
128 - margin-top: -35px;
129 - margin-left: 7px;
130 - margin-right: 7px;
131 - border-radius: 32px;
132 - background: rgba(0, 0, 0, 0.10) no-repeat 50% 50%;
133 - color: rgba(255, 255, 255, 0.8);
134 - font: normal 20px/1 dashicons;
135 - speak: none;
136 - padding: 3px 2px 3px 4px;
137 - -webkit-font-smoothing: antialiased;
138 - -moz-osx-font-smoothing: grayscale;
139 -}
140 -.unslider-arrow:hover {
141 - background-color: rgba(0, 0, 0, 0.20);
142 - color: #FFF;
143 -}
144 -.unslider-arrow.prev {
145 - padding: 3px 4px 3px 2px;
146 -}
147 -.unslider-arrow.next {
148 - right: 0px;
149 -}
150 -.unslider-arrow.prev::before {
151 - content: "\f341";
152 -}
153 -.unslider-arrow.next::before {
154 - content: "\f345";
155 -}
156 -
157 -/* responsive stuff: hide admin-feed on smaller screens */
158 -@media (min-width: 961px) {
159 - #autoptimize_main {float:left;width:69%;}
160 - #autoptimize_admin_feed{float:right;width:30%;display:block !important;}
161 - }
162 -@media (max-width: 960px) {
163 - #autoptimize_main {width:100%;}
164 - #autoptimize_admin_feed {width:0%;display:none !important;}
165 -}
166 -@media (max-width: 782px) {
167 - #ao_hide_adv span, #ao_show_adv span {display: none;}
168 - #ao_hide_adv,#ao_show_adv {height: 34px;padding: 4px 12px 8px 8px;}
169 - #ao_hide_adv:before,#ao_show_adv:before {font-size: 25px;}
170 - #autoptimize_main input[type="checkbox"] {margin-left: 10px;}
171 - #autoptimize_main .cb_label {display: block; padding-left: 45px; text-indent: -45px;}
172 -}
173 -</style>
174 -
175 51 <div class="wrap">
52 +<h2><?php _e('Autoptimize Settings','autoptimize'); ?></h2>
176 53
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 -<?php } ?>
180 -
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 -<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', '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 - <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>
204 -
205 - <?php echo $this->ao_admin_tabs(); ?>
206 -
54 +<div style="float:left;width:70%;">
207 55 <form method="post" action="options.php">
208 -<?php settings_fields( 'autoptimize' ); ?>
56 +<?php settings_fields('autoptimize'); ?>
209 57
210 -<ul>
211 -
212 -<li class="itemDetail">
213 -<h2 class="itemTitle"><?php _e('HTML Options','autoptimize'); ?></h2>
58 +<h3><?php _e('HTML Options','autoptimize'); ?></h3>
214 59 <table class="form-table">
215 60 <tr valign="top">
216 61 <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>
62 +<td><input type="checkbox" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
218 63 </tr>
219 -<tr class="<?php echo $hiddenClass;?>html_sub ao_adv" valign="top">
64 +<tr valign="top">
220 65 <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>
66 +<td><label for="autoptimize_html_keepcomments"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/>
67 +<?php _e('Disabled by default. Enable this if you want HTML comments to remain in the page.','autoptimize'); ?></label></td>
223 68 </tr>
224 69 </table>
225 -</li>
226 70
227 -<li class="itemDetail">
228 -<h2 class="itemTitle"><?php _e('JavaScript Options','autoptimize'); ?></h2>
229 -<table class="form-table">
71 +<h3><?php _e('JavaScript Options','autoptimize'); ?></h3>
72 +<table class="form-table">
230 73 <tr valign="top">
231 74 <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>
75 +<td><input type="checkbox" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
233 76 </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>
77 +<tr valign="top">
78 +<th scope="row"><?php _e('Exclude scripts from autoptimize:','autoptimize'); ?></th>
79 +<td><label for="autoptimize_js_exclude"><input type="text" style="width:100%;" name="autoptimize_js_exclude" value="<?php echo get_option('autoptimize_js_exclude',"s_sid,smowtion_size,sc_project,WAU_,wau_add,comment-form-quicktags,edToolbar,ch_client"); ?>"/><br />
80 +<?php _e('A comma-seperated list of scripts you want to exclude from being Autoptimized, for example \'whatever.js, another.js\' (without the quotes) to exclude those scripts from being aggregated and minimized by Autoptimize.','autoptimize'); ?></label></td>
238 81 </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>
82 +<tr valign="top">
83 +<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?','autoptimize'); ?></th>
84 +<td><label for="autoptimize_js_justhead"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
85 +<?php _e('Disabled by default. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
243 86 </tr>
244 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv js_aggregate">
87 +<tr valign="top">
245 88 <th scope="row"><?php _e('Force JavaScript in &lt;head&gt;?','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>
89 +<td><label for="autoptimize_js_forcehead"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead')?'checked="checked" ':''; ?>/>
90 +<?php _e('Disabled by default. For performance reasons JavaScript is best put at the end of the HTML, but in some circumstances this breaks things. You can in that case check this option to add JavaScript to the &lt;head&gt; section.','autoptimize'); ?></label></td>
248 91 </tr>
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 &lt;head&gt;?','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>
92 +<tr valign="top">
93 +<th scope="row"><?php _e('Add try-catch wrapping?','autoptimize'); ?></th>
94 +<td><label for="autoptimize_js_trycatch"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch')?'checked="checked" ':''; ?>/>
95 +<?php _e('Disabled by default. If your scripts break because of an script error, you might want to try this.','autoptimize'); ?></label></td>
254 96 </tr>
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>
97 +<tr valign="top">
98 +<th scope="row"><?php _e('Use YUI compression?','autoptimize'); ?></th>
99 +<td><label for="autoptimize_js_yui"><input type="checkbox" name="autoptimize_js_yui" <?php echo get_option('autoptimize_js_yui')?'checked="checked" ':''; ?>/>
100 +<?php _e('<b>Deprecated!</b> Disabled by default. Read [autoptimize]/yui/README.txt for more information.','autoptimize'); ?></label></td>
260 101 </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>
265 -</tr>
266 102 </table>
267 -</li>
268 103
269 -<li class="itemDetail">
270 -<h2 class="itemTitle"><?php _e('CSS Options','autoptimize'); ?></h2>
271 -<table class="form-table">
104 +<h3><?php _e('CSS Options','autoptimize'); ?></h3>
105 +<table class="form-table">
272 106 <tr valign="top">
273 107 <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>
108 +<td><input type="checkbox" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
275 109 </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>
110 +<tr valign="top">
111 +<th scope="row"><?php _e('Look for styles on just &lt;head&gt;?','autoptimize'); ?></th>
112 +<td><label for="autoptimize_css_justhead"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
113 +<?php _e('Disabled by default. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
280 114 </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>
115 +<tr valign="top">
116 +<th scope="row"><?php _e('Generate data: URIs for images?','autoptimize'); ?></th>
117 +<td><label for="autoptimize_css_datauris"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris')?'checked="checked" ':''; ?>/>
118 +<?php _e('Disabled by default. Enable this to include images on the CSS itself.','autoptimize'); ?></label></td>
285 119 </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>
120 +<tr valign="top">
121 +<th scope="row"><?php _e('Use YUI compression?','autoptimize'); ?></th>
122 +<td><label for="autoptimize_css_yui"><input type="checkbox" name="autoptimize_css_yui" <?php echo get_option('autoptimize_css_yui')?'checked="checked" ':''; ?>/>
123 +<?php _e('<b>Deprecated!</b> Disabled by default. Read [autoptimize]/yui/README.txt for more information.','autoptimize'); ?></label></td>
290 124 </tr>
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 &lt;head&gt;?','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>
125 +</table>
126 +
127 +<h3><?php _e('CDN Options','autoptimize'); ?> (Deprecated!)</h3>
128 +<table class="form-table">
129 +<tr valign="top">
130 +<th scope="row"><?php _e('Rewrite JavaScript URLs?','autoptimize'); ?></th>
131 +<td><label for="autoptimize_cdn_js"><input type="checkbox" name="autoptimize_cdn_js" <?php echo get_option('autoptimize_cdn_js')?'checked="checked" ':''; ?>/>
132 +<?php _e('Disabled by default. Do not enable this unless you know what you are doing.','autoptimize'); ?></label></td>
296 133 </tr>
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" ':''; ?>/>
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' ) ) {
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>' );
307 -}
308 -?>
309 -</label></td>
134 +<tr valign="top">
135 +<th scope="row"><?php _e('JavaScript Base URL','autoptimize'); ?></th>
136 +<td><label for="autoptimize_cdn_js_url"><input type="text" name="autoptimize_cdn_js_url" value="<?php $it = get_option('autoptimize_cdn_js_url');echo htmlentities($it?$it:site_url()); ?>" />
137 +<?php _e('This is the new base URL that will be used when rewriting. It should point to the blog root directory.','autoptimize'); ?></label></td>
310 138 </tr>
311 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv" id="autoptimize_css_defer_inline">
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>
139 +<tr valign="top">
140 +<th scope="row"><?php _e('Rewrite CSS URLs?','autoptimize'); ?></th>
141 +<td><label for="autoptimize_cdn_css"><input type="checkbox" name="autoptimize_cdn_css" <?php echo get_option('autoptimize_cdn_css')?'checked="checked" ':''; ?>/>
142 +<?php _e('Disabled by default. Do not enable this unless you know what you are doing.','autoptimize'); ?></label></td>
314 143 </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>
144 +<tr valign="top">
145 +<th scope="row"><?php _e('CSS Base URL','autoptimize'); ?></th>
146 +<td><label for="autoptimize_cdn_css_url"><input type="text" name="autoptimize_cdn_css_url" value="<?php $it = get_option('autoptimize_cdn_css_url');echo htmlentities($it?$it:site_url()); ?>" />
147 +<?php _e('This is the new base URL that will be used when rewriting. It should point to the blog root directory.','autoptimize'); ?></label></td>
319 148 </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>
149 +<tr valign="top">
150 +<th scope="row"><?php _e('Rewrite Image URLs?','autoptimize'); ?></th>
151 +<td><label for="autoptimize_cdn_img"><input type="checkbox" name="autoptimize_cdn_img" <?php echo get_option('autoptimize_cdn_img')?'checked="checked" ':''; ?>/>
152 +<?php _e('Disabled by default. Do not enable this unless you know what you are doing.','autoptimize'); ?></label></td>
324 153 </tr>
325 -</table>
326 -</li>
327 -
328 -<li class="itemDetail">
329 -<h2 class="itemTitle"><?php _e('CDN Options','autoptimize'); ?></h2>
330 -<table class="form-table">
331 154 <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>
155 +<th scope="row"><?php _e('Image Base URL','autoptimize'); ?></th>
156 +<td><label for="autoptimize_cdn_img_url"><input type="text" name="autoptimize_cdn_img_url" value="<?php $it = get_option('autoptimize_cdn_img_url');echo htmlentities($it?$it:site_url()); ?>" />
157 +<?php _e('This is the new base URL that will be used when rewriting. It should point to the blog root directory.','autoptimize'); ?></label></td>
335 158 </tr>
336 159 </table>
337 -</li>
338 160
339 -<li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
340 -<h2 class="itemTitle"><?php _e('Cache Info','autoptimize'); ?></h2>
341 -<table class="form-table" >
342 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
161 +<h3><?php _e('Cache Info','autoptimize'); ?></h3>
162 +<table class="form-table">
163 +<tr valign="top">
343 164 <th scope="row"><?php _e('Cache folder','autoptimize'); ?></th>
344 165 <td><?php echo htmlentities(AUTOPTIMIZE_CACHE_DIR); ?></td>
345 166 </tr>
346 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
167 +<tr valign="top">
347 168 <th scope="row"><?php _e('Can we write?','autoptimize'); ?></th>
348 169 <td><?php echo (autoptimizeCache::cacheavail() ? __('Yes','autoptimize') : __('No','autoptimize')); ?></td>
349 170 </tr>
350 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
171 +<tr valign="top">
351 172 <th scope="row"><?php _e('Cached styles and scripts','autoptimize'); ?></th>
352 -<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 - }
362 -?></td>
173 +<td><?php echo autoptimizeCache::stats(); ?></td>
363 174 </tr>
175 +<tr valign="top">
176 +<th scope="row"><?php _e('Do not compress cache files','autoptimize'); ?></th>
177 +<td><label for="autoptimize_cache_nogzip"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip')?'checked="checked" ':''; ?>/>
178 +<?php _e('Disabled by default. Enable this if you want to compress the served files using your webserver.','autoptimize'); ?></label></td>
179 +</tr>
364 180 </table>
365 -</li>
366 181
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 - <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 - </tr>
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") ) {
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>
387 - </td>
388 - </tr>
389 - <?php } ?>
390 182 </table>
391 -</li>
392 183
393 -</ul>
394 -
395 -<input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv','0'); ?>">
396 -
397 184 <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') ?>" />
185 +<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
186 +<input type="submit" name="autoptimize_cache_clean" value="<?php _e('Save Changes and Empty Cache') ?>" />
400 187 </p>
401 188
402 189 </form>
403 190 </div>
404 -<div id="autoptimize_admin_feed" class="hidden">
405 - <div class="autoptimize_banner hidden">
406 - <ul>
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 ) );
415 - set_transient('autoptimize_banner', $AO_banner, DAY_IN_SECONDS);
416 - }
417 - }
418 - }
419 - echo $AO_banner;
420 - }
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>
424 - </ul>
425 - </div>
426 - <div style="margin-left:10px;margin-top:-5px;">
427 - <h2>
428 - <?php _e("futtta about","autoptimize") ?>
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>
433 - </select>
434 - </h2>
435 - <div id="futtta_feed">
436 - <div id="autoptimizefeed">
437 - <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_autoptimize"); ?>
438 - </div>
439 - <div id="wordpressfeed">
440 - <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_wordpress"); ?>
441 - </div>
442 - <div id="webtechfeed">
443 - <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_webtech"); ?>
444 - </div>
191 +<div style="float:right;width:30%" id="autoptimize_admin_feed">
192 + <div style="margin-left:10px;margin-top:-5px;">
193 + <h3>
194 + <?php _e("futtta about","autoptimize") ?>
195 + <select id="feed_dropdown" >
196 + <option value="1"><?php _e("Autoptimize","autoptimize") ?></option>
197 + <option value="2"><?php _e("WordPress","autoptimize") ?></option>
198 + <option value="3"><?php _e("Web Technology","autoptimize") ?></option>
199 + </select>
200 + </h3>
201 + <div id="futtta_feed"></div>
445 202 </div>
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>
448 203 </div>
449 204
450 205 <script type="text/javascript">
451 - var feed = new Array;
452 - feed[1]="autoptimizefeed";
453 - feed[2]="wordpressfeed";
454 - feed[3]="webtechfeed";
455 - cookiename="autoptimize_feed";
206 + var feed = new Array;
207 + feed[1]="http://feeds.feedburner.com/futtta_autoptimize";
208 + feed[2]="http://feeds.feedburner.com/futtta_wordpress";
209 + feed[3]="http://feeds.feedburner.com/futtta_webtech";
210 + cookiename="autoptimize_feed";
456 211
457 - jQuery(document).ready(function() {
458 - check_ini_state();
212 + jQuery(document).ready(function() {
213 + jQuery("#feed_dropdown").change(function() { show_feed(jQuery("#feed_dropdown").val()) });
459 214
460 - jQuery('#autoptimize_admin_feed').fadeTo("slow",1).show();
461 - 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();
215 + feedid=jQuery.cookie(cookiename);
216 + if(typeof(feedid) !== "string") feedid=1;
462 217
463 - jQuery( "#feed_dropdown" ).change(function() {
464 - jQuery("#futtta_feed").fadeTo(0,0);
465 - jQuery("#futtta_feed").fadeTo("slow",1);
466 - });
218 + show_feed(feedid);
219 + })
467 220
468 - jQuery( "#ao_show_adv" ).click(function() {
469 - jQuery( "#ao_show_adv" ).hide();
470 - jQuery( "#ao_hide_adv" ).show();
471 - jQuery( ".ao_adv" ).removeClass("hidden");
472 - jQuery( ".ao_adv" ).show("slow");
473 - if (jQuery("#autoptimize_css").attr('checked')) {
474 - jQuery(".css_sub:visible").fadeTo("fast",1);
475 - if (!jQuery("#autoptimize_css_defer").attr('checked')) {
476 - jQuery("#autoptimize_css_defer_inline").hide();
477 - }
478 - }
479 - if (jQuery("#autoptimize_js").attr('checked')) {
480 - jQuery(".js_sub:visible").fadeTo("fast",1);
481 - }
482 - check_ini_state();
483 - jQuery( "input#autoptimize_show_adv" ).val("1");
484 - });
221 + function show_feed(id) {
222 + jQuery('#futtta_feed').rssfeed(feed[id], {
223 + <?php if ( is_ssl() ) echo "ssl: true,"; ?>
224 + limit: 4,
225 + date: true,
226 + header: false
227 + });
228 + jQuery("#feed_dropdown").val(id);
229 + jQuery.cookie(cookiename,id,{ expires: 365 });
230 + }
231 +</script>
485 232
486 - jQuery( "#ao_hide_adv" ).click(function() {
487 - jQuery( "#ao_hide_adv" ).hide();
488 - jQuery( "#ao_show_adv" ).show();
489 - jQuery( ".ao_adv" ).hide("slow");
490 - jQuery( ".ao_adv" ).addClass("hidden");
491 - if (!jQuery("#autoptimize_css").attr('checked')) {
492 - jQuery(".css_sub:visible").fadeTo("fast",.33);
493 - }
494 - if (!jQuery("#autoptimize_js").attr('checked')) {
495 - jQuery(".js_sub:visible").fadeTo("fast",.33);
496 - }
497 - check_ini_state();
498 - jQuery( "input#autoptimize_show_adv" ).val("0");
499 - });
500 -
501 - jQuery( "#autoptimize_html" ).change(function() {
502 - if (this.checked) {
503 - jQuery(".html_sub:visible").fadeTo("fast",1);
504 - } else {
505 - jQuery(".html_sub:visible").fadeTo("fast",.33);
506 - }
507 - });
508 -
509 - jQuery( "#autoptimize_js" ).change(function() {
510 - if (this.checked) {
511 - jQuery(".js_sub:visible").fadeTo("fast",1);
512 - } else {
513 - jQuery(".js_sub:visible").fadeTo("fast",.33);
514 - }
515 - });
516 -
517 - jQuery( "#autoptimize_js_aggregate" ).change(function() {
518 - if (this.checked && jQuery("#autoptimize_js").attr('checked')) {
519 - jQuery(".js_aggregate:visible").fadeTo("fast",1);
520 - } else {
521 - jQuery(".js_aggregate:visible").fadeTo("fast",.33);
522 - }
523 - });
524 -
525 - jQuery( "#autoptimize_css" ).change(function() {
526 - if (this.checked) {
527 - jQuery(".css_sub:visible").fadeTo("fast",1);
528 - } else {
529 - jQuery(".css_sub:visible").fadeTo("fast",.33);
530 - }
531 - });
532 -
533 - jQuery( "#autoptimize_css_aggregate" ).change(function() {
534 - if (this.checked && jQuery("#autoptimize_css").attr('checked')) {
535 - jQuery(".css_aggregate:visible").fadeTo("fast",1);
536 - } else {
537 - jQuery(".css_aggregate:visible").fadeTo("fast",.33);
538 - }
539 - });
540 -
541 - jQuery( "#autoptimize_css_inline" ).change(function() {
542 - if (this.checked) {
543 - jQuery("#autoptimize_css_defer").prop("checked",false);
544 - jQuery("#autoptimize_css_defer_inline").hide("slow");
545 - }
546 - });
547 -
548 - jQuery( "#autoptimize_css_defer" ).change(function() {
549 - if (this.checked) {
550 - jQuery("#autoptimize_css_inline").prop("checked",false);
551 - jQuery("#autoptimize_css_defer_inline").show("slow");
552 - } else {
553 - jQuery("#autoptimize_css_defer_inline").hide("slow");
554 - }
555 - });
556 -
557 - jQuery("#feed_dropdown").change(function() { show_feed(jQuery("#feed_dropdown").val()) });
558 - feedid=jQuery.cookie(cookiename);
559 - if(typeof(feedid) !== "string") feedid=1;
560 - show_feed(feedid);
561 - })
562 -
563 - // validate cdn_url.
564 - var cdn_url=document.getElementById("cdn_url");
565 - cdn_url_baseCSS=cdn_url.style.cssText;
566 - if ("validity" in cdn_url) {
567 - jQuery("#cdn_url").focusout(function (event) {
568 - if (cdn_url.validity.valid) {
569 - cdn_url.style.cssText=cdn_url_baseCSS;
570 - } else {
571 - cdn_url.style.cssText=cdn_url_baseCSS+"border:1px solid #f00;color:#f00;box-shadow: 0 0 2px #f00;";
572 - }});
573 - }
574 -
575 - function check_ini_state() {
576 - if (!jQuery("#autoptimize_css_defer").attr('checked')) {
577 - jQuery("#autoptimize_css_defer_inline").hide();
578 - }
579 - if (!jQuery("#autoptimize_html").attr('checked')) {
580 - jQuery(".html_sub:visible").fadeTo('fast',.33);
581 - }
582 - if (!jQuery("#autoptimize_css").attr('checked')) {
583 - jQuery(".css_sub:visible").fadeTo('fast',.33);
584 - }
585 - if (!jQuery("#autoptimize_css_aggregate").attr('checked')) {
586 - jQuery(".css_aggregate:visible").fadeTo('fast',.33);
587 - }
588 - if (!jQuery("#autoptimize_js").attr('checked')) {
589 - jQuery(".js_sub:visible").fadeTo('fast',.33);
590 - }
591 - if (!jQuery("#autoptimize_js_aggregate").attr('checked')) {
592 - jQuery(".js_aggregate:visible").fadeTo('fast',.33);
593 - }
594 - }
595 -
596 - function show_feed(id) {
597 - jQuery('#futtta_feed').children().hide();
598 - jQuery('#'+feed[id]).show();
599 - jQuery("#feed_dropdown").val(id);
600 - jQuery.cookie(cookiename,id,{ expires: 365 });
601 - }
602 -</script>
603 233 </div>
604 -
605 234 <?php
606 - }
235 + }
236 +
237 + public function addmenu()
238 + {
239 + $hook=add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize','manage_options','autoptimize',array($this,'show'));
240 + add_action( 'admin_print_scripts-'.$hook,array($this,'autoptimize_admin_scripts'));
241 + add_action( 'admin_print_styles-'.$hook,array($this,'autoptimize_admin_styles'));
242 + }
607 243
608 - public function addmenu()
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' ) );
613 - }
244 + public function autoptimize_admin_scripts() {
245 + wp_enqueue_script('jqzrssfeed', plugins_url('/external/jquery.zrssfeed.min.js', __FILE__), array('jquery'),null,true);
246 + wp_enqueue_script('jqcookie', plugins_url('/external/jquery.cookie.min.js', __FILE__), array('jquery'),null,true);
247 + }
614 248
615 - public function autoptimize_admin_scripts()
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 );
619 - }
249 + public function autoptimize_admin_styles() {
250 + wp_enqueue_style('zrssfeed', plugins_url('/external/jquery.zrssfeed.css', __FILE__));
251 + }
620 252
621 - public function autoptimize_admin_styles()
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__ ) );
625 - }
626 -
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' );
652 - }
653 -
654 - public function setmeta($links, $file = null)
655 - {
656 - // Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/.
657 - // Do it only once - saves time.
658 - static $plugin;
659 - if ( empty( $plugin ) ) {
660 - $plugin = plugin_basename( AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php' );
661 - }
662 -
663 - if ( null === $file ) {
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 );
667 - } else {
668 - // 2.8 and higher.
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 );
673 - }
674 - }
675 -
676 - return $links;
677 - }
678 -
679 - /**
680 - * @return array
681 - */
682 - public static function get_defaults()
683 - {
684 - static $config = array(
685 - 'autoptimize_html' => 0,
686 - 'autoptimize_html_keepcomments' => 0,
687 - 'autoptimize_js' => 0,
688 - 'autoptimize_js_aggregate' => 1,
689 - 'autoptimize_js_exclude' => 'seal.js, js/jquery/jquery.js',
690 - 'autoptimize_js_trycatch' => 0,
691 - 'autoptimize_js_justhead' => 0,
692 - 'autoptimize_js_include_inline' => 0,
693 - 'autoptimize_js_forcehead' => 0,
694 - 'autoptimize_css' => 0,
695 - 'autoptimize_css_aggregate' => 1,
696 - 'autoptimize_css_exclude' => 'admin-bar.min.css, dashicons.min.css, wp-content/cache/, wp-content/uploads/',
697 - 'autoptimize_css_justhead' => 0,
698 - 'autoptimize_css_include_inline' => 1,
699 - 'autoptimize_css_defer' => 0,
700 - 'autoptimize_css_defer_inline' => '',
701 - 'autoptimize_css_inline' => 0,
702 - 'autoptimize_css_datauris' => 0,
703 - 'autoptimize_cdn_url' => '',
704 - 'autoptimize_cache_nogzip' => 1,
705 - 'autoptimize_show_adv' => 0,
706 - 'autoptimize_optimize_logged' => 1,
707 - 'autoptimize_optimize_checkout' => 1
708 - );
709 -
710 - return $config;
711 - }
712 -
713 - /**
714 - * Returns default option values for autoptimizeExtra.
715 - *
716 - * @return array
717 - */
718 - public static function get_ao_extra_default_options()
719 - {
720 - $defaults = array(
721 - 'autoptimize_extra_checkbox_field_1' => '0',
722 - 'autoptimize_extra_checkbox_field_0' => '0',
723 - 'autoptimize_extra_radio_field_4' => '1',
724 - 'autoptimize_extra_text_field_2' => '',
725 - 'autoptimize_extra_text_field_3' => '',
726 - 'autoptimize_extra_checkbox_field_5' => '0',
727 - 'autoptimize_extra_select_field_6' => '2',
728 - );
729 -
730 - return $defaults;
731 - }
732 -
733 - /**
734 - * Returns preload polyfill JS.
735 - *
736 - * @return string
737 - */
738 - public static function get_ao_css_preload_polyfill()
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>');
741 - return $preload_poly;
742 - }
743 -
744 - /**
745 - * Returns preload JS onload handler.
746 - *
747 - * @return string
748 - */
749 - public static function get_ao_css_preload_onload()
750 - {
751 - $preload_onload = apply_filters('autoptimize_filter_css_preload_onload',"this.onload=null;this.rel='stylesheet'");
752 - return $preload_onload;
753 - }
754 -
755 - public function get($key)
756 - {
757 - if ( ! is_array( $this->config ) ) {
758 - // Default config.
759 - $config = self::get_defaults();
760 -
761 - // Override with user settings.
762 - foreach ( array_keys( $config ) as $name ) {
763 - $conf = get_option( $name );
764 - if ( false !== $conf ) {
765 - // It was set before!
766 - $config[ $name ] = $conf;
767 - }
768 - }
769 -
770 - // Save for next call.
771 - $this->config = apply_filters( 'autoptimize_filter_get_config', $config );
772 - }
773 -
774 - if ( isset( $this->config[ $key ] ) ) {
775 - return $this->config[ $key ];
776 - }
777 -
778 - return false;
779 - }
780 -
781 - private function getFutttaFeeds($url) {
782 - if ( $this->settings_screen_do_remote_http ) {
783 - $rss = fetch_feed( $url );
784 - $maxitems = 0;
785 -
786 - if ( ! is_wp_error( $rss ) ) {
787 - $maxitems = $rss->get_item_quantity( 7 );
788 - $rss_items = $rss->get_items( 0, $maxitems );
789 - }
790 - ?>
791 - <ul>
792 - <?php if ( $maxitems == 0 ) : ?>
793 - <li><?php _e( 'No items', 'autoptimize' ); ?></li>
794 - <?php else : ?>
795 - <?php foreach ( $rss_items as $item ) : ?>
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() ); ?>
800 - </a>
801 - </li>
802 - <?php endforeach; ?>
803 - <?php endif; ?>
804 - </ul>
805 - <?php
806 - }
807 - }
808 -
809 - // based on http://wordpress.stackexchange.com/a/58826
810 - static function ao_admin_tabs()
811 - {
812 - $tabs = apply_filters( 'autoptimize_filter_settingsscreen_tabs' ,array( 'autoptimize' => __( 'Main', 'autoptimize' ) ) );
813 - $tabContent = '';
814 - $tabs_count = count($tabs);
815 - if ( $tabs_count > 1 ) {
816 - if ( isset( $_GET['page'] ) ) {
817 - $currentId = $_GET['page'];
818 - } else {
819 - $currentId = "autoptimize";
820 - }
821 - $tabContent .= '<h2 class="nav-tab-wrapper">';
822 - foreach ($tabs as $tabId => $tabName) {
823 - if ( $currentId == $tabId ) {
824 - $class = ' nav-tab-active';
825 - } else{
826 - $class = '';
827 - }
828 - $tabContent .= '<a class="nav-tab' . $class . '" href="?page=' . $tabId . '">' . $tabName . '</a>';
829 - }
830 - $tabContent .= '</h2>';
831 - } else {
832 - $tabContent = '<hr/>';
833 - }
834 -
835 - return $tabContent;
836 - }
837 -
838 - /**
839 - * Returns true if in admin (and not in admin-ajax.php!)
840 - *
841 - * @return bool
842 - */
843 - public static function is_admin_and_not_ajax()
844 - {
845 - return ( is_admin() && ! self::doing_ajax() );
846 - }
847 -
848 - /**
849 - * Returns true if doing ajax.
850 - *
851 - * @return type
852 - */
853 - protected static function doing_ajax()
854 - {
855 - if ( function_exists( 'wp_doing_ajax' ) ) {
856 - return wp_doing_ajax();
857 - } else {
858 - return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
859 - }
860 - }
253 +
254 + public function registersettings()
255 + {
256 + register_setting('autoptimize','autoptimize_html');
257 + register_setting('autoptimize','autoptimize_html_keepcomments');
258 + register_setting('autoptimize','autoptimize_js');
259 + register_setting('autoptimize','autoptimize_js_exclude');
260 + register_setting('autoptimize','autoptimize_js_trycatch');
261 + register_setting('autoptimize','autoptimize_js_justhead');
262 + register_setting('autoptimize','autoptimize_js_forcehead');
263 + register_setting('autoptimize','autoptimize_js_yui');
264 + register_setting('autoptimize','autoptimize_css');
265 + register_setting('autoptimize','autoptimize_css_justhead');
266 + register_setting('autoptimize','autoptimize_css_datauris');
267 + register_setting('autoptimize','autoptimize_css_yui');
268 + register_setting('autoptimize','autoptimize_cdn_js');
269 + register_setting('autoptimize','autoptimize_cdn_js_url');
270 + register_setting('autoptimize','autoptimize_cdn_css');
271 + register_setting('autoptimize','autoptimize_cdn_css_url');
272 + register_setting('autoptimize','autoptimize_cdn_img');
273 + register_setting('autoptimize','autoptimize_cdn_img_url');
274 + register_setting('autoptimize','autoptimize_cache_clean');
275 + register_setting('autoptimize','autoptimize_cache_nogzip');
276 + }
277 +
278 + public function setmeta($links,$file=null)
279 + {
280 + //Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/
281 +
282 + //Do it only once - saves time
283 + static $plugin;
284 + if(empty($plugin))
285 + $plugin = plugin_basename(WP_PLUGIN_DIR.'/autoptimize/autoptimize.php');
286 +
287 + if($file===null)
288 + {
289 + //2.7
290 + $settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'));
291 + array_unshift($links,$settings_link);
292 + }else{
293 + //2.8
294 + //If it's us, add the link
295 + if($file === $plugin)
296 + {
297 + $newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>',__('Settings')));
298 + $links = array_merge($links,$newlink);
299 + }
300 + }
301 +
302 + return $links;
303 + }
304 +
305 + public function get($key)
306 + {
307 + if(!is_array($this->config))
308 + {
309 + //Default config
310 + $config = array('autoptimize_html' => 0,
311 + 'autoptimize_html_keepcomments' => 0,
312 + 'autoptimize_js' => 0,
313 + 'autoptimize_js_exclude' => "s_sid, smowtion_size, sc_project, WAU_, wau_add, comment-form-quicktags, edToolbar, ch_client",
314 + 'autoptimize_js_trycatch' => 0,
315 + 'autoptimize_js_justhead' => 0,
316 + 'autoptimize_js_forcehead' => 0,
317 + 'autoptimize_js_yui' => 0,
318 + 'autoptimize_css' => 0,
319 + 'autoptimize_css_justhead' => 0,
320 + 'autoptimize_css_datauris' => 0,
321 + 'autoptimize_css_yui' => 0,
322 + 'autoptimize_cdn_js' => 0,
323 + 'autoptimize_cdn_js_url' => site_url(),
324 + 'autoptimize_cdn_css' => 0,
325 + 'autoptimize_cdn_css_url' => site_url(),
326 + 'autoptimize_cdn_img' => 0,
327 + 'autoptimize_cdn_img_url' => site_url(),
328 + 'autoptimize_cache_nogzip' => 0,
329 + );
330 +
331 + //Override with user settings
332 + foreach(array_keys($config) as $name)
333 + {
334 + $conf = get_option($name);
335 + if($conf!==false)
336 + {
337 + //It was set before!
338 + $config[$name] = $conf;
339 + }
340 + }
341 +
342 + //Save for next question
343 + $this->config = $config;
344 + }
345 +
346 + if(isset($this->config[$key]))
347 + return $this->config[$key];
348 +
349 + return false;
350 + }
861 351 }