Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed May 28, 2024
2 parents c310f0a + b8321e4 commit e441773
Show file tree
Hide file tree
Showing 5 changed files with 5,414 additions and 1,575 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Automatically clear related pages from Pantheon's Edge when you update content.

## Description ##

[![Actively Maintained](https://img.shields.io/badge/Pantheon-Actively_Maintained-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#actively-maintained-support)
[![Lint and Test](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/lint-test.yml/badge.svg)](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/lint-test.yml)
[![CircleCI](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache.svg?style=svg)](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache)
[![Actively Maintained](https://img.shields.io/badge/Pantheon-Actively_Maintained-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#actively-maintained-support)
[![Lint and Test](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/lint-test.yml/badge.svg)](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/lint-test.yml)
[![CircleCI](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache.svg?style=svg)](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache)
Expand Down Expand Up @@ -177,6 +180,20 @@ When the cache max age is filtered in this way, the admin option is disabled and

![Page Cache Max Age with filtered value](.wordpress-org/screenshots/page-cache-max-age-filtered.png)

### Setting the Cache Max Age with a filter

The cache max age setting is controlled by the [Pantheon Page Cache](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-pluginhttps://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:

```php
add_filter( 'pantheon_cache_default_max_age', function() {
return 10 * DAY_IN_SECONDS;
} );
```

When the cache max age is filtered in this way, the admin option is disabled and a notice is displayed.

![Page Cache Max Age with filtered value](.wordpress-org/screenshots/page-cache-max-age-filtered.png)

## WP-CLI Commands ##

This plugin implements a variety of [WP-CLI](https://wp-cli.org) commands. All commands are grouped into the `wp pantheon cache` namespace.
Expand Down Expand Up @@ -348,6 +365,7 @@ Different WordPress actions cause different surrogate keys to be purged, documen
## Surrogate Keys for taxonomy terms ##
Setting surrogate keys for posts with large numbers of taxonomies (such as WooCommerce products with a large number of global attributes) can suffer from slower queries. Surrogate keys can be skipped for 'product' post types' taxonomy terms (or any other criteria you see fit) with the following filter:

```php
```php
function custom_should_add_terms($should_add_terms, $wp_query) {
if ( $wp_query->is_singular( 'product' ) ) {
Expand Down Expand Up @@ -380,6 +398,28 @@ add_filter( 'pantheon_apc_disable_admin_notices', function( $disable_notices, $c

The above example would disable _only_ the admin notice recommending a higher cache max age.

## Other Filters ##

### `pantheon_apc_disable_admin_notices`
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.

```php
add_filter( 'pantheon_apc_disable_admin_notices', '__return_true' );
```

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:

```php
add_filter( 'pantheon_apc_disable_admin_notices', function( $disable_notices, $callback ) {
if ( $callback === '\\Pantheon_Advanced_Page_Cache\\Admin_Interface\\admin_notice_maybe_recommend_higher_max_age' ) {
return true;
}
return $disable_notices;
}, 10, 2 );
```

The above example would disable _only_ the admin notice recommending a higher cache max age.

## Plugin Integrations ##

Pantheon Advanced Page Cache integrates with WordPress plugins, including:
Expand Down
Loading

0 comments on commit e441773

Please sign in to comment.