Changeset 3246776
- Timestamp:
- 02/25/2025 11:35:50 PM (13 months ago)
- Location:
- pantheon-advanced-page-cache
- Files:
-
- 6 edited
- 1 copied
-
tags/2.1.1 (copied) (copied from pantheon-advanced-page-cache/trunk)
-
tags/2.1.1/inc/class-purger.php (modified) (1 diff)
-
tags/2.1.1/pantheon-advanced-page-cache.php (modified) (1 diff)
-
tags/2.1.1/readme.txt (modified) (3 diffs)
-
trunk/inc/class-purger.php (modified) (1 diff)
-
trunk/pantheon-advanced-page-cache.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pantheon-advanced-page-cache/tags/2.1.1/inc/class-purger.php
r3132786 r3246776 37 37 } 38 38 self::purge_post_with_related( $post ); 39 if ( 'publish' === $old_status ) { 40 return; 41 } 42 // Targets 404 pages that could be cached with no surrogate keys (i.e. 43 // a drafted post going live after the 404 has been cached). 44 self::clear_post_path( $post ); 45 } 46 47 48 /** 49 * Purge the cache for a given post's path 50 * 51 * @param WP_Post $post Post object. 52 * 53 * @since 2.1.1-dev 54 */ 55 public static function clear_post_path( $post ) { 56 $post_path = get_permalink( $post->ID ); 57 $parsed_url = parse_url( $post_path ); 58 $path = $parsed_url['path']; 59 $paths = [ trailingslashit( $path ), untrailingslashit( $path ) ]; 60 61 /** 62 * Paths possibly without surrogate keys purges 63 * 64 * @param array $paths paths to clear. 65 */ 66 $paths = apply_filters( 'pantheon_clear_post_path', $paths ); 67 pantheon_wp_clear_edge_paths( $paths ); 39 68 } 40 69 -
pantheon-advanced-page-cache/tags/2.1.1/pantheon-advanced-page-cache.php
r3132786 r3246776 8 8 * Text Domain: pantheon-advanced-page-cache 9 9 * Domain Path: /languages 10 * Version: 2.1. 010 * Version: 2.1.1 11 11 * Requires at least: 6.4 12 * Tested up to: 6. 6.112 * Tested up to: 6.7.2 13 13 * 14 14 * @package Pantheon_Advanced_Page_Cache -
pantheon-advanced-page-cache/tags/2.1.1/readme.txt
r3132786 r3246776 3 3 Tags: pantheon, cdn, cache 4 4 Requires at least: 6.4 5 Tested up to: 6. 6.16 Stable tag: 2.1. 05 Tested up to: 6.7.2 6 Stable tag: 2.1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 127 127 Lastly, the `pantheon_wp_rest_api_surrogate_keys` filter lets you filter surrogate keys present in a REST API response. 128 128 129 = Additional purging by path = 130 131 When a post is published for the first time, the permalink's path is also purged even if it has no matching keys. This can be further filtered with the `pantheon_clear_post_path` filter. 132 133 add_action('pantheon_clear_post_path', function($paths) { 134 // Add or remove paths from $paths 135 return $paths 136 }, 10, 3); 137 129 138 Need a bit more power? In addition to `pantheon_wp_clear_edge_keys()`, there are two additional helper functions you can use: 130 139 … … 369 378 370 379 == Changelog == 380 381 = 2.1.1 (25 February 2025) = 382 * Fixes 404 pages remaining cached after a post has been published ([#315](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/315)) 383 371 384 = 2.1.0 (8 August 2024) = 372 385 * Adds any callable functions hooked to the `pantheon_cache_default_max_age` filter to the message that displays in the WordPress admin when a cache max age filter is active. [[#292](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/292)] This gives some context to troubleshoot if the filter is active somewhere in the codebase. If an anonymous function is used, it is noted in the message that displays. -
pantheon-advanced-page-cache/trunk/inc/class-purger.php
r3132786 r3246776 37 37 } 38 38 self::purge_post_with_related( $post ); 39 if ( 'publish' === $old_status ) { 40 return; 41 } 42 // Targets 404 pages that could be cached with no surrogate keys (i.e. 43 // a drafted post going live after the 404 has been cached). 44 self::clear_post_path( $post ); 45 } 46 47 48 /** 49 * Purge the cache for a given post's path 50 * 51 * @param WP_Post $post Post object. 52 * 53 * @since 2.1.1-dev 54 */ 55 public static function clear_post_path( $post ) { 56 $post_path = get_permalink( $post->ID ); 57 $parsed_url = parse_url( $post_path ); 58 $path = $parsed_url['path']; 59 $paths = [ trailingslashit( $path ), untrailingslashit( $path ) ]; 60 61 /** 62 * Paths possibly without surrogate keys purges 63 * 64 * @param array $paths paths to clear. 65 */ 66 $paths = apply_filters( 'pantheon_clear_post_path', $paths ); 67 pantheon_wp_clear_edge_paths( $paths ); 39 68 } 40 69 -
pantheon-advanced-page-cache/trunk/pantheon-advanced-page-cache.php
r3132786 r3246776 8 8 * Text Domain: pantheon-advanced-page-cache 9 9 * Domain Path: /languages 10 * Version: 2.1. 010 * Version: 2.1.1 11 11 * Requires at least: 6.4 12 * Tested up to: 6. 6.112 * Tested up to: 6.7.2 13 13 * 14 14 * @package Pantheon_Advanced_Page_Cache -
pantheon-advanced-page-cache/trunk/readme.txt
r3132786 r3246776 3 3 Tags: pantheon, cdn, cache 4 4 Requires at least: 6.4 5 Tested up to: 6. 6.16 Stable tag: 2.1. 05 Tested up to: 6.7.2 6 Stable tag: 2.1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 127 127 Lastly, the `pantheon_wp_rest_api_surrogate_keys` filter lets you filter surrogate keys present in a REST API response. 128 128 129 = Additional purging by path = 130 131 When a post is published for the first time, the permalink's path is also purged even if it has no matching keys. This can be further filtered with the `pantheon_clear_post_path` filter. 132 133 add_action('pantheon_clear_post_path', function($paths) { 134 // Add or remove paths from $paths 135 return $paths 136 }, 10, 3); 137 129 138 Need a bit more power? In addition to `pantheon_wp_clear_edge_keys()`, there are two additional helper functions you can use: 130 139 … … 369 378 370 379 == Changelog == 380 381 = 2.1.1 (25 February 2025) = 382 * Fixes 404 pages remaining cached after a post has been published ([#315](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/315)) 383 371 384 = 2.1.0 (8 August 2024) = 372 385 * Adds any callable functions hooked to the `pantheon_cache_default_max_age` filter to the message that displays in the WordPress admin when a cache max age filter is active. [[#292](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/292)] This gives some context to troubleshoot if the filter is active somewhere in the codebase. If an anonymous function is used, it is noted in the message that displays.
Note: See TracChangeset
for help on using the changeset viewer.