PHPackages                             devuri/wp-hook-scanner - 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. devuri/wp-hook-scanner

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

devuri/wp-hook-scanner
======================

Scans PHP files for WordPress hooks and outputs a categorized report or JSON.

v0.1.2(4mo ago)1168MITPHPPHP ^8.1CI passing

Since Jan 14Pushed 4mo agoCompare

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

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

WP Hook Scanner
===============

[](#wp-hook-scanner)

A PHP tool that scans your codebase for WordPress hooks (`add_action`, `do_action`, `add_filter`, `apply_filters`) and generates categorized reports.

Perfect for:

- **Documenting** hooks in your WordPress plugins and themes
- **CI/CD pipelines** to track hook changes between releases
- **Code audits** to understand hook dependencies

Requirements
------------

[](#requirements)

- PHP 8.1 or higher

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

[](#installation)

Install via Composer:

```
composer require --dev devuri/wp-hook-scanner
```

Or add to your `composer.json`:

```
{
    "require-dev": {
        "devuri/wp-hook-scanner": "^1.0"
    }
}
```

Usage
-----

[](#usage)

### Command Line

[](#command-line)

**Pretty output (default):**

```
vendor/bin/scan-hooks src
```

Output:

```
  Hook Scanner v1.0
  ══════════════════════════════════════════════════

  ▶ Registered Actions (3)
  ────────────────────────────────────────────────
    ✓ admin_init → src/Admin.php:45
    ✓ init → src/Plugin.php:23
    ✓ wp_loaded → src/Bootstrap.php:12

  ⚡ Fired Actions (2)
  ────────────────────────────────────────────────
    ✓ my_plugin_loaded → src/Plugin.php:30
    ✓ my_custom_event (2 occurrences)

  ══════════════════════════════════════════════════
  Summary: 5 unique hooks found
  3 registered actions · 2 fired actions

```

**JSON output:**

```
vendor/bin/scan-hooks src --json
```

**All options:**

```
vendor/bin/scan-hooks [directory] [options]

Options:
  --json                 Output results as JSON
  --update               Create/update snapshot file
  --check                Compare against snapshot (for CI)
  --snapshot=      Custom snapshot file path (default: .hooks-snapshot.json)
  --no-color             Disable colored output
  --help, -h             Show help message
  --version, -v          Show version information
```

### Snapshot Mode (CI/CD)

[](#snapshot-mode-cicd)

Track hook changes across releases using snapshots:

**Create a snapshot:**

```
vendor/bin/scan-hooks src --update
```

This creates `.hooks-snapshot.json` containing all current hooks.

**Check against snapshot:**

```
vendor/bin/scan-hooks src --check
```

Returns exit code `0` if hooks match, `1` if there are differences.

**Custom snapshot path:**

```
vendor/bin/scan-hooks src --update --snapshot=hooks.json
vendor/bin/scan-hooks src --check --snapshot=hooks.json
```

### GitHub Actions Example

[](#github-actions-example)

```
name: Hook Check

on: [push, pull_request]

jobs:
  hooks:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'

      - name: Install dependencies
        run: composer install --no-progress

      - name: Check hooks
        run: vendor/bin/scan-hooks src --check
```

### Programmatic Usage

[](#programmatic-usage)

```
use WPHookScanner\HookScanner;

$scanner = new HookScanner();
$scanner->scan('src');

// Get all hooks as array
$hooks = $scanner->toArray();

// Get hooks as JSON
$json = $scanner->toJson();

// Check for specific hook
if ($scanner->hasHook('my_custom_action', 'add_action')) {
    echo "Found it!";
}

// Get hooks by type
$actions = $scanner->getHooksByType('add_action');
$filters = $scanner->getHooksByType('apply_filters');

// Get total count
$total = $scanner->getTotalCount();

// Snapshot operations
$scanner->saveSnapshot('.hooks-snapshot.json');
$snapshot = HookScanner::loadSnapshot('.hooks-snapshot.json');
$diff = $scanner->compareToSnapshot($snapshot);
```

Hook Types Detected
-------------------

[](#hook-types-detected)

TypeDescriptionSymbol`add_action`Registered action hooks▶`do_action`Fired/triggered actions⚡`add_filter`Registered filter hooks◆`apply_filters`Applied filter hooks✦Output Formats
--------------

[](#output-formats)

### Pretty Print (Terminal)

[](#pretty-print-terminal)

Colorized, categorized output ideal for development.

### JSON

[](#json)

Machine-readable format for tooling integration:

```
{
    "add_action": {
        "init": [
            {"file": "src/Plugin.php", "line": 23}
        ],
        "admin_init": [
            {"file": "src/Admin.php", "line": 45}
        ]
    },
    "do_action": { ... },
    "add_filter": { ... },
    "apply_filters": { ... }
}
```

### Snapshot

[](#snapshot)

Normalized format for comparison (excludes line numbers):

```
{
    "add_action": ["admin_init", "init", "wp_loaded"],
    "do_action": ["my_custom_event", "my_plugin_loaded"],
    "add_filter": ["the_content", "the_title"],
    "apply_filters": ["my_plugin_value"]
}
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Or directly:

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance77

Regular maintenance activity

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 83.3% 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

Unknown

Total

1

Last Release

125d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fd19f958b007ec6588d0a5ca2fe78e107edd652f286b836d36b5d1781d573a5?d=identicon)[devuri](/maintainers/devuri)

---

Top Contributors

[![devuri](https://avatars.githubusercontent.com/u/4777400?v=4)](https://github.com/devuri "devuri (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

wordpressstatic analysishooksfiltersactionsscanner

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devuri-wp-hook-scanner/health.svg)

```
[![Health](https://phpackages.com/badges/devuri-wp-hook-scanner/health.svg)](https://phpackages.com/packages/devuri-wp-hook-scanner)
```

###  Alternatives

[tormjens/eventy

The WordPress filter/action system in Laravel

438912.9k16](/packages/tormjens-eventy)[php-stubs/wordpress-stubs

WordPress function and class declaration stubs for static analysis.

19513.0M263](/packages/php-stubs-wordpress-stubs)[bainternet/php-hooks

A fork of the WordPress filters hook system rolled in to a class to be ported into any PHP-based system

27621.3k2](/packages/bainternet-php-hooks)[voku/php-hooks

A fork of the WordPress filters hook system rolled in to a class to be ported into any PHP-based system

7637.3k3](/packages/voku-php-hooks)[x-wp/di

The dependency injection container for WordPress

301.1k10](/packages/x-wp-di)[php-stubs/wp-cli-stubs

WP-CLI function and class declaration stubs for static analysis.

302.3M79](/packages/php-stubs-wp-cli-stubs)

PHPackages © 2026

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