Hi I have a meta-box that shows fields in pages and posts. Also I have a settings page with a checkbox field that when disabled should hide the meta-box in the pages/posts and show another one.
I tried to insert this, but the variable $enable is not loaded:
add_filter( 'rwmb_meta_boxes', 'sidebar_post' );
function sidebar_post( $meta_boxes ) {
$enable = rwmb_meta( 'enable', array( 'object_type' => 'setting' ), 'my_settings' );
if ( $enable ) {
$meta_boxes[] = [
'title' => __( 'Set View', 'my-name' ),
'id' => 'set-view',
'context' => 'side',
'fields' => [
[
'type' => 'custom_html',
'std' => '<div class="alert alert-warning">My first custom message here.</div>',
],
],
];
} else {
$meta_boxes[] = [
'title' => __( 'Set View', 'my-name' ),
'id' => 'set-view',
'context' => 'side',
'fields' => [
[
'type' => 'custom_html',
'std' => '<div class="alert alert-warning">My second custom message here.</div>',
],
],
];
}
return $meta_boxes;
}