Changeset 3030444
- Timestamp:
- 02/02/2024 08:20:24 AM (2 years ago)
- Location:
- rabbit-loader
- Files:
-
- 1 added
- 21 edited
- 14 copied
-
tags/2.19.16 (added)
-
tags/2.19.16/admin (copied) (copied from rabbit-loader/trunk/admin)
-
tags/2.19.16/advanced-cache.php (copied) (copied from rabbit-loader/trunk/advanced-cache.php) (2 diffs)
-
tags/2.19.16/assets (copied) (copied from rabbit-loader/trunk/assets)
-
tags/2.19.16/autoload.php (copied) (copied from rabbit-loader/trunk/autoload.php) (1 diff)
-
tags/2.19.16/images (copied) (copied from rabbit-loader/trunk/images)
-
tags/2.19.16/inc (copied) (copied from rabbit-loader/trunk/inc)
-
tags/2.19.16/inc/RabbitLoader/SDK/Cache.php (modified) (2 diffs)
-
tags/2.19.16/inc/RabbitLoader/SDK/File.php (modified) (1 diff)
-
tags/2.19.16/inc/RabbitLoader/SDK/Request.php (modified) (4 diffs)
-
tags/2.19.16/inc/RabbitLoader/SDK/Util.php (modified) (2 diffs)
-
tags/2.19.16/inc/admin.php (copied) (copied from rabbit-loader/trunk/inc/admin.php) (5 diffs)
-
tags/2.19.16/inc/core/core.php (modified) (5 diffs)
-
tags/2.19.16/inc/core/integrations.php (modified) (17 diffs)
-
tags/2.19.16/inc/public.php (copied) (copied from rabbit-loader/trunk/inc/public.php) (2 diffs)
-
tags/2.19.16/inc/tab_settings.php (modified) (1 diff)
-
tags/2.19.16/inc/util_wp.php (copied) (copied from rabbit-loader/trunk/inc/util_wp.php) (5 diffs)
-
tags/2.19.16/index.php (copied) (copied from rabbit-loader/trunk/index.php)
-
tags/2.19.16/rabbit-loader.php (copied) (copied from rabbit-loader/trunk/rabbit-loader.php) (2 diffs)
-
tags/2.19.16/readme.txt (copied) (copied from rabbit-loader/trunk/readme.txt) (13 diffs)
-
tags/2.19.16/uninstall.php (copied) (copied from rabbit-loader/trunk/uninstall.php)
-
tags/2.19.16/wp-cli.php (copied) (copied from rabbit-loader/trunk/wp-cli.php)
-
trunk/advanced-cache.php (modified) (2 diffs)
-
trunk/autoload.php (modified) (1 diff)
-
trunk/inc/RabbitLoader/SDK/Cache.php (modified) (2 diffs)
-
trunk/inc/RabbitLoader/SDK/File.php (modified) (1 diff)
-
trunk/inc/RabbitLoader/SDK/Request.php (modified) (4 diffs)
-
trunk/inc/RabbitLoader/SDK/Util.php (modified) (2 diffs)
-
trunk/inc/admin.php (modified) (5 diffs)
-
trunk/inc/core/core.php (modified) (5 diffs)
-
trunk/inc/core/integrations.php (modified) (17 diffs)
-
trunk/inc/public.php (modified) (2 diffs)
-
trunk/inc/tab_settings.php (modified) (1 diff)
-
trunk/inc/util_wp.php (modified) (5 diffs)
-
trunk/rabbit-loader.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rabbit-loader/tags/2.19.16/advanced-cache.php
r3023894 r3030444 4 4 * If you have deleted the plugin without using Standard WordPress un-installation methods, such as deleting file system folders etc, you need to clean the advanced-cache.php file's content. 5 5 */ 6 defined( 'ABSPATH' ) or die( 'not allowed');6 defined('ABSPATH') or die('not allowed'); 7 7 8 if (!defined('RABBITLOADER_AC_PLUG_DIR')){8 if (!defined('RABBITLOADER_AC_PLUG_DIR')) { 9 9 10 10 define('RABBITLOADER_AC_ABSPATH', '%%RABBITLOADER_AC_ABSPATH%%'); … … 19 19 define('RABBITLOADER_AC_PLUG_VERSION', '%%RABBITLOADER_AC_PLUG_VERSION%%'); //should not be replaced from the automation script 20 20 define('RABBITLOADER_AC_PLUG_ENV', '%%RABBITLOADER_AC_PLUG_ENV%%'); 21 try { 22 include_once RABBITLOADER_AC_PLUG_DIR . "inc/core/core.php"; 23 include_once RABBITLOADER_AC_PLUG_DIR . "inc/core/util.php"; 24 include_once RABBITLOADER_AC_PLUG_DIR . "inc/core/integrations.php"; 25 include_once RABBITLOADER_AC_PLUG_DIR . "inc/util_wp.php"; 26 include_once RABBITLOADER_AC_PLUG_DIR . "inc/public.php"; 21 27 22 include_once RABBITLOADER_AC_PLUG_DIR."inc/core/core.php"; 23 include_once RABBITLOADER_AC_PLUG_DIR."inc/core/util.php"; 24 include_once RABBITLOADER_AC_PLUG_DIR."inc/core/integrations.php"; 25 include_once RABBITLOADER_AC_PLUG_DIR."inc/util_wp.php"; 26 include_once RABBITLOADER_AC_PLUG_DIR."inc/public.php"; 27 28 try{ 29 RabbitLoader_21_Public::process_incoming_request('ac'); 30 }catch(\Throwable $e){ 31 RabbitLoader_21_Core::on_exception($e); 32 } catch(Exception $e) { 33 RabbitLoader_21_Core::on_exception($e); 28 try { 29 RabbitLoader_21_Public::process_incoming_request('ac'); 30 } catch (\Throwable $e) { 31 RabbitLoader_21_Core::on_exception($e); 32 } catch (Exception $e) { 33 RabbitLoader_21_Core::on_exception($e); 34 } 35 } catch (Exception $e) { 34 36 } 35 37 } 36 38 } 37 38 ?> -
rabbit-loader/tags/2.19.16/autoload.php
r3023896 r3030444 4 4 define('RABBITLOADER_CACHE_DIR', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . "rabbitloader"); 5 5 define('RABBITLOADER_PLUG_URL', plugin_dir_url(__FILE__)); 6 define('RABBITLOADER_PLUG_VERSION', '2.19.1 5');6 define('RABBITLOADER_PLUG_VERSION', '2.19.16'); 7 7 define('RABBITLOADER_TEXT_DOMAIN', 'rabbit-loader'); 8 8 define('RABBITLOADER_PLUG_ENV', 'PROD'); -
rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/Cache.php
r3010353 r3030444 6 6 { 7 7 8 publicconst TTL_LONG = "long";9 publicconst TTL_SHORT = "short";8 const TTL_LONG = "long"; 9 const TTL_SHORT = "short"; 10 10 11 11 private $request_url = ''; … … 74 74 private function getPathForTTL($ttl, $fileType) 75 75 { 76 return $ttl == self::TTL_LONG ? $this->fp_long . '_' . $fileType : $this->fp_short . '_' . $fileType;76 return $ttl === self::TTL_LONG ? $this->fp_long . '_' . $fileType : $this->fp_short . '_' . $fileType; 77 77 } 78 78 -
rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/File.php
r3016306 r3030444 130 130 public function fgc($length = 5000) 131 131 { 132 if (empty($this->fp) || !file_exists($this->fp)) { 133 return ''; 134 } 132 135 return file_get_contents($this->fp, false, null, 0, $length); 133 136 } -
rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/Request.php
r3020814 r3030444 22 22 private $platform = []; 23 23 24 privateconst IG_PARAMS = ['_gl', 'epik', 'fbclid', 'gbraid', 'gclid', 'msclkid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'vgo_ee', 'wbraid', 'zenid', 'rltest', 'rlrand'];24 const IG_PARAMS = ['_gl', 'epik', 'fbclid', 'gbraid', 'gclid', 'msclkid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'vgo_ee', 'wbraid', 'zenid', 'rltest', 'rlrand']; 25 25 26 26 public function __construct($licenseKey, $rootDir) … … 49 49 public function ignoreRequest($reason = 'default') 50 50 { 51 //replace newlines form reason text to avoid issues in appendFooter 52 $reason = str_replace(array("\n", "\r"), '', $reason); 51 53 $this->ignoreRead = true; 52 54 $this->ignoreWrite = true; … … 334 336 $resJson = json_encode($response); 335 337 if ($resJson) { 338 //print resJson string if encode success 336 339 Util::sendHeader('x-rl-debug-refresh1:' . $resJson, true); 337 340 } else { 341 //print raw response if encode fails 338 342 Util::sendHeader('x-rl-debug-refresh2:' . $response, true); 339 343 } … … 341 345 if (!empty($response['saved']) && !empty($this->purgeCallback)) { 342 346 call_user_func_array($this->purgeCallback, [$url]); 347 Util::sendHeader('x-rl-refresh-saved: 1', true); 343 348 } else { 344 349 $this->cacheFile->set429(); 345 if (!empty($response['message']) && strcasecmp($response['message'], 'BQE') === 0) { 346 $this->cacheFile->deleteAll(); 350 if (!empty($response['message'])) { 351 Util::sendHeader('x-rl-debug-refresh1:' . $resJson, true); 352 if (strcasecmp($response['message'], 'BQE') === 0) { 353 $this->cacheFile->deleteAll(); 354 } 347 355 } 348 356 } -
rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/Util.php
r2955982 r3030444 5 5 class Util 6 6 { 7 //count of headers sent so far by RabbitLoader 8 private static $sentCount = 0; 9 7 10 public static function getRequestMethod() 8 11 { … … 12 15 public static function sendHeader($header, $replace) 13 16 { 14 if (!headers_sent()) { 15 header($header, $replace); 17 if (!empty($header) && (self::$sentCount < 50) && !headers_sent()) { 18 header(substr($header, 0, 150), $replace); 19 self::$sentCount++; 16 20 } 17 21 } -
rabbit-loader/tags/2.19.16/inc/admin.php
r3023896 r3030444 40 40 $response['result'] = true; 41 41 } else { 42 RL21UtilWP::onPostChange( 'all');42 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL); 43 43 $response['result'] = true; 44 44 } … … 103 103 $page = RabbitLoader_21_Util_Core::get_param('page'); 104 104 105 if ( $page == 'rabbitloader') {105 if (strcmp($page, 'rabbitloader') === 0) { 106 106 add_action('admin_head', 'admin_styles', 10, 1); 107 107 function admin_styles($a) … … 181 181 //delete_user_meta($user_id, 'rl_survey_dismissed'); 182 182 $dismiss_time = intval(get_user_meta($user_id, 'rl_survey_dismissed', true)); 183 if (self::SURVEY_DIS_PERMA == $dismiss_time) {183 if (self::SURVEY_DIS_PERMA === $dismiss_time) { 184 184 //permanently dismissed 185 185 return; … … 246 246 if (!defined('RABBITLOADER_AC_ACTIVE') || (RABBITLOADER_PLUG_VERSION != RABBITLOADER_AC_PLUG_VERSION) || (LOGGED_IN_COOKIE != RABBITLOADER_AC_LOGGED_IN_COOKIE)) { 247 247 $aac_code = self::activate_advanced_cache(); 248 if ($aac_code == 4) {248 if ($aac_code === 4) { 249 249 self::$rabbitloader_cache_warnings[] = $adv_cache_msg; 250 250 } … … 386 386 $http = RabbitLoader_21_Core::callPOSTAPI('domain/heartbeat', $post_data, $apiError, $apiMessage); 387 387 388 RabbitLoader_21_Core::cleanAllCachedFiles(); 389 388 try { 389 RabbitLoader_21_Core::cleanAllCachedFiles(); 390 RabbitLoader_21_Core::delete_log_file(RabbitLoader_21_Core::LOCAL_CONFIG_FILE); 391 } catch (Exception $e) { 392 } 390 393 $ourOptions = array('rabbitloader_field_apikey', 'rabbitloader_field_apisecret', 'rabbitloader_field_domain', 'rl_optimizer_engine_version', 'rabbit_loader_wp_options', 'rabbit_loader_user_options', 'rabbitloader_cdn_prefix'); 391 394 -
rabbit-loader/tags/2.19.16/inc/core/core.php
r3010353 r3030444 18 18 */ 19 19 const ORPHANED_LONG_AGE_SEC = 30 * 24 * 3600; 20 const LOCAL_CONFIG_FILE = "rl_config"; 20 21 21 22 private static function addKeys(&$args, &$rabbitloader_field_domain) … … 295 296 $rl_wp_options = get_option('rabbit_loader_wp_options'); 296 297 } else { 297 RabbitLoader_21_Core::get_log_file( 'rl_config', $rl_config);298 RabbitLoader_21_Core::get_log_file(self::LOCAL_CONFIG_FILE, $rl_config); 298 299 if (file_exists($rl_config)) { 299 300 $rl_wp_options = json_decode(file_get_contents($rl_config), true); … … 323 324 } 324 325 try { 325 RabbitLoader_21_Core::get_log_file( 'rl_config', $rl_config);326 RabbitLoader_21_Core::get_log_file(self::LOCAL_CONFIG_FILE, $rl_config); 326 327 $rl_json = json_encode($rl_wp_options, JSON_INVALID_UTF8_IGNORE); 327 328 RabbitLoader_21_Util_Core::fpc($rl_config, $rl_json, WP_DEBUG); … … 352 353 { 353 354 $fp = RL21UtilWP::get_cache_dir() . DIRECTORY_SEPARATOR . $fn . ".log"; 355 } 356 357 public static function delete_log_file($fn) 358 { 359 $fp = ''; 360 self::get_log_file($fn, $fp); 361 if ($fp && file_exists($fp)) { 362 @unlink($fp); 363 } 354 364 } 355 365 … … 379 389 } 380 390 exit; 381 }382 383 public static function sendHeader($header, $replace)384 {385 if (!headers_sent()) {386 header($header, $replace);387 }388 /*else{389 $is_wp_cron_script = !empty($_SERVER['SCRIPT_NAME']) && stripos($_SERVER['SCRIPT_NAME'], '/wp-cron.php')!==false;390 $is_wp_cron_self = !empty($_SERVER['PHP_SELF']) && stripos($_SERVER['PHP_SELF'], '/wp-cron.php') !==false;391 $is_admin_ajax_self = !empty($_SERVER['PHP_SELF']) && stripos($_SERVER['PHP_SELF'], '/admin-ajax.php') !==false;392 $is_admin_update_self = !empty($_SERVER['PHP_SELF']) && stripos($_SERVER['PHP_SELF'], '/update.php') !==false;393 $is_wp_shell = !empty($_SERVER['SHELL']);394 if($is_wp_cron_script || $is_wp_cron_self || $is_wp_shell || $is_admin_ajax_self || $is_admin_update_self){395 //wp-cron will usually send the Cache-Control and Expires headers in advance, we need not to worry logging error in this case396 return;397 }398 399 RabbitLoader_21_Core::on_exception('Trying to send header when it is already sent. Header=> '.$header.'. Headers already sent=>'.print_r(headers_list(), true));400 }*/401 391 } 402 392 -
rabbit-loader/tags/2.19.16/inc/core/integrations.php
r2936874 r3030444 1 1 <?php 2 2 3 class RabbitLoader_21_TP { 3 class RabbitLoader_21_TP 4 { 4 5 5 6 const PURGE_ALL = 1; … … 8 9 private static $rl_wp_options = []; 9 10 10 public static function purge_all(&$success_count){ 11 public static function purge_all(&$success_count) 12 { 11 13 self::call_tpvs(self::PURGE_ALL, '', $success_count); 12 14 } 13 15 14 public static function purge_url($url, &$success_count){ 16 public static function purge_url($url, &$success_count) 17 { 15 18 self::call_tpvs(self::PURGE_URL, $url, $success_count); 16 19 } 17 20 18 public static function purge_post_id($post_id, &$success_count){ 21 public static function purge_post_id($post_id, &$success_count) 22 { 19 23 self::call_tpvs(self::PURGE_ID, $post_id, $success_count); 20 24 } 21 25 22 private static function call_tpvs($purge_type, $url_id, &$success_count){ 26 private static function call_tpvs($purge_type, $url_id, &$success_count) 27 { 23 28 RabbitLoader_21_Core::getWpOption(RabbitLoader_21_TP::$rl_wp_options); 24 29 $class_methods = get_class_methods('RabbitLoader_21_TP'); 25 30 foreach ($class_methods as $method_name) { 26 if (substr($method_name,0,3)=='tpv'){27 try {28 if (self::$method_name($purge_type, $url_id)){31 if (substr($method_name, 0, 3) == 'tpv') { 32 try { 33 if (self::$method_name($purge_type, $url_id)) { 29 34 ++$success_count; 30 35 } 31 } catch(\Throwable $e){36 } catch (\Throwable $e) { 32 37 RabbitLoader_21_Core::on_exception($e); 33 38 } … … 36 41 } 37 42 38 private static function tpv_wp_core($purge_type, $url_id){ 43 private static function tpv_wp_core($purge_type, $url_id) 44 { 39 45 if (function_exists('wp_cache_flush')) { 40 46 wp_cache_flush(); 41 47 } 42 48 43 if (function_exists('opcache_reset')) {49 if (function_exists('opcache_reset')) { 44 50 opcache_reset(); 45 51 } 46 52 47 if (function_exists( 'apc_clear_cache')) {53 if (function_exists('apc_clear_cache')) { 48 54 apc_clear_cache(); 49 55 } 50 56 } 51 57 52 private static function tpv_litespeed($purge_type, $url_id){ 53 $isLS = !empty($_SERVER["X-LSCACHE"]) || (!empty($_SERVER["SERVER_SOFTWARE"]) && "litespeed" == strtolower($_SERVER["SERVER_SOFTWARE"]) ) || RabbitLoader_21_Util_Core::isDev(); 54 if(!$isLS){ 55 return false; 56 } 57 if($purge_type==self::PURGE_ALL){ 58 RabbitLoader_21_Core::sendHeader("X-LiteSpeed-Purge: *", false); 59 }elseif($purge_type==self::PURGE_URL){ 58 private static function tpv_litespeed($purge_type, $url_id) 59 { 60 $isLS = !empty($_SERVER["X-LSCACHE"]) || (!empty($_SERVER["SERVER_SOFTWARE"]) && "litespeed" == strtolower($_SERVER["SERVER_SOFTWARE"])) || RabbitLoader_21_Util_Core::isDev(); 61 if (!$isLS) { 62 return false; 63 } 64 if ($purge_type == self::PURGE_ALL) { 65 RabbitLoader\SDK\Util::sendHeader("X-LiteSpeed-Purge: *", false); 66 } elseif ($purge_type == self::PURGE_URL) { 60 67 $path = parse_url($url_id, PHP_URL_PATH); 61 if (empty($path)){68 if (empty($path)) { 62 69 $path = '/'; 63 70 } 64 RabbitLoader _21_Core::sendHeader("X-LiteSpeed-Purge: ".$path, false);71 RabbitLoader\SDK\Util::sendHeader("X-LiteSpeed-Purge: " . $path, false); 65 72 } 66 73 return true; … … 70 77 * https://github.com/pantheon-systems/pantheon-advanced-page-cache/blob/master/pantheon-advanced-page-cache.php 71 78 */ 72 private static function tpv_pantheon($purge_type, $url_id){ 73 if(!function_exists('pantheon_wp_clear_edge_all')){ 74 return false; 75 } 76 if($purge_type==self::PURGE_ALL) { 79 private static function tpv_pantheon($purge_type, $url_id) 80 { 81 if (!function_exists('pantheon_wp_clear_edge_all')) { 82 return false; 83 } 84 if ($purge_type == self::PURGE_ALL) { 77 85 pantheon_wp_clear_edge_all(); 78 } elseif($purge_type==self::PURGE_ID){86 } elseif ($purge_type == self::PURGE_ID) { 79 87 do_action('clean_post_cache', $url_id); 80 88 } … … 82 90 } 83 91 84 private static function tpv_nginx($purge_type, $url_id){ 92 private static function tpv_nginx($purge_type, $url_id) 93 { 85 94 global $nginx_purger; 86 if (empty($nginx_purger)){87 return false; 88 } 89 if ($purge_type==self::PURGE_ALL){95 if (empty($nginx_purger)) { 96 return false; 97 } 98 if ($purge_type == self::PURGE_ALL) { 90 99 $nginx_purger->purge_all(); 91 } elseif($purge_type==self::PURGE_URL){100 } elseif ($purge_type == self::PURGE_URL) { 92 101 $nginx_purger->purge_url($url_id); 93 102 } … … 98 107 * https://github.com/Savvii/warpdrive/ 99 108 */ 100 private static function tpv_savii($purge_type, $url_id){ 101 if(!defined( '\Savvii\CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW')){ 102 return false; 103 } 104 do_action( 'warpdrive_domain_flush' ); 105 return true; 106 } 107 108 private static function tpv_ninukis($purge_type, $url_id){ 109 if (!defined('WP_NINUKIS_WP_NAME') || !class_exists('Ninukis_Plugin')){ 110 return false; 111 } 112 if($purge_type==self::PURGE_ALL){ 109 private static function tpv_savii($purge_type, $url_id) 110 { 111 if (!defined('\Savvii\CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW')) { 112 return false; 113 } 114 do_action('warpdrive_domain_flush'); 115 return true; 116 } 117 118 private static function tpv_ninukis($purge_type, $url_id) 119 { 120 if (!defined('WP_NINUKIS_WP_NAME') || !class_exists('Ninukis_Plugin')) { 121 return false; 122 } 123 if ($purge_type == self::PURGE_ALL) { 113 124 $purge_pressidum = Ninukis_Plugin::get_instance(); 114 125 $purge_pressidum->purgeAllCaches(); 115 126 return true; 116 } elseif($purge_type==self::PURGE_ID){117 118 }119 } 120 121 private static function tpv_pagely_cache($purge_type, $url_id){127 } elseif ($purge_type == self::PURGE_ID) { 128 } 129 } 130 131 private static function tpv_pagely_cache($purge_type, $url_id) 132 { 122 133 if (!class_exists('\PagelyCachePurge')) { 123 134 return false; 124 135 } 125 if ($purge_type==self::PURGE_ALL){136 if ($purge_type == self::PURGE_ALL) { 126 137 $purge_pagely = new PagelyCachePurge(); 127 138 $purge_pagely->purgeAll(); 128 } elseif($purge_type==self::PURGE_URL){139 } elseif ($purge_type == self::PURGE_URL) { 129 140 $purge_pagely = new PagelyCachePurge(); 130 141 $purge_pagely->purgePath(parse_url($url_id, PHP_URL_PATH) . "(.*)"); … … 134 145 135 146 //wpengine - https://wpengine.com/support/cache/ 136 private static function tpv_wpengine($purge_type, $url_id){ 147 private static function tpv_wpengine($purge_type, $url_id) 148 { 137 149 if (!class_exists("\WpeCommon")) { 138 150 return false; 139 151 } 140 if ($purge_type==self::PURGE_ALL){152 if ($purge_type == self::PURGE_ALL) { 141 153 \WpeCommon::purge_memcached(); 142 154 \WpeCommon::purge_varnish_cache(); 143 } elseif($purge_type==self::PURGE_ID){155 } elseif ($purge_type == self::PURGE_ID) { 144 156 \WpeCommon::purge_varnish_cache($url_id); 145 157 } … … 148 160 149 161 //godaddy 150 private static function tpv_wpass($purge_type, $url_id){ 151 if (!class_exists('WPaaS\Plugin')){ 152 return false; 153 } 154 if($purge_type==self::PURGE_ALL){ 155 if (method_exists( 'WPass\Plugin', 'vip' )) { 162 private static function tpv_wpass($purge_type, $url_id) 163 { 164 if (!class_exists('WPaaS\Plugin')) { 165 return false; 166 } 167 if ($purge_type == self::PURGE_ALL) { 168 if (method_exists('WPass\Plugin', 'vip')) { 156 169 //godaddy 157 170 $method = 'BAN'; 158 171 $url = home_url(); 159 172 $host = wpraiser_get_domain(); 160 $url = set_url_scheme( str_replace( $host, WPaas\Plugin::vip(), $url ), 'http');161 update_option( 'gd_system_last_cache_flush', time(), 'no'); # purge apc162 wp_remote_request( esc_url_raw( $url ), array('method' => $method, 'blocking' => false, 'headers' => array('Host' => $host)));173 $url = set_url_scheme(str_replace($host, WPaas\Plugin::vip(), $url), 'http'); 174 update_option('gd_system_last_cache_flush', time(), 'no'); # purge apc 175 wp_remote_request(esc_url_raw($url), array('method' => $method, 'blocking' => false, 'headers' => array('Host' => $host))); 163 176 } 164 177 return true; 165 }elseif($purge_type==self::PURGE_ID){ 166 178 } elseif ($purge_type == self::PURGE_ID) { 167 179 } 168 180 } 169 181 170 182 //https://github.com/cloudflare/Cloudflare-WordPress/blob/74acc2df4938df1fcfa4347e971d73e2fc6e4edc/src/WordPress/Hooks.php 171 private static function tpv_cloudflare($purge_type, $url_id){ 172 if(!class_exists('\CF\WordPress\Hooks')){ 173 return false; 174 } 175 if($purge_type==self::PURGE_ALL){ 183 private static function tpv_cloudflare($purge_type, $url_id) 184 { 185 if (!class_exists('\CF\WordPress\Hooks')) { 186 return false; 187 } 188 if ($purge_type == self::PURGE_ALL) { 176 189 $cfHooks = new \CF\WordPress\Hooks(); 177 190 $cfHooks->purgeCacheEverything(); 178 } elseif($purge_type==self::PURGE_ID){191 } elseif ($purge_type == self::PURGE_ID) { 179 192 $cfHooks = new \CF\WordPress\Hooks(); 180 193 $cfHooks->purgeCacheByRelevantURLs($url_id); … … 183 196 } 184 197 185 private static function tpv_kinsta($purge_type, $url_id){ 198 private static function tpv_kinsta($purge_type, $url_id) 199 { 186 200 if (!defined("KINSTAMU_VERSION")) { 187 201 return false; 188 202 } 189 if ($purge_type==self::PURGE_ALL){190 $response = wp_remote_get( 'https://localhost/kinsta-clear-cache-all', [191 'sslverify' => false, 203 if ($purge_type == self::PURGE_ALL) { 204 $response = wp_remote_get('https://localhost/kinsta-clear-cache-all', [ 205 'sslverify' => false, 192 206 'timeout' => 5 193 207 ]); 194 } elseif($purge_type==self::PURGE_URL){208 } elseif ($purge_type == self::PURGE_URL) { 195 209 $response = wp_remote_post('https://localhost/kinsta-clear-cache/v2/immediate', [ 196 'sslverify' => false, 210 'sslverify' => false, 197 211 'timeout' => 5, 198 212 'body' => [ 199 'single' => preg_replace( '@^https?://@', '', $url_id)213 'single' => preg_replace('@^https?://@', '', $url_id) 200 214 ] 201 215 ]); … … 205 219 206 220 //SiteGround - https://wordpress.org/plugins/sg-cachepress/ 207 private static function tpv_siteground_cachepress($purge_type, $url_id){ 221 private static function tpv_siteground_cachepress($purge_type, $url_id) 222 { 208 223 if (!function_exists('sg_cachepress_purge_cache')) { 209 224 return false; 210 225 } 211 if ($purge_type==self::PURGE_ALL){226 if ($purge_type == self::PURGE_ALL) { 212 227 sg_cachepress_purge_cache(); 213 } elseif($purge_type==self::PURGE_URL){228 } elseif ($purge_type == self::PURGE_URL) { 214 229 sg_cachepress_purge_cache($url_id); 215 230 } … … 217 232 } 218 233 219 private static function tpv_siteground($purge_type, $url_id){ 234 private static function tpv_siteground($purge_type, $url_id) 235 { 220 236 $wp_config_path = RL21UtilWP::get_wp_config(); 221 if (empty($wp_config_path) || strpos(file_get_contents($wp_config_path), 'Added by SiteGround')===false){222 return false; 223 } 224 if ($purge_type==self::PURGE_ALL){225 $url_id = home_url() .'/(.*)';226 } elseif($purge_type==self::PURGE_URL){237 if (empty($wp_config_path) || strpos(file_get_contents($wp_config_path), 'Added by SiteGround') === false) { 238 return false; 239 } 240 if ($purge_type == self::PURGE_ALL) { 241 $url_id = home_url() . '/(.*)'; 242 } elseif ($purge_type == self::PURGE_URL) { 227 243 //$url_id is already set 228 } else if($purge_type==self::PURGE_ID){244 } else if ($purge_type == self::PURGE_ID) { 229 245 return false; 230 246 } … … 239 255 * CloudWays: HTTP_X_VARNISH would be set if Varnish is on 240 256 */ 241 private static function tpv_varnish($purge_type, $url_id){ 257 private static function tpv_varnish($purge_type, $url_id) 258 { 242 259 $is_cloudways = isset($_SERVER['cw_allowed_ip']); 243 260 $uses_varnish = $is_cloudways && isset($_SERVER['HTTP_X_VARNISH']); 244 if (!$uses_varnish && !empty(RabbitLoader_21_TP::$rl_wp_options['rl_varnish'])){245 $uses_varnish = intval(RabbitLoader_21_TP::$rl_wp_options['rl_varnish']) ===1;246 } 247 if (!$uses_varnish){261 if (!$uses_varnish && !empty(RabbitLoader_21_TP::$rl_wp_options['rl_varnish'])) { 262 $uses_varnish = intval(RabbitLoader_21_TP::$rl_wp_options['rl_varnish']) === 1; 263 } 264 if (!$uses_varnish) { 248 265 return false; 249 266 } 250 267 $method = 'PURGE'; 251 if ($purge_type==self::PURGE_ALL){252 $url_id = home_url() .'/.*';253 } elseif($purge_type==self::PURGE_URL){268 if ($purge_type == self::PURGE_ALL) { 269 $url_id = home_url() . '/.*'; 270 } elseif ($purge_type == self::PURGE_URL) { 254 271 //$url_id is already set for single URL 255 if ($is_cloudways){272 if ($is_cloudways) { 256 273 $method = 'URLPURGE'; 257 274 } 258 } else if($purge_type==self::PURGE_ID){275 } else if ($purge_type == self::PURGE_ID) { 259 276 return false; 260 277 } … … 262 279 } 263 280 264 private static function tpv_wp_rocket_residue($purge_type, $url_id){ 265 if(!defined('WP_ROCKET_CACHE_PATH')){ 281 private static function tpv_wp_rocket_residue($purge_type, $url_id) 282 { 283 if (!defined('WP_ROCKET_CACHE_PATH')) { 266 284 return; 267 285 } … … 269 287 $wp_rocket_cache_path = WP_ROCKET_CACHE_PATH; #/wp-content/cache/wp-rocket/ 270 288 $host = parse_url(get_site_url(), PHP_URL_HOST); 271 $wp_rocket_cache_dir = $wp_rocket_cache_path .$host;289 $wp_rocket_cache_dir = $wp_rocket_cache_path . $host; 272 290 if (!file_exists($wp_rocket_cache_dir)) { 273 $wp_rocket_cache_dir = $wp_rocket_cache_path ."www.".$host;291 $wp_rocket_cache_dir = $wp_rocket_cache_path . "www." . $host; 274 292 } 275 293 if (file_exists($wp_rocket_cache_dir)) { 276 $special_files = ['.htaccess', '.','..',''];277 $files = glob($wp_rocket_cache_dir .'/*');278 foreach ($files as $file){279 if (empty($file) || in_array(basename($file), $special_files)){294 $special_files = ['.htaccess', '.', '..', '']; 295 $files = glob($wp_rocket_cache_dir . '/*'); 296 foreach ($files as $file) { 297 if (empty($file) || in_array(basename($file), $special_files)) { 280 298 continue; 281 299 } 282 if (is_file($file)) {300 if (is_file($file)) { 283 301 @unlink($file); // delete file 284 } elseif(is_dir($file)){ //category, tags etc285 $cat_files = glob($file .DIRECTORY_SEPARATOR.'/*');286 foreach ($cat_files as $file){302 } elseif (is_dir($file)) { //category, tags etc 303 $cat_files = glob($file . DIRECTORY_SEPARATOR . '/*'); 304 foreach ($cat_files as $file) { 287 305 @unlink($file); // delete file 288 306 } 289 307 } 290 308 } 291 } else{292 $files = glob($wp_rocket_cache_path .'*');293 if (!empty($files) && count($files)==1 && stripos($files[0], 'cache/wp-rocket/index.html')!==false){309 } else { 310 $files = glob($wp_rocket_cache_path . '*'); 311 if (!empty($files) && count($files) == 1 && stripos($files[0], 'cache/wp-rocket/index.html') !== false) { 294 312 //no dir exists 295 } else{296 RabbitLoader_21_Core::on_exception('WP_ROCKET_CACHE_PATH is true but dir not found ' .$wp_rocket_cache_dir. ' files '.print_r($files, true), 1);313 } else { 314 RabbitLoader_21_Core::on_exception('WP_ROCKET_CACHE_PATH is true but dir not found ' . $wp_rocket_cache_dir . ' files ' . print_r($files, true), 1); 297 315 } 298 316 } … … 302 320 * Doc - Hostgator and https://github.com/bluehost/endurance-page-cache/blob/master/endurance-page-cache.php 303 321 */ 304 private static function tpv_endurance($purge_type, $url_id){ 305 if (!class_exists('Endurance_Page_Cache')){ 322 private static function tpv_endurance($purge_type, $url_id) 323 { 324 if (!class_exists('Endurance_Page_Cache')) { 306 325 return; 307 326 } 308 if ($purge_type==self::PURGE_ALL){327 if ($purge_type == self::PURGE_ALL) { 309 328 do_action('epc_purge'); 310 } elseif($purge_type==self::PURGE_URL){329 } elseif ($purge_type == self::PURGE_URL) { 311 330 do_action('epc_purge_request', $url_id); 312 331 } 313 332 } 314 333 315 private static function tpv_sample($purge_type, $url_id){ 316 if($purge_type==self::PURGE_ALL){ 317 318 }elseif($purge_type==self::PURGE_ID){ 319 320 }elseif($purge_type==self::PURGE_URL){ 321 334 private static function tpv_sample($purge_type, $url_id) 335 { 336 if ($purge_type == self::PURGE_ALL) { 337 } elseif ($purge_type == self::PURGE_ID) { 338 } elseif ($purge_type == self::PURGE_URL) { 322 339 } 323 340 } … … 327 344 * @param string method - PURGE, URLPURGE 328 345 */ 329 private static function purge_varnish($url_pattern, $method){ 346 private static function purge_varnish($url_pattern, $method) 347 { 330 348 $url_parts = parse_url($url_pattern); 331 $port = (empty($url_parts['scheme']) || $url_parts['scheme'] =='https') ? '443' : '80';349 $port = (empty($url_parts['scheme']) || $url_parts['scheme'] == 'https') ? '443' : '80'; 332 350 $ch = curl_init($url_pattern); 333 351 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); 334 curl_setopt($ch, CURLOPT_RESOLVE, array($url_parts['host'] .":$port:127.0.0.1"));352 curl_setopt($ch, CURLOPT_RESOLVE, array($url_parts['host'] . ":$port:127.0.0.1")); 335 353 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 336 354 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); … … 352 370 } 353 371 } 354 ?> -
rabbit-loader/tags/2.19.16/inc/public.php
r3023896 r3030444 1 1 <?php 2 3 use RabbitLoader\SDK\RabbitLoader;4 2 5 3 class RabbitLoader_21_Public … … 149 147 { 150 148 try { 151 RabbitLoader _21_Core::sendHeader("x-rl-mode: $mode", false);149 RabbitLoader\SDK\Util::sendHeader("x-rl-mode: $mode", false); 152 150 $rlSDK = RabbitLoader_21_Core::getSDK(); 153 151 -
rabbit-loader/tags/2.19.16/inc/tab_settings.php
r3020814 r3030444 234 234 if ($userUpdating) { 235 235 $user_options['exclude_patterns'] = sanitize_textarea_field($_POST['exclude_patterns']); 236 RL21UtilWP::onPostChange( 'all', 'EX_PATTERN_CHANGE');236 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL); 237 237 } else { 238 238 $user_options['exclude_patterns'] = $exclude_patterns; -
rabbit-loader/tags/2.19.16/inc/util_wp.php
r3023896 r3030444 3 3 class RL21UtilWP 4 4 { 5 6 const POST_ID_ALL = "all"; 5 7 6 8 private static $isSearch = false; … … 165 167 public static function onPostChange($post_id) 166 168 { 167 if ( $post_id == 'all') {168 self::$purge_queue[ 'all'] = true;169 if (strcmp($post_id, RL21UtilWP::POST_ID_ALL) === 0) { 170 self::$purge_queue[RL21UtilWP::POST_ID_ALL] = true; 169 171 } else { 170 172 try { … … 196 198 self::$purge_queue['post_ids'][$lang_post_id] = true; 197 199 } 198 RabbitLoader _21_Core::sendHeader("x-rl-wpml_posts: " . json_encode($wpml_posts), false);199 } 200 RabbitLoader _21_Core::sendHeader("x-rl-posts:" . json_encode(self::$purge_queue['post_ids']), false);200 RabbitLoader\SDK\Util::sendHeader("x-rl-wpml_posts: " . json_encode($wpml_posts), false); 201 } 202 RabbitLoader\SDK\Util::sendHeader("x-rl-posts:" . json_encode(self::$purge_queue['post_ids']), false); 201 203 } 202 204 } … … 209 211 $clean_cache = !empty($user_options['purge_on_change']); 210 212 211 if (!empty(self::$purge_queue[ 'all'])) {213 if (!empty(self::$purge_queue[RL21UtilWP::POST_ID_ALL])) { 212 214 RabbitLoader_21_Core::purge_all($local_purge_count, $purge_source, $tp_purge_count); 213 215 } else if (!empty(self::$purge_queue['post_ids'])) { … … 240 242 $local_purge_count++; 241 243 } 242 RabbitLoader _21_Core::sendHeader("x-rl-url: $url", false);244 RabbitLoader\SDK\Util::sendHeader("x-rl-url: $url", false); 243 245 } 244 246 do_action('rl_purge_request_complete', $urls_to_purge); -
rabbit-loader/tags/2.19.16/rabbit-loader.php
r3023896 r3030444 7 7 * Author URI: https://rabbitloader.com/ 8 8 * Description: RabbitLoader can improve Google PageSpeed score and get you 100 out of 100 by improving the page load time to just a few milliseconds. It improves the Core Web Vitals score for your pages and boost PageSpeed score to help better search rankings and best the experience for your end user. 9 * Version: 2.19.1 59 * Version: 2.19.16 10 10 * Text Domain: rabbit-loader 11 11 */ … … 19 19 20 20 add_action('save_post', function ($post_ID, $post, $update) { 21 RL21UtilWP::onPostChange($post_ID); 21 if (strcmp($post->post_type, 'nav_menu_item') === 0) { 22 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL); 23 } else { 24 RL21UtilWP::onPostChange($post_ID); 25 } 22 26 }, 10, 3); 23 27 add_action('wp_insert_post', function ($post_ID, $post, $update) { -
rabbit-loader/tags/2.19.16/readme.txt
r3023896 r3030444 1 === RabbitLoader === 1 2 === RabbitLoader - All in One PageSpeed Optimization Plugin with Cache, Image Optimization, Lazy Loading & more === 2 3 Contributors: sanrl, abhishekgr 3 Tags: cache, c aching, cdn, lazy loading, speed optimization4 Tags: cache, cdn, lazy loading, speed optimization, performance. 4 5 Requires at least: 4.7 5 6 Tested up to: 6.4 6 Stable tag: 2.19.1 57 Stable tag: 2.19.16 7 8 Requires PHP: 5.6 8 9 License: GNU General Public License, version 2 … … 42 43 Caching is the process of storing frequently accessed data or assets in a temporary storage space for faster access and retrieval. RabbitLoader does this automatically, and one doesn't need to use any separate plugin for caching when using RabbitLoader. 43 44 44 It stores the website's assets in the cache memory, which means that the browser does not have to fetch them again from the server, resulting in faster page loads and a better user experience.45 It stores the website's assets in the nearest [cache servers](https://rabbitloader.com/articles/category/caching/ "Cache"), which means that the browser does not have to fetch them again from the server, resulting in faster page loads and a better user experience. 45 46 46 47 **CSS and JavaScript Cache** … … 60 61 RabbitLoader improves image caching by utilizing the browser caching headers, similar to CSS and JavaScript caching. It sets optimal caching headers to ensure that the images are cached for the appropriate amount of time, reducing the number of times the browser has to request them from the server. 61 62 62 RabbitLoader does all this automatically, improving the performance of a website by reducing the load time of images, resulting in a better user experience.63 RabbitLoader does all this automatically, improving the performance of a website by [reducing the load time of images](https://rabbitloader.com/articles/compressing-images-for-the-modern-web/ "reducing the load time of images using RabbitLoader"), resulting in a better user experience. 63 64 64 65 **Browser Cache** … … 84 85 The Next-gen AVIF and WebP formats are image formats that uses advanced compression techniques to reduce the size of images while maintaining their quality. These images are up to 30% smaller than JPEG or PNG images, resulting in faster page load times. 85 86 86 RabbitLoader improves the use of next-gen WebP formatby automatically converting images to the most efficient Next-gen format. RabbitLoader detects the user's browser and serves the AVIF/WebP version of the image if the browser supports it. If the browser does not support the any of the modern format, RabbitLoader serves the original image format. This ensures that the user always receives the best version of the image that their browser supports.87 RabbitLoader [improves the use of next-gen AVIF/WebP format](https://rabbitloader.com/articles/next-gen-formats/ "convert image to next-gen AVIF/WebP format") by automatically converting images to the most efficient Next-gen format. RabbitLoader detects the user's browser and serves the AVIF/WebP version of the image if the browser supports it. If the browser does not support the any of the modern format, RabbitLoader serves the original image format. This ensures that the user always receives the best version of the image that their browser supports. 87 88 88 89 **Image Placeholders** … … 102 103 This feature reduces the loading time of a website by serving content from the server nearest to the user, which in turn reduces bounce rates and improves the user experience. 103 104 104 With an [integrated CDN](https://rabbitloader.com/origin-savings/ "Integrated Premium CDN"), RabbitLoader caches the website assets at multiple locations around the world, ensuring that the content is delivered to the user from the closest server. This reduces the latency and response time, resulting in faster website loading times.105 With an integrated CDN, RabbitLoader caches the website assets at multiple locations around the world, ensuring that the content is delivered to the user from the closest server. This reduces the latency and response time, resulting in faster website loading times. 105 106 106 107 This is especially important for websites with a global audience, as it ensures that visitors from all over the world can access the website quickly and without any delay. … … 108 109 **300+ PoP's** 109 110 110 RabbitLoader uses a Content Delivery Network(CDN) that is distributed throughout the world with over 300 Points of Presence (PoP). This means that no matter where your visitors are located, they can access your website's content in milliseconds, resulting in a faster and smoother experience.111 RabbitLoader uses a [Content Delivery Network](https://rabbitloader.com/origin-savings/ "Content Delivery Network")(CDN) that is distributed throughout the world with over 300 Points of Presence (PoP). This means that no matter where your visitors are located, they can access your website's content in milliseconds, resulting in a faster and smoother experience. 111 112 112 113 This is essential for websites with a global audience, as it ensures that users from all regions can access your website quickly without experiencing any delays. With a distributed network, RabbitLoader is able to provide a faster response time for website content, which can improve user engagement and reduce bounce rates. The CDN's wide coverage ensures that the content can be delivered to users from the nearest server, resulting in lower latency and faster loading times. … … 189 190 Core Web Vitals are a set of performance metrics used to measure the user experience of a website. These metrics were introduced by Google in 2020 and include three specific factors: loading, interactivity, and visual stability. The loading factor measures how quickly the main content of a page loads, the interactivity factor measures how quickly users can interact with the page, and the visual stability factor measures how stable the visual elements of a page are while it loads. 190 191 191 Having a [good Core Web Vitals score](https://rabbitloader.com/best-pagespeed-score/ "Increase SpeedScore")is essential for providing a better user experience, and it can also lead to better rankings in Google Search. When a website has good Core Web Vitals, it can lead to higher engagement, longer time on site, and more conversions.192 193 RabbitLoader helps to improve Core Web Vitalsby optimizing various aspects of a website, including image loading, CSS, and JavaScript optimization, and deferring non-critical resources.192 Having a good Core Web Vitals score is essential for providing a better user experience, and it can also lead to better rankings in Google Search. When a website has good Core Web Vitals, it can lead to higher engagement, longer time on site, and more conversions. 193 194 RabbitLoader helps to improve [Core Web Vitals score](https://rabbitloader.com/best-pagespeed-score/ "Increase SpeedScore using RabbitLoader") by optimizing various aspects of a website, including image loading, CSS, and JavaScript optimization, and deferring non-critical resources. 194 195 195 196 By improving these aspects, RabbitLoader can help to reduce page load times, improve interactivity, and prevent visual instability. As a result, websites that use RabbitLoader are more likely to have good Core Web Vitals scores and better overall user experiences. … … 197 198 **FID (First Input Delay)** 198 199 199 FIDis a Core Web Vitals metric that measures the time between a user's first interaction with a page and the browser's response to that interaction. This metric is essential because it provides insight into how quickly a page responds to user input, which can significantly impact the user experience.200 [FID](https://rabbitloader.com/articles/first-input-delay/ "first input delay") is a Core Web Vitals metric that measures the time between a user's first interaction with a page and the browser's response to that interaction. This metric is essential because it provides insight into how quickly a page responds to user input, which can significantly impact the user experience. 200 201 201 202 An ideal page should have an FID below 100 milliseconds. Slow FID can lead to frustration for users and impact engagement metrics, such as bounce rates and time on page. Therefore, it's essential to optimize FID for a better user experience. … … 209 210 LCP is an important Core Web Vital metric that measures the loading speed of the largest content element on a web page. Google recommends a good LCP score of less than 2.5 seconds. 210 211 211 A high LCP scorecan lead to a poor user experience and negatively impact the page's search engine ranking.212 A [high LCP score](https://rabbitloader.com/articles/largest-contentful-paint/ "Largest Contentful Paint") can lead to a poor user experience and negatively impact the page's search engine ranking. 212 213 213 214 RabbitLoader's CDN Cache can significantly improve the LCP score of a website by delivering content quickly to visitors, regardless of their location. By utilizing caching and compression technologies, RabbitLoader minimizes the time it takes for a website to load the largest content element, ensuring that it appears quickly on the user's screen. … … 219 220 CLS is a metric used to evaluate the visual stability of a web page. It measures the sum total of all layout shifts that occur during the page load, including any unexpected shifts that might occur after the page has loaded. 220 221 221 Any sudden changes can adversely impact the user's experience, making CLS an essential metric for evaluating the user experience. 222 Any sudden changes can adversely impact the user's experience, making [CLS an essential metric for evaluating the user experience](https://rabbitloader.com/articles/cumulative-layout-shift/ "Cumulative Layout Shift"). 223 222 224 223 225 While it largely relies on how website developers insert dynamic content or advertisements through JavaScript, RabbitLoader attempts to allocate the necessary space for elements that will be loaded at later stages of a page's timeline. … … 242 244 * Lazy loading of ads (AdSense, AdThrive, etc. It loads data into cache when it is a necessity. 243 245 * Option to exclude pages from caching and full control through page rules. If you want to remove any particular page from cache. 244 * Woo-Commerce compatibilitywith multi-currency plugins. The cache has to be manually excluded from Woo-Commerce.246 * [Woo-Commerce compatibility](https://rabbitloader.com/wordpress-speed-optimization/ "Woo-Commerce speed optimization") with multi-currency plugins. The cache has to be manually excluded from Woo-Commerce. 245 247 246 248 All the CPU intensive optimizations are performed by RabbitLoader cloud servers, thus reducing the usage of your hosting resources and your hosting bandwidth usage. … … 249 251 250 252 Just use any shared hosting environment or even a low end hosting configuration and still achieve a perfect PageSpeed Insights score. 253 254 **SHARE THE RABBITLOADER** 255 256 Join our [Facebook Community](https://www.facebook.com/Rabbitloader/) & [LinkedIn](https://www.linkedin.com/company/rabbitloader) 257 Learn from our tutorials on [YouTube Channel](https://www.youtube.com/@rabbitloader827) 258 Or, Rate us on [Wordpress](https://wordpress.org/support/plugin/rabbit-loader/reviews/?filter=5) 251 259 252 260 == Frequently Asked Questions == … … 307 315 == Changelog == 308 316 317 = 2.19.16 = 318 * Prevent errors when plugin folder is directly deleted 319 * Performance improvements while saving navigation menus 320 309 321 = 2.19.15 = 310 322 * Bugfix for admin-ajax sending 403 in some cases -
rabbit-loader/trunk/advanced-cache.php
r2945212 r3030444 4 4 * If you have deleted the plugin without using Standard WordPress un-installation methods, such as deleting file system folders etc, you need to clean the advanced-cache.php file's content. 5 5 */ 6 defined( 'ABSPATH' ) or die( 'not allowed');6 defined('ABSPATH') or die('not allowed'); 7 7 8 if (!defined('RABBITLOADER_AC_PLUG_DIR')){8 if (!defined('RABBITLOADER_AC_PLUG_DIR')) { 9 9 10 10 define('RABBITLOADER_AC_ABSPATH', '%%RABBITLOADER_AC_ABSPATH%%'); … … 19 19 define('RABBITLOADER_AC_PLUG_VERSION', '%%RABBITLOADER_AC_PLUG_VERSION%%'); //should not be replaced from the automation script 20 20 define('RABBITLOADER_AC_PLUG_ENV', '%%RABBITLOADER_AC_PLUG_ENV%%'); 21 try { 22 include_once RABBITLOADER_AC_PLUG_DIR . "inc/core/core.php"; 23 include_once RABBITLOADER_AC_PLUG_DIR . "inc/core/util.php"; 24 include_once RABBITLOADER_AC_PLUG_DIR . "inc/core/integrations.php"; 25 include_once RABBITLOADER_AC_PLUG_DIR . "inc/util_wp.php"; 26 include_once RABBITLOADER_AC_PLUG_DIR . "inc/public.php"; 21 27 22 include_once RABBITLOADER_AC_PLUG_DIR."inc/core/core.php"; 23 include_once RABBITLOADER_AC_PLUG_DIR."inc/core/util.php"; 24 include_once RABBITLOADER_AC_PLUG_DIR."inc/core/integrations.php"; 25 include_once RABBITLOADER_AC_PLUG_DIR."inc/util_wp.php"; 26 include_once RABBITLOADER_AC_PLUG_DIR."inc/public.php"; 27 28 try{ 29 RabbitLoader_21_Public::process_incoming_request('ac'); 30 }catch(\Throwable $e){ 31 RabbitLoader_21_Core::on_exception($e); 32 } catch(Exception $e) { 33 RabbitLoader_21_Core::on_exception($e); 28 try { 29 RabbitLoader_21_Public::process_incoming_request('ac'); 30 } catch (\Throwable $e) { 31 RabbitLoader_21_Core::on_exception($e); 32 } catch (Exception $e) { 33 RabbitLoader_21_Core::on_exception($e); 34 } 35 } catch (Exception $e) { 34 36 } 35 37 } 36 38 } 37 38 ?> -
rabbit-loader/trunk/autoload.php
r3023896 r3030444 4 4 define('RABBITLOADER_CACHE_DIR', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . "rabbitloader"); 5 5 define('RABBITLOADER_PLUG_URL', plugin_dir_url(__FILE__)); 6 define('RABBITLOADER_PLUG_VERSION', '2.19.1 5');6 define('RABBITLOADER_PLUG_VERSION', '2.19.16'); 7 7 define('RABBITLOADER_TEXT_DOMAIN', 'rabbit-loader'); 8 8 define('RABBITLOADER_PLUG_ENV', 'PROD'); -
rabbit-loader/trunk/inc/RabbitLoader/SDK/Cache.php
r3010353 r3030444 6 6 { 7 7 8 publicconst TTL_LONG = "long";9 publicconst TTL_SHORT = "short";8 const TTL_LONG = "long"; 9 const TTL_SHORT = "short"; 10 10 11 11 private $request_url = ''; … … 74 74 private function getPathForTTL($ttl, $fileType) 75 75 { 76 return $ttl == self::TTL_LONG ? $this->fp_long . '_' . $fileType : $this->fp_short . '_' . $fileType;76 return $ttl === self::TTL_LONG ? $this->fp_long . '_' . $fileType : $this->fp_short . '_' . $fileType; 77 77 } 78 78 -
rabbit-loader/trunk/inc/RabbitLoader/SDK/File.php
r3016306 r3030444 130 130 public function fgc($length = 5000) 131 131 { 132 if (empty($this->fp) || !file_exists($this->fp)) { 133 return ''; 134 } 132 135 return file_get_contents($this->fp, false, null, 0, $length); 133 136 } -
rabbit-loader/trunk/inc/RabbitLoader/SDK/Request.php
r3020814 r3030444 22 22 private $platform = []; 23 23 24 privateconst IG_PARAMS = ['_gl', 'epik', 'fbclid', 'gbraid', 'gclid', 'msclkid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'vgo_ee', 'wbraid', 'zenid', 'rltest', 'rlrand'];24 const IG_PARAMS = ['_gl', 'epik', 'fbclid', 'gbraid', 'gclid', 'msclkid', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'vgo_ee', 'wbraid', 'zenid', 'rltest', 'rlrand']; 25 25 26 26 public function __construct($licenseKey, $rootDir) … … 49 49 public function ignoreRequest($reason = 'default') 50 50 { 51 //replace newlines form reason text to avoid issues in appendFooter 52 $reason = str_replace(array("\n", "\r"), '', $reason); 51 53 $this->ignoreRead = true; 52 54 $this->ignoreWrite = true; … … 334 336 $resJson = json_encode($response); 335 337 if ($resJson) { 338 //print resJson string if encode success 336 339 Util::sendHeader('x-rl-debug-refresh1:' . $resJson, true); 337 340 } else { 341 //print raw response if encode fails 338 342 Util::sendHeader('x-rl-debug-refresh2:' . $response, true); 339 343 } … … 341 345 if (!empty($response['saved']) && !empty($this->purgeCallback)) { 342 346 call_user_func_array($this->purgeCallback, [$url]); 347 Util::sendHeader('x-rl-refresh-saved: 1', true); 343 348 } else { 344 349 $this->cacheFile->set429(); 345 if (!empty($response['message']) && strcasecmp($response['message'], 'BQE') === 0) { 346 $this->cacheFile->deleteAll(); 350 if (!empty($response['message'])) { 351 Util::sendHeader('x-rl-debug-refresh1:' . $resJson, true); 352 if (strcasecmp($response['message'], 'BQE') === 0) { 353 $this->cacheFile->deleteAll(); 354 } 347 355 } 348 356 } -
rabbit-loader/trunk/inc/RabbitLoader/SDK/Util.php
r2955982 r3030444 5 5 class Util 6 6 { 7 //count of headers sent so far by RabbitLoader 8 private static $sentCount = 0; 9 7 10 public static function getRequestMethod() 8 11 { … … 12 15 public static function sendHeader($header, $replace) 13 16 { 14 if (!headers_sent()) { 15 header($header, $replace); 17 if (!empty($header) && (self::$sentCount < 50) && !headers_sent()) { 18 header(substr($header, 0, 150), $replace); 19 self::$sentCount++; 16 20 } 17 21 } -
rabbit-loader/trunk/inc/admin.php
r3023896 r3030444 40 40 $response['result'] = true; 41 41 } else { 42 RL21UtilWP::onPostChange( 'all');42 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL); 43 43 $response['result'] = true; 44 44 } … … 103 103 $page = RabbitLoader_21_Util_Core::get_param('page'); 104 104 105 if ( $page == 'rabbitloader') {105 if (strcmp($page, 'rabbitloader') === 0) { 106 106 add_action('admin_head', 'admin_styles', 10, 1); 107 107 function admin_styles($a) … … 181 181 //delete_user_meta($user_id, 'rl_survey_dismissed'); 182 182 $dismiss_time = intval(get_user_meta($user_id, 'rl_survey_dismissed', true)); 183 if (self::SURVEY_DIS_PERMA == $dismiss_time) {183 if (self::SURVEY_DIS_PERMA === $dismiss_time) { 184 184 //permanently dismissed 185 185 return; … … 246 246 if (!defined('RABBITLOADER_AC_ACTIVE') || (RABBITLOADER_PLUG_VERSION != RABBITLOADER_AC_PLUG_VERSION) || (LOGGED_IN_COOKIE != RABBITLOADER_AC_LOGGED_IN_COOKIE)) { 247 247 $aac_code = self::activate_advanced_cache(); 248 if ($aac_code == 4) {248 if ($aac_code === 4) { 249 249 self::$rabbitloader_cache_warnings[] = $adv_cache_msg; 250 250 } … … 386 386 $http = RabbitLoader_21_Core::callPOSTAPI('domain/heartbeat', $post_data, $apiError, $apiMessage); 387 387 388 RabbitLoader_21_Core::cleanAllCachedFiles(); 389 388 try { 389 RabbitLoader_21_Core::cleanAllCachedFiles(); 390 RabbitLoader_21_Core::delete_log_file(RabbitLoader_21_Core::LOCAL_CONFIG_FILE); 391 } catch (Exception $e) { 392 } 390 393 $ourOptions = array('rabbitloader_field_apikey', 'rabbitloader_field_apisecret', 'rabbitloader_field_domain', 'rl_optimizer_engine_version', 'rabbit_loader_wp_options', 'rabbit_loader_user_options', 'rabbitloader_cdn_prefix'); 391 394 -
rabbit-loader/trunk/inc/core/core.php
r3010353 r3030444 18 18 */ 19 19 const ORPHANED_LONG_AGE_SEC = 30 * 24 * 3600; 20 const LOCAL_CONFIG_FILE = "rl_config"; 20 21 21 22 private static function addKeys(&$args, &$rabbitloader_field_domain) … … 295 296 $rl_wp_options = get_option('rabbit_loader_wp_options'); 296 297 } else { 297 RabbitLoader_21_Core::get_log_file( 'rl_config', $rl_config);298 RabbitLoader_21_Core::get_log_file(self::LOCAL_CONFIG_FILE, $rl_config); 298 299 if (file_exists($rl_config)) { 299 300 $rl_wp_options = json_decode(file_get_contents($rl_config), true); … … 323 324 } 324 325 try { 325 RabbitLoader_21_Core::get_log_file( 'rl_config', $rl_config);326 RabbitLoader_21_Core::get_log_file(self::LOCAL_CONFIG_FILE, $rl_config); 326 327 $rl_json = json_encode($rl_wp_options, JSON_INVALID_UTF8_IGNORE); 327 328 RabbitLoader_21_Util_Core::fpc($rl_config, $rl_json, WP_DEBUG); … … 352 353 { 353 354 $fp = RL21UtilWP::get_cache_dir() . DIRECTORY_SEPARATOR . $fn . ".log"; 355 } 356 357 public static function delete_log_file($fn) 358 { 359 $fp = ''; 360 self::get_log_file($fn, $fp); 361 if ($fp && file_exists($fp)) { 362 @unlink($fp); 363 } 354 364 } 355 365 … … 379 389 } 380 390 exit; 381 }382 383 public static function sendHeader($header, $replace)384 {385 if (!headers_sent()) {386 header($header, $replace);387 }388 /*else{389 $is_wp_cron_script = !empty($_SERVER['SCRIPT_NAME']) && stripos($_SERVER['SCRIPT_NAME'], '/wp-cron.php')!==false;390 $is_wp_cron_self = !empty($_SERVER['PHP_SELF']) && stripos($_SERVER['PHP_SELF'], '/wp-cron.php') !==false;391 $is_admin_ajax_self = !empty($_SERVER['PHP_SELF']) && stripos($_SERVER['PHP_SELF'], '/admin-ajax.php') !==false;392 $is_admin_update_self = !empty($_SERVER['PHP_SELF']) && stripos($_SERVER['PHP_SELF'], '/update.php') !==false;393 $is_wp_shell = !empty($_SERVER['SHELL']);394 if($is_wp_cron_script || $is_wp_cron_self || $is_wp_shell || $is_admin_ajax_self || $is_admin_update_self){395 //wp-cron will usually send the Cache-Control and Expires headers in advance, we need not to worry logging error in this case396 return;397 }398 399 RabbitLoader_21_Core::on_exception('Trying to send header when it is already sent. Header=> '.$header.'. Headers already sent=>'.print_r(headers_list(), true));400 }*/401 391 } 402 392 -
rabbit-loader/trunk/inc/core/integrations.php
r2936874 r3030444 1 1 <?php 2 2 3 class RabbitLoader_21_TP { 3 class RabbitLoader_21_TP 4 { 4 5 5 6 const PURGE_ALL = 1; … … 8 9 private static $rl_wp_options = []; 9 10 10 public static function purge_all(&$success_count){ 11 public static function purge_all(&$success_count) 12 { 11 13 self::call_tpvs(self::PURGE_ALL, '', $success_count); 12 14 } 13 15 14 public static function purge_url($url, &$success_count){ 16 public static function purge_url($url, &$success_count) 17 { 15 18 self::call_tpvs(self::PURGE_URL, $url, $success_count); 16 19 } 17 20 18 public static function purge_post_id($post_id, &$success_count){ 21 public static function purge_post_id($post_id, &$success_count) 22 { 19 23 self::call_tpvs(self::PURGE_ID, $post_id, $success_count); 20 24 } 21 25 22 private static function call_tpvs($purge_type, $url_id, &$success_count){ 26 private static function call_tpvs($purge_type, $url_id, &$success_count) 27 { 23 28 RabbitLoader_21_Core::getWpOption(RabbitLoader_21_TP::$rl_wp_options); 24 29 $class_methods = get_class_methods('RabbitLoader_21_TP'); 25 30 foreach ($class_methods as $method_name) { 26 if (substr($method_name,0,3)=='tpv'){27 try {28 if (self::$method_name($purge_type, $url_id)){31 if (substr($method_name, 0, 3) == 'tpv') { 32 try { 33 if (self::$method_name($purge_type, $url_id)) { 29 34 ++$success_count; 30 35 } 31 } catch(\Throwable $e){36 } catch (\Throwable $e) { 32 37 RabbitLoader_21_Core::on_exception($e); 33 38 } … … 36 41 } 37 42 38 private static function tpv_wp_core($purge_type, $url_id){ 43 private static function tpv_wp_core($purge_type, $url_id) 44 { 39 45 if (function_exists('wp_cache_flush')) { 40 46 wp_cache_flush(); 41 47 } 42 48 43 if (function_exists('opcache_reset')) {49 if (function_exists('opcache_reset')) { 44 50 opcache_reset(); 45 51 } 46 52 47 if (function_exists( 'apc_clear_cache')) {53 if (function_exists('apc_clear_cache')) { 48 54 apc_clear_cache(); 49 55 } 50 56 } 51 57 52 private static function tpv_litespeed($purge_type, $url_id){ 53 $isLS = !empty($_SERVER["X-LSCACHE"]) || (!empty($_SERVER["SERVER_SOFTWARE"]) && "litespeed" == strtolower($_SERVER["SERVER_SOFTWARE"]) ) || RabbitLoader_21_Util_Core::isDev(); 54 if(!$isLS){ 55 return false; 56 } 57 if($purge_type==self::PURGE_ALL){ 58 RabbitLoader_21_Core::sendHeader("X-LiteSpeed-Purge: *", false); 59 }elseif($purge_type==self::PURGE_URL){ 58 private static function tpv_litespeed($purge_type, $url_id) 59 { 60 $isLS = !empty($_SERVER["X-LSCACHE"]) || (!empty($_SERVER["SERVER_SOFTWARE"]) && "litespeed" == strtolower($_SERVER["SERVER_SOFTWARE"])) || RabbitLoader_21_Util_Core::isDev(); 61 if (!$isLS) { 62 return false; 63 } 64 if ($purge_type == self::PURGE_ALL) { 65 RabbitLoader\SDK\Util::sendHeader("X-LiteSpeed-Purge: *", false); 66 } elseif ($purge_type == self::PURGE_URL) { 60 67 $path = parse_url($url_id, PHP_URL_PATH); 61 if (empty($path)){68 if (empty($path)) { 62 69 $path = '/'; 63 70 } 64 RabbitLoader _21_Core::sendHeader("X-LiteSpeed-Purge: ".$path, false);71 RabbitLoader\SDK\Util::sendHeader("X-LiteSpeed-Purge: " . $path, false); 65 72 } 66 73 return true; … … 70 77 * https://github.com/pantheon-systems/pantheon-advanced-page-cache/blob/master/pantheon-advanced-page-cache.php 71 78 */ 72 private static function tpv_pantheon($purge_type, $url_id){ 73 if(!function_exists('pantheon_wp_clear_edge_all')){ 74 return false; 75 } 76 if($purge_type==self::PURGE_ALL) { 79 private static function tpv_pantheon($purge_type, $url_id) 80 { 81 if (!function_exists('pantheon_wp_clear_edge_all')) { 82 return false; 83 } 84 if ($purge_type == self::PURGE_ALL) { 77 85 pantheon_wp_clear_edge_all(); 78 } elseif($purge_type==self::PURGE_ID){86 } elseif ($purge_type == self::PURGE_ID) { 79 87 do_action('clean_post_cache', $url_id); 80 88 } … … 82 90 } 83 91 84 private static function tpv_nginx($purge_type, $url_id){ 92 private static function tpv_nginx($purge_type, $url_id) 93 { 85 94 global $nginx_purger; 86 if (empty($nginx_purger)){87 return false; 88 } 89 if ($purge_type==self::PURGE_ALL){95 if (empty($nginx_purger)) { 96 return false; 97 } 98 if ($purge_type == self::PURGE_ALL) { 90 99 $nginx_purger->purge_all(); 91 } elseif($purge_type==self::PURGE_URL){100 } elseif ($purge_type == self::PURGE_URL) { 92 101 $nginx_purger->purge_url($url_id); 93 102 } … … 98 107 * https://github.com/Savvii/warpdrive/ 99 108 */ 100 private static function tpv_savii($purge_type, $url_id){ 101 if(!defined( '\Savvii\CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW')){ 102 return false; 103 } 104 do_action( 'warpdrive_domain_flush' ); 105 return true; 106 } 107 108 private static function tpv_ninukis($purge_type, $url_id){ 109 if (!defined('WP_NINUKIS_WP_NAME') || !class_exists('Ninukis_Plugin')){ 110 return false; 111 } 112 if($purge_type==self::PURGE_ALL){ 109 private static function tpv_savii($purge_type, $url_id) 110 { 111 if (!defined('\Savvii\CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW')) { 112 return false; 113 } 114 do_action('warpdrive_domain_flush'); 115 return true; 116 } 117 118 private static function tpv_ninukis($purge_type, $url_id) 119 { 120 if (!defined('WP_NINUKIS_WP_NAME') || !class_exists('Ninukis_Plugin')) { 121 return false; 122 } 123 if ($purge_type == self::PURGE_ALL) { 113 124 $purge_pressidum = Ninukis_Plugin::get_instance(); 114 125 $purge_pressidum->purgeAllCaches(); 115 126 return true; 116 } elseif($purge_type==self::PURGE_ID){117 118 }119 } 120 121 private static function tpv_pagely_cache($purge_type, $url_id){127 } elseif ($purge_type == self::PURGE_ID) { 128 } 129 } 130 131 private static function tpv_pagely_cache($purge_type, $url_id) 132 { 122 133 if (!class_exists('\PagelyCachePurge')) { 123 134 return false; 124 135 } 125 if ($purge_type==self::PURGE_ALL){136 if ($purge_type == self::PURGE_ALL) { 126 137 $purge_pagely = new PagelyCachePurge(); 127 138 $purge_pagely->purgeAll(); 128 } elseif($purge_type==self::PURGE_URL){139 } elseif ($purge_type == self::PURGE_URL) { 129 140 $purge_pagely = new PagelyCachePurge(); 130 141 $purge_pagely->purgePath(parse_url($url_id, PHP_URL_PATH) . "(.*)"); … … 134 145 135 146 //wpengine - https://wpengine.com/support/cache/ 136 private static function tpv_wpengine($purge_type, $url_id){ 147 private static function tpv_wpengine($purge_type, $url_id) 148 { 137 149 if (!class_exists("\WpeCommon")) { 138 150 return false; 139 151 } 140 if ($purge_type==self::PURGE_ALL){152 if ($purge_type == self::PURGE_ALL) { 141 153 \WpeCommon::purge_memcached(); 142 154 \WpeCommon::purge_varnish_cache(); 143 } elseif($purge_type==self::PURGE_ID){155 } elseif ($purge_type == self::PURGE_ID) { 144 156 \WpeCommon::purge_varnish_cache($url_id); 145 157 } … … 148 160 149 161 //godaddy 150 private static function tpv_wpass($purge_type, $url_id){ 151 if (!class_exists('WPaaS\Plugin')){ 152 return false; 153 } 154 if($purge_type==self::PURGE_ALL){ 155 if (method_exists( 'WPass\Plugin', 'vip' )) { 162 private static function tpv_wpass($purge_type, $url_id) 163 { 164 if (!class_exists('WPaaS\Plugin')) { 165 return false; 166 } 167 if ($purge_type == self::PURGE_ALL) { 168 if (method_exists('WPass\Plugin', 'vip')) { 156 169 //godaddy 157 170 $method = 'BAN'; 158 171 $url = home_url(); 159 172 $host = wpraiser_get_domain(); 160 $url = set_url_scheme( str_replace( $host, WPaas\Plugin::vip(), $url ), 'http');161 update_option( 'gd_system_last_cache_flush', time(), 'no'); # purge apc162 wp_remote_request( esc_url_raw( $url ), array('method' => $method, 'blocking' => false, 'headers' => array('Host' => $host)));173 $url = set_url_scheme(str_replace($host, WPaas\Plugin::vip(), $url), 'http'); 174 update_option('gd_system_last_cache_flush', time(), 'no'); # purge apc 175 wp_remote_request(esc_url_raw($url), array('method' => $method, 'blocking' => false, 'headers' => array('Host' => $host))); 163 176 } 164 177 return true; 165 }elseif($purge_type==self::PURGE_ID){ 166 178 } elseif ($purge_type == self::PURGE_ID) { 167 179 } 168 180 } 169 181 170 182 //https://github.com/cloudflare/Cloudflare-WordPress/blob/74acc2df4938df1fcfa4347e971d73e2fc6e4edc/src/WordPress/Hooks.php 171 private static function tpv_cloudflare($purge_type, $url_id){ 172 if(!class_exists('\CF\WordPress\Hooks')){ 173 return false; 174 } 175 if($purge_type==self::PURGE_ALL){ 183 private static function tpv_cloudflare($purge_type, $url_id) 184 { 185 if (!class_exists('\CF\WordPress\Hooks')) { 186 return false; 187 } 188 if ($purge_type == self::PURGE_ALL) { 176 189 $cfHooks = new \CF\WordPress\Hooks(); 177 190 $cfHooks->purgeCacheEverything(); 178 } elseif($purge_type==self::PURGE_ID){191 } elseif ($purge_type == self::PURGE_ID) { 179 192 $cfHooks = new \CF\WordPress\Hooks(); 180 193 $cfHooks->purgeCacheByRelevantURLs($url_id); … … 183 196 } 184 197 185 private static function tpv_kinsta($purge_type, $url_id){ 198 private static function tpv_kinsta($purge_type, $url_id) 199 { 186 200 if (!defined("KINSTAMU_VERSION")) { 187 201 return false; 188 202 } 189 if ($purge_type==self::PURGE_ALL){190 $response = wp_remote_get( 'https://localhost/kinsta-clear-cache-all', [191 'sslverify' => false, 203 if ($purge_type == self::PURGE_ALL) { 204 $response = wp_remote_get('https://localhost/kinsta-clear-cache-all', [ 205 'sslverify' => false, 192 206 'timeout' => 5 193 207 ]); 194 } elseif($purge_type==self::PURGE_URL){208 } elseif ($purge_type == self::PURGE_URL) { 195 209 $response = wp_remote_post('https://localhost/kinsta-clear-cache/v2/immediate', [ 196 'sslverify' => false, 210 'sslverify' => false, 197 211 'timeout' => 5, 198 212 'body' => [ 199 'single' => preg_replace( '@^https?://@', '', $url_id)213 'single' => preg_replace('@^https?://@', '', $url_id) 200 214 ] 201 215 ]); … … 205 219 206 220 //SiteGround - https://wordpress.org/plugins/sg-cachepress/ 207 private static function tpv_siteground_cachepress($purge_type, $url_id){ 221 private static function tpv_siteground_cachepress($purge_type, $url_id) 222 { 208 223 if (!function_exists('sg_cachepress_purge_cache')) { 209 224 return false; 210 225 } 211 if ($purge_type==self::PURGE_ALL){226 if ($purge_type == self::PURGE_ALL) { 212 227 sg_cachepress_purge_cache(); 213 } elseif($purge_type==self::PURGE_URL){228 } elseif ($purge_type == self::PURGE_URL) { 214 229 sg_cachepress_purge_cache($url_id); 215 230 } … … 217 232 } 218 233 219 private static function tpv_siteground($purge_type, $url_id){ 234 private static function tpv_siteground($purge_type, $url_id) 235 { 220 236 $wp_config_path = RL21UtilWP::get_wp_config(); 221 if (empty($wp_config_path) || strpos(file_get_contents($wp_config_path), 'Added by SiteGround')===false){222 return false; 223 } 224 if ($purge_type==self::PURGE_ALL){225 $url_id = home_url() .'/(.*)';226 } elseif($purge_type==self::PURGE_URL){237 if (empty($wp_config_path) || strpos(file_get_contents($wp_config_path), 'Added by SiteGround') === false) { 238 return false; 239 } 240 if ($purge_type == self::PURGE_ALL) { 241 $url_id = home_url() . '/(.*)'; 242 } elseif ($purge_type == self::PURGE_URL) { 227 243 //$url_id is already set 228 } else if($purge_type==self::PURGE_ID){244 } else if ($purge_type == self::PURGE_ID) { 229 245 return false; 230 246 } … … 239 255 * CloudWays: HTTP_X_VARNISH would be set if Varnish is on 240 256 */ 241 private static function tpv_varnish($purge_type, $url_id){ 257 private static function tpv_varnish($purge_type, $url_id) 258 { 242 259 $is_cloudways = isset($_SERVER['cw_allowed_ip']); 243 260 $uses_varnish = $is_cloudways && isset($_SERVER['HTTP_X_VARNISH']); 244 if (!$uses_varnish && !empty(RabbitLoader_21_TP::$rl_wp_options['rl_varnish'])){245 $uses_varnish = intval(RabbitLoader_21_TP::$rl_wp_options['rl_varnish']) ===1;246 } 247 if (!$uses_varnish){261 if (!$uses_varnish && !empty(RabbitLoader_21_TP::$rl_wp_options['rl_varnish'])) { 262 $uses_varnish = intval(RabbitLoader_21_TP::$rl_wp_options['rl_varnish']) === 1; 263 } 264 if (!$uses_varnish) { 248 265 return false; 249 266 } 250 267 $method = 'PURGE'; 251 if ($purge_type==self::PURGE_ALL){252 $url_id = home_url() .'/.*';253 } elseif($purge_type==self::PURGE_URL){268 if ($purge_type == self::PURGE_ALL) { 269 $url_id = home_url() . '/.*'; 270 } elseif ($purge_type == self::PURGE_URL) { 254 271 //$url_id is already set for single URL 255 if ($is_cloudways){272 if ($is_cloudways) { 256 273 $method = 'URLPURGE'; 257 274 } 258 } else if($purge_type==self::PURGE_ID){275 } else if ($purge_type == self::PURGE_ID) { 259 276 return false; 260 277 } … … 262 279 } 263 280 264 private static function tpv_wp_rocket_residue($purge_type, $url_id){ 265 if(!defined('WP_ROCKET_CACHE_PATH')){ 281 private static function tpv_wp_rocket_residue($purge_type, $url_id) 282 { 283 if (!defined('WP_ROCKET_CACHE_PATH')) { 266 284 return; 267 285 } … … 269 287 $wp_rocket_cache_path = WP_ROCKET_CACHE_PATH; #/wp-content/cache/wp-rocket/ 270 288 $host = parse_url(get_site_url(), PHP_URL_HOST); 271 $wp_rocket_cache_dir = $wp_rocket_cache_path .$host;289 $wp_rocket_cache_dir = $wp_rocket_cache_path . $host; 272 290 if (!file_exists($wp_rocket_cache_dir)) { 273 $wp_rocket_cache_dir = $wp_rocket_cache_path ."www.".$host;291 $wp_rocket_cache_dir = $wp_rocket_cache_path . "www." . $host; 274 292 } 275 293 if (file_exists($wp_rocket_cache_dir)) { 276 $special_files = ['.htaccess', '.','..',''];277 $files = glob($wp_rocket_cache_dir .'/*');278 foreach ($files as $file){279 if (empty($file) || in_array(basename($file), $special_files)){294 $special_files = ['.htaccess', '.', '..', '']; 295 $files = glob($wp_rocket_cache_dir . '/*'); 296 foreach ($files as $file) { 297 if (empty($file) || in_array(basename($file), $special_files)) { 280 298 continue; 281 299 } 282 if (is_file($file)) {300 if (is_file($file)) { 283 301 @unlink($file); // delete file 284 } elseif(is_dir($file)){ //category, tags etc285 $cat_files = glob($file .DIRECTORY_SEPARATOR.'/*');286 foreach ($cat_files as $file){302 } elseif (is_dir($file)) { //category, tags etc 303 $cat_files = glob($file . DIRECTORY_SEPARATOR . '/*'); 304 foreach ($cat_files as $file) { 287 305 @unlink($file); // delete file 288 306 } 289 307 } 290 308 } 291 } else{292 $files = glob($wp_rocket_cache_path .'*');293 if (!empty($files) && count($files)==1 && stripos($files[0], 'cache/wp-rocket/index.html')!==false){309 } else { 310 $files = glob($wp_rocket_cache_path . '*'); 311 if (!empty($files) && count($files) == 1 && stripos($files[0], 'cache/wp-rocket/index.html') !== false) { 294 312 //no dir exists 295 } else{296 RabbitLoader_21_Core::on_exception('WP_ROCKET_CACHE_PATH is true but dir not found ' .$wp_rocket_cache_dir. ' files '.print_r($files, true), 1);313 } else { 314 RabbitLoader_21_Core::on_exception('WP_ROCKET_CACHE_PATH is true but dir not found ' . $wp_rocket_cache_dir . ' files ' . print_r($files, true), 1); 297 315 } 298 316 } … … 302 320 * Doc - Hostgator and https://github.com/bluehost/endurance-page-cache/blob/master/endurance-page-cache.php 303 321 */ 304 private static function tpv_endurance($purge_type, $url_id){ 305 if (!class_exists('Endurance_Page_Cache')){ 322 private static function tpv_endurance($purge_type, $url_id) 323 { 324 if (!class_exists('Endurance_Page_Cache')) { 306 325 return; 307 326 } 308 if ($purge_type==self::PURGE_ALL){327 if ($purge_type == self::PURGE_ALL) { 309 328 do_action('epc_purge'); 310 } elseif($purge_type==self::PURGE_URL){329 } elseif ($purge_type == self::PURGE_URL) { 311 330 do_action('epc_purge_request', $url_id); 312 331 } 313 332 } 314 333 315 private static function tpv_sample($purge_type, $url_id){ 316 if($purge_type==self::PURGE_ALL){ 317 318 }elseif($purge_type==self::PURGE_ID){ 319 320 }elseif($purge_type==self::PURGE_URL){ 321 334 private static function tpv_sample($purge_type, $url_id) 335 { 336 if ($purge_type == self::PURGE_ALL) { 337 } elseif ($purge_type == self::PURGE_ID) { 338 } elseif ($purge_type == self::PURGE_URL) { 322 339 } 323 340 } … … 327 344 * @param string method - PURGE, URLPURGE 328 345 */ 329 private static function purge_varnish($url_pattern, $method){ 346 private static function purge_varnish($url_pattern, $method) 347 { 330 348 $url_parts = parse_url($url_pattern); 331 $port = (empty($url_parts['scheme']) || $url_parts['scheme'] =='https') ? '443' : '80';349 $port = (empty($url_parts['scheme']) || $url_parts['scheme'] == 'https') ? '443' : '80'; 332 350 $ch = curl_init($url_pattern); 333 351 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); 334 curl_setopt($ch, CURLOPT_RESOLVE, array($url_parts['host'] .":$port:127.0.0.1"));352 curl_setopt($ch, CURLOPT_RESOLVE, array($url_parts['host'] . ":$port:127.0.0.1")); 335 353 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 336 354 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); … … 352 370 } 353 371 } 354 ?> -
rabbit-loader/trunk/inc/public.php
r3023896 r3030444 1 1 <?php 2 3 use RabbitLoader\SDK\RabbitLoader;4 2 5 3 class RabbitLoader_21_Public … … 149 147 { 150 148 try { 151 RabbitLoader _21_Core::sendHeader("x-rl-mode: $mode", false);149 RabbitLoader\SDK\Util::sendHeader("x-rl-mode: $mode", false); 152 150 $rlSDK = RabbitLoader_21_Core::getSDK(); 153 151 -
rabbit-loader/trunk/inc/tab_settings.php
r3020814 r3030444 234 234 if ($userUpdating) { 235 235 $user_options['exclude_patterns'] = sanitize_textarea_field($_POST['exclude_patterns']); 236 RL21UtilWP::onPostChange( 'all', 'EX_PATTERN_CHANGE');236 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL); 237 237 } else { 238 238 $user_options['exclude_patterns'] = $exclude_patterns; -
rabbit-loader/trunk/inc/util_wp.php
r3023896 r3030444 3 3 class RL21UtilWP 4 4 { 5 6 const POST_ID_ALL = "all"; 5 7 6 8 private static $isSearch = false; … … 165 167 public static function onPostChange($post_id) 166 168 { 167 if ( $post_id == 'all') {168 self::$purge_queue[ 'all'] = true;169 if (strcmp($post_id, RL21UtilWP::POST_ID_ALL) === 0) { 170 self::$purge_queue[RL21UtilWP::POST_ID_ALL] = true; 169 171 } else { 170 172 try { … … 196 198 self::$purge_queue['post_ids'][$lang_post_id] = true; 197 199 } 198 RabbitLoader _21_Core::sendHeader("x-rl-wpml_posts: " . json_encode($wpml_posts), false);199 } 200 RabbitLoader _21_Core::sendHeader("x-rl-posts:" . json_encode(self::$purge_queue['post_ids']), false);200 RabbitLoader\SDK\Util::sendHeader("x-rl-wpml_posts: " . json_encode($wpml_posts), false); 201 } 202 RabbitLoader\SDK\Util::sendHeader("x-rl-posts:" . json_encode(self::$purge_queue['post_ids']), false); 201 203 } 202 204 } … … 209 211 $clean_cache = !empty($user_options['purge_on_change']); 210 212 211 if (!empty(self::$purge_queue[ 'all'])) {213 if (!empty(self::$purge_queue[RL21UtilWP::POST_ID_ALL])) { 212 214 RabbitLoader_21_Core::purge_all($local_purge_count, $purge_source, $tp_purge_count); 213 215 } else if (!empty(self::$purge_queue['post_ids'])) { … … 240 242 $local_purge_count++; 241 243 } 242 RabbitLoader _21_Core::sendHeader("x-rl-url: $url", false);244 RabbitLoader\SDK\Util::sendHeader("x-rl-url: $url", false); 243 245 } 244 246 do_action('rl_purge_request_complete', $urls_to_purge); -
rabbit-loader/trunk/rabbit-loader.php
r3023896 r3030444 7 7 * Author URI: https://rabbitloader.com/ 8 8 * Description: RabbitLoader can improve Google PageSpeed score and get you 100 out of 100 by improving the page load time to just a few milliseconds. It improves the Core Web Vitals score for your pages and boost PageSpeed score to help better search rankings and best the experience for your end user. 9 * Version: 2.19.1 59 * Version: 2.19.16 10 10 * Text Domain: rabbit-loader 11 11 */ … … 19 19 20 20 add_action('save_post', function ($post_ID, $post, $update) { 21 RL21UtilWP::onPostChange($post_ID); 21 if (strcmp($post->post_type, 'nav_menu_item') === 0) { 22 RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL); 23 } else { 24 RL21UtilWP::onPostChange($post_ID); 25 } 22 26 }, 10, 3); 23 27 add_action('wp_insert_post', function ($post_ID, $post, $update) { -
rabbit-loader/trunk/readme.txt
r3023896 r3030444 1 === RabbitLoader === 1 2 === RabbitLoader - All in One PageSpeed Optimization Plugin with Cache, Image Optimization, Lazy Loading & more === 2 3 Contributors: sanrl, abhishekgr 3 Tags: cache, c aching, cdn, lazy loading, speed optimization4 Tags: cache, cdn, lazy loading, speed optimization, performance. 4 5 Requires at least: 4.7 5 6 Tested up to: 6.4 6 Stable tag: 2.19.1 57 Stable tag: 2.19.16 7 8 Requires PHP: 5.6 8 9 License: GNU General Public License, version 2 … … 42 43 Caching is the process of storing frequently accessed data or assets in a temporary storage space for faster access and retrieval. RabbitLoader does this automatically, and one doesn't need to use any separate plugin for caching when using RabbitLoader. 43 44 44 It stores the website's assets in the cache memory, which means that the browser does not have to fetch them again from the server, resulting in faster page loads and a better user experience.45 It stores the website's assets in the nearest [cache servers](https://rabbitloader.com/articles/category/caching/ "Cache"), which means that the browser does not have to fetch them again from the server, resulting in faster page loads and a better user experience. 45 46 46 47 **CSS and JavaScript Cache** … … 60 61 RabbitLoader improves image caching by utilizing the browser caching headers, similar to CSS and JavaScript caching. It sets optimal caching headers to ensure that the images are cached for the appropriate amount of time, reducing the number of times the browser has to request them from the server. 61 62 62 RabbitLoader does all this automatically, improving the performance of a website by reducing the load time of images, resulting in a better user experience.63 RabbitLoader does all this automatically, improving the performance of a website by [reducing the load time of images](https://rabbitloader.com/articles/compressing-images-for-the-modern-web/ "reducing the load time of images using RabbitLoader"), resulting in a better user experience. 63 64 64 65 **Browser Cache** … … 84 85 The Next-gen AVIF and WebP formats are image formats that uses advanced compression techniques to reduce the size of images while maintaining their quality. These images are up to 30% smaller than JPEG or PNG images, resulting in faster page load times. 85 86 86 RabbitLoader improves the use of next-gen WebP formatby automatically converting images to the most efficient Next-gen format. RabbitLoader detects the user's browser and serves the AVIF/WebP version of the image if the browser supports it. If the browser does not support the any of the modern format, RabbitLoader serves the original image format. This ensures that the user always receives the best version of the image that their browser supports.87 RabbitLoader [improves the use of next-gen AVIF/WebP format](https://rabbitloader.com/articles/next-gen-formats/ "convert image to next-gen AVIF/WebP format") by automatically converting images to the most efficient Next-gen format. RabbitLoader detects the user's browser and serves the AVIF/WebP version of the image if the browser supports it. If the browser does not support the any of the modern format, RabbitLoader serves the original image format. This ensures that the user always receives the best version of the image that their browser supports. 87 88 88 89 **Image Placeholders** … … 102 103 This feature reduces the loading time of a website by serving content from the server nearest to the user, which in turn reduces bounce rates and improves the user experience. 103 104 104 With an [integrated CDN](https://rabbitloader.com/origin-savings/ "Integrated Premium CDN"), RabbitLoader caches the website assets at multiple locations around the world, ensuring that the content is delivered to the user from the closest server. This reduces the latency and response time, resulting in faster website loading times.105 With an integrated CDN, RabbitLoader caches the website assets at multiple locations around the world, ensuring that the content is delivered to the user from the closest server. This reduces the latency and response time, resulting in faster website loading times. 105 106 106 107 This is especially important for websites with a global audience, as it ensures that visitors from all over the world can access the website quickly and without any delay. … … 108 109 **300+ PoP's** 109 110 110 RabbitLoader uses a Content Delivery Network(CDN) that is distributed throughout the world with over 300 Points of Presence (PoP). This means that no matter where your visitors are located, they can access your website's content in milliseconds, resulting in a faster and smoother experience.111 RabbitLoader uses a [Content Delivery Network](https://rabbitloader.com/origin-savings/ "Content Delivery Network")(CDN) that is distributed throughout the world with over 300 Points of Presence (PoP). This means that no matter where your visitors are located, they can access your website's content in milliseconds, resulting in a faster and smoother experience. 111 112 112 113 This is essential for websites with a global audience, as it ensures that users from all regions can access your website quickly without experiencing any delays. With a distributed network, RabbitLoader is able to provide a faster response time for website content, which can improve user engagement and reduce bounce rates. The CDN's wide coverage ensures that the content can be delivered to users from the nearest server, resulting in lower latency and faster loading times. … … 189 190 Core Web Vitals are a set of performance metrics used to measure the user experience of a website. These metrics were introduced by Google in 2020 and include three specific factors: loading, interactivity, and visual stability. The loading factor measures how quickly the main content of a page loads, the interactivity factor measures how quickly users can interact with the page, and the visual stability factor measures how stable the visual elements of a page are while it loads. 190 191 191 Having a [good Core Web Vitals score](https://rabbitloader.com/best-pagespeed-score/ "Increase SpeedScore")is essential for providing a better user experience, and it can also lead to better rankings in Google Search. When a website has good Core Web Vitals, it can lead to higher engagement, longer time on site, and more conversions.192 193 RabbitLoader helps to improve Core Web Vitalsby optimizing various aspects of a website, including image loading, CSS, and JavaScript optimization, and deferring non-critical resources.192 Having a good Core Web Vitals score is essential for providing a better user experience, and it can also lead to better rankings in Google Search. When a website has good Core Web Vitals, it can lead to higher engagement, longer time on site, and more conversions. 193 194 RabbitLoader helps to improve [Core Web Vitals score](https://rabbitloader.com/best-pagespeed-score/ "Increase SpeedScore using RabbitLoader") by optimizing various aspects of a website, including image loading, CSS, and JavaScript optimization, and deferring non-critical resources. 194 195 195 196 By improving these aspects, RabbitLoader can help to reduce page load times, improve interactivity, and prevent visual instability. As a result, websites that use RabbitLoader are more likely to have good Core Web Vitals scores and better overall user experiences. … … 197 198 **FID (First Input Delay)** 198 199 199 FIDis a Core Web Vitals metric that measures the time between a user's first interaction with a page and the browser's response to that interaction. This metric is essential because it provides insight into how quickly a page responds to user input, which can significantly impact the user experience.200 [FID](https://rabbitloader.com/articles/first-input-delay/ "first input delay") is a Core Web Vitals metric that measures the time between a user's first interaction with a page and the browser's response to that interaction. This metric is essential because it provides insight into how quickly a page responds to user input, which can significantly impact the user experience. 200 201 201 202 An ideal page should have an FID below 100 milliseconds. Slow FID can lead to frustration for users and impact engagement metrics, such as bounce rates and time on page. Therefore, it's essential to optimize FID for a better user experience. … … 209 210 LCP is an important Core Web Vital metric that measures the loading speed of the largest content element on a web page. Google recommends a good LCP score of less than 2.5 seconds. 210 211 211 A high LCP scorecan lead to a poor user experience and negatively impact the page's search engine ranking.212 A [high LCP score](https://rabbitloader.com/articles/largest-contentful-paint/ "Largest Contentful Paint") can lead to a poor user experience and negatively impact the page's search engine ranking. 212 213 213 214 RabbitLoader's CDN Cache can significantly improve the LCP score of a website by delivering content quickly to visitors, regardless of their location. By utilizing caching and compression technologies, RabbitLoader minimizes the time it takes for a website to load the largest content element, ensuring that it appears quickly on the user's screen. … … 219 220 CLS is a metric used to evaluate the visual stability of a web page. It measures the sum total of all layout shifts that occur during the page load, including any unexpected shifts that might occur after the page has loaded. 220 221 221 Any sudden changes can adversely impact the user's experience, making CLS an essential metric for evaluating the user experience. 222 Any sudden changes can adversely impact the user's experience, making [CLS an essential metric for evaluating the user experience](https://rabbitloader.com/articles/cumulative-layout-shift/ "Cumulative Layout Shift"). 223 222 224 223 225 While it largely relies on how website developers insert dynamic content or advertisements through JavaScript, RabbitLoader attempts to allocate the necessary space for elements that will be loaded at later stages of a page's timeline. … … 242 244 * Lazy loading of ads (AdSense, AdThrive, etc. It loads data into cache when it is a necessity. 243 245 * Option to exclude pages from caching and full control through page rules. If you want to remove any particular page from cache. 244 * Woo-Commerce compatibilitywith multi-currency plugins. The cache has to be manually excluded from Woo-Commerce.246 * [Woo-Commerce compatibility](https://rabbitloader.com/wordpress-speed-optimization/ "Woo-Commerce speed optimization") with multi-currency plugins. The cache has to be manually excluded from Woo-Commerce. 245 247 246 248 All the CPU intensive optimizations are performed by RabbitLoader cloud servers, thus reducing the usage of your hosting resources and your hosting bandwidth usage. … … 249 251 250 252 Just use any shared hosting environment or even a low end hosting configuration and still achieve a perfect PageSpeed Insights score. 253 254 **SHARE THE RABBITLOADER** 255 256 Join our [Facebook Community](https://www.facebook.com/Rabbitloader/) & [LinkedIn](https://www.linkedin.com/company/rabbitloader) 257 Learn from our tutorials on [YouTube Channel](https://www.youtube.com/@rabbitloader827) 258 Or, Rate us on [Wordpress](https://wordpress.org/support/plugin/rabbit-loader/reviews/?filter=5) 251 259 252 260 == Frequently Asked Questions == … … 307 315 == Changelog == 308 316 317 = 2.19.16 = 318 * Prevent errors when plugin folder is directly deleted 319 * Performance improvements while saving navigation menus 320 309 321 = 2.19.15 = 310 322 * Bugfix for admin-ajax sending 403 in some cases
Note: See TracChangeset
for help on using the changeset viewer.