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