Multiple Options Pages, Menu Tricks - rogerlos/cmb2-metatabs-options GitHub Wiki
- You can use the same WordPress options key on multiple pages, each with a sub-set of the overall options, if you want to break options into multiple pages for very complex configurations.
- You can re-use metaboxes on your multiple options pages. For example, if using a two-column layout with a "publish" box in the right column, you can re-use that box on every page. If you re-use a box with a savable field in it, note that the field value is not independent from page-to-page!
- If a submenu page has the same menu slug as the parent page, WordPress will display it in the submenu but link it to the parent page. This is the trick WP uses for posts, pages, etc: top-level menus with a different label than the first child, despite linking to and displaying the same page.
// parent page -- boxes, etc left out for clarity
$args = array(
'key' => 'fabulous_opts',
'title' => 'Fabulous Plugin Options',
'menuargs' => array(
'menu_title' => 'Fabulous Plugin',
'menu_slug' => 'fabulous_plugin',
),
)
new CMB2_Metatabs_Options( $args );
// first child, pointing at same page with different menu title
$args = array(
'key' => 'fabulous_opts',
'title' => 'Fabulous Plugin Options',
'regkey' => FALSE,
'menuargs' => array(
'menu_title' => 'Fab Options',
'parent_slug' => 'fabulous_plugin', // make these two match
'menu_slug' => 'fabulous_plugin', // the parent page slug
),
)
new CMB2_Metatabs_Options( $args );
- You can insert a horizontal rule into a menu via a hack, introducing a span into the menu title. In CMO configuration, it would look like this (the styling of the line is up to you, this inserts a nearly-white line):
$args = array(
'key' => 'my_option',
'title' => '',
'regkey' => FALSE,
'menuargs' => array(
'parent_slug' => 'my_parent_page',
'menu_title' => '<span style="display:block;margin:1px 0 1px -5px;'
. 'padding:0;height:1px;line-height:1px;'
. 'background:#ccc;"></span>',
'menu_slug' => '#',
),
)
new CMB2_Metatabs_Options( $args );