Skip to content

Commit

Permalink
Merge pull request #7 from alleyinteractive/issue-6
Browse files Browse the repository at this point in the history
Refactor and update wp-404-caching to version 1.0.2
  • Loading branch information
attackant committed Mar 15, 2024
2 parents 02a2828 + 5404045 commit 6957628
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to `WP 404 Caching` will be documented in this file.

## 1.0.2

- Fixed issue with Feature_Manager setup
- Added `wp_404_caching_enabled` filter to allow disabling the cache

## 1.0.1

- Initial release
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A WordPress plugin to provide full page caching for 404 pages, improving perform

- **Contributors**: alleyinteractive
- **Tags**: alleyinteractive, wp-404-caching
- **Stable tag**: 1.0.1
- **Stable tag**: 1.0.2

## Requirements
- SSL enabled on the website.
Expand Down Expand Up @@ -58,6 +58,9 @@ add_filter( 'wp_404_caching_cache_time', function( $cache_time ) {
add_filter( 'wp_404_caching_stale_cache_time', function( $stale_cache_time ) {
return 2 * DAY_IN_SECONDS; // Set stale cache time to 2 days.
} );

// Programmatically bypass the cache.
add_filter( 'wp_404_caching_enabled', '__return_false' );
```

## Changelog
Expand Down
25 changes: 0 additions & 25 deletions src/class-wp-404-caching.php

This file was deleted.

4 changes: 4 additions & 0 deletions src/features/class-full-page-cache-404.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public function boot(): void {
return;
}

if ( ! apply_filters( 'wp_404_caching_enabled', true ) ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return;
}

// Return 404 page cache on template_redirect.
add_action( 'template_redirect', [ self::class, 'action__template_redirect' ], 1 );

Expand Down
11 changes: 7 additions & 4 deletions wp-404-caching.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP 404 Caching
* Plugin URI: https://github.com/alleyinteractive/wp-404-caching
* Description: Full Page Cache for WordPress 404s
* Version: 1.0.1
* Version: 1.0.2
* Author: Alley
* Author URI: https://github.com/alleyinteractive/wp-404-caching
* Requires at least: 6.3
Expand All @@ -17,6 +17,9 @@

namespace Alley\WP\WP_404_Caching;

use Composer\InstalledVersions;
use function add_action;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
Expand All @@ -32,8 +35,8 @@
// to see if the Composer dependencies have been installed in a parent
// folder. This is useful for when the plugin is loaded as a Composer
// dependency in a larger project.
if ( ! class_exists( \Composer\InstalledVersions::class ) ) {
\add_action(
if ( ! class_exists( InstalledVersions::class ) ) {
add_action(
'admin_notices',
function () {
?>
Expand Down Expand Up @@ -61,7 +64,7 @@ function () {
function main(): void {
// This should be an array with keys set to feature classnames and arguments.
$features = [
// Add initial features here.
'Alley\WP\WP_404_Caching\Features\Full_Page_Cache_404' => [],
];
$features = apply_filters( 'wp_404_caching_features', $features );
Feature_Manager::add_features( $features );
Expand Down

0 comments on commit 6957628

Please sign in to comment.