Changeset 2036979
- Timestamp:
- 02/22/2019 12:20:54 PM (7 years ago)
- Location:
- cache-control-by-cacholong
- Files:
-
- 28 added
- 38 edited
- 44 copied
- 2 moved
-
tags/4.0.2 (added)
-
tags/4.0.2/CacholongCacheControl.php (copied) (copied from cache-control-by-cacholong/trunk/CacholongCacheControl.php)
-
tags/4.0.2/changelog.txt (copied) (copied from cache-control-by-cacholong/trunk/changelog.txt)
-
tags/4.0.2/core (added)
-
tags/4.0.2/core/controller (added)
-
tags/4.0.2/core/controller/admin (added)
-
tags/4.0.2/core/controller/admin/AdminSettingsPageController.php (copied) (copied from cache-control-by-cacholong/trunk/core/controller/admin/AdminSettingsPageController.php)
-
tags/4.0.2/core/controller/admin/PurgeCacheController.php (copied) (copied from cache-control-by-cacholong/trunk/core/controller/admin/PurgeCacheController.php)
-
tags/4.0.2/core/controller/admin/ToolbarController.php (copied) (copied from cache-control-by-cacholong/trunk/core/controller/admin/ToolbarController.php)
-
tags/4.0.2/core/designpattern (added)
-
tags/4.0.2/core/designpattern/observer (added)
-
tags/4.0.2/core/designpattern/observer/CacheHelperObserver.php (copied) (copied from cache-control-by-cacholong/trunk/core/designpattern/observer/CacheHelperObserver.php)
-
tags/4.0.2/core/designpattern/observer/CacheHelperSubject.php (copied) (copied from cache-control-by-cacholong/trunk/core/designpattern/observer/CacheHelperSubject.php)
-
tags/4.0.2/core/designpattern/observer/NginxFastCGICacheHelperObserver.php (copied) (copied from cache-control-by-cacholong/trunk/core/designpattern/observer/NginxFastCGICacheHelperObserver.php)
-
tags/4.0.2/core/designpattern/observer/NginxPageSpeedCacheHelperObserver.php (copied) (copied from cache-control-by-cacholong/trunk/core/designpattern/observer/NginxPageSpeedCacheHelperObserver.php)
-
tags/4.0.2/core/entities (added)
-
tags/4.0.2/core/entities/AdminNoticeClass.php (copied) (copied from cache-control-by-cacholong/trunk/core/entities/AdminNoticeClass.php)
-
tags/4.0.2/core/entities/AdminPostAction.php (copied) (copied from cache-control-by-cacholong/trunk/core/entities/AdminPostAction.php)
-
tags/4.0.2/core/entities/AjaxResponseType.php (copied) (copied from cache-control-by-cacholong/trunk/core/entities/AjaxResponseType.php)
-
tags/4.0.2/core/entities/CacheType.php (moved) (moved from cache-control-by-cacholong/trunk/core/entities/CacheType.php)
-
tags/4.0.2/core/entities/HttpApiRequest.php (copied) (copied from cache-control-by-cacholong/trunk/core/entities/HttpApiRequest.php)
-
tags/4.0.2/core/entities/Identifier.php (copied) (copied from cache-control-by-cacholong/trunk/core/entities/Identifier.php)
-
tags/4.0.2/core/entities/PostType.php (copied) (copied from cache-control-by-cacholong/trunk/core/entities/PostType.php)
-
tags/4.0.2/core/libraries (added)
-
tags/4.0.2/core/libraries/AdminMessage.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/AdminMessage.php)
-
tags/4.0.2/core/libraries/CacholongCacheControlSetup.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/CacholongCacheControlSetup.php)
-
tags/4.0.2/core/libraries/File.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/File.php)
-
tags/4.0.2/core/libraries/FlashData.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/FlashData.php)
-
tags/4.0.2/core/libraries/Helpers.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/Helpers.php)
-
tags/4.0.2/core/libraries/Hosts.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/Hosts.php)
-
tags/4.0.2/core/libraries/HttpApiRequest.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/HttpApiRequest.php)
-
tags/4.0.2/core/libraries/Json.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/Json.php)
-
tags/4.0.2/core/libraries/PurgeCache.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/PurgeCache.php)
-
tags/4.0.2/core/libraries/Style.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/Style.php)
-
tags/4.0.2/core/libraries/UserOptions.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/UserOptions.php)
-
tags/4.0.2/core/libraries/WordpressURL.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/WordpressURL.php)
-
tags/4.0.2/core/libraries/purgeSetting (added)
-
tags/4.0.2/core/libraries/purgeSetting/CustomtPostPurgeSetting.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/purgeSetting/CustomtPostPurgeSetting.php)
-
tags/4.0.2/core/libraries/purgeSetting/DefaultPostPurgeSetting.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/purgeSetting/DefaultPostPurgeSetting.php)
-
tags/4.0.2/core/libraries/purgeSetting/PurgeSetting.php (copied) (copied from cache-control-by-cacholong/trunk/core/libraries/purgeSetting/PurgeSetting.php)
-
tags/4.0.2/core/view (added)
-
tags/4.0.2/core/view/admin (added)
-
tags/4.0.2/core/view/admin/misc (added)
-
tags/4.0.2/core/view/admin/misc/admin_message.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/misc/admin_message.phtml)
-
tags/4.0.2/core/view/admin/settings (added)
-
tags/4.0.2/core/view/admin/settings/field (added)
-
tags/4.0.2/core/view/admin/settings/field/custom_post_purge_settings.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/settings/field/custom_post_purge_settings.phtml)
-
tags/4.0.2/core/view/admin/settings/field/default_post_purge_settings.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/settings/field/default_post_purge_settings.phtml)
-
tags/4.0.2/core/view/admin/settings/field/location_json_hosts_file.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/settings/field/location_json_hosts_file.phtml)
-
tags/4.0.2/core/view/admin/settings/field/remove_style_id.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/settings/field/remove_style_id.phtml)
-
tags/4.0.2/core/view/admin/settings/page (added)
-
tags/4.0.2/core/view/admin/settings/page/cacholong_cache_control.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/settings/page/cacholong_cache_control.phtml)
-
tags/4.0.2/core/view/admin/settings/section (added)
-
tags/4.0.2/core/view/admin/settings/section/cacholong_cache_control_settings.phtml (copied) (copied from cache-control-by-cacholong/trunk/core/view/admin/settings/section/cacholong_cache_control_settings.phtml)
-
tags/4.0.2/core/wordpress (added)
-
tags/4.0.2/core/wordpress/readme.txt (copied) (copied from cache-control-by-cacholong/trunk/core/wordpress/readme.txt)
-
tags/4.0.2/js (added)
-
tags/4.0.2/js/cachalong-cache-control.js (moved) (moved from cache-control-by-cacholong/trunk/js/cachalong-cache-control.js)
-
tags/4.0.2/languages (added)
-
tags/4.0.2/languages/cacholong-en_US.mo (copied) (copied from cache-control-by-cacholong/trunk/languages/cacholong-en_US.mo)
-
tags/4.0.2/languages/cacholong-en_US.po (copied) (copied from cache-control-by-cacholong/trunk/languages/cacholong-en_US.po)
-
tags/4.0.2/languages/cacholong-nl_NL.mo (copied) (copied from cache-control-by-cacholong/trunk/languages/cacholong-nl_NL.mo)
-
tags/4.0.2/languages/cacholong-nl_NL.po (copied) (copied from cache-control-by-cacholong/trunk/languages/cacholong-nl_NL.po)
-
tags/4.0.2/license.txt (copied) (copied from cache-control-by-cacholong/trunk/license.txt)
-
tags/4.0.2/readme.txt (copied) (copied from cache-control-by-cacholong/trunk/readme.txt)
-
trunk/CacholongCacheControl.php (modified) (24 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/core/controller/admin/AdminSettingsPageController.php (modified) (17 diffs)
-
trunk/core/controller/admin/PurgeCacheController.php (modified) (7 diffs)
-
trunk/core/controller/admin/ToolbarController.php (modified) (3 diffs)
-
trunk/core/designpattern/observer/CacheHelperObserver.php (modified) (5 diffs)
-
trunk/core/designpattern/observer/CacheHelperSubject.php (modified) (21 diffs)
-
trunk/core/designpattern/observer/NginxFastCGICacheHelperObserver.php (modified) (5 diffs)
-
trunk/core/designpattern/observer/NginxPageSpeedCacheHelperObserver.php (modified) (10 diffs)
-
trunk/core/entities/AdminNoticeClass.php (modified) (1 diff)
-
trunk/core/entities/AdminPostAction.php (modified) (3 diffs)
-
trunk/core/entities/AjaxResponseType.php (modified) (1 diff)
-
trunk/core/entities/HttpApiRequest.php (modified) (1 diff)
-
trunk/core/entities/Identifier.php (modified) (5 diffs)
-
trunk/core/entities/PostType.php (modified) (1 diff)
-
trunk/core/entities/SchedulerRecurrence.php (added)
-
trunk/core/libraries/AdminMessage.php (modified) (1 diff)
-
trunk/core/libraries/CacholongCacheControlSetup.php (modified) (7 diffs)
-
trunk/core/libraries/File.php (modified) (1 diff)
-
trunk/core/libraries/FlashData.php (modified) (1 diff)
-
trunk/core/libraries/Helpers.php (modified) (2 diffs)
-
trunk/core/libraries/Hosts.php (modified) (3 diffs)
-
trunk/core/libraries/HttpApiRequest.php (modified) (1 diff)
-
trunk/core/libraries/Json.php (modified) (2 diffs)
-
trunk/core/libraries/PurgeCache.php (modified) (18 diffs)
-
trunk/core/libraries/Scheduler.php (added)
-
trunk/core/libraries/Style.php (modified) (1 diff)
-
trunk/core/libraries/UserOptions.php (modified) (1 diff)
-
trunk/core/libraries/WordpressURL.php (modified) (1 diff)
-
trunk/core/libraries/purgeSetting/CustomtPostPurgeSetting.php (modified) (1 diff)
-
trunk/core/libraries/purgeSetting/DefaultPostPurgeSetting.php (modified) (1 diff)
-
trunk/core/libraries/purgeSetting/PurgeSetting.php (modified) (1 diff)
-
trunk/core/view/admin/misc/admin_message.phtml (modified) (1 diff)
-
trunk/core/view/admin/settings/field/cron_cache_helpers.phtml (added)
-
trunk/core/view/admin/settings/field/cron_enabled.phtml (added)
-
trunk/core/view/admin/settings/field/cron_time.phtml (added)
-
trunk/core/view/admin/settings/field/custom_post_purge_settings.phtml (modified) (1 diff)
-
trunk/core/view/admin/settings/field/default_post_purge_settings.phtml (modified) (1 diff)
-
trunk/core/view/admin/settings/field/location_json_hosts_file.phtml (modified) (1 diff)
-
trunk/core/view/admin/settings/field/remove_style_id.phtml (modified) (1 diff)
-
trunk/core/view/admin/settings/page/cacholong_cache_control.phtml (modified) (3 diffs)
-
trunk/core/view/admin/settings/section/cacholong_cache_control_settings.phtml (modified) (2 diffs)
-
trunk/core/view/admin/settings/section/cacholong_cache_control_settings_cronjob.phtml (added)
-
trunk/css (added)
-
trunk/css/cacholong-cache-control.css (added)
-
trunk/js/cacholong-cache-control.js (added)
-
trunk/readme.txt (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cache-control-by-cacholong/trunk/CacholongCacheControl.php
r1974788 r2036979 1 1 <?php 2 2 3 /* 3 4 Plugin Name: Cache control by Cacholong 4 5 Description: Automates purging of Nginx Pagespeed cache and Nginx FastCGI cache on your Nginx server(s). 5 Version: 4. 0.26 Version: 4.1.1 6 7 Author: Cacholong 7 8 Author URI: http://www.cacholong.nl … … 11 12 Domain Path: /languages 12 13 13 Copyright © 2016-201 8, Cacholong <[email protected]>14 14 Copyright © 2016-2019, Cacholong <[email protected]> 15 15 16 This file is part of Cache Control 16 17 17 18 Cache Control is free software: you can redistribute it and/or modify 18 19 it under the terms of the GNU General Public License as published by 19 20 the Free Software Foundation, either version 3 of the License, or 20 21 (at your option) any later version. 21 22 22 23 Cache Control is distributed in the hope that it will be useful, 23 24 but WITHOUT ANY WARRANTY; without even the implied warranty of 24 25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 26 GNU General Public License for more details. 26 27 27 28 You should have received a copy of the GNU General Public License 28 29 along with Cache Control. If not, see <http://www.gnu.org/licenses/>. 29 30 */ 31 30 32 namespace Cacholong; 31 33 … … 51 53 * @return CacholongCache Instance of CacholongCacheControl 52 54 */ 53 public static function init() 54 { 55 if(is_null(self::$_instance)) 56 { 55 public static function init() { 56 if (is_null(self::$_instance)) { 57 57 self::$_instance = new self; 58 58 } … … 71 71 * 72 72 */ 73 protected function __construct() 74 { 73 protected function __construct() { 75 74 do_action('cacholong_cache_control_construct'); 76 75 … … 90 89 * 91 90 */ 92 private function define_constants() 93 { 91 private function define_constants() { 94 92 $dir = dirname(__FILE__); 95 93 $dir = str_replace('\\', '/', $dir); … … 120 118 * @return void 121 119 */ 122 private function define($name, $value) 123 { 120 private function define($name, $value) { 124 121 $name_uppercase = strtoupper($name); 125 122 126 if(!defined($name_uppercase)) 127 { 123 if (!defined($name_uppercase)) { 128 124 define($name_uppercase, $value); 129 125 } … … 138 134 * 139 135 * @version 1.0.0 Created at 2015-10-21 140 * @version 1.0.1 2016-09-07 Added entity PostType 141 * @return void 142 */ 143 private function requires() 144 { 136 * 137 * @return void 138 */ 139 private function requires() { 145 140 //entities 146 require_once(CACHOLONG_CACHE_DIR . '/core/entities/CacheType.php');147 141 require_once(CACHOLONG_CACHE_DIR . '/core/entities/Identifier.php'); 148 142 require_once(CACHOLONG_CACHE_DIR . '/core/entities/AdminPostAction.php'); … … 151 145 require_once(CACHOLONG_CACHE_DIR . '/core/entities/PostType.php'); 152 146 require_once(CACHOLONG_CACHE_DIR . '/core/entities/HttpApiRequest.php'); 147 require_once(CACHOLONG_CACHE_DIR . '/core/entities/SchedulerRecurrence.php'); 153 148 154 149 //libraries / helpers … … 158 153 require_once(CACHOLONG_CACHE_DIR . '/core/libraries/Json.php'); 159 154 require_once(CACHOLONG_CACHE_DIR . '/core/libraries/Style.php'); 155 require_once(CACHOLONG_CACHE_DIR . '/core/libraries/Scheduler.php'); 160 156 161 157 //setup … … 176 172 * 177 173 * @version 1.0.0 Created at 2015-10-21 178 * @version 1.0.1 2015-11-16 Added parameters to save_post 179 * @version 1.0.2 2015-11-25 enqueue_scripts_and_styles + wp_ajax_xxxxx 180 * @version 1.1.0 2016-09-14 Delete post 181 * @version 1.2.0 2017-12-15 Added optional style_loader_tag filter 182 * @version 1.3.0 2017-12-15 Removed sessions 183 * @version 1.4.0 2017-12-21 Most hooks only available for admin 184 * @version 1.5.0 2017-12-22 Bugfix: style_loader_tag + parse_request out of is_admin if() 185 * @version 1.6.0 2018-11-15 wp_uniquie_post_slug > 6 arguments 186 * @return void 187 */ 188 private function init_hooks() 189 { 190 if(is_admin()) 191 { 174 * 175 * @return void 176 */ 177 private function init_hooks() { 178 if (is_admin()) { 192 179 //hooks for setup 193 180 register_activation_hook(__FILE__, array('\Cacholong\Libraries\CacholongCacheControlSetup', 'on_activation')); 194 181 register_deactivation_hook(__FILE__, array('\Cacholong\Libraries\CacholongCacheControlSetup', 'on_deactivation')); 195 182 register_uninstall_hook(__FILE__, array('\Cacholong\Libraries\CacholongCacheControlSetup', 'on_uninstall')); // test in development with register_deactivation_hook 196 197 198 183 //actions and filters 199 184 add_action('init', array('\Cacholong\CacholongCacheControl', 'load_plugin_textdomain')); 200 add_action('admin_bar_menu', array('\Cacholong\Controller\Admin\ToolbarController', 'create_toolbar_node_purge_all'), 999);201 185 202 186 add_action('init', array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'init')); 203 187 204 188 add_action('save_post', array('\Cacholong\Controller\Admin\PurgeCacheController', 'handle_purge_post_save'), 10, 3); //purge when new post and updating post 205 189 add_action('wp_trash_post', array('\Cacholong\Controller\Admin\PurgeCacheController', 'handle_purge_post_trash_and_untrash'), 10); //purge when post is trashed … … 210 194 add_action('wp_update_nav_menu', array('\Cacholong\CacholongCacheControl', 'handle_nav_menu_update'), 10, 2); //nav bar save 211 195 212 add_action('admin_init', array('\Cacholong\CacholongCacheControl', 'handle_purge_from_admin_bar'), 999); 213 214 add_action('admin_enqueue_scripts', array('\Cacholong\CacholongCacheControl', 'enqueue_scripts_and_styles')); 196 add_action('admin_enqueue_scripts', array('\Cacholong\CacholongCacheControl', 'enqueue_scripts_and_styles_backend')); 215 197 216 198 //handle messages … … 223 205 224 206 //front- and back-end 225 if(get_option(\Cacholong\Entities\Identifier::CC_FIELD_REMOVE_STYLE_ID) == 1) 226 { 207 add_action('wp_enqueue_scripts', array('\Cacholong\CacholongCacheControl', 'enqueue_scripts_and_styles_frontend')); 208 add_action('admin_bar_menu', array('\Cacholong\Controller\Admin\ToolbarController', 'create_toolbar_node_purge_all'), 999); 209 add_action('admin_bar_init', array('\Cacholong\CacholongCacheControl', 'handle_purge_from_admin_bar'), 999); 210 211 if (get_option(\Cacholong\Entities\Identifier::CC_FIELD_REMOVE_STYLE_ID) == 1) { 227 212 add_filter('style_loader_tag', array('\Cacholong\Libraries\Style', 'remove_id')); //remove style id (if allowed) 228 213 } … … 232 217 add_action('parse_request', array('\Cacholong\CacholongCacheControl', 'handle_custom_url_parsing')); 233 218 add_action('init', array('\Cacholong\Controller\Admin\PurgeCacheController', 'init')); 234 } 235 236 /** 237 * Enqueu all scripts and styles 219 220 //Debug 221 add_action('cc_debug_hook', array('\Cacholong\CacholongCacheControl', 'handle_debug_hook')); 222 223 self::init_hooks_cron(); 224 } 225 226 227 /** 228 * Init hooks cronjobs 229 * 230 * This function will hook into updating of cron settings. Whenever a cron option is updated, handle_update_options_for_cron_settings is called. 231 * New cron settings must be added to this function in order to be caught. 232 * 233 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 234 * @copyright Cacholong <[email protected]> 235 * @todo ok 236 * 237 * @version 1.0.0 Created at 2019-02-20 238 * 239 * @return void 240 */ 241 private function init_hooks_cron() { 242 243 //collect all cron options 244 $cronOptions[] = \Cacholong\Entities\Identifier::CC_FIELD_CRON_ENABLED; 245 $cronOptions[] = \Cacholong\Entities\Identifier::CC_FIELD_CRON_TIME; 246 247 $cronCacheSettings = cacholong_cc_get_cron_settings_caches_field_key_and_name(); 248 foreach ($cronCacheSettings as $cronSettingCacheKey => $cacheName) { 249 $cronOptions[] = $cronSettingCacheKey; 250 } 251 252 //Add action to each option 253 foreach ($cronOptions as $cronOption) 254 { 255 add_action('update_option_' . $cronOption, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'handle_update_options_for_cron_settings'), 10, 3); //Action called when option is saved 256 } 257 } 258 259 /** 260 * Enqueu all scripts and styles backend 238 261 * 239 262 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) … … 244 267 * @version 1.1.0 2016-09-07 Some settingsSection* vars 245 268 * @version 1.2.0 2018-02-28 Cache busting with fingerprinting 246 * @ return void247 * /248 public static function enqueue_scripts_and_styles()249 {269 * @versopm 1.3.0 2019-02-21 Added style 270 * @return void 271 */ 272 public static function enqueue_scripts_and_styles_backend() { 250 273 $cc_plugin_data['ajaxUrl'] = admin_url('admin-ajax.php'); 251 274 $cc_plugin_data['ajaxResponseTypeSuccess'] = \Cacholong\Entities\AjaxResponseType::SUCCESS; … … 264 287 ); 265 288 266 wp_register_script("cachalong-cache-control", CACHOLONG_CACHE_URL . '/js/cachalong-cache-control.js', array('jquery'), Libraries\File::fingerprint(CACHOLONG_CACHE_DIR . '/js/cachalong-cache-control.js')); 267 wp_localize_script('cachalong-cache-control', 'cacholong_cc_plugin_data', $cc_plugin_data); 268 269 wp_enqueue_script('cachalong-cache-control'); 270 } 289 wp_register_script("cacholong-cache-control", CACHOLONG_CACHE_URL . '/js/cacholong-cache-control.js', array('jquery'), Libraries\File::fingerprint(CACHOLONG_CACHE_DIR . '/js/cacholong-cache-control.js')); 290 wp_localize_script('cacholong-cache-control', 'cacholong_cc_plugin_data', $cc_plugin_data); 291 292 wp_enqueue_script('cacholong-cache-control'); 293 294 wp_enqueue_style("cacholong-cache-control-style", CACHOLONG_CACHE_URL . "/css/cacholong-cache-control.css", array(), Libraries\File::fingerprint(CACHOLONG_CACHE_DIR . '/css/cacholong-cache-control.css')); 295 } 296 297 /** 298 * Enqueu all scripts and styles (frontend) 299 * 300 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 301 * @copyright Cacholong <[email protected]> 302 * @todo ok 303 * 304 * @version 1.0.0 2019-02-21 305 * @return void 306 */ 307 public static function enqueue_scripts_and_styles_frontend() { 308 //on frontend because of adminbar 309 wp_enqueue_style("cacholong-cache-control-style", CACHOLONG_CACHE_URL . "/css/cacholong-cache-control.css", array(), Libraries\File::fingerprint(CACHOLONG_CACHE_DIR . '/css/cacholong-cache-control.css')); 310 } 311 271 312 272 313 /** … … 281 322 * @return void 282 323 */ 283 public static function load_plugin_textdomain() 284 { 324 public static function load_plugin_textdomain() { 285 325 load_plugin_textdomain(\Cacholong\Entities\Identifier::CC_TEXT_DOMAIN, false, dirname(CACHOLONG_CACHE_BASENAME) . '/languages/'); 286 326 } … … 298 338 * @return void 299 339 */ 300 public static function handle_custom_url_parsing($query) 301 { 302 if($query->request == \Cacholong\Entities\Identifier::CC_CUSTOM_URL_PARSE) 303 { 340 public static function handle_custom_url_parsing($query) { 341 if ($query->request == \Cacholong\Entities\Identifier::CC_CUSTOM_URL_PARSE) { 304 342 self::handle_nginx_fastcgi_full_purge(); 305 343 exit(); //query is handled outside of wordpress logic … … 321 359 * @return void 322 360 */ 323 public static function handle_purge_from_admin_bar() 324 { 325 if(isset($_GET[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY]) && 326 ($_GET[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY] == \Cacholong\Entities\Identifier::CC_REQUEST_ACTION_PURGE_ALL_ADMIN_BAR)) 327 { 361 public static function handle_purge_from_admin_bar() { 362 if (isset($_GET[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY]) && 363 ($_GET[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY] == \Cacholong\Entities\Identifier::CC_REQUEST_ACTION_PURGE_ALL_ADMIN_BAR)) { 328 364 $nonce = $_GET['_wpnonce']; 329 if(wp_verify_nonce($nonce)) 330 { 365 if (wp_verify_nonce($nonce)) { 331 366 \Cacholong\Controller\Admin\PurgeCacheController::handle_purge_all_from_admin_bar(); 332 } 333 else 334 { 367 } else { 335 368 //silent fail 336 369 cacholong_cc_log_error(__('Purge from admin bar failed silently, because nonce was not valid', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), __FILE__); … … 351 384 * @return void 352 385 */ 353 private static function handle_nginx_fastcgi_full_purge() 354 { 355 if(isset($_POST[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY]) && ($_POST[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY] == \Cacholong\Entities\Identifier::CC_REQUEST_ACTION_PURGE_ALL_NGINX_FASTCGI)) 356 { 386 private static function handle_nginx_fastcgi_full_purge() { 387 if (isset($_POST[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY]) && ($_POST[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY] == \Cacholong\Entities\Identifier::CC_REQUEST_ACTION_PURGE_ALL_NGINX_FASTCGI)) { 357 388 $httpResponseCode = \Cacholong\Controller\Admin\PurgeCacheController::handle_purge_nginx_fastcgi(); 358 } 359 else 360 { 389 } else { 361 390 $httpResponseCode = 404; //Error, not found 362 391 } … … 364 393 365 394 //Response 366 if(!headers_sent()) 367 { 395 if (!headers_sent()) { 368 396 http_response_code($httpResponseCode); 369 } 370 else 371 { 397 } else { 372 398 cacholong_cc_log_error(sprintf(__('Cannot sent http response code %s, because header is already send.', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), $httpResponseCode), __FILE__); 373 399 } … … 385 411 * @return void 386 412 */ 387 public static function handle_ajax_messages() 388 { 413 public static function handle_ajax_messages() { 389 414 \Cacholong\Libraries\AdminMessage::handle_ajax_messages(); 390 415 } … … 404 429 * @return void 405 430 */ 406 public static function handle_nav_menu_update($menu_id, $menu_data = array()) 407 { 431 public static function handle_nav_menu_update($menu_id, $menu_data = array()) { 408 432 \Cacholong\Controller\Admin\PurgeCacheController::handle_nav_bar_change($menu_id, $menu_data = array()); 409 433 } … … 421 445 * @return void 422 446 */ 423 public static function handle_shutdown() 424 { 447 public static function handle_shutdown() { 425 448 $ajax = defined('DOING_AJAX') && DOING_AJAX; 426 if(!$ajax) 427 { 449 if (!$ajax) { 428 450 \Cacholong\Controller\Admin\PurgeCacheController::purge_navbar_changes(); 429 451 \Cacholong\Controller\Admin\PurgeCacheController::purge_slug_changes(); … … 432 454 } 433 455 456 /** 457 * Handle debug hook 458 * 459 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 460 * @copyright Cacholong <[email protected]> 461 * @todo ok 462 * 463 * @version 1.0.0 Created at 2019-02-20 464 * 465 * @param mixed ... Optional. Unlimited number of additional variables. Default none. 466 * 467 * @return void 468 */ 469 public static function handle_debug_hook() { 470 $arguments = func_get_args(); 471 $argumentsList = cacholong_cc_itemlist_to_sentence($arguments); 472 473 cacholong_cc_log_error("Debug hook is called with following arguments: {$argumentsList}."); 474 } 475 434 476 } 477 435 478 /** 436 479 * Start plugin -
cache-control-by-cacholong/trunk/changelog.txt
r1974795 r2036979 1 1 == Changelog == 2 2 All notable changes to this plugin will be documented in this file. Copy of all changes for last MAJOR version can also be found in readme.txt. 3 4 = 4.1.1 - 2019-02-22 = 5 6 * Added - When Wordpress cronjobs are disabled (DISABLE_WP_CRON = true), text with link to FAQ is shown underneath setting to activate cronjob purging 7 * Added - Current timezone underneath setting for cronjob time of day 8 9 = 4.1.0 - 2019-02-21 = 10 * Added - Plugin is capable to purge with Wordpress cronjobs 11 * Added - Plugin is tested for usage with Wordpress 5.0.3 12 * Added - Icon for 'Purge all caches' on adminbar 13 * Fixed - Errors caused by empty 'File with hosts (JSON)' setting 14 * Changed - 'Purge all caches' also available on frontend adminbar 15 * Changed - Corrected a few spellerrors (cachalong -> cacholong) 16 * Changed - Updated copyright from 2015-2018 to 2015-2019 17 3 18 4 19 = 4.0.2 - 2018-11-15 = -
cache-control-by-cacholong/trunk/core/controller/admin/AdminSettingsPageController.php
r1834268 r2036979 1 1 <?php 2 2 3 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 4 5 * 5 6 * This file is part of Cache Control … … 18 19 * along with Cache Control. If not, see <http://www.gnu.org/licenses/>. 19 20 */ 21 20 22 namespace Cacholong\Controller\Admin; 21 23 22 24 defined('ABSPATH') OR exit; 25 26 use Cacholong\Libraries\Scheduler; 23 27 24 28 /** … … 31 35 */ 32 36 class AdminSettingsPageController { 37 /* 38 * @const string FLASHDATA_KEY_CRON_CACHE_SETTINGS_CHANGED Updated cron cache settings on settings page (can't use bool, because of new UserOptions lib) 39 */ 40 41 const FLASHDATA_KEY_CRON_CACHE_SETTINGS_CHANGED = 'updated_cron_cache_settings'; 33 42 34 43 /** … … 40 49 * 41 50 * @version 1.0.0 Created at 2015-10-21 42 * 43 */ 44 public static function init() 45 { 51 * @version 1.1.0 2019-02-21 Added action update_cron_cache_purging_if_needed 52 */ 53 public static function init() { 46 54 do_action('cacholong_cache_control_admin_settings_before_init'); 47 55 … … 50 58 add_action('admin_init', array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'register_settings')); 51 59 60 add_action('admin_init', array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'update_cron_cache_purging_if_needed')); 61 52 62 do_action('cacholong_cache_control_admin_settings_after_init'); 63 } 64 65 /** 66 * Handle updated options for cron settings on settings page 67 * Note: will only set flash signal, cron handling in self::update_cron_cache_purging_if_needed(). 68 * 69 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 70 * @copyright Cacholong <[email protected]> 71 * @todo ok 72 * 73 * @version 1.0.0 2019-02-20 74 * 75 * @param mixed $oldValue Old value 76 * @param mixed $newValue New value 77 * @param string $optionName Name of option 78 * 79 * @return void 80 */ 81 public static function handle_update_options_for_cron_settings($oldValue, $newValue, $optionName) { 82 \Cacholong\Libraries\FlashData::set_flash([self::FLASHDATA_KEY_CRON_CACHE_SETTINGS_CHANGED => '1']); 83 } 84 85 /** 86 * Update cron cache purging if needed 87 * 88 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 89 * @copyright Cacholong <[email protected]> 90 * @todo ok 91 * 92 * @version 1.0.0 2019-02-20 93 * 94 * @return void 95 */ 96 public static function update_cron_cache_purging_if_needed() { 97 98 $cronCacheSettingsChanged = \Cacholong\Libraries\FlashData::get_flash(self::FLASHDATA_KEY_CRON_CACHE_SETTINGS_CHANGED); //one or more cron cache settings changed 99 100 if ($cronCacheSettingsChanged[self::FLASHDATA_KEY_CRON_CACHE_SETTINGS_CHANGED] === '1') { 101 $cronKeysAndHookPurgeNames = cacholong_cc_get_cron_settings_caches_field_key_and_hook_purge_name(); 102 103 $cronOptionEnabled = get_option(\Cacholong\Entities\Identifier::CC_FIELD_CRON_ENABLED); 104 $cronOptionTime = cacholong_cc_get_option_cron_time(); 105 $cronOptionsCache = cacholong_cc_get_options_cron_caches(); 106 107 //Set / unset all scheduled events 108 foreach ($cronKeysAndHookPurgeNames as $cronCacheFieldKey => $cronCacheHookPurgeName) { 109 if ($cronOptionEnabled) { 110 if ($cronOptionsCache[$cronCacheFieldKey] === '1') { 111 Scheduler::set_daily_event($cronOptionTime, $cronCacheHookPurgeName); 112 } 113 else 114 { 115 Scheduler::unset_event($cronCacheHookPurgeName); 116 } 117 } else { //ok 118 //Unsetting can be done for all, no need to check if event was there. 119 Scheduler::unset_event($cronCacheHookPurgeName); 120 } 121 } 122 } 123 //else do nop 53 124 } 54 125 … … 65 136 * @return void 66 137 */ 67 public static function create_settings_page() 68 { 138 public static function create_settings_page() { 69 139 add_options_page( 70 _x('Cache control by Cacholong', 'Title of settings page', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), _x('Cache control', 'Menu title of settings page', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), 'manage_options', \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_page')140 _x('Cache control by Cacholong', 'Title of settings page', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), _x('Cache control', 'Menu title of settings page', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), 'manage_options', \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_page') 71 141 ); 72 142 } … … 83 153 * @return void 84 154 */ 85 public static function create_settings_page_sections() 86 { 155 public static function create_settings_page_sections() { 87 156 self::create_section_settings(); 88 157 } … … 98 167 * @version 1.1.0 2016-09-07 Add purge settings 99 168 * @version 1.2.0 2017-12-15 Add CC_FIELD_REMOVE_STYLE_ID 100 * 101 * @return void 102 */ 103 private static function create_section_settings() 104 { 105 //create section on options page 169 * @version 1.3.0 2019-02-19 Cronjob settings section + cronjob settings 170 * @return void 171 */ 172 private static function create_section_settings() { 173 //create sections on options page 106 174 add_settings_section( 107 \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION, _x('Settings', 'Subtitle for settings section', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_section_settings'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID); 108 109 //create fields in section on options page 110 add_settings_field( 111 \Cacholong\Entities\Identifier::CC_FIELD_HOSTS_FILE, _x('File with hosts (JSON)', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_location_json_hosts_file'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 112 113 add_settings_field( 114 \Cacholong\Entities\Identifier::CC_FIELD_REMOVE_STYLE_ID, _x('Pagespeed optimized CSS', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_remove_style_id'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 115 116 add_settings_field( 117 \Cacholong\Entities\Identifier::CC_FIELD_DEFAULT_POST_PURGE_SETTINGS, _x('Purge settings default post types', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_default_post_purge_settings'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 118 119 if(\Cacholong\Entities\PostType::has_custom()) 120 { 175 \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION, _x('Settings', 'Subtitle for settings section', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_section_settings'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID); 176 177 add_settings_section( 178 \Cacholong\Entities\Identifier::CC_SETTINGS_CRONJOB_SECTION, _x('Cronjob settings', 'Subtitle for cronjob settings section', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_section_settings_cronjob'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID); 179 180 181 //create fields in section CC_SETTINGS_SECTION on options page 182 add_settings_field( 183 \Cacholong\Entities\Identifier::CC_FIELD_HOSTS_FILE, _x('File with hosts (JSON)', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_location_json_hosts_file'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 184 185 add_settings_field( 186 \Cacholong\Entities\Identifier::CC_FIELD_REMOVE_STYLE_ID, _x('Pagespeed optimized CSS', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_remove_style_id'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 187 188 add_settings_field( 189 \Cacholong\Entities\Identifier::CC_FIELD_DEFAULT_POST_PURGE_SETTINGS, _x('Purge settings default post types', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_default_post_purge_settings'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 190 191 if (\Cacholong\Entities\PostType::has_custom()) { 121 192 add_settings_field( 122 \Cacholong\Entities\Identifier::CC_FIELD_CUSTOM_POST_PURGE_SETTINGS, _x('Purge settings custom post type(s)', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_custom_post_purge_settings'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION);193 \Cacholong\Entities\Identifier::CC_FIELD_CUSTOM_POST_PURGE_SETTINGS, _x('Purge settings custom post type(s)', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_custom_post_purge_settings'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION); 123 194 } 195 196 197 //create fields in section CC_SETTINGS_CRONJOB_SECTION on options page 198 add_settings_field( 199 \Cacholong\Entities\Identifier::CC_FIELD_CRON_ENABLED, _x('Cronjob purging', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_cron_enabled'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_CRONJOB_SECTION); 200 201 202 add_settings_field( 203 \Cacholong\Entities\Identifier::CC_FIELD_CRON_TIME, _x('Cronjob time of each day', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_cron_time'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_CRONJOB_SECTION); 204 205 add_settings_field( 206 \Cacholong\Entities\Identifier::CC_FIELDSET_CRON_CACHE_HELPERS, _x('Purge caches', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'render_field_cron_cache_helpers'), \Cacholong\Entities\Identifier::CC_SETTINGS_PAGE_ID, \Cacholong\Entities\Identifier::CC_SETTINGS_CRONJOB_SECTION); 124 207 } 125 208 … … 135 218 * @return void 136 219 */ 137 public static function render_page() 138 { 220 public static function render_page() { 139 221 require(CACHOLONG_VIEW_DIR . '/admin/settings/page/cacholong_cache_control.phtml'); 140 222 } … … 151 233 * @return void 152 234 */ 153 public static function render_section_settings() 154 { 235 public static function render_section_settings() { 155 236 require(CACHOLONG_VIEW_DIR . '/admin/settings/section/cacholong_cache_control_settings.phtml'); 156 237 } 157 238 158 159 /** 239 /** 240 * Render section 'cacholong_cache_control_settings_cronjob' 241 * 242 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 243 * @copyright Cacholong <[email protected]> 244 * @todo ok 245 * 246 * @version 1.0.0 2019-02-19 247 * 248 * @return void 249 */ 250 public static function render_section_settings_cronjob() { 251 require(CACHOLONG_VIEW_DIR . '/admin/settings/section/cacholong_cache_control_settings_cronjob.phtml'); 252 } 253 254 /** 160 255 * Render field 'remove_style_id' 161 256 * … … 168 263 * @return void 169 264 */ 170 public static function render_field_remove_style_id() 171 { 265 public static function render_field_remove_style_id() { 172 266 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/remove_style_id.phtml'); 173 267 } 174 268 175 269 /** 176 270 * Render field 'location_json_hosts_file' … … 184 278 * @return void 185 279 */ 186 public static function render_field_location_json_hosts_file() 187 { 280 public static function render_field_location_json_hosts_file() { 188 281 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/location_json_hosts_file.phtml'); 189 282 } 190 283 191 284 /** 285 * Render field 'cacholong_cc_field_cron_enabled' 286 * 287 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 288 * @copyright Cacholong <[email protected]> 289 * @todo ok 290 * 291 * @version 1.0.0 2019-02-19 292 * 293 * @return void 294 */ 295 public static function render_field_cron_enabled() { 296 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/cron_enabled.phtml'); 297 } 298 299 /** 300 * Render field 'cacholong_cc_field_cron_time' 301 * 302 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 303 * @copyright Cacholong <[email protected]> 304 * @todo ok 305 * 306 * @version 1.0.0 2019-02-19 307 * 308 * @return void 309 */ 310 public static function render_field_cron_time() { 311 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/cron_time.phtml'); 312 } 313 314 /** 315 * Render field 'cacholong_cc_fieldset_cron_cache_helpers' 316 * 317 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 318 * @copyright Cacholong <[email protected]> 319 * @todo ok 320 * 321 * @version 1.0.0 2019-02-19 322 * 323 * @return void 324 */ 325 public static function render_field_cron_cache_helpers() { 326 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/cron_cache_helpers.phtml'); 327 } 328 329 /* Render field 'cc_field_custom_purge_settings' 330 * 331 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 332 * @copyright Cacholong <[email protected]> 333 * @todo ok 334 * 335 * @version 1.0.0 2016-09-07 336 * 337 * @return void 338 */ 339 340 public static function render_field_custom_post_purge_settings() { 341 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/custom_post_purge_settings.phtml'); 342 } 343 344 /** 192 345 * Render field 'cc_field_default_post_purge_settings' 193 346 * … … 200 353 * @return void 201 354 */ 202 public static function render_field_default_post_purge_settings() 203 { 355 public static function render_field_default_post_purge_settings() { 204 356 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/default_post_purge_settings.phtml'); 205 }206 207 /* Render field 'cc_field_custom_purge_settings'208 *209 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong)210 * @copyright Cacholong <[email protected]>211 * @todo ok212 *213 * @version 1.0.0 2016-09-07214 *215 * @return void216 */217 218 public static function render_field_custom_post_purge_settings()219 {220 require(CACHOLONG_VIEW_DIR . '/admin/settings/field/custom_post_purge_settings.phtml');221 357 } 222 358 … … 231 367 * @version 1.1.0 2016-09-07 All purge settings 232 368 * @version 1.2.0 2017-12-15 Added CC_FIELD_REMOVE_STYLE_ID 233 * @ return void234 * /235 public static function register_settings()236 {237 register_setting( 238 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_FIELD_HOSTS_FILE, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_location_json_hosts_file'));239 240 register_setting( 241 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_FIELD_REMOVE_STYLE_ID, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean'));242 369 * @version 1.3.0 2019-02-19 Added cron settings 370 * @return void 371 */ 372 public static function register_settings() { 373 register_setting( 374 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_FIELD_HOSTS_FILE, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_location_json_hosts_file')); 375 376 register_setting( 377 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_FIELD_REMOVE_STYLE_ID, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 378 243 379 //default post types 244 380 register_setting( 245 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_DEFAULT, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean'));246 register_setting( 247 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_HOME, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean'));248 register_setting( 249 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_CATEGORIES_WORDPRESS, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean'));250 register_setting( 251 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_CATEGORIES_WOOCOMMERCE, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean'));252 register_setting( 253 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_FLUSH_ALL, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean'));381 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_DEFAULT, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 382 register_setting( 383 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_HOME, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 384 register_setting( 385 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_CATEGORIES_WORDPRESS, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 386 register_setting( 387 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_CATEGORIES_WOOCOMMERCE, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 388 register_setting( 389 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_DEFAULT_POST_PURGE_SETTINGS_FLUSH_ALL, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 254 390 255 391 //custom post types 256 392 register_setting( 257 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_DEFAULT, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 258 register_setting( 259 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_HOME, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 260 register_setting( 261 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_CATEGORIES_WORDPRESS, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 262 register_setting( 263 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_CATEGORIES_WOOCOMMERCE, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 264 register_setting( 265 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_FLUSH_ALL, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 393 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_DEFAULT, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 394 register_setting( 395 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_HOME, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 396 register_setting( 397 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_CATEGORIES_WORDPRESS, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 398 register_setting( 399 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_CATEGORIES_WOOCOMMERCE, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 400 register_setting( 401 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_FLUSH_ALL, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 402 403 //cronjob settings 404 register_setting( 405 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_FIELD_CRON_ENABLED, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 406 register_setting( 407 \Cacholong\Entities\Identifier::CC_OPTIONS, \Cacholong\Entities\Identifier::CC_FIELD_CRON_TIME, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_hh_mm_24h')); 408 409 $cronCacheSettings = cacholong_cc_get_cron_settings_caches_field_key_and_name(); 410 foreach ($cronCacheSettings as $cronCacheFieldKey => $cronCacheName) { 411 register_setting( 412 \Cacholong\Entities\Identifier::CC_OPTIONS, $cronCacheFieldKey, array('\Cacholong\Controller\Admin\AdminSettingsPageController', 'sanitize_field_boolean')); 413 } 266 414 } 267 415 … … 275 423 * @version 1.0.0 2015-10-26 276 424 * @version 1.0.1 2015-11-02 Replace slashes 425 * @version 1.1.0 2019-02-21 Extra trim + safeguards 277 426 * 278 427 * @param string $unsafeInput Unsafe input for location field … … 280 429 * @return string Sanatized location field 281 430 */ 282 public static function sanitize_field_location_json_hosts_file($unsafeInput) 283 { 284 if($unsafeInput) 285 { 431 public static function sanitize_field_location_json_hosts_file($unsafeInput) { 432 $unsafeInput = trim($unsafeInput); 433 $finalHostsFile = null; 434 435 if ($unsafeInput) { 286 436 $input = str_replace('\\', '/', $unsafeInput); 287 437 $input = ltrim($input, '/'); 288 return $input; 438 $finalHostsFile = $input; 439 } elseif(defined('CACHOLONG_CACHE_DEFAULT_JSON_HOSTS_PATH')) 440 { 441 $finalHostsFile = CACHOLONG_CACHE_DEFAULT_JSON_HOSTS_PATH; 289 442 } 290 else 291 { 292 return CACHOLONG_CACHE_DEFAULT_JSON_HOSTS_PATH; 293 } 443 //else default 444 445 return $finalHostsFile; 294 446 } 295 447 … … 307 459 * @return bool Sanatized boolean field 308 460 */ 309 public static function sanitize_field_boolean($unsafeInput) 310 { 461 public static function sanitize_field_boolean($unsafeInput) { 311 462 $activated = (bool) $unsafeInput; 312 463 return $activated ? '1' : '0'; 313 464 } 314 465 466 /** 467 * Sanitize input for hh mm field (24hour format) 468 * 469 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 470 * @copyright Cacholong <[email protected]> 471 * @todo ok 472 * 473 * @version 1.0.0 2019-02-19 474 * @version 1.1.0 2019-02-20 abstracted to cacholong_cc_sanitize_time_hh_mm_24h() 475 * 476 * @param string $unsafeInput Unsafe input for a hh:mm field 477 * 478 * @return bool Sanatized hh:mm field 479 */ 480 public static function sanitize_field_hh_mm_24h($unsafeInput) { 481 482 return cacholong_cc_sanitize_time_hh_mm_24h($unsafeInput); 483 } 484 315 485 } -
cache-control-by-cacholong/trunk/core/controller/admin/PurgeCacheController.php
r1974788 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control … … 48 48 49 49 /* 50 * @const str omg DEBUG_FAST_CGI_CACHE_PATH Debug fast cgi cache path50 * @const string DEBUG_FAST_CGI_CACHE_PATH Debug fast cgi cache path 51 51 */ 52 52 const DEBUG_FAST_CGI_CACHE_PATH = 'd:/temp/nginx/'; … … 60 60 * 61 61 * @version 1.0.0 Created at 2015-10-21 62 * @version 1.1.0 2019-02-21 Cron cache settings 62 63 * 63 64 */ … … 65 66 do_action('cacholong_cache_control_purge_cache_before_init'); 66 67 68 //purge all / single 67 69 add_action(\Cacholong\Entities\AdminPostAction::get_action_hook_name(\Cacholong\Entities\AdminPostAction::PURGE_ALL), array('\Cacholong\Controller\Admin\PurgeCacheController', 'handle_purge_all_settings_page')); 68 70 add_action(\Cacholong\Entities\AdminPostAction::get_action_hook_name(\Cacholong\Entities\AdminPostAction::PURGE_SINGLE), array('\Cacholong\Controller\Admin\PurgeCacheController', 'handle_purge_single_settings_page')); 71 72 //cron purge hook names 73 $cronCacheKeyAndHooks = cacholong_cc_get_cron_settings_caches_field_key_and_hook_purge_name(); 74 foreach ($cronCacheKeyAndHooks as $cronCacheFieldKey => $cronCacheHookName) { 75 add_action($cronCacheHookName, function() use ($cronCacheHookName) { 76 self::handle_purge_all_specific($cronCacheHookName); 77 }); 78 } 69 79 70 80 do_action('cacholong_cache_control_purge_cache_after_init'); … … 102 112 $purgeCache = new \Cacholong\Libraries\PurgeCache(); 103 113 $purgeCache->handle_purge_all(); 114 } 115 116 /** 117 * Handle purge all request for specific cache 118 * 119 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 120 * @copyright Cacholong <[email protected]> 121 * @todo ok 122 * 123 * @param string $hookPurgeCache Hook name of cache helper 124 * 125 * @return void 126 */ 127 public static function handle_purge_all_specific($hookPurgeCache) { 128 $purgeCache = new \Cacholong\Libraries\PurgeCache(); 129 $purgeCache->handle_purge_all_specific($hookPurgeCache); 104 130 } 105 131 … … 210 236 if ($is_update) { 211 237 //must be an update 212 238 213 239 if (\Cacholong\Entities\PostType::get_purge_is_required($postID)) { 214 240 $post_status = get_post_status($postID); … … 302 328 } 303 329 //else no slug change, donop 304 305 330 //original filter 306 331 return $slug; -
cache-control-by-cacholong/trunk/core/controller/admin/ToolbarController.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control … … 43 43 * @version 1.0.0 2015-10-31 44 44 * @version 1.0.1 2016-02-16 cacholong_cc_get_settings_page_url($queryAction) removed, added current page + query vars + wp_nonce 45 * @version 1.1.0 2019-02-21 ab-icon class added for icon 46 * 47 * @param \WP_Admin_Bar $wpAdminBar Instance of wp_admin_bar 45 48 * @return void 46 49 */ 47 public static function create_toolbar_node_purge_all( $wpAdminBar)50 public static function create_toolbar_node_purge_all(\WP_Admin_Bar $wpAdminBar) 48 51 { 49 52 $queryAction[\Cacholong\Entities\Identifier::CC_REQUEST_ACTION_KEY] = \Cacholong\Entities\Identifier::CC_REQUEST_ACTION_PURGE_ALL_ADMIN_BAR; … … 54 57 $nodeArguments = array( 55 58 'id' => \Cacholong\Entities\Identifier::CC_TOOLBAR_NODE_PURGE_ALL, 56 'title' => __('Purge all caches', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN),59 'title' =>'<span class="ab-icon"></span>' . __('Purge all caches', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), 57 60 'href' => $href 58 61 ); -
cache-control-by-cacholong/trunk/core/designpattern/observer/CacheHelperObserver.php
r1834268 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control … … 164 164 */ 165 165 abstract public function getCacheHelperName(); 166 167 /** 168 * Required get method to get cache helper hook name 169 * 170 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 171 * @copyright Cacholong <[email protected]> 172 * @todo ok 173 * 174 * @version 1.0.0 2019-02-21 175 * 176 * @return string Name of cache helper 177 */ 178 abstract public function getCacheHelperHookName(); 179 180 181 /** 182 * Required get method to get cache helper cron setting cache field key 183 * 184 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 185 * @copyright Cacholong <[email protected]> 186 * @todo ok 187 * 188 * @version 1.0.0 2019-02-19 189 * 190 * @return string cache helper cron setting cache field key 191 */ 192 abstract public function getCacheHelperCronSettingCacheFieldKey(); 166 193 167 194 /** … … 317 344 * @return string $url 318 345 */ 319 public function preparePurgeHostUrl($hostUrl, $relative_path = null) 320 { 346 public function preparePurgeHostUrl($hostUrl, $relative_path = null) { 321 347 //Prepare host (remove http(s) + add relative path) 322 348 $hostUrl = preg_replace('#^https?://#', '', $hostUrl); … … 328 354 $protocol = 'https://'; 329 355 } 330 356 331 357 $hostUrl = $protocol . $hostUrl; 332 358 … … 339 365 return $hostUrl; 340 366 } 367 341 368 } -
cache-control-by-cacholong/trunk/core/designpattern/observer/CacheHelperSubject.php
r1834268 r2036979 1 1 <?php 2 2 3 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 4 5 * 5 6 * This file is part of Cache Control … … 67 68 * @return void 68 69 */ 69 public function __construct() 70 { 70 public function __construct() { 71 71 $this->observers = array(); 72 72 $this->hosts = array(); … … 87 87 * @return void 88 88 */ 89 public function attach(CacheHelperObserver $observer) 90 { 89 public function attach(CacheHelperObserver $observer) { 91 90 //prevent same object observing twice or more 92 91 $i = array_search($observer, $this->observers); 93 if($i === false) 94 { 92 if ($i === false) { 95 93 $this->observers[] = $observer; 96 94 } … … 108 106 * @return void 109 107 */ 110 public function detach(CacheHelperObserver $observer) 111 { 112 if(!empty($this->observers)) 113 { 108 public function detach(CacheHelperObserver $observer) { 109 if (!empty($this->observers)) { 114 110 $index = array_search($observer, $this->observers); 115 if($index !== false) 116 { 111 if ($index !== false) { 117 112 unset($this->observers[$index]); 118 113 } … … 131 126 * @return array Array of CacheHelperObserver objects or empty array 132 127 */ 133 public function getObservers() 134 { 128 public function getObservers() { 135 129 return $this->observers; 136 130 } … … 148 142 * @return void 149 143 */ 150 public function notifyPurgeAllRequest() 151 { 144 public function notifyPurgeAllRequest() { 152 145 $this->notify($this, 'purgeAll'); 153 146 $this->handlePurgeResults(); … … 166 159 * @return void 167 160 */ 168 public function notifyPurgeSingleRequest() 169 { 161 public function notifyPurgeSingleRequest() { 170 162 $this->notify($this, 'purgeSingleURL'); 171 163 $this->handlePurgeResults(); … … 183 175 * @return void 184 176 */ 185 public function notifyPurgeMultipleRequest() 186 { 177 public function notifyPurgeMultipleRequest() { 187 178 $this->notify($this, 'purgeMultipleURL'); 188 179 $this->handlePurgeResults(); … … 205 196 * @return void 206 197 */ 207 private function handlePurgeResults() 208 { 198 private function handlePurgeResults() { 209 199 $purgeResults = $this->notify($this, 'getPurgeResults', true); 210 200 … … 212 202 //Content of purgeResults -> [$adminNoticeClass][$cacheHelperName]['flushDelayPossible'] = bool 213 203 214 foreach ($purgeResults as $adminNoticeClass => $cacheHelpers) 215 { 204 foreach ($purgeResults as $adminNoticeClass => $cacheHelpers) { 216 205 //cache helper sentences 217 206 $cacheHelperSentences = array(); … … 220 209 $flushDelayPossible = false; 221 210 222 foreach ($cacheHelpers as $cacheHelper => $cacheHelperResult) 223 { 211 foreach ($cacheHelpers as $cacheHelper => $cacheHelperResult) { 224 212 //host information per cache helper 225 213 $hostNames = array_keys($cacheHelperResult['hosts']); … … 228 216 $suffix = '</b>'; 229 217 230 if($hostNames[0] == CacheHelperObserver::ALL_HOSTS && count($hostNames) == 1) 231 { 218 if ($hostNames[0] == CacheHelperObserver::ALL_HOSTS && count($hostNames) == 1) { 232 219 $hostNamesSentence = $prefix . __("all hosts", \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN) . $suffix; 233 } 234 else 235 { 220 } else { 236 221 $hostNamesSentence = cacholong_cc_itemlist_to_sentence($hostNames, $prefix, $suffix); 237 222 } … … 248 233 $finalCacheHelperSentence = cacholong_cc_itemlist_to_sentence($cacheHelperSentences); 249 234 250 switch ($adminNoticeClass) 251 { 235 switch ($adminNoticeClass) { 252 236 case AdminNoticeClass::SUCCESS: //ok 253 237 $message = sprintf(__("Succesfully purged %s.", \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), $finalCacheHelperSentence); 254 238 255 if($flushDelayPossible) 256 { 239 if ($flushDelayPossible) { 257 240 $message .= ' ' . __("It could take a few minutes to be visible at the frontend.", \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN); 258 241 } 259 242 260 if(is_admin()) 261 { 243 if (is_admin()) { 262 244 AdminMessage::set_message($message, AdminNoticeClass::SUCCESS, true); 263 } 264 else 265 { 245 } else { 266 246 cacholong_cc_log_error($message); 267 247 } … … 270 250 $message = sprintf(__("Failed to purge %s.", \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), $finalCacheHelperSentence); 271 251 272 if(is_admin()) 273 { 252 if (is_admin()) { 274 253 AdminMessage::set_message($message, AdminNoticeClass::ERROR, true); 275 } 276 else 277 { 254 } else { 278 255 cacholong_cc_log_error($message); 279 256 } … … 302 279 * @return mixed Array with result of $customMethod or nothing (void) 303 280 */ 304 private function notify($subject, $customMethod, $returnResult = false) 305 { 281 private function notify($subject, $customMethod, $returnResult = false) { 306 282 $result = array(); 307 283 308 if(!empty($this->observers)) 309 { 310 foreach ($this->observers as $observer) 311 { 312 if(!empty($customMethod) && method_exists($observer, $customMethod)) 313 { 314 if($returnResult) 315 { 284 if (!empty($this->observers)) { 285 foreach ($this->observers as $observer) { 286 if (!empty($customMethod) && method_exists($observer, $customMethod)) { 287 if ($returnResult) { 316 288 $observerResult = $observer->$customMethod($subject); 317 289 $result = array_merge_recursive($result, $observerResult); //will merge all non-numeric keys 318 } 319 else 320 { 290 } else { 321 291 $observer->$customMethod($subject); 322 292 } 323 } 324 else 325 { 293 } else { 326 294 $observer_name = get_class($observer); 327 295 cacholong_cc_log_exception( 328 new \Exception(329 sprintf(330 _x("Custom method '%s' does not exist in observer class '%s'.", 'Internal exception message', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), $customMethod, $observer_name)331 )296 new \Exception( 297 sprintf( 298 _x("Custom method '%s' does not exist in observer class '%s'.", 'Internal exception message', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN), $customMethod, $observer_name) 299 ) 332 300 ); 333 301 } 334 302 } 335 303 336 if($returnResult) 337 { 304 if ($returnResult) { 338 305 return $result; 339 306 } … … 353 320 * @return void 354 321 */ 355 public function set_hosts_info($hosts) 356 { 357 if(is_array($hosts)) 358 { 322 public function set_hosts_info($hosts) { 323 if (is_array($hosts)) { 359 324 $this->hosts = $hosts; 360 325 } … … 372 337 * @return array Array of hosts info 373 338 */ 374 public function get_hosts_info() 375 { 339 public function get_hosts_info() { 376 340 return $this->hosts; 377 341 } … … 389 353 * @return void 390 354 */ 391 public function set_single_relative_path_url($path) 392 { 355 public function set_single_relative_path_url($path) { 393 356 $path = ltrim($path, '/'); 394 357 $this->relative_path = $path; … … 407 370 * @return string Relative url path 408 371 */ 409 public function get_single_relative_path_url() 410 { 372 public function get_single_relative_path_url() { 411 373 return $this->relative_path; 412 374 } … … 425 387 * @return void 426 388 */ 427 public function set_multiple_relative_path_urls($paths) 428 { 389 public function set_multiple_relative_path_urls($paths) { 429 390 $relative_paths = is_array($paths) ? $paths : (array) $paths; 430 array_walk($relative_paths, function(&$single_path) 431 { 391 array_walk($relative_paths, function(&$single_path) { 432 392 $single_path = ltrim($single_path, '/'); 433 393 }); … … 447 407 * @return array Multiple relative url paths 448 408 */ 449 public function get_multiple_relative_path_urls() 450 { 409 public function get_multiple_relative_path_urls() { 451 410 return $this->relative_paths; 452 411 } 453 412 413 /** 414 * Get cron settings field key for cache helper and cache helper name 415 * 416 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 417 * @copyright Cacholong <[email protected]> 418 * @todo ok 419 * 420 * @version 1.0.0 2019-02-20 421 * 422 * @return array Multiple relative url paths 423 */ 424 public function getCronSettingsFieldKeyAndName() { 425 $cronSettings = array(); 426 $observers = $this->getObservers(); 427 428 foreach ($observers as $observer) { 429 $key = \Cacholong\Entities\Identifier::CC_FIELD_CRON_CACHE_PREFIX . $observer->getCacheHelperCronSettingCacheFieldKey(); 430 $name = $observer->getCacheHelperName(); 431 $cronSettings[$key] = $name; 432 } 433 return $cronSettings; 434 } 435 436 /** 437 * Get cron settings field key for cache helper and cache helper hook purge name 438 * 439 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 440 * @copyright Cacholong <[email protected]> 441 * @todo ok 442 * 443 * @version 1.0.0 2019-02-21 444 * 445 * @return array Multiple relative url paths 446 */ 447 public function getCronSettingsFieldKeyAndHookPurgeName() { 448 $cronSettings = array(); 449 $observers = $this->getObservers(); 450 451 foreach ($observers as $observer) { 452 $key = \Cacholong\Entities\Identifier::CC_FIELD_CRON_CACHE_PREFIX . $observer->getCacheHelperCronSettingCacheFieldKey(); 453 $hookName = \Cacholong\Entities\Identifier::CC_HOOK_CRON_PURGE_CACHE_PREFIX . $observer->getCacheHelperHookName(); 454 $cronSettings[$key] = $hookName; 455 } 456 return $cronSettings; 457 } 458 454 459 } -
cache-control-by-cacholong/trunk/core/designpattern/observer/NginxFastCGICacheHelperObserver.php
r1834268 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control … … 45 45 46 46 /* 47 * @const string Cron setting field key for this cache helper 48 */ 49 const CACHE_HELPER_CRON_SETTING_CACHE_FIELD_KEY = 'cron_fastCGI'; 50 51 /* 52 * @const string Hook name for this cache helper (only use hook valid chars) 53 */ 54 const CACHE_HELPER_HOOK_NAME = 'fastCGI'; 55 56 /* 47 57 * @const bool Cache flush could be delayed (true) or not (false) 48 58 */ … … 77 87 public function getCacheHelperName() { 78 88 return self::CACHE_HELPER_NAME; 89 } 90 91 /** 92 * Get cache helper hook name 93 * 94 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 95 * @copyright Cacholong <[email protected]> 96 * @todo ok 97 * 98 * @version 1.0.0 2016-09-09 99 * 100 * @return string Name of hook for cache helper 101 */ 102 public function getCacheHelperHookName() { 103 return self::CACHE_HELPER_HOOK_NAME; 104 } 105 106 /** 107 * Get cache helper cron setting cache field key 108 * 109 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 110 * @copyright Cacholong <[email protected]> 111 * @todo ok 112 * 113 * @version 1.0.0 2019-02-19 114 * 115 * @return string cache helper cron setting cache field key 116 */ 117 public function getCacheHelperCronSettingCacheFieldKey() { 118 return self::CACHE_HELPER_CRON_SETTING_CACHE_FIELD_KEY; 79 119 } 80 120 … … 177 217 $relative_path = self::PURGE_PREFIX_RELATIVE_URL . '/' . $subject->get_single_relative_path_url(); 178 218 179 $httpApiRequestOptions[HttpApiRequest::HTTP_METHOD] = HttpApiRequest::HTTP_METHOD_GET; 219 $httpApiRequestOptions[HttpApiRequest::HTTP_METHOD] = HttpApiRequest::HTTP_METHOD_GET; 180 220 $result = $this->purge($hosts_info, $relative_path, $httpApiRequestOptions); 181 221 … … 213 253 $default_options[HttpApiRequest::TIME_OUT] = self::HTTP_API_TIMEOUT; 214 254 $default_options[HttpApiRequest::SSL_VERIFY] = false; //Disabled to prevent issues with malformed SSL certificates in (shared) hosting environments 215 216 255 //which identical keys $options array overrules default 217 256 $final_options = $httpApiRequestOptions + $default_options; -
cache-control-by-cacholong/trunk/core/designpattern/observer/NginxPageSpeedCacheHelperObserver.php
r1834268 r2036979 1 1 <?php 2 2 3 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 4 5 * 5 6 * This file is part of Cache Control … … 44 45 45 46 /* 47 * @const string Cron setting field key for this cache helper 48 */ 49 const CACHE_HELPER_CRON_SETTING_CACHE_FIELD_KEY = 'cron_pagespeed'; 50 51 /* 52 * @const string Hook name for this cache helper (only use hook valid chars) 53 */ 54 const CACHE_HELPER_HOOK_NAME = 'pagespeed'; 55 56 57 /* 46 58 * @const bool Cache flush could be delayed (true) or not (false) 47 59 */ … … 69 81 * @return string Name of cache helper 70 82 */ 71 72 public function getCacheHelperName() 73 { 83 public function getCacheHelperName() { 74 84 return self::CACHE_HELPER_NAME; 75 85 } 76 86 77 /** 87 /** 88 * Get cache helper hook name 89 * 90 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 91 * @copyright Cacholong <[email protected]> 92 * @todo ok 93 * 94 * @version 1.0.0 2016-09-09 95 * 96 * @return string Name of hook for cache helper 97 */ 98 public function getCacheHelperHookName() { 99 return self::CACHE_HELPER_HOOK_NAME; 100 } 101 102 /** 103 * Get cache helper cron setting cache field key 104 * 105 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 106 * @copyright Cacholong <[email protected]> 107 * @todo ok 108 * 109 * @version 1.0.0 2019-02-19 110 * 111 * @return string cache helper cron setting cache field key 112 */ 113 public function getCacheHelperCronSettingCacheFieldKey() { 114 return self::CACHE_HELPER_CRON_SETTING_CACHE_FIELD_KEY; 115 } 116 117 /** 78 118 * Get cache flush could be delayed switch 79 119 * … … 86 126 * @return bool Cache flush could be delayed (true) or not (false) 87 127 */ 88 public function getFlushCouldBeDelayed() 89 { 128 public function getFlushCouldBeDelayed() { 90 129 return self::CACHE_FLUSH_COULD_BE_DELAYED; 91 130 } … … 108 147 * @return void 109 148 */ 110 public function purgeAll($subject) 111 { 149 public function purgeAll($subject) { 112 150 $hosts_info = $subject->get_hosts_info(); 113 151 $purge_all_suffix = '*'; … … 134 172 * @return void 135 173 */ 136 public function purgeSingleURL($subject) 137 { 174 public function purgeSingleURL($subject) { 138 175 $hosts_info = $subject->get_hosts_info(); 139 176 $relative_path = $subject->get_single_relative_path_url(); … … 159 196 * @return void 160 197 */ 161 public function purgeMultipleURL($subject) 162 { 198 public function purgeMultipleURL($subject) { 163 199 $hosts_info = $subject->get_hosts_info(); 164 200 $relative_paths = $subject->get_multiple_relative_path_urls(); 165 201 166 if(is_array($relative_paths) && $relative_paths) 167 { 168 foreach ($relative_paths as $relative_path) 169 { 202 if (is_array($relative_paths) && $relative_paths) { 203 foreach ($relative_paths as $relative_path) { 170 204 $result = $this->purge($hosts_info, $relative_path); 171 205 $this->handlePurgeResult($hosts_info, $result, $this->get_http_response_codes_success(), $relative_path, \Cacholong\Libraries\Hosts::NGINX_PAGESPEED_KEY); … … 196 230 * @return array Original key as key, value true (succes) or false (failure). 197 231 */ 198 private function purge($hosts_info, $relative_path = null, $httpApiRequestOptions = array()) 199 { 232 private function purge($hosts_info, $relative_path = null, $httpApiRequestOptions = array()) { 200 233 $result = array(); 201 234 … … 204 237 $default_options[HttpApiRequest::SSL_VERIFY] = false; //Disabled to prevent issues with malformed SSL certificates in (shared) hosting environments 205 238 $default_options[HttpApiRequest::HTTP_METHOD] = HttpApiRequest::HTTP_METHOD_PURGE; 206 239 207 240 //which identical keys $options array overrules default 208 241 $final_options = $httpApiRequestOptions + $default_options; 209 242 210 foreach ($hosts_info as $key => $host) 211 { 212 if($host[\Cacholong\Libraries\Hosts::NGINX_PAGESPEED_KEY]) 213 { 243 foreach ($hosts_info as $key => $host) { 244 if ($host[\Cacholong\Libraries\Hosts::NGINX_PAGESPEED_KEY]) { 214 245 $purgeHost = $this->preparePurgeHostUrl($host[\Cacholong\Libraries\Hosts::HOST_KEY], $relative_path); 215 246 $result[$key] = \Cacholong\Libraries\HttpApiRequest::execute($purgeHost, $final_options); … … 232 263 * @return array HTTP response codes 233 264 */ 234 private function get_http_response_codes_success() 235 { 265 private function get_http_response_codes_success() { 236 266 $httpResponseCode[] = self::HTTP_RESPONSE_CODE_PURGE_SUCCESS; 237 267 -
cache-control-by-cacholong/trunk/core/entities/AdminNoticeClass.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/entities/AdminPostAction.php
r1834268 r2036979 1 1 <?php 2 2 3 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 4 5 * 5 6 * This file is part of Cache Control … … 33 34 34 35 const WORDPRESS_ADMIN_POST_ACTION_PREFIX = 'admin_post_'; 35 36 36 const PURGE_ALL = 'purge_all'; 37 37 const PURGE_SINGLE = 'purge_single'; … … 48 48 * @return string Action hook 49 49 */ 50 public static function get_action_hook_name($action) 51 { 50 public static function get_action_hook_name($action) { 52 51 return self::WORDPRESS_ADMIN_POST_ACTION_PREFIX . $action; 53 52 } 54 53 55 54 } 55 56 56 /* End of file AdminPostAction.php */ -
cache-control-by-cacholong/trunk/core/entities/AjaxResponseType.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/entities/HttpApiRequest.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/entities/Identifier.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control … … 34 34 * @version 1.1.0 2016-09-07 Added ID's 35 35 * @version 1.2.0 2018-02-23 All values > prefix from cc_ to cacholong_cc_ 36 * @version 1.3.0 2019-02-19 Cron fields 37 * 36 38 */ 37 39 abstract class Identifier { … … 43 45 const CC_SETTINGS_PAGE_ID = 'cacholong-cache-control-settings-page'; //also visible in url 44 46 const CC_SETTINGS_SECTION = 'cacholong_cc_settings_section'; 47 const CC_SETTINGS_CRONJOB_SECTION = 'cacholong_cc_settings_cronjob_section'; 45 48 const CC_SETTINGS_SECTION_FORM_ID = 'cacholong_cc_settings_form'; 46 49 … … 54 57 const CC_FIELD_CUSTOM_POST_PURGE_SETTINGS = 'cacholong_cc_field_custom_purge_settings'; //field name used in javascript 55 58 const CC_FIELD_REMOVE_STYLE_ID = 'cacholong_cc_field_remove_style_id'; 59 const CC_FIELD_CRON_ENABLED = 'cacholong_cc_field_cron_enabled'; 60 const CC_FIELD_CRON_TIME = 'cacholong_cc_field_cron_time'; 61 const CC_FIELD_CRON_CACHE_PREFIX = 'cacholong_cc_field_'; 62 const CC_HOOK_CRON_PURGE_CACHE_PREFIX = 'cacholong_cc_purge_'; 56 63 57 64 //fieldsets 58 const CC_FIELDSET_DEFAULT_POST_PURGE_SETTINGS = 'cacholong_cc_fieldset_default_purge_settings'; //field name used in javascript 59 const CC_FIELDSET_CUSTOM_POST_PURGE_SETTINGS = 'cacholong_cc_fieldset_custom_purge_settings'; //field name used in javascript 65 const CC_FIELDSET_DEFAULT_POST_PURGE_SETTINGS = 'cacholong_cc_fieldset_default_purge_settings'; //field name used in javascript 66 const CC_FIELDSET_CUSTOM_POST_PURGE_SETTINGS = 'cacholong_cc_fieldset_custom_purge_settings'; //field name used in javascript 67 const CC_FIELDSET_CRON_CACHE_HELPERS = 'cacholong_cc_fieldset_cron_cache_helpers'; 60 68 61 69 //Radio options for default post purge settings … … 88 96 //ajax actions 89 97 const CC_AJAX_ACTION_GET_MESSAGES = 'cacholong_cc_action_get_messages'; //note: do not use wp_ajax_ prefix here 98 99 const DEFAULT_DATETIME = 'Y-m-d H:i:s'; 100 101 //Regex for time of day (24H) 102 const TIME_OF_DAY_24H_REGEX = '/^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/'; 103 104 const WORDPRESS_PLUGIN_PATH = 'https://wordpress.org/plugins/cache-control-by-cacholong'; 105 const WORDPRESS_PLUGIN_PATH_FAQ = 'https://wordpress.org/plugins/cache-control-by-cacholong#faq-header'; 90 106 } 91 107 /* End of file Identifier.php */ -
cache-control-by-cacholong/trunk/core/entities/PostType.php
r1974788 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/AdminMessage.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/CacholongCacheControlSetup.php
r1834268 r2036979 1 1 <?php 2 2 3 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 4 5 * 5 6 * This file is part of Cache Control … … 18 19 * along with Cache Control. If not, see <http://www.gnu.org/licenses/>. 19 20 */ 21 20 22 namespace Cacholong\Libraries; 21 23 … … 46 48 * @version 1.2.0 2016-09-09 Bugfix: nonce check created are you sure question that got you nowhere in some cases. Removed. 47 49 * @version 1.3.0 2017-12-15 Added CC_FIELD_REMOVE_STYLE_ID 50 * @version 1.4.0 2019-02-19 Added cron settings 51 * @version 1.4.1 2019-02-21 Default value cache fields 0 -> 1 48 52 */ 49 public static function on_activation() 50 { 53 public static function on_activation() { 51 54 //security 52 if(!current_user_can('activate_plugins')) 53 { 55 if (!current_user_can('activate_plugins')) { 54 56 wp_die(__('You are not allowed to access this part of the site.', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN)); 55 57 } … … 70 72 add_option(\Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_CATEGORIES_WOOCOMMERCE, 0); 71 73 add_option(\Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_FLUSH_ALL, 0); 74 75 add_option(\Cacholong\Entities\Identifier::CC_FIELD_CRON_ENABLED, 0); 76 add_option(\Cacholong\Entities\Identifier::CC_FIELD_CRON_TIME, '00:00'); 77 78 $cronCacheSettings = cacholong_cc_get_cron_settings_caches_field_key_and_name(); 79 foreach ($cronCacheSettings as $cronCacheFieldKey => $cronCacheName) { 80 add_option($cronCacheFieldKey, 1); 81 } 72 82 } 73 83 … … 81 91 * @version 1.0.0 Created at 2015-10-21 82 92 */ 83 public static function on_deactivation() 84 { 93 public static function on_deactivation() { 85 94 86 95 } … … 98 107 * @version 1.2.0 2017-12-15 Added CC_FIELD_REMOVE_STYLE_ID 99 108 * @version 1.3.0 2017-12-21 Removed check_admin_referer('bulk-plugins') + Also remove possible leftover flashData 109 * @version 1.4.0 2019-02-19 Added cron settings 100 110 * 101 111 */ 102 public static function on_uninstall() 103 { 104 if(current_user_can('install_plugins')) 105 { 112 public static function on_uninstall() { 113 if (current_user_can('install_plugins')) { 106 114 delete_option(\Cacholong\Entities\Identifier::CC_FIELD_HOSTS_FILE); 107 115 … … 119 127 delete_option(\Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_CATEGORIES_WOOCOMMERCE); 120 128 delete_option(\Cacholong\Entities\Identifier::CC_CUSTOM_POST_PURGE_SETTINGS_FLUSH_ALL); 121 129 130 delete_option(\Cacholong\Entities\Identifier::CC_FIELD_CRON_ENABLED); 131 delete_option(\Cacholong\Entities\Identifier::CC_FIELD_CRON_TIME); 132 133 $cronCacheSettings = cacholong_cc_get_cron_settings_caches_field_key_and_name(); 134 foreach ($cronCacheSettings as $cronCacheFieldKey => $cronCacheName) { 135 delete_option($cronCacheFieldKey, 0); 136 } 137 122 138 //remove possible leftover flashData 123 139 \Cacholong\Libraries\FlashData::delete_all_flash_data(); 124 } 125 else 126 { 140 } else { 127 141 wp_die(__('You are not allowed to access this part of the site.', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN)); 128 142 } -
cache-control-by-cacholong/trunk/core/libraries/File.php
r1834268 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/FlashData.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/Helpers.php
r1974788 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control … … 321 321 322 322 /** 323 * Get cron settings cache(s) field key and name 324 * 325 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 326 * @copyright Cacholong <[email protected]> 327 * @todo ok 328 * 329 * @version 1.0.0 2019-02-19 Original 330 * 331 * @return array 332 */ 333 function cacholong_cc_get_cron_settings_caches_field_key_and_name() { 334 $purgeCache = new \Cacholong\Libraries\PurgeCache(); 335 return $purgeCache->getCronSettingsFieldKeyAndName(); 336 } 337 338 /** 339 * Get cron settings cache(s) field key and hook purge name 340 * 341 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 342 * @copyright Cacholong <[email protected]> 343 * @todo ok 344 * 345 * @version 1.0.0 2019-02-21 Original 346 * 347 * @return array 348 */ 349 function cacholong_cc_get_cron_settings_caches_field_key_and_hook_purge_name() { 350 $purgeCache = new \Cacholong\Libraries\PurgeCache(); 351 return $purgeCache->getCronSettingsFieldKeyAndHookPurgeName(); 352 } 353 354 /** 355 * Returns guaranteed string with hh:mm (24hour format) format or null in case of invalid input. 356 * 357 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 358 * @copyright Cacholong <[email protected]> 359 * @todo ok 360 * 361 * @version 1.0.0 2019-02-19 362 * 363 * @param string $unsafeInput Unsafe input for a hh:mm field 364 * 365 * @return string|null Sanatized hh:mm field or null if not valid format. 366 */ 367 function cacholong_cc_sanitize_time_hh_mm_24h($unsafeInput) { 368 369 $sanitizedHHMM = null; 370 $unsafeInput = trim($unsafeInput); 371 372 if (preg_match(Cacholong\Entities\Identifier::TIME_OF_DAY_24H_REGEX, $unsafeInput) == 1) { 373 $sanitizedHHMM = $unsafeInput; 374 } 375 376 return $sanitizedHHMM; 377 } 378 379 /** 380 * Returns option cron time (from db) 381 * Note: because of sanitazion safe. 382 * 383 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 384 * @copyright Cacholong <[email protected]> 385 * @todo ok 386 * 387 * @version 1.0.0 2019-02-20 388 * 389 * @return string Cron time or 00:00 (if was empty) 390 */ 391 function cacholong_cc_get_option_cron_time() { 392 $value = get_option(\Cacholong\Entities\Identifier::CC_FIELD_CRON_TIME); 393 return empty($value) ? '00:00' : $value; 394 } 395 396 /** 397 * Get cron options for purge caches 398 * 399 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 400 * @copyright Cacholong <[email protected]> 401 * @todo ok 402 * 403 * @version 1.0.0 2019-02-19 Original 404 * 405 * @return array Key of setting and value of setting 406 */ 407 function cacholong_cc_get_options_cron_caches() { 408 $cronOptions = array(); 409 410 $cronCacheSettings = cacholong_cc_get_cron_settings_caches_field_key_and_name(); 411 foreach ($cronCacheSettings as $cronCacheFieldKey => $cronCacheName) { 412 $cronOptions[$cronCacheFieldKey] = get_option($cronCacheFieldKey); 413 } 414 415 return $cronOptions; 416 } 417 418 /** 419 * Get current used timezone (wordpress or php fallback) 420 * 421 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 422 * @copyright Cacholong <[email protected]> 423 * @todo ok 424 * 425 * @version 1.0.0 2019-02-22 Original 426 * 427 * @return string valid timezone 428 */ 429 function cacholong_cc_get_timezone() { 430 $wordpressTimeZone = get_option('timezone_string'); 431 return $wordpressTimeZone ? $wordpressTimeZone : date_default_timezone_get(); 432 } 433 434 /** 323 435 * Does woocommerce exist? 324 436 * -
cache-control-by-cacholong/trunk/core/libraries/Hosts.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control … … 82 82 { 83 83 $fileContent = self::read_file($locationHostsFile, $isFilePath); 84 if($fileContent !== FALSE )84 if($fileContent !== FALSE && $fileContent) 85 85 { 86 86 return self::convert_json_hosts_to_array($fileContent); … … 142 142 * 143 143 * @version 1.0.0 2015-11-02 144 * 145 * @param string $JSON JSON string 144 146 * 145 147 * @return array|false Array with information about hosts or false in case of error -
cache-control-by-cacholong/trunk/core/libraries/HttpApiRequest.php
r1834268 r2036979 2 2 3 3 /** 4 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 5 5 * 6 6 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/Json.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control … … 30 30 * 31 31 * @version 1.0.0 2011-06-09 32 * @version 1.0.1 2015-10-28 Adjusted for Cach along32 * @version 1.0.1 2015-10-28 Adjusted for Cacholong 33 33 */ 34 34 class Json { -
cache-control-by-cacholong/trunk/core/libraries/PurgeCache.php
r1834268 r2036979 1 1 <?php 2 2 3 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>4 * Copyright © 2015-2019, Cacholong <[email protected]> 4 5 * 5 6 * This file is part of Cache Control … … 65 66 * @return void 66 67 */ 67 public function __construct() 68 { 68 public function __construct() { 69 69 70 70 } … … 81 81 * @return void 82 82 */ 83 public function handle_purge_all() 84 { 83 public function handle_purge_all() { 85 84 $this->start_purge_all(); 85 } 86 87 /** 88 * Handle purge all request for specific cache 89 * 90 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 91 * @copyright Cacholong <[email protected]> 92 * @todo ok 93 * 94 * @version 1.0.0 2019-02-21 95 * 96 * @param string $hookPurgeCache Hook name of cache helper 97 * 98 * @return void 99 */ 100 public function handle_purge_all_specific($hookPurgeCache) { 101 try { 102 $hosts = $this->get_hosts(); 103 if (is_array($hosts)) { 104 $this->cacheHelperSubject = new \Cacholong\Designpattern\Observer\CacheHelperSubject(); 105 $this->cacheHelperSubject->set_hosts_info($hosts); 106 107 $this->create_all_observers($this->cacheHelperSubject); 108 109 foreach ($this->cacheHelperObservers as $cacheHelperObserver) { 110 $cacheHelperObserverHookName = \Cacholong\Entities\Identifier::CC_HOOK_CRON_PURGE_CACHE_PREFIX . $cacheHelperObserver->getCacheHelperHookName(); 111 112 if ($hookPurgeCache == $cacheHelperObserverHookName) { 113 $cacheHelperObserver->purgeAll($this->cacheHelperSubject); 114 break; 115 } 116 } 117 } 118 //else do nop 119 } catch (\Exception $ex) { 120 cacholong_cc_log_exception($ex); 121 } 86 122 } 87 123 … … 101 137 * @return void 102 138 */ 103 public function handle_purge_single($relative_path) 104 { 139 public function handle_purge_single($relative_path) { 105 140 $postId = url_to_postid($relative_path); 106 141 107 if($postId !== 0) 108 { 142 if ($postId !== 0) { 109 143 $postType = get_post_type($postId); 110 144 $postTypeIsDefault = \Cacholong\Entities\PostType::is_wordpress_default_type($postType); 111 145 112 146 //Create correct purgeSetting object 113 if($postTypeIsDefault) 114 { 147 if ($postTypeIsDefault) { 115 148 $purgeSetting = new \Cacholong\Libraries\PurgeSetting\DefaultPostPurgeSetting(); 116 } 117 else 118 { 149 } else { 119 150 $purgeSetting = new \Cacholong\Libraries\PurgeSetting\CustomPostPurgeSetting(); 120 151 } … … 128 159 129 160 //Decide which purge fits 130 if($purgeSettingFlushAll && !($purgeSettingDefault || $purgeSettingHome || $purgeSettingCategoriesWordpress || $purgeSettingCategoriesWoocommerce)) //ok 131 { 161 if ($purgeSettingFlushAll && !($purgeSettingDefault || $purgeSettingHome || $purgeSettingCategoriesWordpress || $purgeSettingCategoriesWoocommerce)) { //ok 132 162 //perform complete flush 133 163 $this->start_purge_all(); 134 } 135 elseif($purgeSettingDefault && !($purgeSettingHome || $purgeSettingCategoriesWordpress || $purgeSettingCategoriesWoocommerce || $purgeSettingFlushAll )) //ok 136 { 164 } elseif ($purgeSettingDefault && !($purgeSettingHome || $purgeSettingCategoriesWordpress || $purgeSettingCategoriesWoocommerce || $purgeSettingFlushAll )) { //ok 137 165 //perform single purge 138 166 $this->start_purge_single($relative_path); 139 } 140 else 141 { 167 } else { 142 168 $multipleUrls = array(); 143 169 144 170 //perform multiple purge 145 if($purgeSettingDefault) //ok 146 { 171 if ($purgeSettingDefault) { //ok 147 172 $multipleUrls[] = $relative_path; 148 173 } 149 174 150 if($purgeSettingHome) //ok 151 { 175 if ($purgeSettingHome) { //ok 152 176 $multipleUrls[] = WordpressURL::get_home(); 153 177 } 154 178 155 if($purgeSettingCategoriesWordpress) //ok 156 { 179 if ($purgeSettingCategoriesWordpress) { //ok 157 180 $categoriesWordpress = WordpressURL::get_wordpress_categories_all($postId); 158 181 $multipleUrls = array_merge($multipleUrls, $categoriesWordpress); 159 182 } 160 183 161 if($purgeSettingCategoriesWoocommerce) 162 { 184 if ($purgeSettingCategoriesWoocommerce) { 163 185 $categoriesWoocommerce = WordpressURL::get_woocommerce_categories(); 164 186 $multipleUrls = array_merge($multipleUrls, $categoriesWoocommerce); … … 167 189 $this->start_purge_multiple($multipleUrls); 168 190 } 169 } 170 else //ok 171 { 191 } else { //ok 172 192 // scenarios: 173 193 // - url has changed -> there is no post attached anymore -> nothing needs to happen -> ok … … 187 207 * @version 1.0.1 2015-11-10 Also url 188 208 * @version 1.0.2 2016-01-04 Bugfix with empty. Before php 5.5 empty does not work with temp result from function. 209 * @version 1.0.3 2019-02-21 Extra check on empty hosts file field 189 210 * 190 211 * @return array|false Array of hosts or false in case of error 191 212 */ 192 private function get_hosts() 193 { 213 private function get_hosts() { 194 214 $pathToHostsFile = get_option(\Cacholong\Entities\Identifier::CC_FIELD_HOSTS_FILE); 195 215 $hosts = false; 196 216 197 if(parse_url($pathToHostsFile, PHP_URL_SCHEME) && parse_url($pathToHostsFile, PHP_URL_HOST)) 198 { 199 //url 200 $fullPathHostsFile = $pathToHostsFile; 201 $hosts = \Cacholong\Libraries\Hosts::get_hosts($fullPathHostsFile, false); 202 } 203 else 204 { 205 //file path 206 $fullPathHostsFile = get_home_path() . "{$pathToHostsFile}"; 207 $hosts = \Cacholong\Libraries\Hosts::get_hosts($fullPathHostsFile, true); 208 } 209 217 if ($pathToHostsFile) { 218 if (parse_url($pathToHostsFile, PHP_URL_SCHEME) && parse_url($pathToHostsFile, PHP_URL_HOST)) { 219 //url 220 $fullPathHostsFile = $pathToHostsFile; 221 $hosts = \Cacholong\Libraries\Hosts::get_hosts($fullPathHostsFile, false); 222 } else { 223 //file path 224 $fullPathHostsFile = get_home_path() . "{$pathToHostsFile}"; 225 $hosts = \Cacholong\Libraries\Hosts::get_hosts($fullPathHostsFile, true); 226 } 227 } 228 210 229 return $hosts; 211 230 } … … 222 241 * @return string|null Relative path or null when not present / error 223 242 */ 224 public function get_relative_path_from_form_field() 225 { 226 if(isset($_POST[\Cacholong\Entities\Identifier::CC_FIELD_SINGLE_PURGE]) && 227 !empty($_POST[\Cacholong\Entities\Identifier::CC_FIELD_SINGLE_PURGE])) 228 { 243 public function get_relative_path_from_form_field() { 244 if (isset($_POST[\Cacholong\Entities\Identifier::CC_FIELD_SINGLE_PURGE]) && 245 !empty($_POST[\Cacholong\Entities\Identifier::CC_FIELD_SINGLE_PURGE])) { 229 246 $unsafeSingleField = $_POST[\Cacholong\Entities\Identifier::CC_FIELD_SINGLE_PURGE]; 230 247 $unsafeSingleField = htmlspecialchars($unsafeSingleField); … … 232 249 $singleField = trim($unsafeSingleField); 233 250 return $singleField; 234 } 235 else 236 { 251 } else { 237 252 return null; 253 } 254 } 255 256 /** 257 * Get cron settings field key and name 258 * 259 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 260 * @copyright Cacholong <[email protected]> 261 * @todo ok 262 * 263 * @version 1.0.0 2019-02-19 264 * 265 * @return array Array of cron settings. Key is cache helper cron setting name, value is cache helper name. 266 */ 267 public function getCronSettingsFieldKeyAndName() { 268 try { 269 $this->cacheHelperSubject = new \Cacholong\Designpattern\Observer\CacheHelperSubject(); 270 $this->create_all_observers($this->cacheHelperSubject); 271 return $this->cacheHelperSubject->getCronSettingsFieldKeyAndName(); 272 } catch (\Exception $ex) { 273 cacholong_cc_log_exception($ex); 274 } 275 } 276 277 /** 278 * Get cron settings field key and hook purge name 279 * 280 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) 281 * @copyright Cacholong <[email protected]> 282 * @todo ok 283 * 284 * @version 1.0.0 2019-02-19 285 * 286 * @return array Array of cron settings. Key is cache helper cron setting name, value is cache helper hook name. 287 */ 288 public function getCronSettingsFieldKeyAndHookPurgeName() { 289 try { 290 $this->cacheHelperSubject = new \Cacholong\Designpattern\Observer\CacheHelperSubject(); 291 $this->create_all_observers($this->cacheHelperSubject); 292 return $this->cacheHelperSubject->getCronSettingsFieldKeyAndHookPurgeName(); 293 } catch (\Exception $ex) { 294 cacholong_cc_log_exception($ex); 238 295 } 239 296 } … … 251 308 * @return void 252 309 */ 253 public function create_all_observers($subject) 254 { 310 public function create_all_observers($subject) { 255 311 $this->cacheHelperObservers[] = new \Cacholong\Designpattern\Observer\NginxPageSpeedCacheHelperObserver($subject); 256 312 $this->cacheHelperObservers[] = new \Cacholong\Designpattern\Observer\NginxFastCGICacheHelperObserver($subject); … … 273 329 * @return void 274 330 */ 275 private function start_purge_single($relative_path) 276 { 277 try 278 { 331 private function start_purge_single($relative_path) { 332 try { 279 333 $hosts = $this->get_hosts(); 280 if(is_array($hosts)) 281 { 282 if(!empty($relative_path)) 283 { 334 if (is_array($hosts)) { 335 if (!empty($relative_path)) { 284 336 $this->cacheHelperSubject = new \Cacholong\Designpattern\Observer\CacheHelperSubject(); 285 337 $this->cacheHelperSubject->set_hosts_info($hosts); … … 289 341 290 342 $this->cacheHelperSubject->notifyPurgeSingleRequest(); 291 } 292 else 293 { 343 } else { 294 344 $message = __("Could not purge single file, because no valid path was given. Please try again.", \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN); 295 345 \Cacholong\Libraries\AdminMessage::set_message($message, \Cacholong\Entities\AdminNoticeClass::ERROR); … … 297 347 } 298 348 //else do nop 299 } 300 catch (\Exception $ex) 301 { 349 } catch (\Exception $ex) { 302 350 cacholong_cc_log_exception($ex); 303 351 } … … 319 367 * @return void 320 368 */ 321 private function start_purge_multiple($relative_paths) 322 { 323 try 324 { 369 private function start_purge_multiple($relative_paths) { 370 try { 325 371 $hosts = $this->get_hosts(); 326 if(is_array($hosts)) 327 { 328 if(is_array($relative_paths) && $relative_paths) 329 { 372 if (is_array($hosts)) { 373 if (is_array($relative_paths) && $relative_paths) { 330 374 $this->cacheHelperSubject = new \Cacholong\Designpattern\Observer\CacheHelperSubject(); 331 375 $this->cacheHelperSubject->set_hosts_info($hosts); … … 335 379 336 380 $this->cacheHelperSubject->notifyPurgeMultipleRequest(); 337 } 338 else 339 { 381 } else { 340 382 $message = __("Nothing is purged. If you expected a purge, please check settings page from Cache control by Cacholong plugin.", \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN); 341 383 \Cacholong\Libraries\AdminMessage::set_message($message, \Cacholong\Entities\AdminNoticeClass::WARNING); … … 343 385 } 344 386 //else do nop 345 } 346 catch (\Exception $ex) 347 { 387 } catch (\Exception $ex) { 348 388 cacholong_cc_log_exception($ex); 349 389 } … … 362 402 * @return void 363 403 */ 364 private function start_purge_all() 365 { 366 try 367 { 404 private function start_purge_all() { 405 try { 368 406 $hosts = $this->get_hosts(); 369 if(is_array($hosts)) 370 { 407 if (is_array($hosts)) { 371 408 $this->cacheHelperSubject = new \Cacholong\Designpattern\Observer\CacheHelperSubject(); 372 409 $this->cacheHelperSubject->set_hosts_info($hosts); … … 377 414 } 378 415 //else do nop 379 } 380 catch (\Exception $ex) 381 { 416 } catch (\Exception $ex) { 382 417 cacholong_cc_log_exception($ex); 383 418 } -
cache-control-by-cacholong/trunk/core/libraries/Style.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/UserOptions.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/WordpressURL.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/purgeSetting/CustomtPostPurgeSetting.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/purgeSetting/DefaultPostPurgeSetting.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/libraries/purgeSetting/PurgeSetting.php
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/view/admin/misc/admin_message.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/view/admin/settings/field/custom_post_purge_settings.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/view/admin/settings/field/default_post_purge_settings.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/view/admin/settings/field/location_json_hosts_file.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/view/admin/settings/field/remove_style_id.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control -
cache-control-by-cacholong/trunk/core/view/admin/settings/page/cacholong_cache_control.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control … … 29 29 * 30 30 * @version 1.0.0 Created at 2015-10-21 31 * @version 1.1.0 2019-02-20 Cron purging form 31 32 */ 32 33 ?> … … 51 52 <?php echo submit_button(__('Purge single item', \Cacholong\Entities\Identifier::CC_TEXT_DOMAIN))?> 52 53 </form> 53 54 54 55 <form id="<?php echo \Cacholong\Entities\Identifier::CC_SETTINGS_SECTION_FORM_ID ?>" method="post" action="options.php"> 55 56 <?php settings_fields(\Cacholong\Entities\Identifier::CC_OPTIONS);?> -
cache-control-by-cacholong/trunk/core/view/admin/settings/section/cacholong_cache_control_settings.phtml
r1834268 r2036979 1 1 <?php 2 2 /** 3 * Copyright © 2015-201 8, Cacholong <[email protected]>3 * Copyright © 2015-2019, Cacholong <[email protected]> 4 4 * 5 5 * This file is part of Cache Control … … 22 22 <?php 23 23 /** 24 * Template for section settings 24 * Template for section settings (default) 25 25 * 26 26 * @author Preliot, Piet Rol <[email protected]> (commissioned by Cacholong) -
cache-control-by-cacholong/trunk/readme.txt
r1974795 r2036979 1 1 === Cache control by Cacholong === 2 2 Contributors: cacholong, preliot 3 Tags: cache control, cache, caching, cacholong, pagespeed, fastcgi, nginx, nginx pagespeed, nginx fastcgi, cache 3 Tags: cache control, cache, caching, cacholong, pagespeed, fastcgi, nginx, nginx pagespeed, nginx fastcgi, cache, cronjob, cronjobs, schedule 4 4 Requires at least: 4.3.1 5 Tested up to: 5.0. 05 Tested up to: 5.0.3 6 6 Requires PHP: 5.6 7 7 Stable tag: trunk … … 19 19 20 20 * Purge Nginx Pagespeed cache and/or Nginx FastCGI cache. 21 * Purging automatically, manually and with Wordpress cronjobs. 21 22 * Purge caches on one or more servers (See hosts.json section for more details). 22 23 * Remove id tag from stylesheet link tags, in order to allow Nginx Pagespeed to combine stylesheets. … … 29 30 There is one caveat: When the user uses “Quick edit” and “Updates” the post, no messages will be displayed, because there's no page refresh. Those messages will be shown on the next request. 30 31 32 It is possible to purge with Wordpress cronjobs. Adjust the 'Crojob settings' to perform a daily purge of caches. 33 31 34 You can also purge items manually. Go to the WordPress dashboard and navigate to: 32 35 … … 41 44 * Purge settings default post types: Select one or more options when purging a default post type. Possible to purge post url (default), home page, all connected Wordpress categories or all caches. 42 45 * Purge settings default custom type(s): Select one or more options when purging a custom post type. Possible to purge post url (default), home page, all connected Wordpress categories or all caches. 46 47 = Cronjob Settings = 48 49 * Cronjob purging: Enable or disable cronjob purging. 50 * Cronjob time of each day: Enter HH:MM in 24 hour notation for cronjob time of day. Will fallback to 00:00 when wrong format is given. 51 * Purge caches Select caches to purge on given cronjob time. 43 52 44 53 = hosts.json = … … 130 139 Although no message is displayed, the purge was activated! You can see the purge message when you refresh the page. This is a technical limitation. 131 140 132 141 = Why do my cronjobs execute later then I expect? = 142 143 Wordpress cronjobs are not the same as real cronjobs. Wordpress cronjobs will start if someone visits your website after (or on the) scheduled time. This might be later then expected. 144 It is possible to disable Wordpress cronjobs and use a real cronjob that polls wp-cron.php on a regular base. 145 146 = Why does my cronjob execute immediately? = 147 148 If you enter a time of day that has already passed, the first cronjob is set to this time of day and is executed the first time the site is loaded (or wp-cron.php is called). 149 150 = What should I do Wordpress cronjobs are disabled? = 151 152 Wordpress cronjobs are disabled ('DISABLE_WP_CRON' = true). Please use a different type of cronjob to poll wp-cron.php on a regular base. 153 If purging of the cache fails through the cron mechanism make sure the hosts.json file is in place with the proper settings. See hosts.json section on the plugins page for more details. 133 154 134 155 == Screenshots == … … 139 160 140 161 == Changelog == 162 163 = 4.1.1 - 2019-02-22 = 164 165 * Added - When Wordpress cronjobs are disabled (DISABLE_WP_CRON = true), text with link to FAQ is shown underneath setting to activate cronjob purging 166 * Added - Current timezone underneath setting for cronjob time of day 167 168 = 4.1.0 - 2019-02-21 = 169 * Added - Plugin is capable to purge with Wordpress cronjobs 170 * Added - Plugin is tested for usage with Wordpress 5.0.3 171 * Added - Icon for 'Purge all caches' on adminbar 172 * Fixed - Errors caused by empty 'File with hosts (JSON)' setting 173 * Changed - 'Purge all caches' also available on frontend adminbar 174 * Changed - Corrected a few spellerrors (cachalong -> cacholong) 175 * Changed - Updated copyright from 2015-2018 to 2015-2019 141 176 142 177 = 4.0.2 - 2018-11-15 = … … 163 198 * Deprecated - Curl class. 164 199 165 = 3.2.1 - 2018-01-25 =166 * Fixed - Small fix for showing 'delay text'.167 168 = 3.2.0 - 2018-01-24 =169 * Changed - Only show 'delay text' for pagespeed when purge was succesful, instead of always.170 171 = 3.1.1 - 2016-09-14 =172 * Fixed - Removed a few purge hooks from is_admin() to work again.173 174 = 3.1.0 - 2017-12-22 =175 * Added - Delay text message for all purges.176 * Fixed - Handle non-array admin messages.177 * Changed - userOptions table is now used to handle session flash data, session handling is removed.178 * Changed - is_admin() to optimize performance frontend.179 * Changed - Removed log message for missing hosts json file, not needed anymore.180 * Changed - Language files updated.181 * Changed - Improvements in messages, phpDoc and debugging.182 * Deprecated - Sessions class.183 184 = 3.0.0 - 2017-12-15 =185 * Added - Setting to enable or disable removing id attribute from stylesheet link tag. Nginx pagespeed needs css id removed to combine stylesheets.186 187 200 See changelog.txt for all versions. 188 201
Note: See TracChangeset
for help on using the changeset viewer.