Plugin Directory

Changeset 3217776


Ignore:
Timestamp:
01/06/2025 02:33:15 PM (14 months ago)
Author:
servebolt
Message:

Update to version 3.5.49 from GitHub

Location:
servebolt-optimizer
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • servebolt-optimizer/tags/3.5.49/Readme.txt

    r3210419 r3217776  
    9898
    9999== Changelog ==
     100
     101= 3.5.49 =
     102* Added purge on WooCommerce stock change or product update, to cover purge events when save_post hook is not fired.
     103* Bugfix: Forcing max-age=0 on all posts that are status "Password Protected" to prevent ever being cached.
     104* Added extra image sizes to the SRCSET when using the image resizer to present clearer images on sites that do not have (m)any image sizes.
    100105
    101106= 3.5.48 =
  • servebolt-optimizer/tags/3.5.49/servebolt-optimizer.php

    r3210419 r3217776  
    22/*
    33Plugin Name: Servebolt Optimizer
    4 Version: 3.5.48
     4Version: 3.5.49
    55Author: Servebolt
    66Author URI: https://servebolt.com
  • servebolt-optimizer/tags/3.5.49/src/Servebolt/Admin/ClearSiteDataHeader/ClearSiteDataHeader.php

    r2869325 r3217776  
    2424    public function setHeader(): void
    2525    {
    26         if (apply_filters('sb_optimizer_clear_site_data_header_active', true)) {           
     26        if (apply_filters('sb_optimizer_clear_site_data_header_active', true)) {
    2727            header('Clear-Site-Data: "cache", "storage"');
    2828        }
  • servebolt-optimizer/tags/3.5.49/src/Servebolt/CachePurge/WpObjectCachePurgeActions/ContentChangeTrigger.php

    r3149848 r3217776  
    3333        remove_action('set_object_terms', [$this, 'purgeCategoryTermsOnFirstSave'], 99, 6);
    3434        remove_action('update_option_permalink_structure', [$this, 'purgeAllOnPermalinkUpdates'], 99, 6);
     35        remove_action('woocommerce_product_set_stock', [$this, 'purgePostOnWooCommerceUpdate'], 99);
     36        remove_action('woocommerce_update_product', [$this, 'purgePostOnWooCommerceUpdate'], 99);
    3537    }
    3638
     
    9698        }
    9799
    98     }
    99 
     100        // Purge post when comment is approved.
     101        if (apply_filters('sb_optimizer_automatic_purge_on_woocommerce_update', true)) {
     102            add_action('woocommerce_product_set_stock', [$this, 'purgePostOnWooCommerceUpdate'], 99);
     103            add_action('woocommerce_update_product', [$this, 'purgePostOnWooCommerceUpdate'], 99);
     104        }
     105    }
     106
     107    /**
     108     * Purge post on WooCommerce update.
     109     *
     110     * Covers both the stock update and the product update hooks.
     111     * It uses the maybePurgePost method to check if the post is already
     112     * scheduled for a purge or not.
     113     *
     114     * @param object $product
     115     *
     116     * @return void
     117     */
     118    function purgePostOnWooCommerceUpdate($product)
     119    {
     120        if(method_exists($product, 'get_id')) return;
     121        $this->maybePurgePost((int) $product->get_id());
     122    }
     123
     124    /**
     125     * Purge all cache when permalinks are updated.
     126     *
     127     * @return void
     128     */
    100129    function purgeAllOnPermalinkUpdates()
    101130    {
     
    126155        if ( $taxonomy !== 'category' || (isset($terms[0]) && isset($old_tt_ids[0])) === false ) return;
    127156        // check if values match up, that we are only dealing with the default category in the correct way.
    128         $default_category = get_option("default_category");   
     157        $default_category = get_option("default_category");
    129158        if(
    130159            (count($tt_ids) == 1 && $tt_ids[0] == $default_category) ||
     
    139168            // don't do anything if its the default. It should never have to do this
    140169            // but just in case it does, better not to set an extra purge event.
    141             if($term_id == $default_category) continue;           
     170            if($term_id == $default_category) continue;
    142171            $this->maybePurgeTerm((int) $term_id, $taxonomy);
    143172        }
  • servebolt-optimizer/tags/3.5.49/src/Servebolt/FullPageCache/FullPageCacheHeaders.php

    r3149848 r3217776  
    102102
    103103        // Unauthenticated cache handling
    104         if ($this->shouldSetCacheHeaders()) {           
    105             add_filter('posts_results', [$this, 'setHeaders']);           
     104        if ($this->shouldSetCacheHeaders()) {
     105            add_filter('posts_results', [$this, 'setHeaders']);
    106106            add_filter('template_include', [$this, 'lastCall']);
    107107            add_filter('sb_optimizer_fullpage_cache_header_item', [$this, 'kill_cache_404'], 10);
     
    180180        // Only trigger this function once
    181181        remove_filter('posts_results', [$this, 'setHeaders']);
     182
     183        if ($this->isPasswordProtected()) {
     184            $this->noCacheHeaders();
     185            if ($debug) {
     186                $this->header('No-cache-trigger: 1');
     187            }
     188            return $posts;
     189        }
    182190
    183191        if ($this->isEcommerceNoCachePage()) {
     
    271279   
    272280    /**
     281     * Check if the current page is password protected.
     282     *
     283     * @return bool
     284     */
     285    private function isPasswordProtected(): bool
     286    {
     287        global $wp_query;
     288        if (!$wp_query->is_singular()) return false;
     289        return apply_filters('sb_optimizer_fpc_password_protected_page', ( isset( $wp_query->post ) && ! empty( $wp_query->post->post_password ) ) );
     290    }
     291
     292    /**
    273293     * Check if we are in an Ecommerce-context and check if we should not cache.
    274294     *
  • servebolt-optimizer/tags/3.5.49/vendor/composer/installed.php

    r3210419 r3217776  
    22    'root' => array(
    33        'name' => 'servebolt/servebolt-wp-optimize-plugin',
    4         'pretty_version' => '3.5.48',
    5         'version' => '3.5.48.0',
    6         'reference' => 'a72afbfd0be29c15d6c143faeab788efeb62ee8b',
     4        'pretty_version' => '3.5.49',
     5        'version' => '3.5.49.0',
     6        'reference' => 'a09a5f53539e4bacaabcc6d6ce5bfd7031f332e8',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    132132        ),
    133133        'servebolt/servebolt-wp-optimize-plugin' => array(
    134             'pretty_version' => '3.5.48',
    135             'version' => '3.5.48.0',
    136             'reference' => 'a72afbfd0be29c15d6c143faeab788efeb62ee8b',
     134            'pretty_version' => '3.5.49',
     135            'version' => '3.5.49.0',
     136            'reference' => 'a09a5f53539e4bacaabcc6d6ce5bfd7031f332e8',
    137137            'type' => 'wordpress-plugin',
    138138            'install_path' => __DIR__ . '/../../',
  • servebolt-optimizer/trunk/Readme.txt

    r3210419 r3217776  
    9898
    9999== Changelog ==
     100
     101= 3.5.49 =
     102* Added purge on WooCommerce stock change or product update, to cover purge events when save_post hook is not fired.
     103* Bugfix: Forcing max-age=0 on all posts that are status "Password Protected" to prevent ever being cached.
     104* Added extra image sizes to the SRCSET when using the image resizer to present clearer images on sites that do not have (m)any image sizes.
    100105
    101106= 3.5.48 =
  • servebolt-optimizer/trunk/servebolt-optimizer.php

    r3210419 r3217776  
    22/*
    33Plugin Name: Servebolt Optimizer
    4 Version: 3.5.48
     4Version: 3.5.49
    55Author: Servebolt
    66Author URI: https://servebolt.com
  • servebolt-optimizer/trunk/src/Servebolt/Admin/ClearSiteDataHeader/ClearSiteDataHeader.php

    r2869325 r3217776  
    2424    public function setHeader(): void
    2525    {
    26         if (apply_filters('sb_optimizer_clear_site_data_header_active', true)) {           
     26        if (apply_filters('sb_optimizer_clear_site_data_header_active', true)) {
    2727            header('Clear-Site-Data: "cache", "storage"');
    2828        }
  • servebolt-optimizer/trunk/src/Servebolt/CachePurge/WpObjectCachePurgeActions/ContentChangeTrigger.php

    r3149848 r3217776  
    3333        remove_action('set_object_terms', [$this, 'purgeCategoryTermsOnFirstSave'], 99, 6);
    3434        remove_action('update_option_permalink_structure', [$this, 'purgeAllOnPermalinkUpdates'], 99, 6);
     35        remove_action('woocommerce_product_set_stock', [$this, 'purgePostOnWooCommerceUpdate'], 99);
     36        remove_action('woocommerce_update_product', [$this, 'purgePostOnWooCommerceUpdate'], 99);
    3537    }
    3638
     
    9698        }
    9799
    98     }
    99 
     100        // Purge post when comment is approved.
     101        if (apply_filters('sb_optimizer_automatic_purge_on_woocommerce_update', true)) {
     102            add_action('woocommerce_product_set_stock', [$this, 'purgePostOnWooCommerceUpdate'], 99);
     103            add_action('woocommerce_update_product', [$this, 'purgePostOnWooCommerceUpdate'], 99);
     104        }
     105    }
     106
     107    /**
     108     * Purge post on WooCommerce update.
     109     *
     110     * Covers both the stock update and the product update hooks.
     111     * It uses the maybePurgePost method to check if the post is already
     112     * scheduled for a purge or not.
     113     *
     114     * @param object $product
     115     *
     116     * @return void
     117     */
     118    function purgePostOnWooCommerceUpdate($product)
     119    {
     120        if(method_exists($product, 'get_id')) return;
     121        $this->maybePurgePost((int) $product->get_id());
     122    }
     123
     124    /**
     125     * Purge all cache when permalinks are updated.
     126     *
     127     * @return void
     128     */
    100129    function purgeAllOnPermalinkUpdates()
    101130    {
     
    126155        if ( $taxonomy !== 'category' || (isset($terms[0]) && isset($old_tt_ids[0])) === false ) return;
    127156        // check if values match up, that we are only dealing with the default category in the correct way.
    128         $default_category = get_option("default_category");   
     157        $default_category = get_option("default_category");
    129158        if(
    130159            (count($tt_ids) == 1 && $tt_ids[0] == $default_category) ||
     
    139168            // don't do anything if its the default. It should never have to do this
    140169            // but just in case it does, better not to set an extra purge event.
    141             if($term_id == $default_category) continue;           
     170            if($term_id == $default_category) continue;
    142171            $this->maybePurgeTerm((int) $term_id, $taxonomy);
    143172        }
  • servebolt-optimizer/trunk/src/Servebolt/FullPageCache/FullPageCacheHeaders.php

    r3149848 r3217776  
    102102
    103103        // Unauthenticated cache handling
    104         if ($this->shouldSetCacheHeaders()) {           
    105             add_filter('posts_results', [$this, 'setHeaders']);           
     104        if ($this->shouldSetCacheHeaders()) {
     105            add_filter('posts_results', [$this, 'setHeaders']);
    106106            add_filter('template_include', [$this, 'lastCall']);
    107107            add_filter('sb_optimizer_fullpage_cache_header_item', [$this, 'kill_cache_404'], 10);
     
    180180        // Only trigger this function once
    181181        remove_filter('posts_results', [$this, 'setHeaders']);
     182
     183        if ($this->isPasswordProtected()) {
     184            $this->noCacheHeaders();
     185            if ($debug) {
     186                $this->header('No-cache-trigger: 1');
     187            }
     188            return $posts;
     189        }
    182190
    183191        if ($this->isEcommerceNoCachePage()) {
     
    271279   
    272280    /**
     281     * Check if the current page is password protected.
     282     *
     283     * @return bool
     284     */
     285    private function isPasswordProtected(): bool
     286    {
     287        global $wp_query;
     288        if (!$wp_query->is_singular()) return false;
     289        return apply_filters('sb_optimizer_fpc_password_protected_page', ( isset( $wp_query->post ) && ! empty( $wp_query->post->post_password ) ) );
     290    }
     291
     292    /**
    273293     * Check if we are in an Ecommerce-context and check if we should not cache.
    274294     *
  • servebolt-optimizer/trunk/vendor/composer/installed.php

    r3210419 r3217776  
    22    'root' => array(
    33        'name' => 'servebolt/servebolt-wp-optimize-plugin',
    4         'pretty_version' => '3.5.48',
    5         'version' => '3.5.48.0',
    6         'reference' => 'a72afbfd0be29c15d6c143faeab788efeb62ee8b',
     4        'pretty_version' => '3.5.49',
     5        'version' => '3.5.49.0',
     6        'reference' => 'a09a5f53539e4bacaabcc6d6ce5bfd7031f332e8',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    132132        ),
    133133        'servebolt/servebolt-wp-optimize-plugin' => array(
    134             'pretty_version' => '3.5.48',
    135             'version' => '3.5.48.0',
    136             'reference' => 'a72afbfd0be29c15d6c143faeab788efeb62ee8b',
     134            'pretty_version' => '3.5.49',
     135            'version' => '3.5.49.0',
     136            'reference' => 'a09a5f53539e4bacaabcc6d6ce5bfd7031f332e8',
    137137            'type' => 'wordpress-plugin',
    138138            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.