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)
- dev-master
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 2.0.0-beta1
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1
- 1.0
- dev-fix/deprecated_functions
- dev-devel
- dev-feat/translations
- dev-feat/upgrade_to_pro_url
- dev-feat/lang
- dev-bugfix/require-interface
- dev-bugfix/require-once-error
- dev-feature/activation-hooks
- dev-feature/template-loader
- dev-feature/template-renderer
- dev-feature/plugin-activation
- dev-feature/hookable-object
- dev-feature/builder-pattern
This package is auto-updated.
Last update: 2024-12-19 09:28:18 UTC
README
WP Builder
wp-builder library defines the interfaces and abstracts to create WordPress plugins.
Requirements
PHP 5.6 or later.
Installation via Composer
In order to install the bindings via Composer run the following command:
composer require wpdesk/wp-builder
Example usage
Use the following code in WordPress plugin's main .php file:
<?php
class ContentExtender implements \WPDesk\PluginBuilder\Plugin\Hookable {
public function hooks() {
add_filter( 'the_content', [ $this, 'append_sample_text_to_content' ] );
}
/**
* @param string $content
* @return string
*/
public function append_sample_text_to_content( $content ) {
return $content . ' Sample text';
}
}
class ExamplePlugin extends \WPDesk\PluginBuilder\Plugin\AbstractPlugin implements \WPDesk\PluginBuilder\Plugin\HookableCollection {
use \WPDesk\PluginBuilder\Plugin\HookableParent;
public function hooks() {
$this->add_hookable( new ContentExtender() );
$this->hooks_on_hookable_objects();
}
}
$plugin_info = new WPDesk_Plugin_Info();
$plugin_info->set_plugin_name( 'Example Plugin' );
$example_plugin = new ExamplePlugin( $plugin_info );