wpdesk / wp-builder
There is no license information available for the latest version (2.1.2) of this package.
2.1.2
2024-11-19 09:22 UTC
Requires
- php: >=7.4 || ^8
Requires (Dev)
This package is auto-updated.
Last update: 2026-06-27 11:43:55 UTC
README
WP Builder
wpdesk/wp-builder provides small base classes and interfaces for building WordPress plugins.
Requirements
PHP 7.4+.
Installation via Composer
Install with Composer:
composer require wpdesk/wp-builder
Example usage
Basic example for a plugin bootstrap file:
<?php use WPDesk\PluginBuilder\Plugin\AbstractPlugin; use WPDesk\PluginBuilder\Plugin\Hookable; use WPDesk\PluginBuilder\Plugin\HookableCollection; use WPDesk\PluginBuilder\Plugin\HookableParent; class ContentExtender implements Hookable { public function hooks() { add_filter( 'the_content', [ $this, 'append_sample_text_to_content' ] ); } public function append_sample_text_to_content( $content ) { return $content . ' Sample text'; } } class ExamplePlugin extends AbstractPlugin implements HookableCollection { use HookableParent; protected function hooks() { parent::hooks(); $this->add_hookable( new ContentExtender() ); $this->hooks_on_hookable_objects(); } } $plugin_info = new WPDesk_Plugin_Info(); $plugin_info->set_plugin_file_name( __FILE__ ); $plugin_info->set_plugin_dir( __DIR__ ); $plugin_info->set_plugin_url( plugin_dir_url( __FILE__ ) ); $plugin_info->set_plugin_name( 'Example Plugin' ); $plugin_info->set_text_domain( 'example-plugin' ); $plugin = new ExamplePlugin( $plugin_info ); $plugin->init();