PHPackages                             jascha030/wp-subscriptions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jascha030/wp-subscriptions

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

jascha030/wp-subscriptions
==========================

OOP Interface for using the WP Plugin API (Hooks)

2.0.1(6y ago)1444MITPHP

Since Apr 9Pushed 6y ago1 watchersCompare

[ Source](https://github.com/jascha030/wp-subscriptions)[ Packagist](https://packagist.org/packages/jascha030/wp-subscriptions)[ RSS](/packages/jascha030-wp-subscriptions/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (5)Used By (4)

WP Subscriptions
================

[](#wp-subscriptions)

Backbone for interfacing with the Wordpress Plugin Common API (Hooks). Keeping track of actions and filters and making it easy to hook or unhook class methods.

Geting started
--------------

[](#geting-started)

#### Requirements

[](#requirements)

- `composer`
- `php >= 7.1`

> This package does not keep in mind, the *Wordpress Coding Standards* and therefore is not compatible with `php 5.3` or any other versions before `php 7.1`

#### Installation

[](#installation)

```
composer require jascha030/wp-subscriptions
```

Usage
-----

[](#usage)

#### Providers

[](#providers)

The two basic types of providers are the `ActionProvider` and the `FilterProvider` interfaces. These interfaces are derivatives of the `SubscriptionProvider` interface.

These interfaces don't require any methods to be implemented and are used by the `WordpressSubscriptionContainer` and other core logic to identify a class within a Wordpress plugin.

These Providers use a static property that tells the Subscription manager to hook specific methods to WP plugin hooks.

Actions:

```
public static $actions = []; // ActionProvider interface
```

Filters:

```
public static $filters = []; // FilterProvider interface
```

Provider example:

```
class ExampleProvider implements ActionProvider
{
    public static $actions = [
        'plugins_loaded' => 'load', // Hook => method
        'pre_get_posts' => ['doQueryStuff', 10, 1], // Example with priority and number of arguments
        'wp_loaded' => [
            ['loaded'],
            ['moreLoaded']
        ], // Example of multiple methods hooked to one action hook
    ];

    public function load() // Method to be hooked to the plugins_loaded hook
    {
        echo "This is a method that loads stuff...";
    }

    public function doQueryStuff()
    {
        // hmmm, doing lots of querylicious stuff
    }

    public function loaded()
    {
        // Much load, such wow, very plugadocious
    }

    public function moreLoaded()
    {
        // Will it ever stop??
    }
}
```

This example shows a basic ActionProvider a class can also implement ActionProvider and FilterProvider at the same time.

#### Registering a provider

[](#registering-a-provider)

```
$subscriptionContainer = WordpressSubscriptionContainer::getInstance(); // Get container instance

$subscriptionContainer->register(ExampleProvider::class); // Register provider

$subscriptionContainer->run(); // Hook all providers and their methods to hooks
```

Info and inspiration
--------------------

[](#info-and-inspiration)

The subscription idea provides flexibility, so you don't have to overuse the singleton pattern in OOP wordpress plugins. Now you are not restricted to extending classes for every other instance you need (for example: when you build a post type class you can create a config with post types you can loop trough instead of having to make separate classes for each post type).

Based on idea from [this article](https://carlalexander.ca/polymorphism-wordpress-interfaces/) by Carl Alexander.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Total

3

Last Release

2210d ago

Major Versions

1.0.3 → 2.0.12020-06-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25476438?v=4)[Jascha van Aalst](/maintainers/Jascha030)[@jascha030](https://github.com/jascha030)

---

Top Contributors

[![jascha030](https://avatars.githubusercontent.com/u/25476438?v=4)](https://github.com/jascha030 "jascha030 (179 commits)")

---

Tags

composer-packagehookswordpresswordpress-developmentwordpress-plugin

### Embed Badge

![Health badge](/badges/jascha030-wp-subscriptions/health.svg)

```
[![Health](https://phpackages.com/badges/jascha030-wp-subscriptions/health.svg)](https://phpackages.com/packages/jascha030-wp-subscriptions)
```

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k455.6M9.6k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

706130.3M13.3k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31182.0M2.4k](/packages/illuminate-container)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k52](/packages/ecotone-ecotone)[symfony/type-info

Extracts PHP types information.

20069.8M270](/packages/symfony-type-info)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
