承接 stephenharris/guise 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stephenharris/guise

Composer 安装命令:

composer require stephenharris/guise

包简介

A framework for modifying the WP admin interface (adding columns, metaboxes etc)

README 文档

README

Guise is a WordPress framework for modifying the UI, it handles the behind-the-scenes interactions with WordPress so that you can focus on writing OOP code.

This is early on in development, contributions are welcome - see the wish list below!

Documentation

The documentation for using Guise can be found here: https://stephenharris.github.io/guise/

Installation

Guise is not yet published on Composer, so you need to add the repository manually:

{
    ...
    "repositories": [
        ...
        {
            "type": "vcs",
            "url": "https://github.com/stephenharris/guise"
        }
    ],
    
    ...
    
    "require": {
      "stephenharris/guise": "0.*"
    },

}

Then run composer update.

You will then need to load Composer's auto-loader in your application:

require 'vendor/autoload.php';

Example

Adding a column to a post type

To add a column to the 'foobar' post type, first define your column view it must implement the Post_Type_Column_View interface.

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 );
    }
}

Then register your column:

$column_view = new My_Foo_Bar_Column_View();
$controller new Post_Type_Column_Controller()

$controller->register( $column_view, 'foo-bar' );

You can also specify the index you want the column to appear in:

//Adds to the second index (i.e. it appears as the third column)
$controller->register( $column_view, 'foobar', 2 );

Please note that later columns can shift it out of place.

Adding a sortable to a post type

To add a sortable column your column view class must implement the Post_Type_Column_View and Sortable_Column_View interfaces.

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';
    }
}

Bug or feature request?

Please open an issue!

Wishlist

  • Metaboxes
  • Settings

统计信息

  • 总下载量: 1.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL
  • 更新时间: 2016-10-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固