Wallogit.com
2017 © Pedro Peláez
Helpers for easier WordPress development
WP Helpers is a collection of classes and librariers for easier WordPress development., (*1)
CustomPostType::add('idea');
mf()->addPostMeta('number-field', ['name' => 'Number Field', type' => 'number'])
queue_action('resources_hungry_action', 'data', 4, 'action')
Add layered/wp-helpers as a require dependency in your composer.json file:, (*2)
$ composer require layered/wp-helpers
Example of adding a Post Type, create a CustomPostType instance with name as first argument:, (*3)
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 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:, (*4)
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 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:, (*5)
// 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');
Please report any issues here on GitHub., (*6)