PluginProbe
Autoptimize / 1.8.2
Autoptimize v1.8.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 +276 -621 2.3.01.8.2 View file →
@@ -1,362 +1,183 @@
1 1 <?php
2 2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 3
4 -class autoptimizeConfig {
5 - private $config = null;
6 - static private $instance = null;
4 +class autoptimizeConfig
5 +{
6 + private $config = null;
7 + static private $instance = null;
8 +
9 + //Singleton: private construct
10 + private function __construct()
11 + {
12 + if( is_admin() )
13 + {
14 + //Add the admin page and settings
15 + add_action('admin_menu',array($this,'addmenu'));
16 + add_action('admin_init',array($this,'registersettings'));
7 17
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'));
18 + //Set meta info
19 + if(function_exists('plugin_row_meta'))
20 + {
21 + //2.8+
22 + add_filter('plugin_row_meta',array($this,'setmeta'),10,2);
23 + } elseif(function_exists('post_class')) {
24 + //2.7
25 + $plugin = plugin_basename(WP_PLUGIN_DIR.'/autoptimize/autoptimize.php');
26 + add_filter('plugin_action_links_'.$plugin,array($this,'setmeta'));
27 + }
14 28
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'));
23 - }
24 -
25 - //Clean cache?
26 - if(get_option('autoptimize_cache_clean')) {
27 - autoptimizeCache::clearall();
28 - update_option('autoptimize_cache_clean',0);
29 - }
30 - }
31 -
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)
34 - $toolbar = new autoptimizeToolbar();
29 + //Clean cache?
30 + if(get_option('autoptimize_cache_clean'))
31 + {
32 + autoptimizeCache::clearall();
33 + update_option('autoptimize_cache_clean',0);
34 + }
35 + }
36 + }
37 +
38 + static public function instance()
39 + {
40 + //Only one instance
41 + if (self::$instance == null)
42 + {
43 + self::$instance = new autoptimizeConfig();
44 + }
45 +
46 + return self::$instance;
35 47 }
36 -
37 - static public function instance() {
38 - //Only one instance
39 - if (self::$instance == null) {
40 - self::$instance = new autoptimizeConfig();
41 - }
42 -
43 - return self::$instance;
44 - }
45 -
46 - public function show() {
48 +
49 + public function show()
50 + {
47 51 ?>
48 -<style>
49 -/* title and button */
50 -#ao_title_and_button:after {content:''; display:block; clear:both;}
51 -#ao_adv_button{float:right;}
52 -#ao_hide_adv:before, #ao_show_adv:before {
53 - display: inline-block;
54 - float: left;
55 - height: 20px;
56 - width: 35px;
57 - background: none;
58 - color: #b4b9be;
59 - font: normal 20px/26px dashicons;
60 - letter-spacing: -4px;
61 - text-align: left;
62 - speak: none;
63 - -webkit-font-smoothing: antialiased;
64 - -moz-osx-font-smoothing: grayscale;
65 -}
66 -#ao_hide_adv:before {
67 - content: "\f108 \f142";
68 -}
69 -#ao_show_adv:before {
70 - content: "\f108 \f140";
71 -}
52 +<style>input[type=url]:invalid {color: red; border-color:red;} .form-table th{font-weight:100;}</style>
72 53
73 -/* animate "show adv" button */
74 -#ao_show_adv { animation: watchmenow 3s linear 5s 10; }
75 -#ao_show_adv:hover { animation: none; }
76 -@keyframes watchmenow {
77 - 0% { box-shadow: unset; }
78 - 100% { box-shadow: 0px 0px 20px yellow; }
79 -}
54 +<div class="wrap">
80 55
81 -/* form */
82 -.itemDetail {
83 - background: #fff;
84 - border: 1px solid #ccc;
85 - padding: 15px;
86 - margin: 15px 10px 10px 0;
87 -}
88 -.itemTitle {
89 - margin-top: 0;
90 -}
91 -input[type=url]:invalid {color: red; border-color:red;} .form-table th{font-weight:100;}
92 -#autoptimize_main .cb_label {display: block; padding-left: 25px; text-indent: -25px;}
56 +<h2><?php _e('Autoptimize Settings','autoptimize'); ?></h2>
93 57
94 -/* rss block */
95 -#futtta_feed ul{list-style:outside;}
96 -#futtta_feed {font-size:medium; margin:0px 20px;}
97 -
98 -/* banner + unslider */
99 -.autoptimize_banner {
100 - margin: 0 38px;
101 - padding-bottom: 5px;
58 +<div style="float:left;width:70%;">
59 +<?php
60 +if (get_option('autoptimize_show_adv','0')=='1') {
61 + ?>
62 + <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><?php _e("Show advanced settings","autoptimize") ?></a>
63 + <a href="javascript:void(0);" id="ao_hide_adv" class="button"><?php _e("Hide advanced settings","autoptimize") ?></a>
64 + <style>.ao_adv {display:table-row};</style>
65 + <?php
66 +} else {
67 + ?>
68 + <a href="javascript:void(0);" id="ao_show_adv" class="button"><?php _e("Show advanced settings","autoptimize") ?></a>
69 + <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><?php _e("Hide advanced settings","autoptimize") ?></a>
70 + <?php
102 71 }
103 -.autoptimize_banner ul li {
104 - font-size:medium;
105 - text-align:center;
106 -}
107 -.unslider {
108 - position:relative;
109 -}
110 -.unslider-arrow {
111 - display: block;
112 - left: unset;
113 - margin-top: -35px;
114 - margin-left: 7px;
115 - margin-right: 7px;
116 - border-radius: 32px;
117 - background: rgba(0, 0, 0, 0.10) no-repeat 50% 50%;
118 - color: rgba(255, 255, 255, 0.8);
119 - font: normal 20px/1 dashicons;
120 - speak: none;
121 - padding: 3px 2px 3px 4px;
122 - -webkit-font-smoothing: antialiased;
123 - -moz-osx-font-smoothing: grayscale;
124 -}
125 -.unslider-arrow:hover {
126 - background-color: rgba(0, 0, 0, 0.20);
127 - color: #FFF;
128 -}
129 -.unslider-arrow.prev {
130 - padding: 3px 4px 3px 2px;
131 -}
132 -.unslider-arrow.next {
133 - right: 0px;
134 -}
135 -.unslider-arrow.prev::before {
136 - content: "\f341";
137 -}
138 -.unslider-arrow.next::before {
139 - content: "\f345";
140 -}
141 -/* responsive stuff: hide admin-feed on smaller screens */
142 -@media (min-width: 961px) {
143 - #autoptimize_main {float:left;width:69%;}
144 - #autoptimize_admin_feed{float:right;width:30%;display:block !important;}
145 - }
146 -@media (max-width: 960px) {
147 - #autoptimize_main {width:100%;}
148 - #autoptimize_admin_feed {width:0%;display:none !important;}
149 -}
150 -@media (max-width: 782px) {
151 - #ao_hide_adv span, #ao_show_adv span {display: none;}
152 - #ao_hide_adv,#ao_show_adv {height: 34px;padding: 4px 12px 8px 8px;}
153 - #ao_hide_adv:before,#ao_show_adv:before {font-size: 25px;}
154 - #autoptimize_main input[type="checkbox"] {margin-left: 10px;}
155 - #autoptimize_main .cb_label {display: block; padding-left: 45px; text-indent: -45px;}
156 -}
157 -</style>
72 +?>
158 73
159 -<div class="wrap">
160 -
161 -<?php if (version_compare(PHP_VERSION, '5.3.0') < 0) { ?>
162 -<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>
163 -<?php } ?>
164 -
165 -<div id="autoptimize_main">
166 -<div id="ao_title_and_button">
167 - <h1 id="ao_title"><?php _e('Autoptimize Settings','autoptimize'); ?>
168 - <span id="ao_adv_button">
169 - <?php
170 - if (get_option('autoptimize_show_adv','0')=='1') {
171 - ?>
172 - <a href="javascript:void(0);" id="ao_show_adv" class="button" style="display:none;"><span><?php _e("Show advanced settings","autoptimize") ?></span></a>
173 - <a href="javascript:void(0);" id="ao_hide_adv" class="button"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a>
174 - <style>tr.ao_adv{display:table-row;} li.ao_adv{display:list-item;}</style>
175 - <?php
176 - $hiddenClass="";
177 - } else {
178 - ?>
179 - <a href="javascript:void(0);" id="ao_show_adv" class="button"><span><?php _e("Show advanced settings","autoptimize") ?></span></a>
180 - <a href="javascript:void(0);" id="ao_hide_adv" class="button" style="display:none;"><span><?php _e("Hide advanced settings","autoptimize") ?></span></a>
181 - <?php
182 - $hiddenClass="hidden ";
183 - }
184 - ?>
185 - </span>
186 - </h1>
187 -</div>
188 -
189 -<?php echo $this->ao_admin_tabs(); ?>
190 -
191 74 <form method="post" action="options.php">
192 75 <?php settings_fields('autoptimize'); ?>
193 76
194 -<ul>
195 -
196 -<li class="itemDetail">
197 -<h2 class="itemTitle"><?php _e('HTML Options','autoptimize'); ?></h2>
77 +<h3><?php _e('HTML Options','autoptimize'); ?></h3>
198 78 <table class="form-table">
199 79 <tr valign="top">
200 80 <th scope="row"><?php _e('Optimize HTML Code?','autoptimize'); ?></th>
201 -<td><input type="checkbox" id="autoptimize_html" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
81 +<td><input type="checkbox" name="autoptimize_html" <?php echo get_option('autoptimize_html')?'checked="checked" ':''; ?>/></td>
202 82 </tr>
203 -<tr class="<?php echo $hiddenClass;?>html_sub ao_adv" valign="top">
83 +<tr valign="top">
204 84 <th scope="row"><?php _e('Keep HTML comments?','autoptimize'); ?></th>
205 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/>
206 -<?php _e('Enable this if you want HTML comments to remain in the page.','autoptimize'); ?></label></td>
85 +<td><label for="autoptimize_html_keepcomments"><input type="checkbox" name="autoptimize_html_keepcomments" <?php echo get_option('autoptimize_html_keepcomments')?'checked="checked" ':''; ?>/>
86 +<?php _e('Enable this if you want HTML comments to remain in the page, needed for e.g. AdSense to function properly.','autoptimize'); ?></label></td>
207 87 </tr>
208 88 </table>
209 -</li>
210 89
211 -<li class="itemDetail">
212 -<h2 class="itemTitle"><?php _e('JavaScript Options','autoptimize'); ?></h2>
90 +<h3><?php _e('JavaScript Options','autoptimize'); ?></h3>
213 91 <table class="form-table">
214 92 <tr valign="top">
215 93 <th scope="row"><?php _e('Optimize JavaScript Code?','autoptimize'); ?></th>
216 -<td><input type="checkbox" id="autoptimize_js" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
94 +<td><input type="checkbox" name="autoptimize_js" <?php echo get_option('autoptimize_js')?'checked="checked" ':''; ?>/></td>
217 95 </tr>
218 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
96 +<tr valign="top" class="hidden ao_adv">
219 97 <th scope="row"><?php _e('Force JavaScript in &lt;head&gt;?','autoptimize'); ?></th>
220 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead')?'checked="checked" ':''; ?>/>
221 -<?php _e('Load JavaScript early, this can potentially fix some JS-errors, but makes the JS render blocking.','autoptimize'); ?></label></td>
98 +<td><label for="autoptimize_js_forcehead"><input type="checkbox" name="autoptimize_js_forcehead" <?php echo get_option('autoptimize_js_forcehead')?'checked="checked" ':''; ?>/>
99 +<?php _e('For performance reasons it is better to include JavaScript at the bottom of HTML, but this sometimes breaks things. Especially useful for jQuery-based themes.','autoptimize'); ?></label></td>
222 100 </tr>
223 -<?php if (get_option('autoptimize_js_justhead')) { ?>
224 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
225 -<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th>
226 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
227 -<?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>
101 +<tr valign="top" class="hidden ao_adv">
102 +<th scope="row"><?php _e('Look for scripts only in &lt;head&gt;?','autoptimize'); ?></th>
103 +<td><label for="autoptimize_js_justhead"><input type="checkbox" name="autoptimize_js_justhead" <?php echo get_option('autoptimize_js_justhead')?'checked="checked" ':''; ?>/>
104 +<?php _e('Mostly usefull in combination with previous option when using jQuery-based templates, but might help keeping cache size under control.','autoptimize'); ?></label></td>
228 105 </tr>
229 -<?php } ?>
230 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
231 -<th scope="row"><?php _e('Also aggregate inline JS?','autoptimize'); ?></th>
232 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_include_inline" <?php echo get_option('autoptimize_js_include_inline')?'checked="checked" ':''; ?>/>
233 -<?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>
234 -</tr>
235 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
106 +<tr valign="top" class="hidden ao_adv">
236 107 <th scope="row"><?php _e('Exclude scripts from Autoptimize:','autoptimize'); ?></th>
237 -<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 />
238 -<?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>
108 +<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 />
109 +<?php _e('A comma-seperated 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>
239 110 </tr>
240 -<tr valign="top" class="<?php echo $hiddenClass;?>js_sub ao_adv">
111 +<tr valign="top" class="hidden ao_adv">
241 112 <th scope="row"><?php _e('Add try-catch wrapping?','autoptimize'); ?></th>
242 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch')?'checked="checked" ':''; ?>/>
243 -<?php _e('If your scripts break because of a JS-error, you might want to try this.','autoptimize'); ?></label></td>
113 +<td><label for="autoptimize_js_trycatch"><input type="checkbox" name="autoptimize_js_trycatch" <?php echo get_option('autoptimize_js_trycatch')?'checked="checked" ':''; ?>/>
114 +<?php _e('If your scripts break because of an script error, you might want to try this.','autoptimize'); ?></label></td>
244 115 </tr>
245 116 </table>
246 -</li>
247 117
248 -<li class="itemDetail">
249 -<h2 class="itemTitle"><?php _e('CSS Options','autoptimize'); ?></h2>
118 +<h3><?php _e('CSS Options','autoptimize'); ?></h3>
250 119 <table class="form-table">
251 120 <tr valign="top">
252 121 <th scope="row"><?php _e('Optimize CSS Code?','autoptimize'); ?></th>
253 -<td><input type="checkbox" id="autoptimize_css" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
122 +<td><input type="checkbox" name="autoptimize_css" <?php echo get_option('autoptimize_css')?'checked="checked" ':''; ?>/></td>
254 123 </tr>
255 -<tr class="<?php echo $hiddenClass;?>css_sub ao_adv" valign="top">
124 +<tr valign="top">
256 125 <th scope="row"><?php _e('Generate data: URIs for images?','autoptimize'); ?></th>
257 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris')?'checked="checked" ':''; ?>/>
258 -<?php _e('Enable this to include small background-images in the CSS itself instead of as separate downloads.','autoptimize'); ?></label></td>
126 +<td><label for="autoptimize_css_datauris"><input type="checkbox" name="autoptimize_css_datauris" <?php echo get_option('autoptimize_css_datauris')?'checked="checked" ':''; ?>/>
127 +<?php _e('Enable this to include small background-images in the CSS itself instead of as seperate downloads.','autoptimize'); ?></label></td>
259 128 </tr>
260 -<?php if (get_option('autoptimize_css_justhead')) { ?>
261 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
262 -<th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); echo ' <i>'. __('(deprecated)','autoptimize') . '</i>'; ?></th>
263 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
129 +<tr valign="top" class="hidden ao_adv">
130 +<th scope="row"><?php _e('Look for styles only in &lt;head&gt;?','autoptimize'); ?></th>
131 +<td><label for="autoptimize_css_justhead"><input type="checkbox" name="autoptimize_css_justhead" <?php echo get_option('autoptimize_css_justhead')?'checked="checked" ':''; ?>/>
264 132 <?php _e('Don\'t autoptimize CSS outside the head-section. If the cache gets big, you might want to enable this.','autoptimize'); ?></label></td>
265 133 </tr>
266 -<?php } ?>
267 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
268 -<th scope="row"><?php _e('Also aggregate inline CSS?','autoptimize'); ?></th>
269 -<td><label class="cb_label"><input type="checkbox" name="autoptimize_css_include_inline" <?php echo get_option('autoptimize_css_include_inline','1')?'checked="checked" ':''; ?>/>
270 -<?php _e('Check this option for Autoptimize to also aggregate CSS in the HTML.','autoptimize'); ?></label></td>
134 +<tr valign="top" class="hidden ao_adv">
135 +<th scope="row"><?php _e('Defer CSS loading?','autoptimize'); ?></th>
136 +<td><label for="autoptimize_css_defer"><input type="checkbox" name="autoptimize_css_defer" id="autoptimize_css_defer" <?php echo get_option('autoptimize_css_defer')?'checked="checked" ':''; ?>/>
137 +<?php _e('Load optimized CSS only after page load (disables CSS inlining). <strong>Warning</strong>: <a href="http://wordpress.org/plugins/autoptimize/faq/" target="_blank">check the FAQ</a> before activating this option!','autoptimize'); ?></label></td>
271 138 </tr>
272 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv">
273 -<th scope="row"><?php _e('Inline and Defer CSS?','autoptimize'); ?></th>
274 -<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" ':''; ?>/>
275 -<?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>
276 -</tr>
277 -<tr valign="top" class="<?php echo $hiddenClass;?>css_sub ao_adv" id="autoptimize_css_defer_inline">
278 -<th scope="row"></th>
279 -<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>
280 -</tr>
281 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub">
139 +<tr valign="top" class="hidden ao_adv">
282 140 <th scope="row"><?php _e('Inline all CSS?','autoptimize'); ?></th>
283 -<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" ':''; ?>/>
284 -<?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>
141 +<td><label for="autoptimize_css_inline"><input type="checkbox" id="autoptimize_css_inline" name="autoptimize_css_inline" <?php echo get_option('autoptimize_css_inline')?'checked="checked" ':''; ?>/>
142 +<?php _e('Inlining all CSS can improve performance for sites with a low pageviews/ visitor-rate, but may slow down performance otherwise. CSS inlining disables CSS deferring.','autoptimize'); ?></label></td>
285 143 </tr>
286 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv css_sub">
144 +<tr valign="top" class="hidden ao_adv">
287 145 <th scope="row"><?php _e('Exclude CSS from Autoptimize:','autoptimize'); ?></th>
288 -<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 />
289 -<?php _e('A comma-separated list of CSS you want to exclude from being optimized.','autoptimize'); ?></label></td>
146 +<td><label for="autoptimize_css_exclude"><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 />
147 +<?php _e('A comma-seperated list of CSS you want to exclude from being optimized.','autoptimize'); ?></label></td>
290 148 </tr>
291 149 </table>
292 -</li>
293 150
294 -<li class="itemDetail">
295 -<h2 class="itemTitle"><?php _e('CDN Options','autoptimize'); ?></h2>
151 +<h3><?php _e('CDN Options','autoptimize'); ?></h3>
296 152 <table class="form-table">
297 153 <tr valign="top">
298 154 <th scope="row"><?php _e('CDN Base URL','autoptimize'); ?></th>
299 -<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 />
300 -<?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 +<td><label for="autoptimize_url"><input id="cdn_url" type="url" name="autoptimize_cdn_url" pattern="^(https?:)?\/\/([\da-z\.-]+)\.([\da-z\.]{2,6})([\/\w \.-]*)*\/?$" style="width:100%" value="<?php $it = get_option('autoptimize_cdn_url','');echo htmlentities($it); ?>" /><br />
156 +<?php _e('Enter your CDN blog root directory URL if you want to enable CDN for images referenced in the CSS.','autoptimize'); ?></label></td>
301 157 </tr>
302 158 </table>
303 -</li>
304 159
305 -<li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
306 -<h2 class="itemTitle"><?php _e('Cache Info','autoptimize'); ?></h2>
160 +<h3 class="hidden ao_adv"><?php _e('Cache Info','autoptimize'); ?></h3>
307 161 <table class="form-table" >
308 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
162 +<tr valign="top" class="hidden ao_adv">
309 163 <th scope="row"><?php _e('Cache folder','autoptimize'); ?></th>
310 164 <td><?php echo htmlentities(AUTOPTIMIZE_CACHE_DIR); ?></td>
311 165 </tr>
312 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
166 +<tr valign="top" class="hidden ao_adv">
313 167 <th scope="row"><?php _e('Can we write?','autoptimize'); ?></th>
314 168 <td><?php echo (autoptimizeCache::cacheavail() ? __('Yes','autoptimize') : __('No','autoptimize')); ?></td>
315 169 </tr>
316 -<tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
170 +<tr valign="top" class="hidden ao_adv">
317 171 <th scope="row"><?php _e('Cached styles and scripts','autoptimize'); ?></th>
318 -<td><?php
319 - $AOstatArr=autoptimizeCache::stats();
320 - $AOcacheSize=round($AOstatArr[1]/1024);
321 - printf( __( '%1$s files, totalling %2$s Kbytes (calculated at %3$s)', 'autoptimize'), $AOstatArr[0], $AOcacheSize, date("H:i e", $AOstatArr[2]) );
322 -?></td>
172 +<td><?php echo autoptimizeCache::stats(); ?></td>
323 173 </tr>
174 +<tr valign="top" class="hidden ao_adv">
175 +<th scope="row"><?php _e('Save aggregated script/css as static files?','autoptimize'); ?></th>
176 +<td><label for="autoptimize_cache_nogzip"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip','1')?'checked="checked" ':''; ?>/>
177 +<?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>
178 +</tr>
324 179 </table>
325 -</li>
326 -
327 -<li class="<?php echo $hiddenClass;?>itemDetail ao_adv">
328 -<h2 class="itemTitle"><?php _e('Misc Options','autoptimize'); ?></h2>
329 -<table class="form-table">
330 - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
331 - <th scope="row"><?php _e('Save aggregated script/css as static files?','autoptimize'); ?></th>
332 - <td><label class="cb_label"><input type="checkbox" name="autoptimize_cache_nogzip" <?php echo get_option('autoptimize_cache_nogzip','1')?'checked="checked" ':''; ?>/>
333 - <?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>
334 - </td>
335 - </tr>
336 - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
337 - <th scope="row"><?php _e('Also optimize for logged in users?','autoptimize'); ?></th>
338 - <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_logged" <?php echo get_option('autoptimize_optimize_logged','1')?'checked="checked" ':''; ?>/>
339 - <?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>
340 - </td>
341 - </tr>
342 - <?php
343 - if ( function_exists("is_checkout") || function_exists("is_cart") || function_exists("edd_is_checkout") || function_exists("wpsc_is_cart") || function_exists("wpsc_is_checkout") ) {
344 - ?>
345 - <tr valign="top" class="<?php echo $hiddenClass;?>ao_adv">
346 - <th scope="row"><?php _e('Also optimize shop cart/ checkout?','autoptimize'); ?></th>
347 - <td><label class="cb_label"><input type="checkbox" name="autoptimize_optimize_checkout" <?php echo get_option('autoptimize_optimize_checkout','1')?'checked="checked" ':''; ?>/>
348 - <?php _e('By default Autoptimize is also active on your shop\'s cart/ checkout, uncheck not to optimize those.','autoptimize'); ?></label>
349 - </td>
350 - </tr>
351 - <?php
352 - }
353 - ?>
354 -</table>
355 -</li>
356 -
357 -</ul>
358 -
359 180 <input type="hidden" id="autoptimize_show_adv" name="autoptimize_show_adv" value="<?php echo get_option('autoptimize_show_adv','0'); ?>">
360 181
361 182 <p class="submit">
362 183 <input type="submit" class="button-secondary" value="<?php _e('Save Changes','autoptimize') ?>" />
@@ -364,349 +185,183 @@
364 185 </p>
365 186
366 187 </form>
367 188 </div>
368 -<div id="autoptimize_admin_feed" class="hidden">
369 - <div class="autoptimize_banner hidden">
370 - <ul>
371 - <?php
372 - if (apply_filters('autoptimize_settingsscreen_remotehttp',true)) {
373 - $AO_banner=get_transient("autoptimize_banner");
374 - if (empty($AO_banner)) {
375 - $banner_resp = wp_remote_get("http://misc.optimizingmatters.com/autoptimize_news.html");
376 - if (!is_wp_error($banner_resp)) {
377 - if (wp_remote_retrieve_response_code($banner_resp)=="200") {
378 - $AO_banner = wp_kses_post(wp_remote_retrieve_body($banner_resp));
379 - set_transient("autoptimize_banner",$AO_banner,DAY_IN_SECONDS);
380 - }
381 - }
382 - }
383 - echo $AO_banner;
384 - }
385 - ?>
386 - <li><?php _e("Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.","autoptimize"); ?></li>
387 - <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>
388 - </ul>
389 - </div>
390 - <div style="margin-left:10px;margin-top:-5px;">
391 - <h2>
392 - <?php _e("futtta about","autoptimize") ?>
393 - <select id="feed_dropdown" >
394 - <option value="1"><?php _e("Autoptimize","autoptimize") ?></option>
395 - <option value="2"><?php _e("WordPress","autoptimize") ?></option>
396 - <option value="3"><?php _e("Web Technology","autoptimize") ?></option>
397 - </select>
398 - </h2>
399 - <div id="futtta_feed">
400 - <div id="autoptimizefeed">
401 - <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_autoptimize"); ?>
402 - </div>
403 - <div id="wordpressfeed">
404 - <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_wordpress"); ?>
405 - </div>
406 - <div id="webtechfeed">
407 - <?php $this->getFutttaFeeds("http://feeds.feedburner.com/futtta_webtech"); ?>
408 - </div>
189 +<div style="float:right;width:30%" id="autoptimize_admin_feed">
190 + <div style="margin-left:10px;margin-top:-5px;">
191 + <h3>
192 + <?php _e("futtta about","autoptimize") ?>
193 + <select id="feed_dropdown" >
194 + <option value="1"><?php _e("Autoptimize","autoptimize") ?></option>
195 + <option value="2"><?php _e("WordPress","autoptimize") ?></option>
196 + <option value="3"><?php _e("Web Technology","autoptimize") ?></option>
197 + </select>
198 + </h3>
199 + <div id="futtta_feed"></div>
409 200 </div>
410 - </div>
411 - <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>
201 + <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 content_url(); ?>/plugins/autoptimize/classes/external/do_not_donate_smallest.png" title="<?php _e("Do not donate for this plugin!"); ?>"></a></div>
412 202 </div>
413 203
414 204 <script type="text/javascript">
415 - var feed = new Array;
416 - feed[1]="autoptimizefeed";
417 - feed[2]="wordpressfeed";
418 - feed[3]="webtechfeed";
419 - cookiename="autoptimize_feed";
205 + var feed = new Array;
206 + feed[1]="http://feeds.feedburner.com/futtta_autoptimize";
207 + feed[2]="http://feeds.feedburner.com/futtta_wordpress";
208 + feed[3]="http://feeds.feedburner.com/futtta_webtech";
209 + cookiename="autoptimize_feed";
420 210
421 - jQuery(document).ready(function() {
422 - check_ini_state();
423 - jQuery('#autoptimize_admin_feed').fadeTo("slow",1).show();
424 - 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();
211 + jQuery(document).ready(function() {
212 + jQuery( "#ao_show_adv" ).click(function() {
213 + jQuery( "#ao_show_adv" ).hide();
214 + jQuery( "#ao_hide_adv" ).show();
215 + jQuery( ".ao_adv" ).show("slow");
216 + jQuery( "input#autoptimize_show_adv" ).val("1");
217 + });
425 218
426 - jQuery( "#feed_dropdown" ).change(function() {
427 - jQuery("#futtta_feed").fadeTo(0,0);
428 - jQuery("#futtta_feed").fadeTo("slow",1);
429 - });
219 + jQuery( "#ao_hide_adv" ).click(function() {
220 + jQuery( "#ao_hide_adv" ).hide();
221 + jQuery( "#ao_show_adv" ).show();
222 + jQuery( ".ao_adv" ).hide("slow");
223 + jQuery( "input#autoptimize_show_adv" ).val("0");
224 + });
225 +
226 + jQuery( "#autoptimize_css_inline" ).change(function() {
227 + if (this.checked) {
228 + jQuery("#autoptimize_css_defer").prop("checked",false);
229 + }
230 + });
231 +
232 + jQuery( "#autoptimize_css_defer" ).change(function() {
233 + if (this.checked) {
234 + jQuery("#autoptimize_css_inline").prop("checked",false);
235 + }
236 + });
237 +
238 + jQuery("#feed_dropdown").change(function() { show_feed(jQuery("#feed_dropdown").val()) });
239 + feedid=jQuery.cookie(cookiename);
240 + if(typeof(feedid) !== "string") feedid=1;
241 + show_feed(feedid);
242 + })
430 243
431 - jQuery( "#ao_show_adv" ).click(function() {
432 - jQuery( "#ao_show_adv" ).hide();
433 - jQuery( "#ao_hide_adv" ).show();
434 - jQuery( ".ao_adv" ).removeClass("hidden");
435 - jQuery( ".ao_adv" ).show("slow");
436 - if (jQuery("#autoptimize_css").attr('checked')) {
437 - jQuery(".css_sub:visible").fadeTo("fast",1);
438 - if (!jQuery("#autoptimize_css_defer").attr('checked')) {
439 - jQuery("#autoptimize_css_defer_inline").hide();
440 - }
441 - }
442 - if (jQuery("#autoptimize_js").attr('checked')) {
443 - jQuery(".js_sub:visible").fadeTo("fast",1);
444 - }
445 - check_ini_state()
446 - jQuery( "input#autoptimize_show_adv" ).val("1");
447 - });
448 -
449 - jQuery( "#ao_hide_adv" ).click(function() {
450 - jQuery( "#ao_hide_adv" ).hide();
451 - jQuery( "#ao_show_adv" ).show();
452 - jQuery( ".ao_adv" ).hide("slow");
453 - jQuery( ".ao_adv" ).addClass("hidden");
454 - if (!jQuery("#autoptimize_css").attr('checked')) {
455 - jQuery(".css_sub:visible").fadeTo("fast",.33);
456 - }
457 - if (!jQuery("#autoptimize_js").attr('checked')) {
458 - jQuery(".js_sub:visible").fadeTo("fast",.33);
459 - }
460 - check_ini_state()
461 - jQuery( "input#autoptimize_show_adv" ).val("0");
462 - });
463 -
464 - jQuery( "#autoptimize_html" ).change(function() {
465 - if (this.checked) {
466 - jQuery(".html_sub:visible").fadeTo("fast",1);
467 - } else {
468 - jQuery(".html_sub:visible").fadeTo("fast",.33);
469 - }
470 - });
471 -
472 - jQuery( "#autoptimize_js" ).change(function() {
473 - if (this.checked) {
474 - jQuery(".js_sub:visible").fadeTo("fast",1);
475 - } else {
476 - jQuery(".js_sub:visible").fadeTo("fast",.33);
477 - }
478 - });
479 -
480 - jQuery( "#autoptimize_css" ).change(function() {
481 - if (this.checked) {
482 - jQuery(".css_sub:visible").fadeTo("fast",1);
483 - } else {
484 - jQuery(".css_sub:visible").fadeTo("fast",.33);
485 - }
486 - });
487 -
488 - jQuery( "#autoptimize_css_inline" ).change(function() {
489 - if (this.checked) {
490 - jQuery("#autoptimize_css_defer").prop("checked",false);
491 - jQuery("#autoptimize_css_defer_inline").hide("slow");
492 - }
493 - });
494 -
495 - jQuery( "#autoptimize_css_defer" ).change(function() {
496 - if (this.checked) {
497 - jQuery("#autoptimize_css_inline").prop("checked",false);
498 - jQuery("#autoptimize_css_defer_inline").show("slow");
499 - } else {
500 - jQuery("#autoptimize_css_defer_inline").hide("slow");
501 - }
502 - });
503 -
504 - jQuery("#feed_dropdown").change(function() { show_feed(jQuery("#feed_dropdown").val()) });
505 - feedid=jQuery.cookie(cookiename);
506 - if(typeof(feedid) !== "string") feedid=1;
507 - show_feed(feedid);
508 - })
509 -
510 - // validate cdn_url
511 - var cdn_url=document.getElementById("cdn_url");
512 - cdn_url_baseCSS=cdn_url.style.cssText;
513 - if ("validity" in cdn_url) {
514 - jQuery("#cdn_url").focusout(function (event) {
515 - if (cdn_url.validity.valid) {
516 - cdn_url.style.cssText=cdn_url_baseCSS;
517 - } else {
518 - cdn_url.style.cssText=cdn_url_baseCSS+"border:1px solid #f00;color:#f00;box-shadow: 0 0 2px #f00;";
519 - }});
520 - }
521 -
522 - function check_ini_state() {
523 - if (!jQuery("#autoptimize_css_defer").attr('checked')) {
524 - jQuery("#autoptimize_css_defer_inline").hide();
525 - }
526 - if (!jQuery("#autoptimize_html").attr('checked')) {
527 - jQuery(".html_sub:visible").fadeTo('fast',.33);
528 - }
529 - if (!jQuery("#autoptimize_css").attr('checked')) {
530 - jQuery(".css_sub:visible").fadeTo('fast',.33);
531 - }
532 - if (!jQuery("#autoptimize_js").attr('checked')) {
533 - jQuery(".js_sub:visible").fadeTo('fast',.33);
534 - }
535 - }
536 -
537 - function show_feed(id) {
538 - jQuery('#futtta_feed').children().hide();
539 - jQuery('#'+feed[id]).show();
540 - jQuery("#feed_dropdown").val(id);
541 - jQuery.cookie(cookiename,id,{ expires: 365 });
542 - }
244 + function show_feed(id) {
245 + jQuery('#futtta_feed').rssfeed(feed[id], {
246 + <?php if ( is_ssl() ) echo "ssl: true,"; ?>
247 + limit: 4,
248 + date: true,
249 + header: false
250 + });
251 + jQuery("#feed_dropdown").val(id);
252 + jQuery.cookie(cookiename,id,{ expires: 365 });
253 + }
543 254 </script>
544 255 </div>
545 256
546 257 <?php
547 - }
258 + }
259 +
260 + public function addmenu()
261 + {
262 + $hook=add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize','manage_options','autoptimize',array($this,'show'));
263 + add_action( 'admin_print_scripts-'.$hook,array($this,'autoptimize_admin_scripts'));
264 + add_action( 'admin_print_styles-'.$hook,array($this,'autoptimize_admin_styles'));
265 + }
548 266
549 - public function addmenu() {
550 - $hook=add_options_page(__('Autoptimize Options','autoptimize'),'Autoptimize','manage_options','autoptimize',array($this,'show'));
551 - add_action( 'admin_print_scripts-'.$hook,array($this,'autoptimize_admin_scripts'));
552 - add_action( 'admin_print_styles-'.$hook,array($this,'autoptimize_admin_styles'));
553 - }
267 + public function autoptimize_admin_scripts() {
268 + wp_enqueue_script('jqzrssfeed', plugins_url('/external/js/jquery.zrssfeed.min.js', __FILE__), array('jquery'),null,true);
269 + wp_enqueue_script('jqcookie', plugins_url('/external/js/jquery.cookie.min.js', __FILE__), array('jquery'),null,true);
270 + }
554 271
555 - public function autoptimize_admin_scripts() {
556 - wp_enqueue_script('jqcookie', plugins_url('/external/js/jquery.cookie.min.js', __FILE__), array('jquery'),null,true);
557 - wp_enqueue_script('unslider', plugins_url('/external/js/unslider-min.js', __FILE__), array('jquery'),null,true);
558 - }
272 + public function autoptimize_admin_styles() {
273 + wp_enqueue_style('zrssfeed', plugins_url('/external/js/jquery.zrssfeed.css', __FILE__));
274 + }
559 275
560 - public function autoptimize_admin_styles() {
561 - wp_enqueue_style('unslider', plugins_url('/external/js/unslider.css', __FILE__));
562 - wp_enqueue_style('unslider-dots', plugins_url('/external/js/unslider-dots.css', __FILE__));
563 - }
564 -
565 - public function registersettings() {
566 - register_setting('autoptimize','autoptimize_html');
567 - register_setting('autoptimize','autoptimize_html_keepcomments');
568 - register_setting('autoptimize','autoptimize_js');
569 - register_setting('autoptimize','autoptimize_js_exclude');
570 - register_setting('autoptimize','autoptimize_js_trycatch');
571 - register_setting('autoptimize','autoptimize_js_justhead');
572 - register_setting('autoptimize','autoptimize_js_forcehead');
573 - register_setting('autoptimize','autoptimize_js_include_inline');
574 - register_setting('autoptimize','autoptimize_css');
575 - register_setting('autoptimize','autoptimize_css_exclude');
576 - register_setting('autoptimize','autoptimize_css_justhead');
577 - register_setting('autoptimize','autoptimize_css_datauris');
578 - register_setting('autoptimize','autoptimize_css_defer');
579 - register_setting('autoptimize','autoptimize_css_defer_inline');
580 - register_setting('autoptimize','autoptimize_css_inline');
581 - register_setting('autoptimize','autoptimize_css_include_inline');
582 - register_setting('autoptimize','autoptimize_cdn_url');
583 - register_setting('autoptimize','autoptimize_cache_clean');
584 - register_setting('autoptimize','autoptimize_cache_nogzip');
585 - register_setting('autoptimize','autoptimize_show_adv');
586 - register_setting('autoptimize','autoptimize_optimize_logged');
587 - register_setting('autoptimize','autoptimize_optimize_checkout');
588 - }
589 -
590 - public function setmeta($links,$file=null) {
591 - //Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/
592 - //Do it only once - saves time
593 - static $plugin;
594 - if(empty($plugin))
595 - $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR.'autoptimize.php');
596 -
597 - if($file===null) {
598 - //2.7
599 - $settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'));
600 - array_unshift($links,$settings_link);
601 - } else {
602 - //2.8
603 - //If it's us, add the link
604 - if($file === $plugin) {
605 - $newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>',__('Settings')));
606 - $links = array_merge($links,$newlink);
607 - }
608 - }
609 -
610 - return $links;
611 - }
612 -
613 - public function get($key) {
614 - if(!is_array($this->config)) {
615 - //Default config
616 - $config = array('autoptimize_html' => 0,
617 - 'autoptimize_html_keepcomments' => 0,
618 - 'autoptimize_js' => 0,
619 - 'autoptimize_js_exclude' => "seal.js, js/jquery/jquery.js",
620 - 'autoptimize_js_trycatch' => 0,
621 - 'autoptimize_js_justhead' => 0,
622 - 'autoptimize_js_include_inline' => 0,
623 - 'autoptimize_js_forcehead' => 0,
624 - 'autoptimize_css' => 0,
625 - 'autoptimize_css_exclude' => "admin-bar.min.css, dashicons.min.css",
626 - 'autoptimize_css_justhead' => 0,
627 - 'autoptimize_css_include_inline' => 1,
628 - 'autoptimize_css_defer' => 0,
629 - 'autoptimize_css_defer_inline' => "",
630 - 'autoptimize_css_inline' => 0,
631 - 'autoptimize_css_datauris' => 0,
632 - 'autoptimize_cdn_url' => "",
633 - 'autoptimize_cache_nogzip' => 1,
634 - 'autoptimize_show_adv' => 0,
635 - 'autoptimize_optimize_logged' => 1,
636 - 'autoptimize_optimize_checkout' => 1
637 - );
638 -
639 - //Override with user settings
640 - foreach(array_keys($config) as $name) {
641 - $conf = get_option($name);
642 - if($conf!==false) {
643 - //It was set before!
644 - $config[$name] = $conf;
645 - }
646 - }
647 -
648 - //Save for next question
649 - $this->config = apply_filters( 'autoptimize_filter_get_config', $config );
650 - }
651 -
652 - if(isset($this->config[$key]))
653 - return $this->config[$key];
654 -
655 - return false;
656 - }
657 -
658 - private function getFutttaFeeds($url) {
659 - if (apply_filters('autoptimize_settingsscreen_remotehttp',true)) {
660 - $rss = fetch_feed( $url );
661 - $maxitems = 0;
662 -
663 - if ( ! is_wp_error( $rss ) ) {
664 - $maxitems = $rss->get_item_quantity( 7 );
665 - $rss_items = $rss->get_items( 0, $maxitems );
666 - }
667 - ?>
668 - <ul>
669 - <?php if ( $maxitems == 0 ) : ?>
670 - <li><?php _e( 'No items', 'autoptimize' ); ?></li>
671 - <?php else : ?>
672 - <?php foreach ( $rss_items as $item ) : ?>
673 - <li>
674 - <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
675 - title="<?php printf( __( 'Posted %s', 'autoptimize' ), $item->get_date('j F Y | g:i a') ); ?>">
676 - <?php echo esc_html( $item->get_title() ); ?>
677 - </a>
678 - </li>
679 - <?php endforeach; ?>
680 - <?php endif; ?>
681 - </ul>
682 - <?php
683 - }
684 - }
685 -
686 - // based on http://wordpress.stackexchange.com/a/58826
687 - static function ao_admin_tabs(){
688 - $tabs = apply_filters('autoptimize_filter_settingsscreen_tabs',array('autoptimize' => __('Main','autoptimize')));
689 - $tabContent="";
690 - if (count($tabs)>1) {
691 - if(isset($_GET['page'])){
692 - $currentId = $_GET['page'];
693 - } else {
694 - $currentId = "autoptimize";
695 - }
696 - $tabContent .= "<h2 class=\"nav-tab-wrapper\">";
697 - foreach($tabs as $tabId => $tabName){
698 - if($currentId == $tabId){
699 - $class = " nav-tab-active";
700 - } else{
701 - $class = "";
702 - }
703 - $tabContent .= '<a class="nav-tab'.$class.'" href="?page='.$tabId.'">'.$tabName.'</a>';
704 - }
705 - $tabContent .= "</h2>";
706 - } else {
707 - $tabContent = "<hr/>";
708 - }
709 -
710 - return $tabContent;
711 - }
276 +
277 + public function registersettings()
278 + {
279 + register_setting('autoptimize','autoptimize_html');
280 + register_setting('autoptimize','autoptimize_html_keepcomments');
281 + register_setting('autoptimize','autoptimize_js');
282 + register_setting('autoptimize','autoptimize_js_exclude');
283 + register_setting('autoptimize','autoptimize_js_trycatch');
284 + register_setting('autoptimize','autoptimize_js_justhead');
285 + register_setting('autoptimize','autoptimize_js_forcehead');
286 + register_setting('autoptimize','autoptimize_css');
287 + register_setting('autoptimize','autoptimize_css_exclude');
288 + register_setting('autoptimize','autoptimize_css_justhead');
289 + register_setting('autoptimize','autoptimize_css_datauris');
290 + register_setting('autoptimize','autoptimize_css_defer');
291 + register_setting('autoptimize','autoptimize_css_inline');
292 + register_setting('autoptimize','autoptimize_cdn_url');
293 + register_setting('autoptimize','autoptimize_cache_clean');
294 + register_setting('autoptimize','autoptimize_cache_nogzip');
295 + register_setting('autoptimize','autoptimize_show_adv');
296 + }
297 +
298 + public function setmeta($links,$file=null)
299 + {
300 + //Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/
301 + //Do it only once - saves time
302 + static $plugin;
303 + if(empty($plugin))
304 + $plugin = plugin_basename(WP_PLUGIN_DIR.'/autoptimize/autoptimize.php');
305 +
306 + if($file===null)
307 + {
308 + //2.7
309 + $settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'));
310 + array_unshift($links,$settings_link);
311 + }else{
312 + //2.8
313 + //If it's us, add the link
314 + if($file === $plugin)
315 + {
316 + $newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>',__('Settings')));
317 + $links = array_merge($links,$newlink);
318 + }
319 + }
320 +
321 + return $links;
322 + }
323 +
324 + public function get($key)
325 + {
326 + if(!is_array($this->config))
327 + {
328 + //Default config
329 + $config = array('autoptimize_html' => 0,
330 + 'autoptimize_html_keepcomments' => 0,
331 + 'autoptimize_js' => 0,
332 + 'autoptimize_js_exclude' => "s_sid, smowtion_size, sc_project, WAU_, wau_add, comment-form-quicktags, edToolbar, ch_client",
333 + 'autoptimize_js_trycatch' => 0,
334 + 'autoptimize_js_justhead' => 0,
335 + 'autoptimize_js_forcehead' => 0,
336 + 'autoptimize_css' => 0,
337 + 'autoptimize_css_exclude' => "admin-bar.min.css, dashicons.min.css",
338 + 'autoptimize_css_justhead' => 0,
339 + 'autoptimize_css_defer' => 0,
340 + 'autoptimize_css_inline' => 0,
341 + 'autoptimize_css_datauris' => 0,
342 + 'autoptimize_cdn_url' => "",
343 + 'autoptimize_cache_nogzip' => 1,
344 + 'autoptimize_show_adv' => 0
345 + );
346 +
347 + //Override with user settings
348 + foreach(array_keys($config) as $name)
349 + {
350 + $conf = get_option($name);
351 + if($conf!==false)
352 + {
353 + //It was set before!
354 + $config[$name] = $conf;
355 + }
356 + }
357 +
358 + //Save for next question
359 + $this->config = $config;
360 + }
361 +
362 + if(isset($this->config[$key]))
363 + return $this->config[$key];
364 +
365 + return false;
366 + }
712 367 }