Documentation

MetaBoxes
in package

AbstractYes

MetaBoxes Registration class.

Enables the batch registration of meta boxes, simplifying the process of adding custom data fields and interfaces to the WordPress admin. Utilizes the MetaBox module for each meta box's registration, ensuring that each meta box is added in accordance with WordPress best practices and standards.

Tags
see
MetaBox

for the MetaBox class.

since
1.0.0

Table of Contents

Methods

set()  : void
Registers multiple meta boxes in bulk.

Methods

set()

Registers multiple meta boxes in bulk.

public static set([array<string|int, mixed> $meta_boxes = [] ]) : void

This method simplifies the registration of custom meta boxes by accepting an array of meta box definitions. Each definition specifies the meta box's ID, title, callback, context, priority, and optional callback arguments, allowing for comprehensive and flexible meta box creation.

Example usage:

MetaBoxes::set([
    [
        'id' => 'custom-meta-box',
        'title' => __('Custom Meta Box', 'text-domain'),
        'callback' => 'custom_meta_box_callback_function',
        'screen' => 'post',
        'context' => 'normal',
        'priority' => 'high',
        'callback_args' => null, // Optional
    ],
    ...
]);
Parameters
$meta_boxes : array<string|int, mixed> = []

An array of meta box definitions. Each definition is an associative array that includes 'id', 'title', 'callback', 'screen', 'context', 'priority', and optionally 'callback_args'.

Tags
since
1.0.0

        
On this page

Search results