thefrosty / wp-utilities
A library containing my standard development resources
Requires
- php: >=8.4
- ext-json: *
- ext-openssl: *
- blakvghost/php-validator: ^2.3
- johnbillion/args: ^2.1
- oscarotero/env: ^2.1
- psr/container: ^2.0
- symfony/http-foundation: ^8.1.11
- yahnis-elsts/plugin-update-checker: ^6.0
Requires (Dev)
- ext-simplexml: *
- dealerdirect/phpcodesniffer-composer-installer: ^1.0.0
- php-di/php-di: ^7.1
- php-stubs/wordpress-stubs: ^7.0
- phpcompatibility/php-compatibility: ^9.3
- phpunit/php-code-coverage: ^11
- phpunit/phpunit: ^11.1
- pimple/pimple: ^3.5
- rector/rector: ^2.8
- roots/wordpress: ^7.0
- slevomat/coding-standard: ^8.18
- squizlabs/php_codesniffer: ^3.9
- szepeviktor/phpstan-wordpress: ^2.0
- thefrosty/wp-utilities-dev: dev-main
- wp-coding-standards/wpcs: ^3.1
- wp-phpunit/wp-phpunit: ^7.0
- yoast/phpunit-polyfills: ^4.0
Suggests
- htmlburger/carbon-fields: WordPress Custom Fields Library.
- illuminate/encryption: Laravel level encryption & decryption.
- jjgrainger/posttypes: Fluent post type & taxonomy registration. No longer used by AbstractPostType/AbstractTaxonomy (v4); require it directly if you use its API.
- php-di/php-di: PSR-11 container with autowiring; PluginFactory uses it by default when installed.
- pimple/pimple: Simple PSR-11 container; PluginFactory falls back to it when PHP-DI is not installed.
- yahnis-elsts/plugin-update-checker: A custom update checker for WordPress plugins.
Provides
None
Conflicts
None
Replaces
None
- dev-develop
- v4.3.1
- v4.3.0
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.0
- v4.0.0
- v4.0-RC1
- v3.13.2
- v3.13.1
- v3.13.0
- v3.12.3
- v3.12.2
- v3.12.1
- v3.12.0
- v3.11.2
- v3.11.1
- v3.11.0
- v3.10.0
- v3.9.1
- v3.9.0
- v3.8.9.1
- v3.8.9
- v3.8.8.1
- v3.8.8
- v3.8.7
- v3.8.6.3
- v3.8.6.2
- v3.8.6.1
- v3.8.6
- v3.8.5
- v3.8.4
- v3.8.3
- v3.8.2
- v3.8.1
- v3.8.0
- v3.7.1
- v3.7.0
- v3.6.1
- v3.6.0
- v3.5.0
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.1.2
- v3.3.1.1
- v3.3.1
- v3.3.0
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.0
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.5.0-RC2
- v2.5.0-RC1
- v2.4.2
- v2.4.2-RC1
- v2.4.1
- v2.4.1-RC1
- v2.4.0
- v2.3.0
- v2.3.0-RC1
- v2.2.1
- v2.2.0
- v2.2.0-RC1
- v2.1.0
- v2.1.0-RC2
- v2.1.0-RC1
- 2.0.0
- 1.9.1
- 1.8.0
- 1.7.2
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.1
- 1.4
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.2.2
- dev-feature/disable-plugin-auto-updates
This package is auto-updated.
Last update: 2026-11-27 23:23:15 UTC
README
A library containing my standard development resources to build high quality WordPress plugins.
Requirements
PHP >= 8.4
WordPress >= 7.0
The required WordPress version will always be the most recent point release of the previous major release branch.
For both PHP and WordPress requirements, although this library may work with a version below the required versions, they will not be supported and any compatibility is entirely coincidental.
Installation
To install this library, use Composer:
composer require thefrosty/wp-utilities:^4.0
Then follow examples in the Plugin README.
Quick start
use MyPlugin\Admin\SettingsPage; use MyPlugin\Api\RestRoutes; use MyPlugin\Cli\Commands; use MyPlugin\Frontend\Assets; use MyPlugin\Integrations\WooCommerce; use MyPlugin\Integrations\WooCommerceAdmin; use MyPlugin\PostTypes\Book; use TheFrosty\WpUtilities\Plugin\DefaultServiceProvider; use TheFrosty\WpUtilities\Plugin\PluginFactory; $plugin = PluginFactory::create('plugin-slug'); // Registers the current HTTP request and a shared View in the plugin's container (PHP-DI or Pimple). $plugin->addServiceProvider(new DefaultServiceProvider()); $plugin // An instance: registered now, its addHooks() runs on initialize(). ->add(new Book()) // Class names (WpHooksInterface implementations) from here on; the plugin instantiates them. // Registered now, only when the bool is true. ->addIfCondition(Commands::class, defined('WP_CLI') && WP_CLI) // Registered on `plugins_loaded` (the default $deferred_tag) when the bool is true. // The bool is evaluated now: use addOnConditionDeferred() when the check needs the deferred hook. ->addIfConditionDeferred(SettingsPage::class, is_admin(), deferred_tag: 'plugins_loaded') // The callable is called now (with $func_args unpacked); if it returns true, register it on $tag // (default `init`). ->addOnCondition( RestRoutes::class, 'extension_loaded', func_args: ['intl'], tag: 'rest_api_init', priority: 10, ) // On `plugins_loaded`, call the callable; if true, register it on `init` (admin only). ->addOnConditionDeferred( WooCommerceAdmin::class, static fn(): bool => class_exists(\WooCommerce::class), deferred_tag: 'plugins_loaded', admin_only: true, ) // Registered on a specific hook; $args are unpacked into the class constructor. // admin_only: true = admin only, false = front-end only, null (default) = both. ->addOnHook(Assets::class, tag: 'wp_enqueue_scripts', priority: 20, admin_only: false, args: ['plugin-slug']) // On `init` (the default $deferred_tag), register it on `wp_loaded`. ->addOnHookDeferred(WooCommerce::class, deferred_tag: 'init', tag: 'wp_loaded', deferred_priority: 20) ->initialize();
See Dependency injection container for extending
DefaultServiceProvider with your own entries.
Guides
- Plugin & hook providers
- Post types (
AbstractPostType) - Taxonomies (
AbstractTaxonomy) - WP_Query models
Development scripts
The PHPCS/PHPCBF/PHPStan/Psalm/ESLint and WordPress test-suite scripts that used to live in bin/ moved to
thefrosty/wp-utilities-dev in v4. If you called
./vendor/thefrosty/wp-utilities/bin/<script>.sh, run composer require --dev thefrosty/wp-utilities-dev and use
./vendor/bin/<script>.sh instead.
