Changeset 3094130
- Timestamp:
- 05/28/2024 07:40:52 PM (22 months ago)
- Location:
- pantheon-advanced-page-cache
- Files:
-
- 2 added
- 8 edited
- 1 copied
-
tags/2.0.0 (copied) (copied from pantheon-advanced-page-cache/trunk)
-
tags/2.0.0/assets/css/styles.css (modified) (1 diff)
-
tags/2.0.0/assets/css/styles.min.css (added)
-
tags/2.0.0/inc/admin-interface.php (modified) (23 diffs)
-
tags/2.0.0/pantheon-advanced-page-cache.php (modified) (3 diffs)
-
tags/2.0.0/readme.txt (modified) (5 diffs)
-
trunk/assets/css/styles.css (modified) (1 diff)
-
trunk/assets/css/styles.min.css (added)
-
trunk/inc/admin-interface.php (modified) (23 diffs)
-
trunk/pantheon-advanced-page-cache.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pantheon-advanced-page-cache/tags/2.0.0/assets/css/styles.css
r3092217 r3094130 1 .pantheon-page-cache hr{display:none}.pantheon-page-cache tr.cache-default-max-age{display:block;padding:10px;background:#fff;color:#1e1e1e;box-shadow:0 0 10px 5px rgba(0,0,0,.1)}.pantheon-page-cache tr.cache-default-max-age td{padding:0}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age{padding:0 10px 10px 0}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age h3{margin-top:.5em}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age i{margin-right:10px;line-height:1em}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar{background:#1d7afc;color:#fff;padding:10px 0 10px 10px;text-align:left;display:block;width:100%;margin-bottom:1em}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a{color:#fff;text-decoration:underline}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:active,.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:hover{color:#fff;text-decoration:none}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age select{background-color:#fff;color:#1e1e1e;border:1px solid #757575;border-radius:0}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-description{color:#757575;margin:10px 0 0} 1 .pantheon-page-cache hr { 2 display: none; 3 } 4 .pantheon-page-cache tr.cache-default-max-age { 5 display: block; 6 padding: 10px; 7 background: #ffffff; 8 color: #1e1e1e; 9 box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.1); 10 } 11 .pantheon-page-cache tr.cache-default-max-age td { 12 padding: 0; 13 } 14 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age { 15 padding: 0 10px 10px 0; 16 } 17 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age h3 { 18 margin-top: 0.5em; 19 } 20 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age i { 21 margin-right: 10px; 22 line-height: 1em; 23 } 24 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar { 25 background: #1d7afc; 26 color: #ffffff; 27 padding: 10px 0 10px 10px; 28 text-align: left; 29 display: block; 30 width: 100%; 31 margin-bottom: 1em; 32 } 33 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a { 34 color: #ffffff; 35 text-decoration: underline; 36 } 37 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:hover, .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:active { 38 color: #ffffff; 39 text-decoration: none; 40 } 41 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age select { 42 background-color: #ffffff; 43 color: #1e1e1e; 44 border: 1px solid #757575; 45 border-radius: 0; 46 } 47 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-description { 48 color: #757575; 49 margin: 10px 0 0 0; 50 } -
pantheon-advanced-page-cache/tags/2.0.0/inc/admin-interface.php
r3091792 r3094130 3 3 * Controller for the admin interface that builds on top of the Pantheon MU plugin. 4 4 * 5 * @since 2.0.0 -dev5 * @since 2.0.0 6 6 * @package Pantheon_Advanced_Page_Cache 7 7 */ … … 12 12 * Kick off the important bits. 13 13 * 14 * @since 2.0.0 -dev14 * @since 2.0.0 15 15 * @return void 16 16 */ … … 43 43 add_filter( 'pantheon_cache_max_age_input', __NAMESPACE__ . '\\update_default_ttl_input' ); 44 44 add_filter( 'pantheon_cache_max_age_input_allowed_html', __NAMESPACE__ . '\\max_age_input_allowed_html' ); 45 add_filter( 'nonce_life', __NAMESPACE__ . '\\filter_nonce_cache_lifetime' ); 45 46 } 46 47 … … 48 49 * Enqueue admin assets. 49 50 * 50 * @since 2.0.0 -dev51 * @since 2.0.0 51 52 * @return void 52 53 */ … … 60 61 // If WP_DEBUG is true, append a timestamp to the end of the path so we get a fresh copy of the css. 61 62 $debug = defined( 'WP_DEBUG' ) && WP_DEBUG ? '-' . time() : ''; 62 wp_enqueue_style( 'papc-admin', plugin_dir_url( __DIR__ ) . 'assets/css/styles.css', [], '2.0.0' . $debug ); 63 // Use minified css unless SCRIPT_DEBUG is true. 64 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 65 wp_enqueue_style( 'papc-admin', plugin_dir_url( __DIR__ ) . "assets/css/styles$min.css", [], '2.0.0' . $debug ); 63 66 } 64 67 … … 66 69 * Add a header to the max-age setting field. 67 70 * 68 * @since 2.0.0 -dev71 * @since 2.0.0 69 72 * @return string 70 73 */ … … 87 90 * Add a description to the max-age setting field. 88 91 * 89 * @since 2.0.0 -dev92 * @since 2.0.0 90 93 * @return string 91 94 */ … … 122 125 * @param int $default_input The default TTL input field from the mu-plugin. 123 126 * 124 * @since 2.0.0 -dev127 * @since 2.0.0 125 128 * @return int 126 129 */ … … 160 163 * Filter the allowed HTML for the max-age input field. 161 164 * 162 * @since 2.0.0 -dev165 * @since 2.0.0 163 166 * @param array $allowed_html The allowed HTML. 164 167 * @return array … … 173 176 * Get the default max age options. Default values are 1 week, 1 month, 1 year. 174 177 * 175 * @since 2.0.0 -dev178 * @since 2.0.0 176 179 * @return array 177 180 */ … … 195 198 * Display an admin notice if the Pantheon MU plugin was not found. 196 199 * 197 * @since 2.0.0 -dev200 * @since 2.0.0 198 201 * @return void 199 202 */ … … 222 225 * Display an admin notice if the Pantheon MU plugin is out of date. 223 226 * 224 * @since 2.0.0 -dev227 * @since 2.0.0 225 228 * @return void 226 229 */ … … 260 263 * Display an admin notice if the max-age is less than a week but not equal to 600 seconds. 261 264 * 262 * @since 2.0.0 -dev265 * @since 2.0.0 263 266 * @return void 264 267 */ … … 330 333 * If the site existed prior to 1.4.0 of the mu-plugin, the default value is 600 seconds. Otherwise, the default value is 1 week. 331 334 * 332 * @since 2.0.0 -dev335 * @since 2.0.0 333 336 * @return int 334 337 */ … … 349 352 * @param array $tests The Site Health tests. 350 353 * 351 * @since 2.0.0 -dev354 * @since 2.0.0 352 355 * @return array 353 356 */ … … 366 369 * @param bool $recommended Whether to get the recommended max-age. 367 370 * 368 * @since 2.0.0 -dev371 * @since 2.0.0 369 372 * @return string 370 373 */ … … 380 383 * Get the default max-age. 381 384 * 382 * @since 2.0.0 -dev385 * @since 2.0.0 383 386 * @return int 384 387 */ … … 390 393 * Compare the current max-age to the default max-age. 391 394 * 392 * @since 2.0.0 -dev395 * @since 2.0.0 393 396 * @return int A ranked value from 0 to 10 where 0 is optimal (equal to or greater than the recommended max age) and 10 is very bad. 394 397 */ … … 419 422 * The GCDN cache max-age Site Health test. 420 423 * 421 * @since 2.0.0 -dev424 * @since 2.0.0 422 425 * @return array 423 426 */ … … 485 488 * Clear the max-age compare cache when the max-age is updated. 486 489 * 487 * @since 2.0.0 -dev490 * @since 2.0.0 488 491 * @return void 489 492 */ … … 495 498 * Set the default_ttl from the mu-plugin to WEEK_IN_SECONDS if it was saved as 600 seconds. 496 499 * 497 * @since 2.0.0 -dev500 * @since 2.0.0 498 501 * @return bool 499 502 */ … … 530 533 * Display an admin notice if the max-age was updated. 531 534 * 532 * @since 2.0.0 -dev535 * @since 2.0.0 533 536 * @return void 534 537 */ … … 584 587 update_user_meta( $current_user_id, 'pantheon_max_age_updated_notice', true ); 585 588 } 589 590 /** 591 * Filter the nonce cache lifetime. 592 * 593 * @param int $lifetime The lifetime of the nonce. 594 * 595 * @since 2.0.0 596 * @return int 597 */ 598 function filter_nonce_cache_lifetime( $lifetime ) { 599 // Bail early if we're in the admin. 600 if ( is_admin() ) { 601 return $lifetime; 602 } 603 604 // Filter the cache default max age to less than the nonce lifetime when creating nonces on the front-end. This prevents the cache from keeping the nonce around longer than it should. 605 add_filter( 'pantheon_cache_default_max_age', function () use ( $lifetime ) { 606 return $lifetime - HOUR_IN_SECONDS; 607 } ); 608 609 return $lifetime; 610 } -
pantheon-advanced-page-cache/tags/2.0.0/pantheon-advanced-page-cache.php
r3092255 r3094130 1 1 <?php 2 2 /** 3 * Plugin Name: Pantheon Advanced Page Cache 4 * Plugin URI: https://wordpress.org/plugins/pantheon-advanced-page-cache/ 5 * Description: Automatically clear related pages from Pantheon's Edge when you update content. High TTL. Fresh content. Visitors never wait. 6 * Author: Pantheon 7 * Author URI: https://pantheon.io 8 * Text Domain: pantheon-advanced-page-cache 9 * Domain Path: /languages 10 * Version: 1.5.0 3 * Plugin Name: Pantheon Advanced Page Cache 4 * Plugin URI: https://wordpress.org/plugins/pantheon-advanced-page-cache/ 5 * Description: Automatically clear related pages from Pantheon's Edge when you update content. High TTL. Fresh content. Visitors never wait. 6 * Author: Pantheon 7 * Author URI: https://pantheon.io 8 * Text Domain: pantheon-advanced-page-cache 9 * Domain Path: /languages 10 * Version: 2.0.0 11 * Requires at least: 6.4 12 * Tested up to: 6.5.3 11 13 * 12 14 * @package Pantheon_Advanced_Page_Cache … … 102 104 103 105 /** 106 * Bootstrapper for namespaced files that aren't classes. 107 * 108 * Expects that a bootstrap() function exists in the namespaced file. 109 * 110 * @since 2.0.0 111 * @return void 112 */ 113 function pantheon_bootstrap_namespaces() { 114 $namespaced_files = [ 115 '\\Pantheon_Advanced_Page_Cache\\Admin_Interface' => __DIR__ . '/inc/admin-interface.php', 116 ]; 117 118 foreach ( $namespaced_files as $namespace => $file ) { 119 if ( file_exists( $file ) ) { 120 require $file; 121 call_user_func( $namespace . '\\bootstrap' ); 122 } else { 123 wp_die( esc_html( "Could not find $file" ), 'Pantheon Advanced Page Cache error' ); 124 125 } 126 } 127 } 128 129 /** 104 130 * Registers the class autoloader. 105 131 */ … … 122 148 } 123 149 ); 150 151 /** 152 * Init namespaced files. 153 */ 154 add_action( 'plugins_loaded', 'pantheon_bootstrap_namespaces' ); 124 155 125 156 /** -
pantheon-advanced-page-cache/tags/2.0.0/readme.txt
r3092255 r3094130 2 2 Contributors: getpantheon, danielbachhuber, kporras07, jspellman, jazzs3quence, ryanshoover, rwagner00, pwtyler 3 3 Tags: pantheon, cdn, cache 4 Requires at least: 4.75 Tested up to: 6. 4.36 Stable tag: 1.5.04 Requires at least: 6.4 5 Tested up to: 6.5.3 6 Stable tag: 2.0.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 151 151 This will prevent the cache from being purged if the given post type is updated. 152 152 153 = Setting the Cache Max Age with a filter = 154 155 The cache max age setting is controlled by the [Pantheon Page Cache](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin) admin page. As of 2.0.0, there are three cache age options by default — 1 week, 1 month, 1 year. Pantheon Advanced Page Cache automatically purges the cache of updated and related posts and pages, but you might want to override the cache max age value and set it programmatically. In this case, you can use the `pantheon_cache_default_max_age` filter added in [Pantheon MU plugin 1.4.0+](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin#override-the-default-max-age). For example: 156 157 add_filter( 'pantheon_cache_default_max_age', function() { 158 return 10 * DAY_IN_SECONDS; 159 } ); 160 161 When the cache max age is filtered in this way, the admin option is disabled and a notice is displayed. 162 153 163 == WP-CLI Commands == 154 164 … … 322 332 add_filter('pantheon_should_add_terms', 'custom_should_add_terms', 10, 2); 323 333 334 == Other Filters == 335 336 = `pantheon_apc_disable_admin_notices` = 337 Since 2.0.0, Pantheon Advanced Page Cache displays a number of admin notices about your current cache max age value. You can disable these notices with the `pantheon_apc_disable_admin_notices` filter. 338 339 add_filter( 'pantheon_apc_disable_admin_notices', '__return_true' ); 340 341 Alternately, the function callback is passed into the `pantheon_apc_disable_admin_notices` filter, allowing you to specify precisely _which_ notice to disable, for example: 342 343 add_filter( 'pantheon_apc_disable_admin_notices', function( $disable_notices, $callback ) { 344 if ( $callback === '\\Pantheon_Advanced_Page_Cache\\Admin_Interface\\admin_notice_maybe_recommend_higher_max_age' ) { 345 return true; 346 } 347 return $disable_notices; 348 }, 10, 2 ); 349 350 The above example would disable _only_ the admin notice recommending a higher cache max age. 351 324 352 == Plugin Integrations == 325 353 … … 333 361 334 362 == Changelog == 363 = 2.0.0 (28 May 2024) = 364 * Adds new admin alerts and Site Health tests about default cache max age settings and recommendations [[#268](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/268), [#271](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/271)]. The default Pantheon GCDN cache max age value has been updated to 1 week in the [Pantheon MU plugin](https://github.com/pantheon-systems/pantheon-mu-plugin). For more information, see the [release note](https://docs.pantheon.io/release-notes/2024/04/pantheon-mu-plugin-1-4-0-update). 365 * Updated UI in Pantheon Page Cache admin page when used in a Pantheon environment (with the Pantheon MU plugin). [[#272](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/272)] 366 * Automatically updates the cache max age to the recommended value (1 week) if it was saved at the old default value (600 seconds). [[#269](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/269)] 367 * Adds a hook into the `nonce_life` filter when nonces are created on the front-end to set the `pantheon_cache_default_max_age` to less than the nonce lifetime to avoid nonces expiring before the cache does. [[#282](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/282)] props [@ryanshoover](https://profiles.wordpress.org/ryanshoover/) 368 335 369 = 1.5.0 (11 March 2024) = 336 370 * Adds filter `pantheon_purge_post_type_ignored` to allow an array of post types to ignore before purging cache [[#258](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/258)] … … 410 444 411 445 == Upgrade Notice == 412 413 = Latest = 446 = 2.0.0 (28 May 2024) = 447 This release requires a minimum WordPress version of 6.4.0. It uses Site Health checks and the `wp_admin_notices` function to alert users to the new cache max-age default settings and recommendations. The plugin will still function with earlier versions, but you will not get the benefit of the alerts and Site Health checks. 448 449 This version also automatically updates the cache max age (set in the [Pantheon Page Cache settings](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin)) to the recommended value (1 week) if it was saved at the old default value (600 seconds). If the cache max age was set to any other value (or not set at all), it will not be changed. A one-time notice will be displayed in the admin interface to inform administrators of this change. 450 451 = 1.3.0 = 414 452 Note that the Pantheon Advanced Page Cache 1.3.0 release now prefixes keys on a WordPress Multisite (WPMS) with the blog ID. For users who already have this plugin installed on a WPMS, they will need to click the Clear Cache button on the settings page to generate the prefixed keys. -
pantheon-advanced-page-cache/trunk/assets/css/styles.css
r3092217 r3094130 1 .pantheon-page-cache hr{display:none}.pantheon-page-cache tr.cache-default-max-age{display:block;padding:10px;background:#fff;color:#1e1e1e;box-shadow:0 0 10px 5px rgba(0,0,0,.1)}.pantheon-page-cache tr.cache-default-max-age td{padding:0}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age{padding:0 10px 10px 0}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age h3{margin-top:.5em}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age i{margin-right:10px;line-height:1em}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar{background:#1d7afc;color:#fff;padding:10px 0 10px 10px;text-align:left;display:block;width:100%;margin-bottom:1em}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a{color:#fff;text-decoration:underline}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:active,.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:hover{color:#fff;text-decoration:none}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age select{background-color:#fff;color:#1e1e1e;border:1px solid #757575;border-radius:0}.pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-description{color:#757575;margin:10px 0 0} 1 .pantheon-page-cache hr { 2 display: none; 3 } 4 .pantheon-page-cache tr.cache-default-max-age { 5 display: block; 6 padding: 10px; 7 background: #ffffff; 8 color: #1e1e1e; 9 box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.1); 10 } 11 .pantheon-page-cache tr.cache-default-max-age td { 12 padding: 0; 13 } 14 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age { 15 padding: 0 10px 10px 0; 16 } 17 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age h3 { 18 margin-top: 0.5em; 19 } 20 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age i { 21 margin-right: 10px; 22 line-height: 1em; 23 } 24 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar { 25 background: #1d7afc; 26 color: #ffffff; 27 padding: 10px 0 10px 10px; 28 text-align: left; 29 display: block; 30 width: 100%; 31 margin-bottom: 1em; 32 } 33 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a { 34 color: #ffffff; 35 text-decoration: underline; 36 } 37 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:hover, .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-info-bar a:active { 38 color: #ffffff; 39 text-decoration: none; 40 } 41 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age select { 42 background-color: #ffffff; 43 color: #1e1e1e; 44 border: 1px solid #757575; 45 border-radius: 0; 46 } 47 .pantheon-page-cache tr.cache-default-max-age .pantheon-cache-default-max-age-description { 48 color: #757575; 49 margin: 10px 0 0 0; 50 } -
pantheon-advanced-page-cache/trunk/inc/admin-interface.php
r3091792 r3094130 3 3 * Controller for the admin interface that builds on top of the Pantheon MU plugin. 4 4 * 5 * @since 2.0.0 -dev5 * @since 2.0.0 6 6 * @package Pantheon_Advanced_Page_Cache 7 7 */ … … 12 12 * Kick off the important bits. 13 13 * 14 * @since 2.0.0 -dev14 * @since 2.0.0 15 15 * @return void 16 16 */ … … 43 43 add_filter( 'pantheon_cache_max_age_input', __NAMESPACE__ . '\\update_default_ttl_input' ); 44 44 add_filter( 'pantheon_cache_max_age_input_allowed_html', __NAMESPACE__ . '\\max_age_input_allowed_html' ); 45 add_filter( 'nonce_life', __NAMESPACE__ . '\\filter_nonce_cache_lifetime' ); 45 46 } 46 47 … … 48 49 * Enqueue admin assets. 49 50 * 50 * @since 2.0.0 -dev51 * @since 2.0.0 51 52 * @return void 52 53 */ … … 60 61 // If WP_DEBUG is true, append a timestamp to the end of the path so we get a fresh copy of the css. 61 62 $debug = defined( 'WP_DEBUG' ) && WP_DEBUG ? '-' . time() : ''; 62 wp_enqueue_style( 'papc-admin', plugin_dir_url( __DIR__ ) . 'assets/css/styles.css', [], '2.0.0' . $debug ); 63 // Use minified css unless SCRIPT_DEBUG is true. 64 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 65 wp_enqueue_style( 'papc-admin', plugin_dir_url( __DIR__ ) . "assets/css/styles$min.css", [], '2.0.0' . $debug ); 63 66 } 64 67 … … 66 69 * Add a header to the max-age setting field. 67 70 * 68 * @since 2.0.0 -dev71 * @since 2.0.0 69 72 * @return string 70 73 */ … … 87 90 * Add a description to the max-age setting field. 88 91 * 89 * @since 2.0.0 -dev92 * @since 2.0.0 90 93 * @return string 91 94 */ … … 122 125 * @param int $default_input The default TTL input field from the mu-plugin. 123 126 * 124 * @since 2.0.0 -dev127 * @since 2.0.0 125 128 * @return int 126 129 */ … … 160 163 * Filter the allowed HTML for the max-age input field. 161 164 * 162 * @since 2.0.0 -dev165 * @since 2.0.0 163 166 * @param array $allowed_html The allowed HTML. 164 167 * @return array … … 173 176 * Get the default max age options. Default values are 1 week, 1 month, 1 year. 174 177 * 175 * @since 2.0.0 -dev178 * @since 2.0.0 176 179 * @return array 177 180 */ … … 195 198 * Display an admin notice if the Pantheon MU plugin was not found. 196 199 * 197 * @since 2.0.0 -dev200 * @since 2.0.0 198 201 * @return void 199 202 */ … … 222 225 * Display an admin notice if the Pantheon MU plugin is out of date. 223 226 * 224 * @since 2.0.0 -dev227 * @since 2.0.0 225 228 * @return void 226 229 */ … … 260 263 * Display an admin notice if the max-age is less than a week but not equal to 600 seconds. 261 264 * 262 * @since 2.0.0 -dev265 * @since 2.0.0 263 266 * @return void 264 267 */ … … 330 333 * If the site existed prior to 1.4.0 of the mu-plugin, the default value is 600 seconds. Otherwise, the default value is 1 week. 331 334 * 332 * @since 2.0.0 -dev335 * @since 2.0.0 333 336 * @return int 334 337 */ … … 349 352 * @param array $tests The Site Health tests. 350 353 * 351 * @since 2.0.0 -dev354 * @since 2.0.0 352 355 * @return array 353 356 */ … … 366 369 * @param bool $recommended Whether to get the recommended max-age. 367 370 * 368 * @since 2.0.0 -dev371 * @since 2.0.0 369 372 * @return string 370 373 */ … … 380 383 * Get the default max-age. 381 384 * 382 * @since 2.0.0 -dev385 * @since 2.0.0 383 386 * @return int 384 387 */ … … 390 393 * Compare the current max-age to the default max-age. 391 394 * 392 * @since 2.0.0 -dev395 * @since 2.0.0 393 396 * @return int A ranked value from 0 to 10 where 0 is optimal (equal to or greater than the recommended max age) and 10 is very bad. 394 397 */ … … 419 422 * The GCDN cache max-age Site Health test. 420 423 * 421 * @since 2.0.0 -dev424 * @since 2.0.0 422 425 * @return array 423 426 */ … … 485 488 * Clear the max-age compare cache when the max-age is updated. 486 489 * 487 * @since 2.0.0 -dev490 * @since 2.0.0 488 491 * @return void 489 492 */ … … 495 498 * Set the default_ttl from the mu-plugin to WEEK_IN_SECONDS if it was saved as 600 seconds. 496 499 * 497 * @since 2.0.0 -dev500 * @since 2.0.0 498 501 * @return bool 499 502 */ … … 530 533 * Display an admin notice if the max-age was updated. 531 534 * 532 * @since 2.0.0 -dev535 * @since 2.0.0 533 536 * @return void 534 537 */ … … 584 587 update_user_meta( $current_user_id, 'pantheon_max_age_updated_notice', true ); 585 588 } 589 590 /** 591 * Filter the nonce cache lifetime. 592 * 593 * @param int $lifetime The lifetime of the nonce. 594 * 595 * @since 2.0.0 596 * @return int 597 */ 598 function filter_nonce_cache_lifetime( $lifetime ) { 599 // Bail early if we're in the admin. 600 if ( is_admin() ) { 601 return $lifetime; 602 } 603 604 // Filter the cache default max age to less than the nonce lifetime when creating nonces on the front-end. This prevents the cache from keeping the nonce around longer than it should. 605 add_filter( 'pantheon_cache_default_max_age', function () use ( $lifetime ) { 606 return $lifetime - HOUR_IN_SECONDS; 607 } ); 608 609 return $lifetime; 610 } -
pantheon-advanced-page-cache/trunk/pantheon-advanced-page-cache.php
r3092255 r3094130 1 1 <?php 2 2 /** 3 * Plugin Name: Pantheon Advanced Page Cache 4 * Plugin URI: https://wordpress.org/plugins/pantheon-advanced-page-cache/ 5 * Description: Automatically clear related pages from Pantheon's Edge when you update content. High TTL. Fresh content. Visitors never wait. 6 * Author: Pantheon 7 * Author URI: https://pantheon.io 8 * Text Domain: pantheon-advanced-page-cache 9 * Domain Path: /languages 10 * Version: 1.5.0 3 * Plugin Name: Pantheon Advanced Page Cache 4 * Plugin URI: https://wordpress.org/plugins/pantheon-advanced-page-cache/ 5 * Description: Automatically clear related pages from Pantheon's Edge when you update content. High TTL. Fresh content. Visitors never wait. 6 * Author: Pantheon 7 * Author URI: https://pantheon.io 8 * Text Domain: pantheon-advanced-page-cache 9 * Domain Path: /languages 10 * Version: 2.0.0 11 * Requires at least: 6.4 12 * Tested up to: 6.5.3 11 13 * 12 14 * @package Pantheon_Advanced_Page_Cache … … 102 104 103 105 /** 106 * Bootstrapper for namespaced files that aren't classes. 107 * 108 * Expects that a bootstrap() function exists in the namespaced file. 109 * 110 * @since 2.0.0 111 * @return void 112 */ 113 function pantheon_bootstrap_namespaces() { 114 $namespaced_files = [ 115 '\\Pantheon_Advanced_Page_Cache\\Admin_Interface' => __DIR__ . '/inc/admin-interface.php', 116 ]; 117 118 foreach ( $namespaced_files as $namespace => $file ) { 119 if ( file_exists( $file ) ) { 120 require $file; 121 call_user_func( $namespace . '\\bootstrap' ); 122 } else { 123 wp_die( esc_html( "Could not find $file" ), 'Pantheon Advanced Page Cache error' ); 124 125 } 126 } 127 } 128 129 /** 104 130 * Registers the class autoloader. 105 131 */ … … 122 148 } 123 149 ); 150 151 /** 152 * Init namespaced files. 153 */ 154 add_action( 'plugins_loaded', 'pantheon_bootstrap_namespaces' ); 124 155 125 156 /** -
pantheon-advanced-page-cache/trunk/readme.txt
r3092255 r3094130 2 2 Contributors: getpantheon, danielbachhuber, kporras07, jspellman, jazzs3quence, ryanshoover, rwagner00, pwtyler 3 3 Tags: pantheon, cdn, cache 4 Requires at least: 4.75 Tested up to: 6. 4.36 Stable tag: 1.5.04 Requires at least: 6.4 5 Tested up to: 6.5.3 6 Stable tag: 2.0.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 151 151 This will prevent the cache from being purged if the given post type is updated. 152 152 153 = Setting the Cache Max Age with a filter = 154 155 The cache max age setting is controlled by the [Pantheon Page Cache](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin) admin page. As of 2.0.0, there are three cache age options by default — 1 week, 1 month, 1 year. Pantheon Advanced Page Cache automatically purges the cache of updated and related posts and pages, but you might want to override the cache max age value and set it programmatically. In this case, you can use the `pantheon_cache_default_max_age` filter added in [Pantheon MU plugin 1.4.0+](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin#override-the-default-max-age). For example: 156 157 add_filter( 'pantheon_cache_default_max_age', function() { 158 return 10 * DAY_IN_SECONDS; 159 } ); 160 161 When the cache max age is filtered in this way, the admin option is disabled and a notice is displayed. 162 153 163 == WP-CLI Commands == 154 164 … … 322 332 add_filter('pantheon_should_add_terms', 'custom_should_add_terms', 10, 2); 323 333 334 == Other Filters == 335 336 = `pantheon_apc_disable_admin_notices` = 337 Since 2.0.0, Pantheon Advanced Page Cache displays a number of admin notices about your current cache max age value. You can disable these notices with the `pantheon_apc_disable_admin_notices` filter. 338 339 add_filter( 'pantheon_apc_disable_admin_notices', '__return_true' ); 340 341 Alternately, the function callback is passed into the `pantheon_apc_disable_admin_notices` filter, allowing you to specify precisely _which_ notice to disable, for example: 342 343 add_filter( 'pantheon_apc_disable_admin_notices', function( $disable_notices, $callback ) { 344 if ( $callback === '\\Pantheon_Advanced_Page_Cache\\Admin_Interface\\admin_notice_maybe_recommend_higher_max_age' ) { 345 return true; 346 } 347 return $disable_notices; 348 }, 10, 2 ); 349 350 The above example would disable _only_ the admin notice recommending a higher cache max age. 351 324 352 == Plugin Integrations == 325 353 … … 333 361 334 362 == Changelog == 363 = 2.0.0 (28 May 2024) = 364 * Adds new admin alerts and Site Health tests about default cache max age settings and recommendations [[#268](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/268), [#271](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/271)]. The default Pantheon GCDN cache max age value has been updated to 1 week in the [Pantheon MU plugin](https://github.com/pantheon-systems/pantheon-mu-plugin). For more information, see the [release note](https://docs.pantheon.io/release-notes/2024/04/pantheon-mu-plugin-1-4-0-update). 365 * Updated UI in Pantheon Page Cache admin page when used in a Pantheon environment (with the Pantheon MU plugin). [[#272](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/272)] 366 * Automatically updates the cache max age to the recommended value (1 week) if it was saved at the old default value (600 seconds). [[#269](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/269)] 367 * Adds a hook into the `nonce_life` filter when nonces are created on the front-end to set the `pantheon_cache_default_max_age` to less than the nonce lifetime to avoid nonces expiring before the cache does. [[#282](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/282)] props [@ryanshoover](https://profiles.wordpress.org/ryanshoover/) 368 335 369 = 1.5.0 (11 March 2024) = 336 370 * Adds filter `pantheon_purge_post_type_ignored` to allow an array of post types to ignore before purging cache [[#258](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/258)] … … 410 444 411 445 == Upgrade Notice == 412 413 = Latest = 446 = 2.0.0 (28 May 2024) = 447 This release requires a minimum WordPress version of 6.4.0. It uses Site Health checks and the `wp_admin_notices` function to alert users to the new cache max-age default settings and recommendations. The plugin will still function with earlier versions, but you will not get the benefit of the alerts and Site Health checks. 448 449 This version also automatically updates the cache max age (set in the [Pantheon Page Cache settings](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin)) to the recommended value (1 week) if it was saved at the old default value (600 seconds). If the cache max age was set to any other value (or not set at all), it will not be changed. A one-time notice will be displayed in the admin interface to inform administrators of this change. 450 451 = 1.3.0 = 414 452 Note that the Pantheon Advanced Page Cache 1.3.0 release now prefixes keys on a WordPress Multisite (WPMS) with the blog ID. For users who already have this plugin installed on a WPMS, they will need to click the Clear Cache button on the settings page to generate the prefixed keys.
Note: See TracChangeset
for help on using the changeset viewer.