Hi with the new version of the MB settings page plugin I have a problem that I did not have with the previous one.
In version 1.3.4 I set this code to get a dynamic checkbox list controlled through the setting page:
<?php
/*------------------------------------*\
SETTING PAGE
\*------------------------------------*/
add_filter( 'mb_settings_pages', 'settings_pages' );
function settings_pages( $settings_pages ) {
$settings_pages[] = array(
'id' => 'options',
'menu_title' => 'Settings',
'title' => 'Option page',
'option_name' => 'options',
'icon_url' => 'dashicons-images-alt',
'submenu_title' => 'Option page',
'tabs' => array(
'allergens' => 'Allergens',
),
);
return $settings_pages;
}
add_filter( 'rwmb_meta_boxes', 'options_meta_boxes' );
function options_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'id' => 'allergens',
'title' => 'Allergens',
'settings_pages' => 'options',
'tab' => 'allergens',
'fields' => array(
array(
'id' => 'list',
'name' => 'List',
'type' => 'text',
'clone' => true,
'add_button' => '+ More',
),
),
);
return $meta_boxes;
}
# ============================== #
# === METABOX - FIELDS === #
# ============================== #
add_filter( 'rwmb_meta_boxes', 'mbfieldse_list' );
function mbfieldse_list( $meta_boxes ) {
$allergens = rwmb_meta( 'list', array( 'object_type' => 'setting' ), 'options' );
if ($allergens) {
//Combine Array
$listallergens = array_combine($allergens, array_values($allergens));
} else {
// if $allergens is empty
$listallergens = null;
}
$meta_boxes[] = array(
'title' => 'My List',
'fields' => array(
array(
'name' => 'List',
'id' => 'allergensList',
'type' => 'checkbox_list',
'options' => $listallergens,
'select_all_none' => true,
),
),
),
),
);
return $meta_boxes;
}
With MB setting page v1.3.4 everything worked fine, but updating the plugin to v2.1.3 the variable $allergens remains empty (NULL).
Maybe I am wrong something?