This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a PHP library for WordPress development that provides utilities for building high-quality WordPress plugins. It requires PHP >= 8.4 and WordPress 6.9 or higher.
The library follows a plugin factory pattern with a container-based architecture:
- Plugin Factory System - Uses
PluginFactoryto create and manage plugin instances - Hook Registration - Core
Initclass handles registration and initialization of hook providers - Hook Provider Pattern - Classes implement
WpHooksInterfaceto register WordPress hooks - Container Support - Integration with PSR-11 containers (Pimple) for dependency injection
Make sure Docker is running with: docker compose up -d.
To run the full PHPUnit test suite (with code coverage):
composer phpunit
To run a specific test:
./vendor/bin/phpunit tests/unit/Plugin/PluginTest.php
The library provides a fluent interface for hook registration:
use TheFrosty\WpUtilities\Plugin\PluginFactory;
$plugin = PluginFactory::create('slug')
->add(new SomeHookProvider())
->add(new AnotherHookProvider())
->initialize();Hook providers can be added conditionally or on specific hooks:
add()- Register immediatelyaddIfCondition()- Register when a condition is metaddOnHook()- Register on a specific WordPress hookaddOnCondition()- Register when a condition is met on a specific hook
Key files:
src/Plugin/PluginFactory.php- Plugin instance creation and managementsrc/Plugin/AbstractPlugin.php- Base plugin class with hook registration methodssrc/Plugin/Init.php- Hook initialization managersrc/Plugin/WpHooksInterface.php- Interface for hook providerssrc/Plugin/AbstractHookProvider.php- Base class for hook providers with traits
- Code standard checking:
composer phpcs - PHPUnit checks:
composer phpunit
- Current tests are for PHPUnit version 11.5.
- All tests should extend
TheFrosty\WpUtilities\Tests\Plugin\Framework\TestCase, which is an abstraction ofPHPUnit\Framework\TestCase. - All tests should use a PHPUnit Attribute for what the test covers, see https://docs.phpunit.de/en/11.5/code-coverage.html
The library uses a pattern where plugin instances are created via PluginFactory::create() and hook providers are
registered using the fluent interface. Providers can be registered with conditional logic, deferred execution, or
specific WordPress hooks.