dxw/iguana-theme
最新稳定版本:v1.1.0
Composer 安装命令:
composer require dxw/iguana-theme
包简介
无描述信息
README 文档
README
Helper functions and template layouts for iguana-based themes.
\Dxw\Iguana\Theme\Helpers
Helper functions.
Installation
Add the following to app/di.php:
$registrar->addInstance(new \Dxw\Iguana\Theme\Helpers()); Usage
Your classes can declare helper functions:
<?php namespace Dxw\MyTheme; class MyClass implements \Dxw\Iguana\Registerable { private $helpers; public function __construct(\Dxw\Iguana\Theme\Helpers $helpers) { $this->helpers = $helpers; } public function register() { $this->helpers->registerFunction('myFunc', [$this, 'myFunc']); } public function myFunc($a) { echo esc_html($a + 1); } } To call this function from a template:
<?php h()->myFunc(4) ?> Using h() means that you only need to pollute the global namespace with one function. And h() is a lot shorter than typing out the full namespace.
All you need to do is pass the Helpers instance to your class during instantiation. Example:
$registrar->addInstance(new \Dxw\MyTheme\MyClass( $registrar->getInstance(\Dxw\Iguana\Theme\Helpers::class) )); \Dxw\Iguana\Theme\Layout and \Dxw\Iguana\Theme\LayoutRegister
Layout templates.
Installation
Add the following to app/di.php:
$registrar->addInstance(new \Dxw\Iguana\Theme\Helpers()); $registrar->addInstance(new \Dxw\Iguana\Theme\LayoutRegister( $registrar->getInstance(\Dxw\Iguana\Theme\Helpers::class) )); Usage
Add something like this to layouts/main.php (within your theme directory):
<!doctype html> <html> <head> ... </head> <body> <?php h()->w_requested_template() ?> </body> </html> And remove the calls to get_header()/get_footer() from all your templates.
Licence
统计信息
- 总下载量: 85.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04