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)0682LGPL-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

23

—

LowBetter than 27% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity31

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

613d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6029133664b39b787817bddb9c1840cfdb8fac3b0ee8dee66edc10a6b9391f80?d=identicon)[kaelan](/maintainers/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

[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/builder-plugin

Builder plugin for October CMS

17147.2k1](/packages/rainlab-builder-plugin)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5671.4k1](/packages/pfefferle-wordpress-activitypub)[civicrm/civicrm-drupal-8

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

18238.1k2](/packages/civicrm-civicrm-drupal-8)[mediawiki/semantic-glossary

A terminology markup extension with a Semantic MediaWiki back-end

1352.4k](/packages/mediawiki-semantic-glossary)[humanmade/lottie-lite

A lightweight Lottie Animations Extension for WordPress

374.3k](/packages/humanmade-lottie-lite)

PHPackages © 2026

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