wpdesk / wp-builder
此包最新版本(2.1.1)没有提供许可证信息。
2.1.1
2023-12-12 11:21 UTC
Requires
- php: >=5.5
Requires (Dev)
- 10up/wp_mock: *
- mockery/mockery: *
- phpunit/phpunit: <7
- squizlabs/php_codesniffer: ^3.0.2
- wimg/php-compatibility: ^8
- wp-coding-standards/wpcs: ^0.14.1
- dev-master
- 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-09-20 12:32:56 UTC
README
WP Builder
wp-builder 库定义了创建 WordPress 插件的接口和抽象。
要求
PHP 5.6 或更高版本。
通过 Composer 安装
为了通过 Composer 安装这些绑定,请运行以下命令
composer require wpdesk/wp-builder
示例用法
在 WordPress 插件的主 .php 文件中使用以下代码
<?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 );