gwa/zero-library-shortcodes
最新稳定版本:v1.3.0
Composer 安装命令:
composer require gwa/zero-library-shortcodes
包简介
Addon for zero library to build wordpress shortcodes faster.
README 文档
README
Master
Develop
Install
Via Composer
$ composer require gwa/zero-library-shortcodes
Usage
First you need to extend RendererData and create a getDefaults function.
use Gwa\Wordpress\Template\Zero\Library\Shortcodes\RendererData; class CardData extends RendererData { public function getDefaults() { return [ 'title' => null, 'btn' => null, 'url' => null, ]; } }
Now we extend the Renderer and add some values for some keys.
use Gwa\Wordpress\Template\Zero\Library\Shortcodes\Renderer; class CardRenderer extends Renderer { public function render() { return $this->get('title'); } }
Last thing now is to create a shortcode class.
use Gwa\Wordpress\Template\Zero\Library\Shortcodes\Shortcode; class CardShortcode extends Shortcode { public $atts = [ 'title' => '' ]; public function getShortcode() { return 'card'; } public function render($atts) { $attr = $this->getWpBridge()->shortcodeAtts($this->atts, $atts); return = (new CardRenderer())->setRendererData($this->getData())->render(); } protected function getData() { $renderdata = new CardData(); $renderdata->set('content', $this->getContent($id)) ->set('url', 'http://google.com/') ->set('title', 'google'); return $renderdata; } }
Register you plugin.
use Gwa\Wordpress\MockeryWpBridge\WpBridge; (new CardShortcode())->setWpBridge(new WpBridge())->init();
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-04