PHPackages                             j10o/whenthen - 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. j10o/whenthen

ActiveLibrary

j10o/whenthen
=============

A drop-in package for wrapping WordPress' add\_action and do\_action(soon)

02PHP

Since Nov 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/JosephGabito/j10o)[ Packagist](https://packagist.org/packages/j10o/whenthen)[ RSS](/packages/j10o-whenthen/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

### WhenThen

[](#whenthen)

A drop-in package for wrapping WordPress' add\_action and do\_action(soon) ![:octocat:](https://github.githubassets.com/images/icons/emoji/octocat.png ":octocat:")

### A Glimpse

[](#a-glimpse)

```
$wp_event = new \WhenThen\MiddleWare\Event();
$wp_event->when( $hook = array( 'name' => 'wp' ) )->then( function(){
    echo '𝙷𝚎𝚕𝚕𝚘, 𝚆𝚘𝚛𝚍𝙿𝚛𝚎𝚜𝚜';
});
```

### Basic usage

[](#basic-usage)

#### Via composer

[](#via-composer)

Do `composer require j10o/whenthen`

Or locate your project's composer.json then add `j10o/whenthen": "dev-main"` in `require` property.

For example:

```
{
    "require": {
        "j10o/whenthen": "dev-main"
    }
}
```

In your plugin's main file include the vendor autoload.

```
// Require Composer's autoload file.
require __DIR__ . '/vendor/autoload.php';

// Create new event object.
$wp_event = new \WhenThen\MiddleWare\Event();

// Similar to add_action stuff with WordPress.
$wp_loaded = array(
    'name' => 'wp',
    'priority' => 10,
    'num_args' => 1
);

// Same here.
$footer_loaded = array(
    'name' => 'wp_footer',
    'priority' => 10,
);

// Closure function to call when something happen.
$do_this_thing_1 = function($query_vars) {
    error_log( var_export( $query_vars, true ) );
};

// Another closure function to call when something happen.
$do_this_thing_2 = function() {
    echo 'I am in footer.';
};

// Listen to the event.
$wp_event->when( $wp_loaded )->then( $do_this_thing_1 );

// Another one.
$wp_event->when( $footer_loaded )->then( $do_this_thing_2 );
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1cc083db7883bf43bea62fbc57b04d7b6060b9477d2207d2db2f632c84153ff?d=identicon)[dunhakdis](/maintainers/dunhakdis)

---

Top Contributors

[![JosephGabito](https://avatars.githubusercontent.com/u/81974552?v=4)](https://github.com/JosephGabito "JosephGabito (10 commits)")

### Embed Badge

![Health badge](/badges/j10o-whenthen/health.svg)

```
[![Health](https://phpackages.com/badges/j10o-whenthen/health.svg)](https://phpackages.com/packages/j10o-whenthen)
```

PHPackages © 2026

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