PHPackages                             paperpixel/wp-hooks - 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. paperpixel/wp-hooks

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

paperpixel/wp-hooks
===================

Split Wordpress functions.php file into small, readable hooks

0.4.0(10y ago)026BSDPHPPHP &gt;=5.3.9

Since Jan 20Pushed 10y ago3 watchersCompare

[ Source](https://github.com/PaperpixelStudio/WPHooks)[ Packagist](https://packagist.org/packages/paperpixel/wp-hooks)[ Docs](http://github.com/PaperpixelStudio/WPHooks)[ RSS](/packages/paperpixel-wp-hooks/feed)WikiDiscussions master Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

WPHooks
=======

[](#wphooks)

Split Wordpress functions.php file into small, readable hooks.

Requirement
-----------

[](#requirement)

Your Wordpress files and plugins should be managed by composer. See [Bedrock boilerplate Wordpress structure](https://github.com/roots/bedrock) to get started.

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

[](#installation)

Install with Composer: `composer require paperpixel/wphooks`

Usage
-----

[](#usage)

### Creating a hook

[](#creating-a-hook)

Create a hook by extending `WPHook` class :

```
use WPHooks\WPHook;

class ExampleHook extends WPHook {
    // Mandatory method, used to register actions and filters with Wordpress.
    public function register() {
        $this->add_action('init', 'my_action_hook');
        $this->add_filter('the_title', 'my_filter_hook');
    }

    private function my_action_hook() {
        // Stuff here will be called by Wordpress
    }

    private function my_filter_hook($title) {
        // Stuff here will be called by Wordpress
    }
}
```

*Note: we take advantage of Composer autoload feature to import class by namespace with the keyword `use`.*

### Using the hook

[](#using-the-hook)

In your functions.php class, instantiate `ExampleHook` and call `register()` method.

```
// functions.php
include 'ExampleHook.php';

$example_hook = new ExampleHook();
$example_hook->register();
```

### Easier hook creation with WPHookLoader

[](#easier-hook-creation-with-wphookloader)

You can use `WPHookLoader` to instantiate your hooks easily :

```
// functions.php

include 'ExampleHook.php';
include 'Hook1.php';
include 'Hook2.php';
include 'Hook3.php';

// You can pass a WPHook instance
WPHooks\WPHookLoader::register(new ExampleHook());

// Or an array of WPHook instances
WPHooks\WPHookLoader::register([
   new Hook1(),
   new Hook2(),
   new Hook3(),
   ...
]);
```

Autoloading
-----------

[](#autoloading)

We can leverage Composer's `ClassLoader` feature in our theme, so that we don't have to require each hook in `functions.php`.

Considering this theme structure :

```
hooks/
    actions/
        ExampleAction.php
    filters/
        ExampleFilter.php
__autoload.php
functions.php

```

Start by creating the `__autoload.php` file :

```
// __autoload.php

use Composer\Autoload\ClassLoader;

$loader = new ClassLoader();
$loader-> register();

$loader->addPsr4('Hooks\\Actions\\', __DIR__ . '/hooks/actions');
$loader->addPsr4('Hooks\\Filters\\', __DIR__ . '/hooks/filters');
```

In your Hook class, add a namespace accordingly to `__autoload.php` :

```
// hooks/actions/ExampleAction.php

namespace Hooks\Actions;

use WPHooks\WPHook;

class ExampleAction extends WPHook {
    function register() {
        ...
    }
}
```

Finally, in `functions.php`, instantiate your hook :

```
// functions.php

// Without WPHookLoader
$example_actions = new Actions\ExampleAction();

// With WPHookLoader
WPHooks\WPHookLoader::register(new Actions\ExampleAction());
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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 ~0 days

Total

4

Last Release

3814d ago

### Community

Maintainers

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

---

Top Contributors

[![drskullster](https://avatars.githubusercontent.com/u/1693766?v=4)](https://github.com/drskullster "drskullster (7 commits)")

---

Tags

wordpress

### Embed Badge

![Health badge](/badges/paperpixel-wp-hooks/health.svg)

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

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k227.8k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.1k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.7k](/packages/afragen-git-updater)[tacowordpress/tacowordpress

WordPress custom post types that feel like CRUD models

232.2k](/packages/tacowordpress-tacowordpress)

PHPackages © 2026

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