sujin/wp-express

快速WordPress开发模块。

4.0.5 2020-07-08 22:28 UTC

README

Build Status Coverage Status

快速WordPress开发模块,帮助您创建新的管理页面、自定义文章类型和分类法。

初始化

包含autoload.php,即可开始。

include_once( $your_path_to . '/wp_express/autoload.php' );

用法

use Sujin\Wordpress\WP_Express\Admin;
use Sujin\Wordpress\WP_Express\Settings_Section;
use Sujin\Wordpress\WP_Express\Fields\Settings\Input;

// Create a new admin page in the root of admin menu
$admin_page_root = Admin::get_instance( 'Admin Root');
// Change position by position id
$admin_page_root->position( 200 );

// Create another admin page under $test_admin_page_1
$admin_page_child = Admin::get_instance( 'Admin Child' )
	->position( $root );
// Change position under Settings
$admin_page_child->position( 'settings' );
// Change position under other menu
$admin_page_child->position( 'Plugin Name' );
// Add a link in the Plugins list
$admin_page_child->plugin( 'Akismet' );
// Set menu icon (use WP Dashicons)
$admin_page_child->icon( 'dashicons-buddicons-activity' );

// Create a new setttings section (default location is settings page)
$settings_section = Settings_Section::get_instance( 'Settings Section' );
// Append the settings section into the admin page
$admin_page_child->append( $settings_section );

// Create a new settting field `headline`
$headline = Input::get_instance( 'Headline' );
// Append the input into the settings section
$settings_section->append( $headline );
// Change the input type to date
$headline->type( 'date' );
// Change the input to the multiple value
$headline->single( false );

// Settngs could be the chaining assignment
$headline
	->show_in_rest( true )
	->single( true )
	->append_to( $settings_section );

这是创建一个新的管理页面并设置设置块及其文本输入的示例。您可以创建新的文章类型、分类法及其字段。

管理项

表单字段

助手

助手