The do_block_editor_incompatible_meta_box() WordPress PHP function renders a “fake” meta box with an information message in the block editor when an incompatible meta box is found.
Usage
To use the do_block_editor_incompatible_meta_box() function, you need to pass in two parameters: $data_object
and $box
. Here’s an example:
$data_object = 'my_data_object'; $box = array( 'id' => 'my_meta_box_id', 'title' => 'My Meta Box Title', 'old_callback' => 'my_old_callback_function', 'args' => array() ); do_block_editor_incompatible_meta_box($data_object, $box);
Parameters
$data_object
(mixed): Required. The data object being rendered on this screen.$box
(array): Required. Custom formatted meta box arguments. It includes:id
(string): Meta box ‘id’ attribute.title
(string): Meta box title.old_callback
(callable): The original callback for this meta box.args
(array): Extra meta box arguments.
More information
See WordPress Developer Resources: do_block_editor_incompatible_meta_box()
Examples
Basic Usage
This example illustrates a basic usage of the function.
$data_object = 'data_object_1'; $box = array( 'id' => 'meta_box_1', 'title' => 'Meta Box 1', 'old_callback' => 'callback_function_1', 'args' => array() ); // Call the function do_block_editor_incompatible_meta_box($data_object, $box);
With Additional Arguments
This example shows how to add extra arguments to the meta box.
$data_object = 'data_object_2'; $box = array( 'id' => 'meta_box_2', 'title' => 'Meta Box 2', 'old_callback' => 'callback_function_2', 'args' => array('extra_arg_1' => 'value_1', 'extra_arg_2' => 'value_2') ); // Call the function do_block_editor_incompatible_meta_box($data_object, $box);
Different Callback Functions
This example shows the usage of different callback functions.
$data_object = 'data_object_3'; $box = array( 'id' => 'meta_box_3', 'title' => 'Meta Box 3', 'old_callback' => 'callback_function_3', 'args' => array() ); // Call the function do_block_editor_incompatible_meta_box($data_object, $box);
Different Data Objects
This example shows the usage of different data objects.
$data_object = 'data_object_4'; $box = array( 'id' => 'meta_box_4', 'title' => 'Meta Box 4', 'old_callback' => 'callback_function_4', 'args' => array() ); // Call the function do_block_editor_incompatible_meta_box($data_object, $box);