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