Plugin Directory

Changeset 3030444


Ignore:
Timestamp:
02/02/2024 08:20:24 AM (2 years ago)
Author:
sanrl
Message:

v2.19.16 release

Location:
rabbit-loader
Files:
1 added
21 edited
14 copied

Legend:

Unmodified
Added
Removed
  • rabbit-loader/tags/2.19.16/advanced-cache.php

    r3023894 r3030444  
    44 * 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.
    55 */
    6 defined( 'ABSPATH' ) or die( 'not allowed' );
     6defined('ABSPATH') or die('not allowed');
    77
    8 if(!defined('RABBITLOADER_AC_PLUG_DIR')){
     8if (!defined('RABBITLOADER_AC_PLUG_DIR')) {
    99
    1010    define('RABBITLOADER_AC_ABSPATH', '%%RABBITLOADER_AC_ABSPATH%%');
     
    1919        define('RABBITLOADER_AC_PLUG_VERSION', '%%RABBITLOADER_AC_PLUG_VERSION%%'); //should not be replaced from the automation script
    2020        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";
    2127
    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) {
    3436        }
    3537    }
    3638}
    37 
    38 ?>
  • rabbit-loader/tags/2.19.16/autoload.php

    r3023896 r3030444  
    44define('RABBITLOADER_CACHE_DIR', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . "rabbitloader");
    55define('RABBITLOADER_PLUG_URL', plugin_dir_url(__FILE__));
    6 define('RABBITLOADER_PLUG_VERSION', '2.19.15');
     6define('RABBITLOADER_PLUG_VERSION', '2.19.16');
    77define('RABBITLOADER_TEXT_DOMAIN', 'rabbit-loader');
    88define('RABBITLOADER_PLUG_ENV', 'PROD');
  • rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/Cache.php

    r3010353 r3030444  
    66{
    77
    8     public const TTL_LONG = "long";
    9     public const TTL_SHORT = "short";
     8    const TTL_LONG = "long";
     9    const TTL_SHORT = "short";
    1010
    1111    private $request_url = '';
     
    7474    private function getPathForTTL($ttl, $fileType)
    7575    {
    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;
    7777    }
    7878
  • rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/File.php

    r3016306 r3030444  
    130130    public function fgc($length = 5000)
    131131    {
     132        if (empty($this->fp) || !file_exists($this->fp)) {
     133            return '';
     134        }
    132135        return file_get_contents($this->fp, false, null, 0, $length);
    133136    }
  • rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/Request.php

    r3020814 r3030444  
    2222    private $platform = [];
    2323
    24     private 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'];
     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'];
    2525
    2626    public function __construct($licenseKey, $rootDir)
     
    4949    public function ignoreRequest($reason = 'default')
    5050    {
     51        //replace newlines form reason text to avoid issues in appendFooter
     52        $reason = str_replace(array("\n", "\r"), '', $reason);
    5153        $this->ignoreRead = true;
    5254        $this->ignoreWrite = true;
     
    334336        $resJson = json_encode($response);
    335337        if ($resJson) {
     338            //print resJson string if encode success
    336339            Util::sendHeader('x-rl-debug-refresh1:' . $resJson, true);
    337340        } else {
     341            //print raw response if encode fails
    338342            Util::sendHeader('x-rl-debug-refresh2:' . $response, true);
    339343        }
     
    341345        if (!empty($response['saved']) && !empty($this->purgeCallback)) {
    342346            call_user_func_array($this->purgeCallback, [$url]);
     347            Util::sendHeader('x-rl-refresh-saved: 1', true);
    343348        } else {
    344349            $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                }
    347355            }
    348356        }
  • rabbit-loader/tags/2.19.16/inc/RabbitLoader/SDK/Util.php

    r2955982 r3030444  
    55class Util
    66{
     7    //count of headers sent so far by RabbitLoader
     8    private static $sentCount = 0;
     9
    710    public static function getRequestMethod()
    811    {
     
    1215    public static function sendHeader($header, $replace)
    1316    {
    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++;
    1620        }
    1721    }
  • rabbit-loader/tags/2.19.16/inc/admin.php

    r3023896 r3030444  
    4040                $response['result'] = true;
    4141            } else {
    42                 RL21UtilWP::onPostChange('all');
     42                RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL);
    4343                $response['result'] = true;
    4444            }
     
    103103        $page = RabbitLoader_21_Util_Core::get_param('page');
    104104
    105         if ($page == 'rabbitloader') {
     105        if (strcmp($page, 'rabbitloader') === 0) {
    106106            add_action('admin_head', 'admin_styles', 10, 1);
    107107            function admin_styles($a)
     
    181181        //delete_user_meta($user_id, 'rl_survey_dismissed');
    182182        $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) {
    184184            //permanently dismissed
    185185            return;
     
    246246            if (!defined('RABBITLOADER_AC_ACTIVE') || (RABBITLOADER_PLUG_VERSION != RABBITLOADER_AC_PLUG_VERSION) || (LOGGED_IN_COOKIE != RABBITLOADER_AC_LOGGED_IN_COOKIE)) {
    247247                $aac_code = self::activate_advanced_cache();
    248                 if ($aac_code == 4) {
     248                if ($aac_code === 4) {
    249249                    self::$rabbitloader_cache_warnings[] = $adv_cache_msg;
    250250                }
     
    386386        $http = RabbitLoader_21_Core::callPOSTAPI('domain/heartbeat', $post_data, $apiError, $apiMessage);
    387387
    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        }
    390393        $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');
    391394
  • rabbit-loader/tags/2.19.16/inc/core/core.php

    r3010353 r3030444  
    1818     */
    1919    const ORPHANED_LONG_AGE_SEC = 30 * 24 * 3600;
     20    const LOCAL_CONFIG_FILE = "rl_config";
    2021
    2122    private static function addKeys(&$args, &$rabbitloader_field_domain)
     
    295296            $rl_wp_options = get_option('rabbit_loader_wp_options');
    296297        } 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);
    298299            if (file_exists($rl_config)) {
    299300                $rl_wp_options = json_decode(file_get_contents($rl_config), true);
     
    323324        }
    324325        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);
    326327            $rl_json = json_encode($rl_wp_options, JSON_INVALID_UTF8_IGNORE);
    327328            RabbitLoader_21_Util_Core::fpc($rl_config, $rl_json, WP_DEBUG);
     
    352353    {
    353354        $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        }
    354364    }
    355365
     
    379389        }
    380390        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 case
    396                 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         }*/
    401391    }
    402392
  • rabbit-loader/tags/2.19.16/inc/core/integrations.php

    r2936874 r3030444  
    11<?php
    22
    3 class RabbitLoader_21_TP {
     3class RabbitLoader_21_TP
     4{
    45
    56    const PURGE_ALL = 1;
     
    89    private static $rl_wp_options = [];
    910
    10     public static function purge_all(&$success_count){
     11    public static function purge_all(&$success_count)
     12    {
    1113        self::call_tpvs(self::PURGE_ALL, '', $success_count);
    1214    }
    1315
    14     public static function purge_url($url, &$success_count){
     16    public static function purge_url($url, &$success_count)
     17    {
    1518        self::call_tpvs(self::PURGE_URL, $url, $success_count);
    1619    }
    1720
    18     public static function purge_post_id($post_id, &$success_count){
     21    public static function purge_post_id($post_id, &$success_count)
     22    {
    1923        self::call_tpvs(self::PURGE_ID, $post_id, $success_count);
    2024    }
    2125
    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    {
    2328        RabbitLoader_21_Core::getWpOption(RabbitLoader_21_TP::$rl_wp_options);
    2429        $class_methods = get_class_methods('RabbitLoader_21_TP');
    2530        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)) {
    2934                        ++$success_count;
    3035                    }
    31                 }catch(\Throwable $e){
     36                } catch (\Throwable $e) {
    3237                    RabbitLoader_21_Core::on_exception($e);
    3338                }
     
    3641    }
    3742
    38     private static function tpv_wp_core($purge_type, $url_id){
     43    private static function tpv_wp_core($purge_type, $url_id)
     44    {
    3945        if (function_exists('wp_cache_flush')) {
    4046            wp_cache_flush();
    4147        }
    4248
    43         if (function_exists('opcache_reset')){
     49        if (function_exists('opcache_reset')) {
    4450            opcache_reset();
    4551        }
    4652
    47         if (function_exists( 'apc_clear_cache')) {
     53        if (function_exists('apc_clear_cache')) {
    4854            apc_clear_cache();
    4955        }
    5056    }
    5157
    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) {
    6067            $path = parse_url($url_id, PHP_URL_PATH);
    61             if(empty($path)){
     68            if (empty($path)) {
    6269                $path = '/';
    6370            }
    64             RabbitLoader_21_Core::sendHeader("X-LiteSpeed-Purge: ".$path, false);
     71            RabbitLoader\SDK\Util::sendHeader("X-LiteSpeed-Purge: " . $path, false);
    6572        }
    6673        return true;
     
    7077     * https://github.com/pantheon-systems/pantheon-advanced-page-cache/blob/master/pantheon-advanced-page-cache.php
    7178     */
    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) {
    7785            pantheon_wp_clear_edge_all();
    78         }elseif($purge_type==self::PURGE_ID){
     86        } elseif ($purge_type == self::PURGE_ID) {
    7987            do_action('clean_post_cache', $url_id);
    8088        }
     
    8290    }
    8391
    84     private static function tpv_nginx($purge_type, $url_id){
     92    private static function tpv_nginx($purge_type, $url_id)
     93    {
    8594        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) {
    9099            $nginx_purger->purge_all();
    91         }elseif($purge_type==self::PURGE_URL){
     100        } elseif ($purge_type == self::PURGE_URL) {
    92101            $nginx_purger->purge_url($url_id);
    93102        }
     
    98107     * https://github.com/Savvii/warpdrive/
    99108     */
    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) {
    113124            $purge_pressidum = Ninukis_Plugin::get_instance();
    114125            $purge_pressidum->purgeAllCaches();
    115126            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    {
    122133        if (!class_exists('\PagelyCachePurge')) {
    123134            return false;
    124135        }
    125         if($purge_type==self::PURGE_ALL){
     136        if ($purge_type == self::PURGE_ALL) {
    126137            $purge_pagely = new PagelyCachePurge();
    127138            $purge_pagely->purgeAll();
    128         }elseif($purge_type==self::PURGE_URL){
     139        } elseif ($purge_type == self::PURGE_URL) {
    129140            $purge_pagely = new PagelyCachePurge();
    130141            $purge_pagely->purgePath(parse_url($url_id, PHP_URL_PATH) . "(.*)");
     
    134145
    135146    //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    {
    137149        if (!class_exists("\WpeCommon")) {
    138150            return false;
    139151        }
    140         if($purge_type==self::PURGE_ALL){
     152        if ($purge_type == self::PURGE_ALL) {
    141153            \WpeCommon::purge_memcached();
    142154            \WpeCommon::purge_varnish_cache();
    143         }elseif($purge_type==self::PURGE_ID){
     155        } elseif ($purge_type == self::PURGE_ID) {
    144156            \WpeCommon::purge_varnish_cache($url_id);
    145157        }
     
    148160
    149161    //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')) {
    156169                //godaddy
    157170                $method = 'BAN';
    158171                $url = home_url();
    159172                $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 apc
    162                 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)));
    163176            }
    164177            return true;
    165         }elseif($purge_type==self::PURGE_ID){
    166            
     178        } elseif ($purge_type == self::PURGE_ID) {
    167179        }
    168180    }
    169181
    170182    //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) {
    176189            $cfHooks = new \CF\WordPress\Hooks();
    177190            $cfHooks->purgeCacheEverything();
    178         }elseif($purge_type==self::PURGE_ID){
     191        } elseif ($purge_type == self::PURGE_ID) {
    179192            $cfHooks = new \CF\WordPress\Hooks();
    180193            $cfHooks->purgeCacheByRelevantURLs($url_id);
     
    183196    }
    184197
    185     private static function tpv_kinsta($purge_type, $url_id){
     198    private static function tpv_kinsta($purge_type, $url_id)
     199    {
    186200        if (!defined("KINSTAMU_VERSION")) {
    187201            return false;
    188202        }
    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,
    192206                'timeout'   => 5
    193207            ]);
    194         }elseif($purge_type==self::PURGE_URL){
     208        } elseif ($purge_type == self::PURGE_URL) {
    195209            $response = wp_remote_post('https://localhost/kinsta-clear-cache/v2/immediate', [
    196                 'sslverify' => false, 
     210                'sslverify' => false,
    197211                'timeout'   => 5,
    198212                'body'      => [
    199                     'single' => preg_replace( '@^https?://@', '', $url_id)
     213                    'single' => preg_replace('@^https?://@', '', $url_id)
    200214                ]
    201215            ]);
     
    205219
    206220    //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    {
    208223        if (!function_exists('sg_cachepress_purge_cache')) {
    209224            return false;
    210225        }
    211         if($purge_type==self::PURGE_ALL){
     226        if ($purge_type == self::PURGE_ALL) {
    212227            sg_cachepress_purge_cache();
    213         }elseif($purge_type==self::PURGE_URL){
     228        } elseif ($purge_type == self::PURGE_URL) {
    214229            sg_cachepress_purge_cache($url_id);
    215230        }
     
    217232    }
    218233
    219     private static function tpv_siteground($purge_type, $url_id){
     234    private static function tpv_siteground($purge_type, $url_id)
     235    {
    220236        $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) {
    227243            //$url_id is already set
    228         }else if($purge_type==self::PURGE_ID){
     244        } else if ($purge_type == self::PURGE_ID) {
    229245            return false;
    230246        }
     
    239255     * CloudWays: HTTP_X_VARNISH would be set if Varnish is on
    240256     */
    241     private static function tpv_varnish($purge_type, $url_id){
     257    private static function tpv_varnish($purge_type, $url_id)
     258    {
    242259        $is_cloudways = isset($_SERVER['cw_allowed_ip']);
    243260        $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) {
    248265            return false;
    249266        }
    250267        $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) {
    254271            //$url_id is already set for single URL
    255             if($is_cloudways){
     272            if ($is_cloudways) {
    256273                $method = 'URLPURGE';
    257274            }
    258         }else if($purge_type==self::PURGE_ID){
     275        } else if ($purge_type == self::PURGE_ID) {
    259276            return false;
    260277        }
     
    262279    }
    263280
    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')) {
    266284            return;
    267285        }
     
    269287        $wp_rocket_cache_path = WP_ROCKET_CACHE_PATH; #/wp-content/cache/wp-rocket/
    270288        $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;
    272290        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;
    274292        }
    275293        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)) {
    280298                    continue;
    281299                }
    282                 if(is_file($file)) {
     300                if (is_file($file)) {
    283301                    @unlink($file); // delete file
    284                 }elseif(is_dir($file)){ //category, tags etc
    285                     $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) {
    287305                        @unlink($file); // delete file
    288306                    }
    289307                }
    290308            }
    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) {
    294312                //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);
    297315            }
    298316        }
     
    302320     * Doc - Hostgator and https://github.com/bluehost/endurance-page-cache/blob/master/endurance-page-cache.php
    303321     */
    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')) {
    306325            return;
    307326        }
    308         if($purge_type==self::PURGE_ALL){
     327        if ($purge_type == self::PURGE_ALL) {
    309328            do_action('epc_purge');
    310         }elseif($purge_type==self::PURGE_URL){
     329        } elseif ($purge_type == self::PURGE_URL) {
    311330            do_action('epc_purge_request', $url_id);
    312331        }
    313332    }
    314333
    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) {
    322339        }
    323340    }
     
    327344     * @param string method - PURGE, URLPURGE
    328345     */
    329     private static function purge_varnish($url_pattern, $method){
     346    private static function purge_varnish($url_pattern, $method)
     347    {
    330348        $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';
    332350        $ch = curl_init($url_pattern);
    333351        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"));
    335353        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    336354        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
     
    352370    }
    353371}
    354 ?>
  • rabbit-loader/tags/2.19.16/inc/public.php

    r3023896 r3030444  
    11<?php
    2 
    3 use RabbitLoader\SDK\RabbitLoader;
    42
    53class RabbitLoader_21_Public
     
    149147    {
    150148        try {
    151             RabbitLoader_21_Core::sendHeader("x-rl-mode: $mode", false);
     149            RabbitLoader\SDK\Util::sendHeader("x-rl-mode: $mode", false);
    152150            $rlSDK = RabbitLoader_21_Core::getSDK();
    153151
  • rabbit-loader/tags/2.19.16/inc/tab_settings.php

    r3020814 r3030444  
    234234            if ($userUpdating) {
    235235                $user_options['exclude_patterns'] = sanitize_textarea_field($_POST['exclude_patterns']);
    236                 RL21UtilWP::onPostChange('all', 'EX_PATTERN_CHANGE');
     236                RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL);
    237237            } else {
    238238                $user_options['exclude_patterns'] = $exclude_patterns;
  • rabbit-loader/tags/2.19.16/inc/util_wp.php

    r3023896 r3030444  
    33class RL21UtilWP
    44{
     5
     6    const POST_ID_ALL = "all";
    57
    68    private static $isSearch = false;
     
    165167    public static function onPostChange($post_id)
    166168    {
    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;
    169171        } else {
    170172            try {
     
    196198                    self::$purge_queue['post_ids'][$lang_post_id] = true;
    197199                }
    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);
    201203        }
    202204    }
     
    209211        $clean_cache = !empty($user_options['purge_on_change']);
    210212
    211         if (!empty(self::$purge_queue['all'])) {
     213        if (!empty(self::$purge_queue[RL21UtilWP::POST_ID_ALL])) {
    212214            RabbitLoader_21_Core::purge_all($local_purge_count, $purge_source, $tp_purge_count);
    213215        } else if (!empty(self::$purge_queue['post_ids'])) {
     
    240242                    $local_purge_count++;
    241243                }
    242                 RabbitLoader_21_Core::sendHeader("x-rl-url: $url", false);
     244                RabbitLoader\SDK\Util::sendHeader("x-rl-url: $url", false);
    243245            }
    244246            do_action('rl_purge_request_complete', $urls_to_purge);
  • rabbit-loader/tags/2.19.16/rabbit-loader.php

    r3023896 r3030444  
    77 * Author URI:   https://rabbitloader.com/
    88 * 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.15
     9 * Version: 2.19.16
    1010 * Text Domain: rabbit-loader
    1111 */
     
    1919
    2020add_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    }
    2226}, 10, 3);
    2327add_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 ===
    23Contributors: sanrl, abhishekgr
    3 Tags: cache, caching, cdn, lazy loading, speed optimization
     4Tags: cache, cdn, lazy loading, speed optimization, performance.
    45Requires at least: 4.7
    56Tested up to: 6.4
    6 Stable tag: 2.19.15
     7Stable tag: 2.19.16
    78Requires PHP: 5.6
    89License: GNU General Public License, version 2
     
    4243Caching 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.
    4344
    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.
     45It 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.
    4546
    4647**CSS and JavaScript Cache**
     
    6061RabbitLoader 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.
    6162
    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.
     63RabbitLoader 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.
    6364
    6465**Browser Cache**
     
    8485The 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.
    8586 
    86 RabbitLoader improves the use of next-gen 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.
     87RabbitLoader [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.
    8788
    8889**Image Placeholders**
     
    102103 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.
    103104 
    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.
     105With 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.
    105106 
    106107This 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.
     
    108109**300+ PoP's**
    109110
    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.
     111RabbitLoader 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.
    111112 
    112113This 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.
     
    189190Core 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.
    190191 
    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 Vitals by optimizing various aspects of a website, including image loading, CSS, and JavaScript optimization, and deferring non-critical resources.
     192Having 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 
     194RabbitLoader 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.
    194195 
    195196By 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.
     
    197198**FID (First Input Delay)**
    198199
    199 FID 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[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.
    200201 
    201202An 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.
     
    209210LCP 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.
    210211 
    211 A high LCP score can lead to a poor user experience and negatively impact the page's search engine ranking.
     212A [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.
    212213 
    213214RabbitLoader'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.
     
    219220CLS 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.
    220221
    221 Any sudden changes can adversely impact the user's experience, making CLS an essential metric for evaluating the user experience.
     222Any 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
    222224
    223225While 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.
     
    242244*   Lazy loading of ads (AdSense, AdThrive, etc. It loads data into cache when it is a necessity.
    243245*   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 compatibility with 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.
    245247
    246248All the CPU intensive optimizations are performed by RabbitLoader cloud servers, thus reducing the usage of your hosting resources and your hosting bandwidth usage.
     
    249251
    250252Just 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
     256Join our [Facebook Community](https://www.facebook.com/Rabbitloader/) & [LinkedIn](https://www.linkedin.com/company/rabbitloader)
     257Learn from our tutorials on [YouTube Channel](https://www.youtube.com/@rabbitloader827)
     258Or, Rate us on [Wordpress](https://wordpress.org/support/plugin/rabbit-loader/reviews/?filter=5)
    251259
    252260== Frequently Asked Questions ==
     
    307315== Changelog ==
    308316
     317= 2.19.16 =
     318* Prevent errors when plugin folder is directly deleted
     319* Performance improvements while saving navigation menus
     320
    309321= 2.19.15 =
    310322* Bugfix for admin-ajax sending 403 in some cases
  • rabbit-loader/trunk/advanced-cache.php

    r2945212 r3030444  
    44 * 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.
    55 */
    6 defined( 'ABSPATH' ) or die( 'not allowed' );
     6defined('ABSPATH') or die('not allowed');
    77
    8 if(!defined('RABBITLOADER_AC_PLUG_DIR')){
     8if (!defined('RABBITLOADER_AC_PLUG_DIR')) {
    99
    1010    define('RABBITLOADER_AC_ABSPATH', '%%RABBITLOADER_AC_ABSPATH%%');
     
    1919        define('RABBITLOADER_AC_PLUG_VERSION', '%%RABBITLOADER_AC_PLUG_VERSION%%'); //should not be replaced from the automation script
    2020        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";
    2127
    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) {
    3436        }
    3537    }
    3638}
    37 
    38 ?>
  • rabbit-loader/trunk/autoload.php

    r3023896 r3030444  
    44define('RABBITLOADER_CACHE_DIR', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . "rabbitloader");
    55define('RABBITLOADER_PLUG_URL', plugin_dir_url(__FILE__));
    6 define('RABBITLOADER_PLUG_VERSION', '2.19.15');
     6define('RABBITLOADER_PLUG_VERSION', '2.19.16');
    77define('RABBITLOADER_TEXT_DOMAIN', 'rabbit-loader');
    88define('RABBITLOADER_PLUG_ENV', 'PROD');
  • rabbit-loader/trunk/inc/RabbitLoader/SDK/Cache.php

    r3010353 r3030444  
    66{
    77
    8     public const TTL_LONG = "long";
    9     public const TTL_SHORT = "short";
     8    const TTL_LONG = "long";
     9    const TTL_SHORT = "short";
    1010
    1111    private $request_url = '';
     
    7474    private function getPathForTTL($ttl, $fileType)
    7575    {
    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;
    7777    }
    7878
  • rabbit-loader/trunk/inc/RabbitLoader/SDK/File.php

    r3016306 r3030444  
    130130    public function fgc($length = 5000)
    131131    {
     132        if (empty($this->fp) || !file_exists($this->fp)) {
     133            return '';
     134        }
    132135        return file_get_contents($this->fp, false, null, 0, $length);
    133136    }
  • rabbit-loader/trunk/inc/RabbitLoader/SDK/Request.php

    r3020814 r3030444  
    2222    private $platform = [];
    2323
    24     private 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'];
     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'];
    2525
    2626    public function __construct($licenseKey, $rootDir)
     
    4949    public function ignoreRequest($reason = 'default')
    5050    {
     51        //replace newlines form reason text to avoid issues in appendFooter
     52        $reason = str_replace(array("\n", "\r"), '', $reason);
    5153        $this->ignoreRead = true;
    5254        $this->ignoreWrite = true;
     
    334336        $resJson = json_encode($response);
    335337        if ($resJson) {
     338            //print resJson string if encode success
    336339            Util::sendHeader('x-rl-debug-refresh1:' . $resJson, true);
    337340        } else {
     341            //print raw response if encode fails
    338342            Util::sendHeader('x-rl-debug-refresh2:' . $response, true);
    339343        }
     
    341345        if (!empty($response['saved']) && !empty($this->purgeCallback)) {
    342346            call_user_func_array($this->purgeCallback, [$url]);
     347            Util::sendHeader('x-rl-refresh-saved: 1', true);
    343348        } else {
    344349            $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                }
    347355            }
    348356        }
  • rabbit-loader/trunk/inc/RabbitLoader/SDK/Util.php

    r2955982 r3030444  
    55class Util
    66{
     7    //count of headers sent so far by RabbitLoader
     8    private static $sentCount = 0;
     9
    710    public static function getRequestMethod()
    811    {
     
    1215    public static function sendHeader($header, $replace)
    1316    {
    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++;
    1620        }
    1721    }
  • rabbit-loader/trunk/inc/admin.php

    r3023896 r3030444  
    4040                $response['result'] = true;
    4141            } else {
    42                 RL21UtilWP::onPostChange('all');
     42                RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL);
    4343                $response['result'] = true;
    4444            }
     
    103103        $page = RabbitLoader_21_Util_Core::get_param('page');
    104104
    105         if ($page == 'rabbitloader') {
     105        if (strcmp($page, 'rabbitloader') === 0) {
    106106            add_action('admin_head', 'admin_styles', 10, 1);
    107107            function admin_styles($a)
     
    181181        //delete_user_meta($user_id, 'rl_survey_dismissed');
    182182        $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) {
    184184            //permanently dismissed
    185185            return;
     
    246246            if (!defined('RABBITLOADER_AC_ACTIVE') || (RABBITLOADER_PLUG_VERSION != RABBITLOADER_AC_PLUG_VERSION) || (LOGGED_IN_COOKIE != RABBITLOADER_AC_LOGGED_IN_COOKIE)) {
    247247                $aac_code = self::activate_advanced_cache();
    248                 if ($aac_code == 4) {
     248                if ($aac_code === 4) {
    249249                    self::$rabbitloader_cache_warnings[] = $adv_cache_msg;
    250250                }
     
    386386        $http = RabbitLoader_21_Core::callPOSTAPI('domain/heartbeat', $post_data, $apiError, $apiMessage);
    387387
    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        }
    390393        $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');
    391394
  • rabbit-loader/trunk/inc/core/core.php

    r3010353 r3030444  
    1818     */
    1919    const ORPHANED_LONG_AGE_SEC = 30 * 24 * 3600;
     20    const LOCAL_CONFIG_FILE = "rl_config";
    2021
    2122    private static function addKeys(&$args, &$rabbitloader_field_domain)
     
    295296            $rl_wp_options = get_option('rabbit_loader_wp_options');
    296297        } 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);
    298299            if (file_exists($rl_config)) {
    299300                $rl_wp_options = json_decode(file_get_contents($rl_config), true);
     
    323324        }
    324325        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);
    326327            $rl_json = json_encode($rl_wp_options, JSON_INVALID_UTF8_IGNORE);
    327328            RabbitLoader_21_Util_Core::fpc($rl_config, $rl_json, WP_DEBUG);
     
    352353    {
    353354        $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        }
    354364    }
    355365
     
    379389        }
    380390        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 case
    396                 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         }*/
    401391    }
    402392
  • rabbit-loader/trunk/inc/core/integrations.php

    r2936874 r3030444  
    11<?php
    22
    3 class RabbitLoader_21_TP {
     3class RabbitLoader_21_TP
     4{
    45
    56    const PURGE_ALL = 1;
     
    89    private static $rl_wp_options = [];
    910
    10     public static function purge_all(&$success_count){
     11    public static function purge_all(&$success_count)
     12    {
    1113        self::call_tpvs(self::PURGE_ALL, '', $success_count);
    1214    }
    1315
    14     public static function purge_url($url, &$success_count){
     16    public static function purge_url($url, &$success_count)
     17    {
    1518        self::call_tpvs(self::PURGE_URL, $url, $success_count);
    1619    }
    1720
    18     public static function purge_post_id($post_id, &$success_count){
     21    public static function purge_post_id($post_id, &$success_count)
     22    {
    1923        self::call_tpvs(self::PURGE_ID, $post_id, $success_count);
    2024    }
    2125
    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    {
    2328        RabbitLoader_21_Core::getWpOption(RabbitLoader_21_TP::$rl_wp_options);
    2429        $class_methods = get_class_methods('RabbitLoader_21_TP');
    2530        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)) {
    2934                        ++$success_count;
    3035                    }
    31                 }catch(\Throwable $e){
     36                } catch (\Throwable $e) {
    3237                    RabbitLoader_21_Core::on_exception($e);
    3338                }
     
    3641    }
    3742
    38     private static function tpv_wp_core($purge_type, $url_id){
     43    private static function tpv_wp_core($purge_type, $url_id)
     44    {
    3945        if (function_exists('wp_cache_flush')) {
    4046            wp_cache_flush();
    4147        }
    4248
    43         if (function_exists('opcache_reset')){
     49        if (function_exists('opcache_reset')) {
    4450            opcache_reset();
    4551        }
    4652
    47         if (function_exists( 'apc_clear_cache')) {
     53        if (function_exists('apc_clear_cache')) {
    4854            apc_clear_cache();
    4955        }
    5056    }
    5157
    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) {
    6067            $path = parse_url($url_id, PHP_URL_PATH);
    61             if(empty($path)){
     68            if (empty($path)) {
    6269                $path = '/';
    6370            }
    64             RabbitLoader_21_Core::sendHeader("X-LiteSpeed-Purge: ".$path, false);
     71            RabbitLoader\SDK\Util::sendHeader("X-LiteSpeed-Purge: " . $path, false);
    6572        }
    6673        return true;
     
    7077     * https://github.com/pantheon-systems/pantheon-advanced-page-cache/blob/master/pantheon-advanced-page-cache.php
    7178     */
    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) {
    7785            pantheon_wp_clear_edge_all();
    78         }elseif($purge_type==self::PURGE_ID){
     86        } elseif ($purge_type == self::PURGE_ID) {
    7987            do_action('clean_post_cache', $url_id);
    8088        }
     
    8290    }
    8391
    84     private static function tpv_nginx($purge_type, $url_id){
     92    private static function tpv_nginx($purge_type, $url_id)
     93    {
    8594        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) {
    9099            $nginx_purger->purge_all();
    91         }elseif($purge_type==self::PURGE_URL){
     100        } elseif ($purge_type == self::PURGE_URL) {
    92101            $nginx_purger->purge_url($url_id);
    93102        }
     
    98107     * https://github.com/Savvii/warpdrive/
    99108     */
    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) {
    113124            $purge_pressidum = Ninukis_Plugin::get_instance();
    114125            $purge_pressidum->purgeAllCaches();
    115126            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    {
    122133        if (!class_exists('\PagelyCachePurge')) {
    123134            return false;
    124135        }
    125         if($purge_type==self::PURGE_ALL){
     136        if ($purge_type == self::PURGE_ALL) {
    126137            $purge_pagely = new PagelyCachePurge();
    127138            $purge_pagely->purgeAll();
    128         }elseif($purge_type==self::PURGE_URL){
     139        } elseif ($purge_type == self::PURGE_URL) {
    129140            $purge_pagely = new PagelyCachePurge();
    130141            $purge_pagely->purgePath(parse_url($url_id, PHP_URL_PATH) . "(.*)");
     
    134145
    135146    //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    {
    137149        if (!class_exists("\WpeCommon")) {
    138150            return false;
    139151        }
    140         if($purge_type==self::PURGE_ALL){
     152        if ($purge_type == self::PURGE_ALL) {
    141153            \WpeCommon::purge_memcached();
    142154            \WpeCommon::purge_varnish_cache();
    143         }elseif($purge_type==self::PURGE_ID){
     155        } elseif ($purge_type == self::PURGE_ID) {
    144156            \WpeCommon::purge_varnish_cache($url_id);
    145157        }
     
    148160
    149161    //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')) {
    156169                //godaddy
    157170                $method = 'BAN';
    158171                $url = home_url();
    159172                $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 apc
    162                 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)));
    163176            }
    164177            return true;
    165         }elseif($purge_type==self::PURGE_ID){
    166            
     178        } elseif ($purge_type == self::PURGE_ID) {
    167179        }
    168180    }
    169181
    170182    //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) {
    176189            $cfHooks = new \CF\WordPress\Hooks();
    177190            $cfHooks->purgeCacheEverything();
    178         }elseif($purge_type==self::PURGE_ID){
     191        } elseif ($purge_type == self::PURGE_ID) {
    179192            $cfHooks = new \CF\WordPress\Hooks();
    180193            $cfHooks->purgeCacheByRelevantURLs($url_id);
     
    183196    }
    184197
    185     private static function tpv_kinsta($purge_type, $url_id){
     198    private static function tpv_kinsta($purge_type, $url_id)
     199    {
    186200        if (!defined("KINSTAMU_VERSION")) {
    187201            return false;
    188202        }
    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,
    192206                'timeout'   => 5
    193207            ]);
    194         }elseif($purge_type==self::PURGE_URL){
     208        } elseif ($purge_type == self::PURGE_URL) {
    195209            $response = wp_remote_post('https://localhost/kinsta-clear-cache/v2/immediate', [
    196                 'sslverify' => false, 
     210                'sslverify' => false,
    197211                'timeout'   => 5,
    198212                'body'      => [
    199                     'single' => preg_replace( '@^https?://@', '', $url_id)
     213                    'single' => preg_replace('@^https?://@', '', $url_id)
    200214                ]
    201215            ]);
     
    205219
    206220    //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    {
    208223        if (!function_exists('sg_cachepress_purge_cache')) {
    209224            return false;
    210225        }
    211         if($purge_type==self::PURGE_ALL){
     226        if ($purge_type == self::PURGE_ALL) {
    212227            sg_cachepress_purge_cache();
    213         }elseif($purge_type==self::PURGE_URL){
     228        } elseif ($purge_type == self::PURGE_URL) {
    214229            sg_cachepress_purge_cache($url_id);
    215230        }
     
    217232    }
    218233
    219     private static function tpv_siteground($purge_type, $url_id){
     234    private static function tpv_siteground($purge_type, $url_id)
     235    {
    220236        $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) {
    227243            //$url_id is already set
    228         }else if($purge_type==self::PURGE_ID){
     244        } else if ($purge_type == self::PURGE_ID) {
    229245            return false;
    230246        }
     
    239255     * CloudWays: HTTP_X_VARNISH would be set if Varnish is on
    240256     */
    241     private static function tpv_varnish($purge_type, $url_id){
     257    private static function tpv_varnish($purge_type, $url_id)
     258    {
    242259        $is_cloudways = isset($_SERVER['cw_allowed_ip']);
    243260        $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) {
    248265            return false;
    249266        }
    250267        $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) {
    254271            //$url_id is already set for single URL
    255             if($is_cloudways){
     272            if ($is_cloudways) {
    256273                $method = 'URLPURGE';
    257274            }
    258         }else if($purge_type==self::PURGE_ID){
     275        } else if ($purge_type == self::PURGE_ID) {
    259276            return false;
    260277        }
     
    262279    }
    263280
    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')) {
    266284            return;
    267285        }
     
    269287        $wp_rocket_cache_path = WP_ROCKET_CACHE_PATH; #/wp-content/cache/wp-rocket/
    270288        $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;
    272290        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;
    274292        }
    275293        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)) {
    280298                    continue;
    281299                }
    282                 if(is_file($file)) {
     300                if (is_file($file)) {
    283301                    @unlink($file); // delete file
    284                 }elseif(is_dir($file)){ //category, tags etc
    285                     $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) {
    287305                        @unlink($file); // delete file
    288306                    }
    289307                }
    290308            }
    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) {
    294312                //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);
    297315            }
    298316        }
     
    302320     * Doc - Hostgator and https://github.com/bluehost/endurance-page-cache/blob/master/endurance-page-cache.php
    303321     */
    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')) {
    306325            return;
    307326        }
    308         if($purge_type==self::PURGE_ALL){
     327        if ($purge_type == self::PURGE_ALL) {
    309328            do_action('epc_purge');
    310         }elseif($purge_type==self::PURGE_URL){
     329        } elseif ($purge_type == self::PURGE_URL) {
    311330            do_action('epc_purge_request', $url_id);
    312331        }
    313332    }
    314333
    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) {
    322339        }
    323340    }
     
    327344     * @param string method - PURGE, URLPURGE
    328345     */
    329     private static function purge_varnish($url_pattern, $method){
     346    private static function purge_varnish($url_pattern, $method)
     347    {
    330348        $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';
    332350        $ch = curl_init($url_pattern);
    333351        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"));
    335353        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    336354        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
     
    352370    }
    353371}
    354 ?>
  • rabbit-loader/trunk/inc/public.php

    r3023896 r3030444  
    11<?php
    2 
    3 use RabbitLoader\SDK\RabbitLoader;
    42
    53class RabbitLoader_21_Public
     
    149147    {
    150148        try {
    151             RabbitLoader_21_Core::sendHeader("x-rl-mode: $mode", false);
     149            RabbitLoader\SDK\Util::sendHeader("x-rl-mode: $mode", false);
    152150            $rlSDK = RabbitLoader_21_Core::getSDK();
    153151
  • rabbit-loader/trunk/inc/tab_settings.php

    r3020814 r3030444  
    234234            if ($userUpdating) {
    235235                $user_options['exclude_patterns'] = sanitize_textarea_field($_POST['exclude_patterns']);
    236                 RL21UtilWP::onPostChange('all', 'EX_PATTERN_CHANGE');
     236                RL21UtilWP::onPostChange(RL21UtilWP::POST_ID_ALL);
    237237            } else {
    238238                $user_options['exclude_patterns'] = $exclude_patterns;
  • rabbit-loader/trunk/inc/util_wp.php

    r3023896 r3030444  
    33class RL21UtilWP
    44{
     5
     6    const POST_ID_ALL = "all";
    57
    68    private static $isSearch = false;
     
    165167    public static function onPostChange($post_id)
    166168    {
    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;
    169171        } else {
    170172            try {
     
    196198                    self::$purge_queue['post_ids'][$lang_post_id] = true;
    197199                }
    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);
    201203        }
    202204    }
     
    209211        $clean_cache = !empty($user_options['purge_on_change']);
    210212
    211         if (!empty(self::$purge_queue['all'])) {
     213        if (!empty(self::$purge_queue[RL21UtilWP::POST_ID_ALL])) {
    212214            RabbitLoader_21_Core::purge_all($local_purge_count, $purge_source, $tp_purge_count);
    213215        } else if (!empty(self::$purge_queue['post_ids'])) {
     
    240242                    $local_purge_count++;
    241243                }
    242                 RabbitLoader_21_Core::sendHeader("x-rl-url: $url", false);
     244                RabbitLoader\SDK\Util::sendHeader("x-rl-url: $url", false);
    243245            }
    244246            do_action('rl_purge_request_complete', $urls_to_purge);
  • rabbit-loader/trunk/rabbit-loader.php

    r3023896 r3030444  
    77 * Author URI:   https://rabbitloader.com/
    88 * 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.15
     9 * Version: 2.19.16
    1010 * Text Domain: rabbit-loader
    1111 */
     
    1919
    2020add_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    }
    2226}, 10, 3);
    2327add_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 ===
    23Contributors: sanrl, abhishekgr
    3 Tags: cache, caching, cdn, lazy loading, speed optimization
     4Tags: cache, cdn, lazy loading, speed optimization, performance.
    45Requires at least: 4.7
    56Tested up to: 6.4
    6 Stable tag: 2.19.15
     7Stable tag: 2.19.16
    78Requires PHP: 5.6
    89License: GNU General Public License, version 2
     
    4243Caching 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.
    4344
    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.
     45It 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.
    4546
    4647**CSS and JavaScript Cache**
     
    6061RabbitLoader 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.
    6162
    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.
     63RabbitLoader 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.
    6364
    6465**Browser Cache**
     
    8485The 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.
    8586 
    86 RabbitLoader improves the use of next-gen 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.
     87RabbitLoader [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.
    8788
    8889**Image Placeholders**
     
    102103 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.
    103104 
    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.
     105With 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.
    105106 
    106107This 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.
     
    108109**300+ PoP's**
    109110
    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.
     111RabbitLoader 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.
    111112 
    112113This 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.
     
    189190Core 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.
    190191 
    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 Vitals by optimizing various aspects of a website, including image loading, CSS, and JavaScript optimization, and deferring non-critical resources.
     192Having 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 
     194RabbitLoader 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.
    194195 
    195196By 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.
     
    197198**FID (First Input Delay)**
    198199
    199 FID 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[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.
    200201 
    201202An 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.
     
    209210LCP 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.
    210211 
    211 A high LCP score can lead to a poor user experience and negatively impact the page's search engine ranking.
     212A [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.
    212213 
    213214RabbitLoader'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.
     
    219220CLS 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.
    220221
    221 Any sudden changes can adversely impact the user's experience, making CLS an essential metric for evaluating the user experience.
     222Any 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
    222224
    223225While 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.
     
    242244*   Lazy loading of ads (AdSense, AdThrive, etc. It loads data into cache when it is a necessity.
    243245*   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 compatibility with 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.
    245247
    246248All the CPU intensive optimizations are performed by RabbitLoader cloud servers, thus reducing the usage of your hosting resources and your hosting bandwidth usage.
     
    249251
    250252Just 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
     256Join our [Facebook Community](https://www.facebook.com/Rabbitloader/) & [LinkedIn](https://www.linkedin.com/company/rabbitloader)
     257Learn from our tutorials on [YouTube Channel](https://www.youtube.com/@rabbitloader827)
     258Or, Rate us on [Wordpress](https://wordpress.org/support/plugin/rabbit-loader/reviews/?filter=5)
    251259
    252260== Frequently Asked Questions ==
     
    307315== Changelog ==
    308316
     317= 2.19.16 =
     318* Prevent errors when plugin folder is directly deleted
     319* Performance improvements while saving navigation menus
     320
    309321= 2.19.15 =
    310322* Bugfix for admin-ajax sending 403 in some cases
Note: See TracChangeset for help on using the changeset viewer.