: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Example of how Themify Metabox plugin can be used in themes and plugins.
* To use this file, enable the Themify Metabox plugin and then copy the contents of this file to
* your theme's functions.php file, or "include" it.'
* @package Themify Metabox
defined( 'ABSPATH' ) || exit;
* Register a custom meta box to display on Page post type
function themify_metabox_example_meta_box( $meta_boxes ) {
$meta_boxes['tm-example'] = array(
'id' => 'tm-example', // later, to add fields to this metabox we'll use "themify_metabox/fields/tm-example" filter hook, see function
'title' => __( 'Themify Metabox Example', 'themify' ),
'screen' => array( 'page' ),
add_filter( 'themify_metaboxes', 'themify_metabox_example_meta_box' );
* Setup the custom fields for our Themify Metabox Example meta box, added earlier in the themify_metabox_example_meta_box function
function themify_metabox_example_meta_box_fields( $fields, $post_type ) {
$first_tab_options = array(
'title' => __( 'Text field', 'themify' ),
'description' => __( 'Field description is displayed below the field.', 'themify' ),
'name' => 'textarea_field',
'title' => __( 'Textarea field', 'themify' ),
'title' => __( 'Image field', 'themify' ),
'name' => 'dropdown_field',
'title' => __( 'Dropdown', 'themify' ),
array( 'value' => '', 'name' => '' ),
array( 'value' => 'yes', 'name' => __( 'Yes', 'themify' ), 'selected' => true ),
array( 'value' => 'no', 'name' => __( 'No', 'themify' ) ),
'description' => __( 'You can set which option is selected by default. Cool, eh?', 'themify' ),
// do not save the custom field when the option is set to Yes
'name' => 'checkbox_field',
'title' => __( 'Checkbox', 'themify' ),
'label' => __( 'Checkbox label', 'themify' ),
'title' => __( 'Radio field', 'themify' ),
'description' => __( 'You can hide or show option based on how other options are configured', 'themify' ),
array( 'value' => 'yes', 'name' => __( 'Yes', 'themify' ), 'selected' => true ),
array( 'value' => 'no', 'name' => __( 'No', 'themify' ) ),
'name' => 'separator_image_size',
//'description' => __( 'Optional text to show after the separator', 'themify'. )
'title' => __( 'Multi fields', 'themify' ),
'label' => __( 'width', 'themify' ),
'meta' => array( 'size' => 'small' )
'name' => 'image_height',
'label' => __( 'height', 'themify' ),
'meta' => array( 'size' => 'small' )
'description' => __( '"Multi" field type allows displaying multiple fields together.', 'themify'),
'title' => __( 'Color', 'themify' ),
'meta' => array( 'default' => null ),
'name' => 'post_id_info_field',
'title' => __( 'Post ID', 'themify' ),
'description' => __( 'This field type shows text with the ID of the post, which is: <code>%s</code>', 'themify' ),
'type' => 'post_id_info',
$second_tab_options = array(
'title' => __( 'Audio field', 'themify' ),
'title' => __( 'Video field', 'themify' ),
'name' => 'gallery_shortcode_field',
'title' => __( 'Gallery Shortcode field', 'themify' ),
'description' => __( 'Using this field type you can add a gallery manager.', 'themify' ),
'type' => 'gallery_shortcode',
'title' => __( 'Date field', 'themify' ),
'pick' => __( 'Pick Date', 'themify' ),
'close' => __( 'Done', 'themify' ),
'clear' => __( 'Clear Date', 'themify' ),
'time_format' => 'HH:mm:ss',
'date_format' => 'yy-mm-dd',
'name' => 'repeater_field',
'title' => __( 'Repeater', 'themify' ),
'title' => __( 'Text Field', 'themify' ),
'title' => __( 'Color', 'themify' ),
'title' => __( 'Dropdown', 'themify' ),
array( 'value' => 'yes', 'name' => __( 'Yes', 'themify' ) ),
array( 'value' => 'no', 'name' => __( 'No', 'themify' ) ),
'add_new_label' => __( 'Add new item', 'themify' ),
'name' => __( 'First Tab', 'themify' ), // Name displayed in box
'options' => $first_tab_options,
'name' => __( 'Second Tab', 'themify' ), // Name displayed in box
'options' => $second_tab_options,
add_filter( 'themify_metabox/fields/tm-example', 'themify_metabox_example_meta_box_fields', 10, 2 );
* Add sample fields to the user profile screen
function themify_metabox_example_user_fields( $fields ) {
$fields['themify-metabox-sample'] = array(
'title' => __( 'Sample fields added by Themify Metabox.', 'themify' ),
'description' => __( 'Description text about the fields.', 'themify' ),
'name' => 'textbox_field',
'title' => __( 'Text box', 'themify' ),
'title' => __( 'Image field', 'themify' ),
'description' => __( 'This is only to show how field types can be used in user profile pages.', 'themify' ),
add_filter( 'themify_metabox/user/fields', 'themify_metabox_example_user_fields' );
* Add a sample Color field to Category taxonomy
function themify_metabox_example_category_fields( $fields ) {
'title' => __( 'Color', 'themify' ),
'meta' => array( 'default' => null ),
return array_merge( $fields, $new_fields );
add_filter( 'themify_metabox/taxonomy/category/fields', 'themify_metabox_example_category_fields', 10 );