layered/wp-helpers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

layered/wp-helpers

Composer 安装命令:

composer require layered/wp-helpers

包简介

Helpers for easier WordPress development

README 文档

README

WP Helpers is a collection of classes and librariers for easier WordPress development.

Features and use cases

  • CustomPostType - Register a new post type. It fills or generates values and post types can be added with one line of code, ex: CustomPostType::add('idea');
  • MetaFields - Easily add meta fields to Posts, Terms, Comments and Users, ex: mf()->addPostMeta('number-field', ['name' => 'Number Field', type' => 'number'])
  • Q - Process WP actions in background without blocking the current request. Usage: queue_action('resources_hungry_action', 'data', 4, 'action')
  • PostMetaBox - Create good looking and functional meta boxes for post types

How to use

Installation

Add layered/wp-helpers as a require dependency in your composer.json file:

$ composer require layered/wp-helpers

Register post type

Example of adding a Post Type, create a CustomPostType instance with name as first argument:

CustomPostType::add('idea', [
	'labels'	=>	[
		'name'	=>	__('Ideas', 'my-theme-or-plugin')
	],
	'rewrite'	=>	[
		'slug'	=>	'my-ideas'
	],
	'supports'	=>	['title', 'editor', 'thumbnail', 'excerpt', 'author']
])
	->addTaxonomy('tag')
	->addColumns(['author'])
;

Meta Fields

Meta Fields are custom fields that can be easily added to Posts, Terms, Comments and Users. They are registered with default WordPress flow, showing up as columns in list views, editable fields on edit pages, editable fields for Quick/Bulk edit screens and REST Api:

MetaFields::instance()->addPostMeta('second-heading', [
	'name'				=>	'Second Heading',
	'type'				=>	'text',
	'placeholder'		=>	'Heading for article',
	'show_in_rest'		=>	true,
	'showInMetaBox'		=>	true,
	'showInColumns'		=>	true,
	'showInQuickEdit'	=>	true,
	'showInBulkEdit'	=>	true
]);

Q

Q adds support for asynchronous actions in plugins and themes. Simple use, only include the file and switch from do_action() to queue_action(). Processing is handled in background, making web requests load qicker. Example:

// keeps request hanging until action is complete
do_action('resource_hungry_action', 'data', 4, 'action');

// queues the action to be handled in background
queue_action('resource_hungry_action', 'data', 4, 'action');

More

Please report any issues here on GitHub.

Any contributions are welcome

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固