Generic WordPress plugin to fetch, cache and display remote content via WP-Cron.
WP Cron Fetcher provides a lightweight framework for scheduling remote content fetches using WP-Cron, storing results in transients, and exposing them via shortcodes. It ships with a built-in fetcher for the Evangelizo liturgical daily feed as a reference implementation.
- Extensible architecture: Register custom fetchers via the
wp_cron_fetcher_registerfilter - WP-Cron scheduling: Automatic periodic fetches with configurable schedules (hourly, daily, etc.)
- Transient caching: Fetched content is stored in WordPress transients with automatic expiration
- Shortcode support: Each fetcher can expose shortcodes to display cached content
- W3TC integration: Automatic page cache purge after successful fetches
- Fallback fetch: If a transient is missing when a shortcode is rendered, a fresh fetch is triggered automatically
- Logging: Full integration with WP Logger for debug and error tracking
- Dependency Isolation: All dependencies are scoped via wpify/scoper to prevent conflicts with other plugins
- PHP ^8.1
- WordPress ^6.0
You can install the plugin in three ways: manually, via Composer from WP Packages, or via Composer from GitHub Releases.
Manual Installation
- Go to the Releases section of this repository.
- Download the latest release zip file.
- Log in to your WordPress admin dashboard.
- Navigate to
Plugins>Add New. - Click
Upload Plugin. - Choose the downloaded zip file and click
Install Now.
Installation via Composer from WP Packages
If you use Composer to manage WordPress plugins, you can install it from WP Packages:
- Open your terminal.
- Navigate to the root directory of your WordPress installation.
- Ensure your
composer.jsonfile has the following configuration: *
{
"require": {
"composer/installers": "^1.0 || ^2.0",
"wp-plugin/wp-cron-fetcher": "^0.1"
},
"repositories": [
{
"name": "wp-packages",
"type": "composer",
"url": "https://repo.wp-packages.org"
}
],
"extra": {
"installer-paths": {
"wp-content/plugins/{$name}/": [
"type:wordpress-plugin"
]
}
}
}- Run the following command:
composer update
Note:
* composer/installers might already be required by another dependency.
Installation via Composer from GitHub Releases
If you use Composer to manage WordPress plugins, you can install it from this repository directly.
Standard Version (uses WordPress update system):
- Open your terminal.
- Navigate to the root directory of your WordPress installation.
- Ensure your
composer.jsonfile has the following configuration: *
{
"require": {
"composer/installers": "^1.0 || ^2.0",
"wp-spaghetti/wp-cron-fetcher": "^0.1"
},
"repositories": [
{
"type": "package",
"package": {
"name": "wp-spaghetti/wp-cron-fetcher",
"version": "0.2.0",
"type": "wordpress-plugin",
"dist": {
"url": "https://github.com/wp-spaghetti/wp-cron-fetcher/releases/download/v0.2.0/wp-cron-fetcher.zip",
"type": "zip"
}
}
}
],
"extra": {
"installer-paths": {
"wp-content/plugins/{$name}/": [
"type:wordpress-plugin"
]
}
}
}Version with Plugin Update Checker (uses PUC for updates via GitHub):
For installations that need updates managed via GitHub instead of WordPress.org, use the --with-puc version:
{
"require": {
"composer/installers": "^1.0 || ^2.0",
"wp-spaghetti/wp-cron-fetcher": "^0.1"
},
"repositories": [
{
"type": "package",
"package": {
"name": "wp-spaghetti/wp-cron-fetcher",
"version": "0.2.0",
"type": "wordpress-plugin",
"dist": {
"url": "https://github.com/wp-spaghetti/wp-cron-fetcher/releases/download/v0.2.0/wp-cron-fetcher--with-puc.zip",
"type": "zip"
}
}
}
],
"extra": {
"installer-paths": {
"wp-content/plugins/{$name}/": [
"type:wordpress-plugin"
]
}
}
}- Run the following command:
composer update
Note:
* composer/installers might already be required by another dependency.
* The --with-puc version includes Plugin Update Checker for automatic update detection from GitHub releases, while the standard version relies on the WordPress.org update system.
WP Cron Fetcher does nothing on its own — you need to register one or more fetchers. Add this in your theme's functions.php or in a dependent plugin:
add_filter('wp_cron_fetcher_register', function (array $fetchers): array {
$fetchers[] = new \WpSpaghetti\WPCF\Fetcher\EvangelizoFetcher();
return $fetchers;
});The bundled EvangelizoFetcher provides two shortcodes:
| Shortcode | Description |
|---|---|
[evangelizo_liturgic] |
Daily liturgical title |
[evangelizo_gospel] |
Commentary + gospel title |
The shortcodes output semantic HTML with CSS classes for easy styling:
/* Liturgic shortcode */
.wpcf-evangelizo-liturgic { }
/* Gospel shortcode */
.wpcf-evangelizo-gospel { }
.wpcf-evangelizo-gospel__comment { }
.wpcf-evangelizo-gospel__title { }Extend AbstractFetcher and implement the FetcherInterface:
use WpSpaghetti\WPCF\Fetcher\AbstractFetcher;
class MyApiFetcher extends AbstractFetcher
{
public function getId(): string
{
return 'my_api';
}
public function fetch(): void
{
$data = $this->remoteGet('https://api.example.com/data');
$this->storeTransient('data', $data);
}
public function getShortcodes(): array
{
return [
'my_api_data' => function (array $atts): string {
$data = $this->readTransient('data');
return $data ? '<div class="my-api-data">' . esc_html($data) . '</div>' : '';
},
];
}
}| Environment Variable | Description | Default |
|---|---|---|
WP_CRON_FETCHER_TIMEOUT |
HTTP request timeout in seconds | 10 |
Please see CHANGELOG for a detailed list of changes for each release.
We follow Semantic Versioning and use Conventional Commits to automatically generate our changelog.
- Major versions (1.0.0 → 2.0.0): Breaking changes
- Minor versions (1.0.0 → 1.1.0): New features, backward compatible
- Patch versions (1.0.0 → 1.0.1): Bug fixes, backward compatible
All releases are automatically created when changes are pushed to the main branch, based on commit message conventions.
For your contributions please use:
See CONTRIBUTING for detailed guidelines.
