Skip to content

GitHub Downloads (all assets, all releases) GitHub Actions Workflow Status GitHub Issues GitHub Release License

WP Cron Fetcher (WordPress Plugin)

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.

Features

  • Extensible architecture: Register custom fetchers via the wp_cron_fetcher_register filter
  • 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

Requirements

  • PHP ^8.1
  • WordPress ^6.0

Installation

You can install the plugin in three ways: manually, via Composer from WP Packages, or via Composer from GitHub Releases.

Manual Installation
  1. Go to the Releases section of this repository.
  2. Download the latest release zip file.
  3. Log in to your WordPress admin dashboard.
  4. Navigate to Plugins > Add New.
  5. Click Upload Plugin.
  6. 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:

  1. Open your terminal.
  2. Navigate to the root directory of your WordPress installation.
  3. Ensure your composer.json file 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"
            ]
        }
    }
}
  1. 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):

  1. Open your terminal.
  2. Navigate to the root directory of your WordPress installation.
  3. Ensure your composer.json file 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"
            ]
        }
    }
}
  1. 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.

Usage

Registering a Fetcher

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;
});

Built-in Shortcodes (EvangelizoFetcher)

The bundled EvangelizoFetcher provides two shortcodes:

Shortcode Description
[evangelizo_liturgic] Daily liturgical title
[evangelizo_gospel] Commentary + gospel title

CSS Classes

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 { }

Creating a Custom Fetcher

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>' : '';
            },
        ];
    }
}

Configuration

Environment Variable Description Default
WP_CRON_FETCHER_TIMEOUT HTTP request timeout in seconds 10

Changelog

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.

Release Process

  • 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.

Contributing

For your contributions please use:

See CONTRIBUTING for detailed guidelines.

Sponsor

Buy Me A Coffee

License

(ɔ) Copyleft 2026 Frugan.
GNU GPLv3, see LICENSE file.

About

Generic WordPress plugin to fetch, cache and display remote content via WP-Cron

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages