Search by

pcfreak30 / wordpress-plugin-framework

pcfreak30

A small WordPress plugin runtime boundary

Package info

github.com/pcfreak30/wordpress-plugin-framework

Issues

pkg:composer/pcfreak30/wordpress-plugin-framework

Statistics

Installs: 123

Dependents: 0

Suggesters: 0

Stars: 8

0.3.4 2018-03-02 14:19 UTC

README

ComposePress Core is a small runtime boundary for WordPress plugins. It coordinates explicit plugin metadata, hook subscribers, and plugin lifecycle handlers without imposing a domain model or dependency container.

Requirements

  • PHP 8.2 or newer
  • WordPress loaded before WordPress-specific context or hook operations

Bootstrap

use ComposePress\Core\Plugin;
use ComposePress\Core\PluginContext;
use ComposePress\Core\WordPressHooks;

$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    subscribers: [new RegisterContentTypes()],
    hooks: new WordPressHooks(),
);

$plugin->boot();

Subscribers receive their application dependencies through constructors and register only WordPress adapters. Business services do not need to depend on ComposePress.

Lifecycle capabilities are opt-in and independent. Implement PluginActivator for activation work and PluginDeactivator for deactivation work; uninstall remains a separate static PluginUninstall contract. Pass only the capabilities the plugin needs:

Requirements are explicit checks that run before subscribers are registered. Each PluginRequirement returns a RequirementResult; unmet results are reported through RequirementsNotMet instead of silently skipping boot.

$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    requirements: [new RequiresWooCommerce('8.0')],
);
$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    activator: new InstallPlugin($migrator),
    deactivator: new DisablePlugin($scheduler),
    uninstaller: UninstallPlugin::class,
);

Development

composer install
composer test
composer analyse

This is a clean-slate rewrite. The historical API and implementation are retired.