Download the PHP package oberonlai/wp-metabox without Composer
On this page you can find all versions of the php package oberonlai/wp-metabox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oberonlai/wp-metabox
More information about oberonlai/wp-metabox
Files in oberonlai/wp-metabox
Package wp-metabox
Short Description Adding custom field for WordPress Post Type.
License MIT
Homepage https://github.com/oberonlai/wp-metabox
Informations about the package wp-metabox
WP Metabox v1.0
Simple WordPress Class for metabox forks from wp-metabox-constructor-class
Requirements
Installation
Install with composer
Run the following in your terminal to install with Composer.
WP Metabox PSR-4 autoloading and can be used with the Composer's autoloader. Below is a basic example of getting started, though your setup may be different depending on how you are using Composer.
See Composer's basic usage guide for details on working with Composer and autoloading.
Basic Usage
Below is a basic example of setting up a simple custom filter with a post meta field.
Usage
To create a metabox, first instantiate an instance of Metabox
. The class takes one argument, which is an associative array. The keys to the array are similar to the arguments provided to the add_meta_box WordPress function; however, you don't provide callback
or callback_args
.
Please add the detection for the WooCommerce order metabox to check whether the HPOS is enabled or not.
Available Fields
After instantiating the above metabox, add a few fields to it. Below is a list of the available fields.
Text
A simple text input. Nothing special.
Textarea
Textareas are used to store a body of text. For a richer experience with HTML, see the WYSIWYG editor.
Checkbox
Checkboxes are a great way to facilitate conditional logic.
Radio
Radio fields are a great way to choose from a selection of options.
Select
Select fields are a great way to choose from a selection of options.
Html
Add HTML markup to display information.
Image Upload
Use this to permit users to upload an image within the metabox. Pro tip: use this with the repeater to dynamically manage the photos within a gallery or slideshow.
WYSIWYG Editor
You can use a WYSIWYG editor to facilitate the management of HTML content.
Repeater
All of the above fields can be added to a repeater to store an array of content with a dynamic length. Here is an example of a repeater block with three fields: text, textarea, and image upload.
Notice: true
is a second argument to the repeater fields. This is required. Also, the variable, $metabox_repeater_block_fields[]
, which stores the repeater block's fields, has a pair of brackets []
at the end of the variable name. This is required.