amostajo/wordpress-plugin-core
最新稳定版本:v1.0.8
Composer 安装命令:
composer require amostajo/wordpress-plugin-core
包简介
Core functionality and libraries for Wordpress Plugin (a light weight plugin template with composer and MVC).
README 文档
README
Core library for Wordpress Plugin (A Wordpress template that comes with composer and MVC);
Installation
Add
"amostajo/wordpress-plugin-core": "1.0.*"
to your composer.json. Then run composer install or composer update.
Add-on development
WP Core now supports Add-on development. To create your custom package, simply create an Add-on main class that extends from this package abstract, like the following example:
namespace MyNamespace; use Amostajo\WPPluginCore\Classes\Addon; class PostPicker extends Addon { /** * Function called when plugin or theme starts. * Add wordpress hooks (actions, filters) here. */ public function init() { // YOUR CUSTOM CODE HERE. } /** * Function called when user is on admin dashboard. * Add wordpress hooks (actions, filters) here. */ public function on_admin() { // YOUR CUSTOM CODE HERE. } }
This is how you should add your Wordpress hooks:
namespace MyNamespace; use Amostajo\WPPluginCore\Classes\Addon; class PostPicker extends Addon { /** * Function called when plugin or theme starts. * Add wordpress hooks (actions, filters) here. */ public function init() { add_filter( 'post_content', [ &$this, 'picker_filter' ] ) } /** * Called by wordpress. */ public function picker_filter() { // YOUR CUSTOM CODE HERE. } }
Accessing the plugin Main class
You can call the main class from any custom method in your Add-on class, like this:
/** * Custom method. */ public function picker_filter() { // Getting a config settings. $this->main->config->get( 'setting' ); }
Calling for Add-on's controllers or views:
MVC
/** * Custom method. */ public function picker_filter() { // Calling MVC. $this->mvc->call( 'Controller@method' ); }
Your controllers should be placed in a controllers folder on the same level as your Add-on class, same for the views folder.
Calling ADD-ON methods from main class
The Main class can call methods in the Add-on by adding the addon_ prefic, like for example addon_picker_filter.
Setup plugin or theme
Finally add your package in the configuration file. For example:
'addons' => [ 'MyNamespace\PostPicker', ],
Coding Guidelines
The coding is a mix between PSR-2 and Wordpress PHP guidelines.
License
Lightweight MVC is free software distributed under the terms of the MIT license.
统计信息
- 总下载量: 816
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-20