Metaboxes

Posted on November 25, 2016

As the name suggests, the Metabox config module helps you build custom WordPress metabox. A metabox can be is a UI container for your custom fields (post metadata).

How it works:

1.Without view Actions

metaboxes_empty
2.With custom view Actions

metaboxes_view
3.With controls Actions

metaboxes_controls

Default config path

{{ Project Name }}/app/config/metaboxes.json

You can rewrite this path by lf_config_metaboxes_path filter.

 

Keys:

meta_box_id

Description: meta box id.

Value: array of metabox properties.

Value item arguments:

$id

(string) (Required) Meta box ID (used in the ‘id’ attribute for the meta box).

$title

(string) (Required) Title of the meta box.

$callback

(callable) (Required) Function that fills the box with the desired content. The function should echo its output.

$screen

(string|array|WP_Screen) (Optional) The screen or screens on which to show the box (such as a post type, ‘link’, or ‘comment’). Accepts a single screen ID, WP_Screen object, or array of screen IDs. Default is the current screen.
Default value: null

$context

(string) (Optional) The context within the screen where the boxes should display. Available contexts vary from screen to screen. Post edit screen contexts include ‘normal’, ‘side’, and ‘advanced’. Comments screen contexts include ‘normal’ and ‘side’. Menus meta boxes (accordion sections) all use the ‘side’ context. Global
Default value: ‘advanced’

$priority

(string) (Optional) The priority within the context where the boxes should show (‘high’, ‘low’).
Default value: ‘default’

$callback_args

(array) (Optional) Data that should be set as the $args property of the box array (which is the second parameter passed to your callback).
Default value: null

$controls

(array) (Optional) Lolita controls.

Based on:

Lolita controls and

add_meta_box( string $id, string $title, callable $callback,string|array|WP_Screen $screen = null, string $context = 'advanced',string $priority = 'default', array $callback_args = null )

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *