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