stephenharris / guise
一个用于修改WP管理界面的框架(添加列、元框等)
0.4.0
2016-11-08 10:31 UTC
Requires
- respect/validation: 0.9.*
Requires (Dev)
- brain/monkey: ^1.4
- inpsyde/monkery-test-case: ^2.0
- mockery/mockery: 0.9.3
- phpmd/phpmd: ^2.4
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2024-09-19 13:50:42 UTC
README
Guise是一个用于修改WordPress UI的WordPress框架,它处理与WordPress的幕后交互,这样您可以专注于编写OOP代码。
这还处于开发的早期阶段,欢迎贡献 - 请参阅下面的愿望清单!
文档
使用Guise的文档可以在以下位置找到: https://stephenharris.github.io/guise/
安装
Guise尚未在Composer上发布,因此您需要手动添加存储库
{
...
"repositories": [
...
{
"type": "vcs",
"url": "https://github.com/stephenharris/guise"
}
],
...
"require": {
"stephenharris/guise": "0.*"
},
}
然后运行 composer update
。
然后您需要在您的应用程序中加载Composer的自动加载器
require 'vendor/autoload.php';
示例
向帖子类型添加列
要向'foobar'帖子类型添加列,首先定义您的列视图,它必须实现Post_Type_Column_View
接口。
use StephenHarris\Guise\Columns\Post_Type_Column_View;
My_Foo_Bar_Column_View implements Post_Type_Column_View {
function label() {
return 'My column header';
}
function render( WP_Post $post ) {
return sprintf( 'This is the cell for post %d', $post->ID );
}
}
然后注册您的列
$column_view = new My_Foo_Bar_Column_View();
$controller new Post_Type_Column_Controller()
$controller->register( $column_view, 'foo-bar' );
您还可以指定列要显示的索引
//Adds to the second index (i.e. it appears as the third column)
$controller->register( $column_view, 'foobar', 2 );
请注意,后面的列可能会将其移位。
向帖子类型添加可排序列
要添加可排序列,您的列视图类必须实现Post_Type_Column_View
和Sortable_Column_View
接口。
use StephenHarris\Guise\Columns\Post_Type_Column_View;
use StephenHarris\Guise\Columns\Sortable_Column_View;
My_Sortable_Foo_Bar_Column_View implements Post_Type_Column_View, Sortable_Column_View {
function label() {
return 'A sortable column';
}
function render( WP_Post $post ) {
return sprintf( 'This is the cell for post %d', $post->ID );
}
function sort_by() {
//Return the value of the orderby query parameter
return 'query-variable';
}
}
有错误或功能请求吗?
请打开一个问题!
愿望清单
- 元框
- 设置