💥 TRENDING: Changeset/ - Full Archive

Changeset 3255528


Ignore:
Timestamp:
03/13/2025 05:43:22 PM (10 months ago)
Author:
aguidrevitch
Message:

🚀 Enhancements

  • Improved Automatic Cache Purging: Introduced new hooks to ensure fresh content is always served after changes, making your site even more responsive and up-to-date.

🛠️ Fixes & Improvements

  • Bug Fixes: Resolved various issues for better stability and performance.

Update now to keep your site lightning-fast with smarter cache management! 🚀

Location:
fastpixel-website-accelerator/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • fastpixel-website-accelerator/trunk/fastpixel.php

    r3251166 r3255528  
    55 * Description: Faster WordPress Made Easy – Solve all your website speed problems effortlessly with just a few clicks.
    66 * Author:      ShortPixel
    7  * Version:     1.0.43
     7 * Version:     1.0.44
    88 * Text Domain: fastpixel-website-accelerator
    99 * Domain Path: /languages
     
    2121defined('ABSPATH') || exit;
    2222
    23 define('FASTPIXEL_VERSION', '1.0.43');
     23define('FASTPIXEL_VERSION', '1.0.44');
    2424define('FASTPIXEL_NAME', 'FastPixel');
    2525if (!defined('FASTPIXEL_PLUGIN_DIR'))
  • fastpixel-website-accelerator/trunk/inc/backend/controllers/cache.php

    r3251166 r3255528  
    269269             * reset cache status when plugins are activated, deactivated, upgraded, theme is changed or upgraded
    270270             */
    271             add_action('activated_plugin', [$this, 'purge_all_on_plugin_activation_deactivation']);
    272             add_action('deactivated_plugin', [$this, 'purge_all_on_plugin_activation_deactivation']);
    273             add_action('after_switch_theme', [$this, 'purge_all_on_theme_switch']);
     271            add_action('activated_plugin', function(string $plugin, bool $network_wide) {
     272                $this->purge_all_with_message_no_request();
     273            }, 10, 2);
     274            add_action('deactivated_plugin', function (string $plugin, bool $network_wide) {
     275                $this->purge_all_with_message_no_request();
     276            }, 10, 2);
     277            add_action('after_switch_theme', function(string $old_name, \WP_Theme $old_theme)
     278            {
     279                $this->purge_all_with_message_no_request();
     280            }, 10, 2);
    274281            add_action('upgrader_process_complete', [$this, 'check_upgraded'], 10, 2);
     282            /*
     283             * Different update hooks
     284             */
     285            add_action('wp_update_nav_menu', function(int $menu_id, array $menu_data) {
     286                $this->purge_all_with_message_no_request();
     287            }, 10, 2);  // When a custom menu is update.
     288            add_action('update_option_sidebars_widgets', function($old_value, $value, string $option) {
     289                $this->purge_all_with_message_no_request();
     290            }, 10, 3);  // When you change the order of widgets.
     291            add_action('update_option_category_base', function ($old_value, $value, string $option) {
     292                $this->purge_all_with_message_no_request();
     293            }, 10, 3);  // When category permalink is updated.
     294            add_action('update_option_tag_base', function ($old_value, $value, string $option) {
     295                $this->purge_all_with_message_no_request();
     296            }, 10, 3);  // When tag permalink is updated.
     297            add_action('add_link', function (int $link_id) {
     298                $this->purge_all_with_message_no_request();
     299            }, 10, 1);  // When a link is added.
     300            add_action('edit_link', function (int $link_id) {
     301                $this->purge_all_with_message_no_request();
     302            }, 10, 1);  // When a link is updated.
     303            add_action('delete_link', function (int $link_id) {
     304                $this->purge_all_with_message_no_request();
     305            }, 10, 1);  // When a link is deleted.
     306            add_action('customize_save', function (\WP_Customize_Manager $manager) {
     307                $this->purge_all_with_message_no_request();
     308            }, 10, 1);  // When customizer is saved.
    275309        }
    276310
     
    757791            if ($diag->run_activation_tests()) {
    758792                $this->functions->update_ac_file();
     793                $this->purge_all_with_message_no_request();
    759794            }
    760795            return $new;
     
    831866        }
    832867
    833         public function check_upgraded($upgrader, $extra)
     868        public function check_upgraded(\WP_Upgrader $upgrader, array $extra)
    834869        {
    835870            if ($this->debug) {
     
    840875            $run_purge = false;
    841876            $skin = $upgrader->skin;
    842             $purge_message = __('Cache has been cleared!', 'fastpixel-website-accelerator');
    843877            if ($extra['type'] === 'plugin') {
    844878                if (property_exists($skin, 'plugin_active') && $skin->plugin_active) {
    845                     $run_purge = true;
     879                    if (property_exists($skin, 'result') && !empty($skin->result['destination_name']) && $skin->result['destination_name'] != FASTPIXEL_TEXTDOMAIN) {
     880                        $run_purge = true;
     881                    }
    846882                }
    847883            }
     
    859895            }
    860896            if ($run_purge) {
    861                 if ($this->purge_all_without_request()) {
    862                     $notices = FASTPIXEL_Notices::get_instance();
    863                     $notices->add_flash_notice($purge_message, 'success', false, 'plugin-theme-change-notice');
    864                 }
    865             }
    866         }
    867 
    868         public function purge_all_on_plugin_activation_deactivation() {
    869             if ($this->purge_all_without_request()) {
    870                 $purge_message = __('Cache has been cleared!', 'fastpixel-website-accelerator');
    871                 $notices = FASTPIXEL_Notices::get_instance();
    872                 $notices->add_flash_notice($purge_message, 'success', false, 'plugin-theme-change-notice');
    873             }
    874         }
    875 
    876         public function purge_all_theme_switch()
    877         {
    878             if ($this->purge_all_without_request()) {
    879                 $purge_message = __('Cache has been cleared!', 'fastpixel-website-accelerator');
    880                 $notices = FASTPIXEL_Notices::get_instance();
    881                 $notices->add_flash_notice($purge_message, 'success', false, 'plugin-theme-change-notice');
    882             }
    883         }
    884 
    885         public function purge_all_without_request()
     897                $this->purge_all_with_message_no_request();
     898            }
     899        }
     900
     901        public function purge_all_with_message_no_request(bool $display_message = true, string $message = '')
    886902        {
    887903            if ($this->debug) {
     
    894910            add_filter('fastpixel/purge_all/clear_cache_folder', function () {
    895911                return false; });
    896             return $this->purge_all();
     912            if ($this->purge_all()) {
     913                if ($display_message) {
     914                    if (empty($message)) {
     915                        $purge_message = __('Cache has been cleared!', 'fastpixel-website-accelerator');
     916                    } else {
     917                        $purge_message = $message;
     918                    }
     919                    $notices = FASTPIXEL_Notices::get_instance();
     920                    $notices->add_flash_notice($purge_message, 'success', false, 'purge-all-notice');
     921                }
     922                return true;
     923            }
     924            return false;
    897925        }
    898926    }
  • fastpixel-website-accelerator/trunk/inc/backend/controllers/classes/post-types-statuses.php

    r3251166 r3255528  
    134134                    $cache_status = $this->be_functions->cache_status_display($url, $status_data);
    135135                    $extra_pages[] = [
    136                         'ID'             => 'homepage',
    137                         'post_title'     => esc_html__('Homepage', 'fastpixel-website-accelerator'),
    138                         'url'            => $url,
    139                         'cache_status'   => $cache_status['status_display'],
    140                         'cachestatus'    => $cache_status['status'],
    141                         'display_status' => '<b>published</b>',
    142                         'post_status'    => 'publish'
     136                        'ID'                => 'homepage',
     137                        'post_title'        => esc_html__('Homepage', 'fastpixel-website-accelerator'),
     138                        'url'               => $url,
     139                        'cache_status'      => $cache_status['status_display'],
     140                        'cachestatus'       => $cache_status['status'],
     141                        'display_status'    => '<b>published</b>',
     142                        'html_created_time' => $cache_status['html_created_time'],
     143                        'post_status'       => 'publish'
    143144                    ];
    144145                }
     
    170171            $purge_id = $item['ID'];
    171172            //setting links for homepage
    172             if ($item['ID'] == null && $item['post_title'] == 'Homepage') {
     173            if (($item['ID'] == null || $item['ID'] == 'homepage') && $item['post_title'] == 'Homepage') {
    173174                $purge_id = 'homepage';
    174175                $link = get_home_url();
    175176            }
    176             $edit_link = get_edit_post_link($item['ID']);
     177            if (is_numeric($item['ID'])) {
     178                $edit_link = get_edit_post_link($item['ID']);
     179            } else {
     180                $edit_link = '';
     181            }
    177182            $purge_link = sprintf('admin-post.php?action=%1$s&nonce=%2$s&id=%3$s&type=%4$s&selected_of_type=%5$s', 'fastpixel_admin_purge_cache', $this->nonce, $purge_id, $this->type, $this->selected_post_type);
    178183            //actions
  • fastpixel-website-accelerator/trunk/inc/classes/local-cache.php

    r3223801 r3255528  
    1919            $this->functions = FASTPIXEL_Functions::get_instance();
    2020            $this->config    = FASTPIXEL_Config_Model::get_instance();
    21             //starting output beffering on fastpixel/init
    22             add_action('fastpixel/cachefiles/exists', function($exists = false) {
    23                 if (!$exists) {
    24                     if ($this->debug) {
    25                         FASTPIXEL_Debug::log('Class FASTPIXEL_Local_Cache: Starting output buffering', $_SERVER['REQUEST_URI']);
     21            //starting output beffering on fastpixel/init, also checking if user is not logged in
     22            if (!$this->functions->user_is_logged_in()) {
     23                add_action('fastpixel/cachefiles/exists', function($exists = false) {
     24                    if (!$exists) {
     25                        if ($this->debug) {
     26                            FASTPIXEL_Debug::log('Class FASTPIXEL_Local_Cache: Starting output buffering', $_SERVER['REQUEST_URI']);
     27                        }
     28                        ob_start(); //starting buffering output
     29                        add_action('fastpixel/shutdown', [$this, 'get_buffer'], 10); //getting buffer into variable
     30                        add_action('fastpixel/shutdown/request/before', [$this, 'save'], 10, 1); //saving buffer to file, if page passed validation
    2631                    }
    27                     ob_start(); //starting buffering output
    28                     add_action('fastpixel/shutdown', [$this, 'get_buffer'], 10); //getting buffer into variable
    29                     add_action('fastpixel/shutdown/request/before', [$this, 'save'], 10, 1); //saving buffer to file, if page passed validation
    30                 }
    31             });
     32                });
     33            }
    3234            add_action('fastpixel/cachefiles/saved', [$this, 'delete_file_on_api_request'], 10, 1);
    3335            add_action('fastpixel/post/trashed', [$this, 'delete_file_on_trashed'], 10, 1);
  • fastpixel-website-accelerator/trunk/inc/functions.php

    r3251166 r3255528  
    184184                // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- none available before WordPress is loaded.
    185185                $meta = json_decode(file_get_contents($meta_file), true); //phpcs:ignore
     186                if (empty($meta)) { //duplicate initialization in case file was broken or json_decode returned null
     187                    $meta = [
     188                        'invalidated_time'   => 0,
     189                        'cache_request_time' => 0
     190                    ];
     191                }
    186192                $data['local_invalidation_time'] = $meta['invalidated_time'];
    187193                $data['last_cache_request_time'] = $meta['cache_request_time'];
     
    232238            $meta = ['invalidated_time' => false, 'cache_request_time' => false];
    233239            if (file_exists($cache_dir . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . 'meta')) {
     240                $loaded_meta = json_decode(file_get_contents($cache_dir . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . 'meta'), true);
     241                if (empty($loaded_meta)) {
     242                    $loaded_meta = [];
     243                }
    234244                //can't use native WP functions because file is included early in advanced-cache.php
    235245                // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- none available before WordPress is loaded.
    236                 $meta = array_merge($meta, json_decode(file_get_contents($cache_dir . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . 'meta'), true)); //phpcs:ignore
     246                $meta = array_merge($meta, $loaded_meta); //phpcs:ignore
    237247            }
    238248            if ($invalidated) {
     
    382392            $var_value_str = $var_value == true ? 'true' : 'false';
    383393            //checking if entry already exists
    384             if (!empty($matches[0][0]) && !empty($matches[1][0])) {
     394            if (!empty($matches[0][0]) && !empty($matches[2][0])) {
    385395                //entry exists, checking status
    386                 if (filter_var($matches[1][0], FILTER_VALIDATE_BOOLEAN) != $var_value) {
     396                if (filter_var($matches[2][0], FILTER_VALIDATE_BOOLEAN) != $var_value) {
    387397                    //need to update status
    388398                    $wp_config_content_replaced = preg_replace($this->match_regexp, "$1define(\"" . self::FASTPIXEL_CACHE_VAR_NAME . "\", " . $var_value_str . ");", $wp_config_content);
     
    425435                }
    426436            }
    427             $url = new FASTPIXEL_Url($url);
     437            if (!is_a($url, 'FASTPIXEL\FASTPIXEL_Url')) {
     438                $url = new FASTPIXEL_Url($url);
     439            }
    428440            $dirs = explode(DIRECTORY_SEPARATOR, $url->get_url_path());
    429441            $path = $cache_dir;
  • fastpixel-website-accelerator/trunk/inc/url.php

    r3245943 r3255528  
    209209                (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] ? $functions->sanitize_text_field($_SERVER['HTTP_X_FORWARDED_PROTO']) :
    210210                (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] ? $functions->sanitize_text_field($_SERVER['REQUEST_SCHEME']) :
    211                 (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'))) . '://' . $functions->sanitize_text_field($this->get_request_host_name()) . '/' . $functions->sanitize_text_field(ltrim($_SERVER['REQUEST_URI'], '/')));
     211                (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'))) . '://' . $functions->sanitize_text_field($this->get_request_host_name()) . '/' . $functions->sanitize_text_field(ltrim(!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', '/')));
    212212        }
    213213        public function get_path()
  • fastpixel-website-accelerator/trunk/readme.txt

    r3251166 r3255528  
    55Tested up to: 6.7
    66Requires PHP: 5.6
    7 Stable tag: 1.0.43
     7Stable tag: 1.0.44
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    201201== Changelog ==
    202202
     203🔄 The Smarter Cache Update
     204
     205= 1.0.44 =
     206
     207 🚀 Enhancements
     208
     209* Improved Automatic Cache Purging: Introduced new hooks to ensure fresh content is always served after changes, making your site even more responsive and up-to-date.
     210
     211 🛠️ Fixes & Improvements
     212
     213* Bug Fixes: Resolved various issues for better stability and performance.
     214
     215Update now to keep your site lightning-fast with smarter cache management! 🚀
     216
    203217= 1.0.43 =
    204218
  • fastpixel-website-accelerator/trunk/vendor/composer/installed.php

    r3251166 r3255528  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => 'bcfe655a7a8207ebf8105d77dd6b0633a4d9ccf5',
     6        'reference' => '12cc62107ef979074d4d13b1b8f3619fcb393a19',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => 'bcfe655a7a8207ebf8105d77dd6b0633a4d9ccf5',
     16            'reference' => '12cc62107ef979074d4d13b1b8f3619fcb393a19',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.