A WordPress plugin that automatically revalidates posts and categories when content changes, sending requests to a configured endpoint for cache invalidation.
Silver Assist Post Revalidate is a lightweight WordPress plugin designed to keep your headless WordPress site's cache fresh. When content is created, updated, or deleted, the plugin automatically triggers revalidation requests to your front-end application (typically Next.js with ISR - Incremental Static Regeneration).
- ✅ Automatic Revalidation: Triggers on post save, update, and delete
- ✅ Category Support: Revalidates when categories are created, updated, or deleted
- ✅ Tag Support: Revalidates when tags are created, updated, or deleted (NEW in v1.2.0)
- ✅ Status Transitions: Smart revalidation on publish/unpublish (NEW in v1.2.0)
- ✅ Post Deletion: Automatic revalidation when posts are deleted (NEW in v1.2.0)
- ✅ Path Deduplication: Prevents duplicate revalidation requests (NEW in v1.2.0)
- ✅ Path-Based: Sends only relative paths (no domain) to your endpoint
- ✅ Secure: Token-based authentication for endpoint requests
- ✅ Simple Configuration: Easy-to-use admin settings page
- ✅ Debug Logs: Built-in debug log viewer with accordion UI (see requests/responses)
- ✅ Centralized Settings: Integrates with Silver Assist Settings Hub
- ✅ Automatic Updates: GitHub-based auto-updates for seamless upgrades
- ✅ Modern PHP: Built with PHP 8.2+ features and PSR-4 autoloading
- ✅ Comprehensive Tests: 36 tests, 100% passing, 0.3s execution time
- WordPress: 6.5 or higher
- PHP: 8.2 or higher
- Composer: For development only
- Download the latest release from the releases page
- Go to WordPress Admin → Plugins → Add New
- Click "Upload Plugin" and select the downloaded ZIP file
- Click "Install Now" and then "Activate"
- Download the plugin files
- Upload the
silver-assist-post-revalidatefolder to/wp-content/plugins/ - Activate the plugin through the "Plugins" menu in WordPress
composer require silver-assist/post-revalidateNavigate to Settings → Post Revalidate in your WordPress admin panel.
Enter your revalidation endpoint URL:
https://your-frontend-site.com/api/revalidate
Enter the authentication token that your endpoint expects:
your-secret-token-here
Click "Save Settings" to store your configuration.
Once configured, the plugin works automatically. No additional setup required!
- The post's permalink
- All categories associated with the post
- All tags associated with the post
- The post's permalink (before deletion)
- All categories associated with the post
- All tags associated with the post
- The post's permalink
- All categories associated with the post
- All tags associated with the post
- Triggers on: draft → publish, publish → draft, publish → private
- The category archive page
- All posts within that category
- The tag archive page
- All posts with that tag
The plugin sends GET requests to your endpoint with the following query parameters:
GET https://your-endpoint.com/api/revalidate?token=YOUR_TOKEN&path=/blog/my-post/
Parameters:
token: Authentication token (from settings)path: Relative path to revalidate (e.g.,/blog/my-post/)
New in v1.2.0: Built-in debug log viewer for complete traceability!
The Debug Logs section appears at the bottom of the settings page and displays all revalidation requests with full request/response details.
- 📊 Accordion UI: Click any log entry to expand and view details
- 🎨 Color-Coded Status: Green for success (200-299), red for errors
- 📝 JSON Formatted: Request and response data formatted for easy reading
- ⏱️ Timestamps: Track when each revalidation occurred
- 🗑️ Clear Logs: Button to remove all logs (with confirmation)
- 🔄 Auto-Rotation: Maximum 100 entries kept (FIFO)
Each log entry contains:
Request Details:
{
"url": "https://example.com/api/revalidate?token=xxx&path=/blog/post/",
"method": "GET",
"headers": {
"User-Agent": "Silver-Assist-Revalidate/1.2.0"
},
"timeout": 30
}Response Details:
{
"code": 200,
"message": "OK",
"body": "{\"revalidated\":true,\"path\":\"/blog/post/\"}",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache"
}
}- Debugging: See exactly what was sent and received
- Duplicate Detection: Identify if requests are being sent multiple times
- Server Issues: Check response codes and error messages
- Performance Monitoring: Track response times and success rates
- Path Verification: Ensure correct paths are being revalidated
- Go to Settings → Post Revalidate (or Silver Assist → Post Revalidate)
- Scroll to the bottom of the page
- See the "Revalidation Debug Logs" section
- Click any log header to expand and view details
┌─────────────────────────────────────────────────────────┐
│ Revalidation Debug Logs [Clear All Logs] │
├─────────────────────────────────────────────────────────┤
│ Showing 3 requests (most recent first). Max 100 kept. │
│ │
│ ✓ /blog/my-post/ SUCCESS (200) 2025-10-09 14:32 │ ← Click to expand
│ ✗ /category/tech/ ERROR (500) 2025-10-09 14:31 │
│ ✓ /blog/another/ SUCCESS (200) 2025-10-09 14:30 │
└─────────────────────────────────────────────────────────┘
When expanded, you'll see formatted JSON for both request and response data.
Here's an example API route for Next.js to handle revalidation requests:
// pages/api/revalidate.js
export default async function handler(req, res) {
const { token, path } = req.query;
// Validate token
if (token !== process.env.REVALIDATE_TOKEN) {
return res.status(401).json({ message: 'Invalid token' });
}
// Validate path
if (!path) {
return res.status(400).json({ message: 'Path is required' });
}
try {
// Revalidate the path
await res.revalidate(path);
return res.json({
revalidated: true,
path,
timestamp: new Date().toISOString()
});
} catch (err) {
return res.status(500).json({
message: 'Error revalidating',
error: err.message
});
}
}- PHP 8.2+
- Composer
- WordPress development environment
- Clone the repository:
git clone https://github.com/SilverAssist/silver-assist-post-revalidate.git
cd silver-assist-post-revalidate- Install dependencies:
composer installRun these commands before committing:
# Auto-fix coding standards
composer run phpcbf
# Check coding standards
composer run phpcs
# Run static analysis
composer run phpstan
# Or run all checks
composer run testsilver-assist-post-revalidate/
├── .github/
│ ├── copilot-instructions.md # Project documentation
│ └── workflows/
│ └── release.yml # GitHub Actions CI/CD
├── assets/
│ ├── css/
│ │ └── admin-debug-logs.css # Debug logs styling with design tokens
│ └── js/
│ └── admin-debug-logs.js # Accordion & AJAX functionality
├── Includes/
│ ├── AdminSettings.php # Admin settings page & debug UI
│ ├── Plugin.php # Main plugin initialization
│ ├── Revalidate.php # Core revalidation logic & logging
│ └── Updater.php # GitHub auto-update integration
├── scripts/
│ ├── build-release.sh # Production build generator
│ └── update-version.sh # Automated version management
├── vendor/ # Composer dependencies (production)
│ ├── silverassist/
│ │ ├── wp-settings-hub/ # Centralized settings menu
│ │ └── wp-github-updater/ # Auto-update system
│ └── ...
├── silver-assist-post-revalidate.php # Main plugin file
├── composer.json # Dependencies & autoloading
├── phpcs.xml # Coding standards config
├── phpstan.neon # Static analysis config
├── phpunit.xml # Unit testing config
├── README.md # This file
├── CHANGELOG.md # Version history
├── LICENSE # Polyform Noncommercial License
└── .gitignore # Git ignore rules
The plugin uses PHPUnit with the WordPress test suite for comprehensive integration testing.
- MySQL/MariaDB server
- SVN (Subversion) client
- WordPress test suite installed
- Install the WordPress test suite using the provided script:
To install the WordPress test library, run:
bash scripts/install-wp-tests.sh wordpress_test root '' localhost latestParameters:
wordpress_test- Test database name (will be created)root- MySQL username''- MySQL password (empty in this example)localhost- MySQL hostlatest- WordPress version (or specific version like6.4.2)
The script will:
- Download WordPress core to
/tmp/wordpress/ - Install WordPress test suite to
/tmp/wordpress-tests-lib/ - Create test database configuration
- Set environment variable (optional, if not using
/tmp/wordpress-tests-lib):
export WP_TESTS_DIR=/path/to/wordpress-tests-libOr update phpunit.xml:
<env name="WP_TESTS_DIR" value="/path/to/wordpress-tests-lib"/># Run all tests
vendor/bin/phpunit
# Run specific test file
vendor/bin/phpunit tests/Unit/Plugin_Test.php
# Run with code coverage (requires Xdebug or PCOV)
vendor/bin/phpunit --coverage-html coverage/tests/
├── bootstrap.php # WordPress test suite bootstrap
└── Unit/
├── Plugin_Test.php # Plugin class tests
├── AdminSettings_Test.php # Settings & options tests
└── Revalidate_Test.php # Core revalidation logic tests
All tests extend WP_UnitTestCase for real WordPress integration:
<?php
namespace RevalidatePosts\Tests\Unit;
use WP_UnitTestCase;
use RevalidatePosts\Plugin;
class Plugin_Test extends WP_UnitTestCase {
public function test_something(): void {
// Create real WordPress posts, users, etc.
$post_id = static::factory()->post->create();
// Test with real WordPress functions
$this->assertTrue( get_post( $post_id ) !== null );
}
}Current tests cover:
- ✅ Plugin Class: Singleton pattern, settings link, initialization
- ✅ AdminSettings Class: Options storage, sanitization, settings registration, AJAX handlers, script/style enqueuing
- ✅ Revalidate Class: Post/category hooks, logging system, FIFO rotation, HTTP requests
Tests run automatically on GitHub Actions for pull requests and releases.
Enable WordPress debug mode to see detailed logs:
// wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);Check wp-content/debug.log for revalidation activity.
- Check Settings: Verify endpoint URL and token are correct
- Test Endpoint: Use curl or Postman to test your endpoint independently
- Check Logs: Enable WP_DEBUG and check debug.log
- Verify Post Type: Plugin only handles "post" type by default
- Check Post Status: Only "publish" status triggers revalidation
Issue: "Endpoint or token not configured" error
- Solution: Configure settings under Settings → Post Revalidate
Issue: Revalidation requests timing out
- Solution: Check your endpoint's response time and increase timeout if needed
Issue: Not all paths are revalidated
- Solution: Verify paths are being generated correctly in debug logs
Future enhancements planned:
- Custom post type support
- Manual revalidation button
- Bulk revalidation tool
- Revalidation queue system
- More granular path control
- Multiple endpoint support
This plugin is licensed under the Polyform Noncommercial License 1.0.0.
- ✅ Free for noncommercial use: You can use, modify, and distribute this plugin for any noncommercial purpose
- ✅ Open source: Source code is publicly available
- ❌ No commercial use: Commercial use requires a separate commercial license
- ✅ Modifications allowed: You can create and distribute modified versions (noncommercial only)
- ✅ Attribution: Please maintain attribution to Silver Assist
Polyform Noncommercial License 1.0.0
Copyright (C) 2025 Silver Assist
The licensor grants you a copyright license for the licensed material to do
everything you might do with the licensed material that would otherwise infringe
the licensor's copyright in it, for any noncommercial purpose, for the duration
of the license, and in all territories.
Commercial purposes means use of the licensed material for a purpose intended
for or directed toward commercial advantage or monetary compensation.
Full license: See LICENSE file or visit https://polyformproject.org/licenses/noncommercial/1.0.0
If you need to use this plugin for commercial purposes, please contact Silver Assist for licensing options.
Developed by Silver Assist
Made with ❤️ by Silver Assist