PHPackages                             cloakwp/hook-modifiers - 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. cloakwp/hook-modifiers

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

cloakwp/hook-modifiers
======================

Extend WordPress hooks with modifiers for more granular filters and actions

0.0.3(1y ago)0732LGPL-3.0-onlyPHPPHP &gt;=7.4

Since Sep 5Pushed 1y agoCompare

[ Source](https://github.com/cloak-labs/wp-hook-modifiers)[ Packagist](https://packagist.org/packages/cloakwp/hook-modifiers)[ RSS](/packages/cloakwp-hook-modifiers/feed)WikiDiscussions main Synced 1mo ago

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

WP Hook Modifiers
=================

[](#wp-hook-modifiers)

WP Hook Modifiers is a WordPress plugin/Composer package that allows you to extend existing hooks with "modifiers", enabling more granular filtering and actions.

For example, if you've ever worked with ACF hooks, you're probably familiar with the `acf/format_value` filter, which has [modifiers](https://www.advancedcustomfields.com/resources/acf-format_value/#modifers) like `name` and `type` that allow you to target your filter to specific fields by name or type (eg. `acf/format_value/name=my_field_name` or `acf/format_value/type=image`). This package makes it easy for you to create your own hook modifiers like ACF, whether you're a plugin/theme developer or a developer looking to extend someone else's plugin or theme.

Installation
------------

[](#installation)

You can install this package via Composer:

```
composer require cloakwp/hook-modifiers
```

Usage
-----

[](#usage)

```
use CloakWP\HookModifiers;

// Apply desired modifiers to an existing hook
HookModifiers::make(['post_type']) // note it accepts an array of multiple modifiers
  ->forFilter('wp_insert_post_data')
  ->register();

// Now you can use the modifier when calling the hook to target a specific post type
add_filter('wp_insert_post_data/post_type=page', function ($data, $postarr, $unsanitized_postarr) {
  $data['post_title'] = 'Page: ' . $data['post_title'];
  return $data;
}, 10, 2);

// The post_type example above is equivalent to:
add_filter('wp_insert_post_data', function ($data, $postarr, $unsanitized_postarr) {
  if ($data['post_type'] === 'page') {
    $data['post_title'] = 'Page: ' . $data['post_title'];
  }
  return $data;
}, 10, 2);
```

The important thing to note is that the modifier must be a property key of one of the values being passed to the filter/action. In the example above, it is known that `post_type` is a property of the `data` array (1st argument) being filtered. By default, we check the first hook argument for the modifier key/value pairs, but this can be changed by calling the `modifiersArgPosition` method. For example, if a filter has 3 arguments and the modifier key/value pairs are in the third argument, you would do this:

```
HookModifiers::make(['type'])
  ->forFilter('some_filter_with_many_args')
  ->modifiersArgPosition(2) // 0 indexed, so the third arg is `2`
  ->register();

add_filter('some_filter_with_many_args/type=image', function ($one, $two, $three) {
  // This filter will only run if the arg $three is an associative array with a property 'type' equal to 'image'
}, 10, 3);
```

Similar to `forFilter`, there is a `forAction` method to apply modifiers to action hooks.

**Note:** you must call `register` on the HookModifiers object to actually apply the modifiers to the hook.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity32

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.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

661d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5499718?v=4)[kaelan](/maintainers/kaelan)[@kaelan](https://github.com/kaelan)

---

Top Contributors

[![kaelansmith](https://avatars.githubusercontent.com/u/60372141?v=4)](https://github.com/kaelansmith "kaelansmith (8 commits)")

### Embed Badge

![Health badge](/badges/cloakwp-hook-modifiers/health.svg)

```
[![Health](https://phpackages.com/badges/cloakwp-hook-modifiers/health.svg)](https://phpackages.com/packages/cloakwp-hook-modifiers)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[mautic/core

Mautic Open Source Distribution

10.0k2.6k9](/packages/mautic-core)[mediawiki/maps

Adds various mapping features to MediaWiki

84152.3k3](/packages/mediawiki-maps)[starcitizentools/citizen-skin

A beautiful, usable, responsive MediaWiki skin with in-depth extension support. Originally developed for the Star Citizen Wiki.

3376.6k](/packages/starcitizentools-citizen-skin)[civicrm/civicrm-drupal-8

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

19251.4k3](/packages/civicrm-civicrm-drupal-8)[altis/core

Core module for Altis

19228.0k3](/packages/altis-core)

PHPackages © 2026

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