Download the PHP package martijnvdb/wordpress-plugin-tools without Composer
On this page you can find all versions of the php package martijnvdb/wordpress-plugin-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download martijnvdb/wordpress-plugin-tools
More information about martijnvdb/wordpress-plugin-tools
Files in martijnvdb/wordpress-plugin-tools
Package wordpress-plugin-tools
Short Description A simple library to quickly create Wordpress plugins
License MIT
Homepage https://github.com/martijnvdb87/wordpress-plugin-tools
Informations about the package wordpress-plugin-tools
Wordpress Plugin Tools
The goal of this library is to simplify the proces of creating custom post types and settings pages in Wordpress.
Installation
You can install the package via composer:
Usage
All documented objects use a fluent interface, which allows you to chain methods. For example:
Every chain should end with a build()
method. The build()
method will register the object using the Wordpress action hooks. Except when using an object as an argument in a method. In the following example, the CustomField object should not end with the build()
method:
PostType
This object allows you to easily create one or multiple post types without having to worry about the Wordpress hooks. Chain any method you like and end with the build()
method to register the post type.
Create a new PostType
Add a MetaBox to the PostType
MetaBoxes on their own won't be shown anywhere. They have to be added to a PostType. These methods will do exactly that.
Add labels to the PostType
All the Wordpress labels can be used. See a full list of supported labels.
Add a description to the PostType
Make the PostType public
PostTypes are false
by default. Using this method the PostType will be shown in the admin interface.
Set menu position of the PostType
Set the icon of the PostType
Add feature support to the PostType
Any Wordpress core feature can be used. The core features are title
, editor
, comments
, revisions
, trackbacks
, author
, excerpt
, page-attributes
, thumbnail
, custom-fields
and post-formats
.
See a full list of supported features
Remove feature support from the PostType
Any Wordpress core feature can be removed. The core features are title
, editor
, comments
, revisions
, trackbacks
, author
, excerpt
, page-attributes
, thumbnail
, custom-fields
and post-formats
.
See a full list of supported features
Set the slug of the PostType
Use the block editor in the PostType
Add any supported option to the PostType
This library only has a handfull of dedicated methods to set post type options. To use any other post type option you can use the addOption()
method. See a full list of possible options.
CustomField
This object allows you to easily create one or multiple custom fields without having to worry about the Wordpress hooks. Chain any method you like and end with the build()
method to register the custom field.
Create a new CustomField
Set the CustomField type
The possible CustomField types are text
, textarea
, checkbox
, number
, select
, radio
and editor
.
Set the label of the CustomField
Add options to the CustomField
This will only be used if the CustomField is a select
or radio
type.
Set the minimal value of the CustomField
This will only be used if the CustomField is a number
type.
Set the maximum value of the CustomField
This will only be used if the CustomField is a number
type.
Set the size of the steps of the CustomField
This will only be used if the CustomField is a number
type.
MetaBox
This object allows you to easily create one or multiple metaboxes without having to worry about the Wordpress hooks. Chain any method you like and end with the build()
method to register the metabox.
Create a new MetaBox
Set the title of the MetaBox
Add a CustomField to a MetaBox
Add a list to a MetaBox
This library allows you to easily create a growable and reorderable list of items. Each item in the list can contain multiple CustomFields. If for example you would like to add multiple URLs with a title and a description to a post, you can use a list for this.
Add the MetaBox to a Wordpress post type
The ID of the post types has to be used as an argument of these methods. These methods allow you to add MetaBoxes to existing post types which aren't created with this library.
Customize text
This library uses two text strings in the MetaBox which can be customized or translated. The following texts are used:
new
Newdelete_confirm
Are you sure you want to delete this item?
This is how to customize them:
SettingsPage
This object allows you to easily create one or multiple setting pages without having to worry about the Wordpress hooks. Chain any method you like and end with the build()
method to register the setting page.