shinepress / framework
Framework for building Wordpress plugins and themes.
1.0.0
2025-05-19 15:30 UTC
Requires
- php: >=8.1
Requires (Dev)
- php-cs-fixer/shim: ^3.75
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^10.0
- shinepress/coding-standard: dev-main
This package is auto-updated.
Last update: 2025-05-19 20:05:34 UTC
README
Description
A framework for creating Wordpress plugins and themes.
Installation
The recommendend installation method is with composer:
$ composer require shinepress/framework
Usage
The core of the framework is the Module class, create registerable modules for plugins and themes by extending it. The configure/initialize/finalize hooks can be overriden to run at specific times.
use ShinePress\Framework\Module; class MyModule extends Module { protected function initialize(): void { // runs during constructor } protected function prepare(): void { // runs before registration } protected function cleanup(): void { // runs after registration } } // register the module MyModule::register();
Attributes
The primary purpose of the framework is to allow the configuration of a plugin/theme component using attributes.
Note: this is an example only, for actions and filters the shinepress/hooks package is recommended.
use ShinePress\Framework\Attribute\MethodAttributeInterface; use ShinePress\Framework\Module; use Attribute; use ReflectionMethod; #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class ActionHook implements MethodAttributeInterface { private string $name; private int $priority; public function __construct(string $name, int $priority = 10) { $this->name = $name; $this->priority = $priority; } public function register(Module $module, ReflectionMethod $method): void; add_action( $this->name, [$module, $method->getName()], $this->priority, $method->getNumberOfParameters(), ); } } class MyModule extends Module { #[ActionHook('save_post', 20)] public function onSavePost($post_id, $post, $update): void { // do something... } } MyModule::register();