Skip to content

Commit

Permalink
Update options-page example in example-functions w/ updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Apr 20, 2017
1 parent 873c594 commit 72541e5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions example-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,18 +646,23 @@ function yourprefix_register_theme_options_metabox() {
$option_key = 'yourprefix_theme_options';

/**
* Metabox for an options page. Will not be added automatically, but needs to be called with
* the `cmb2_metabox_form` helper function. See https://github.com/CMB2/CMB2/wiki for more info.
* Registers options page menu item and form.
*/
$cmb_options = new_cmb2_box( array(
'id' => $option_key . 'page',
'title' => esc_html__( 'Theme Options Metabox', 'cmb2' ),
'hookup' => false, // Do not need the normal user/post hookup.
'show_on' => array(
// These are important, don't remove.
'key' => 'options-page',
'value' => array( $option_key ),
'id' => $option_key . 'page',
'title' => esc_html__( 'Theme Options', 'cmb2' ),
'icon_url' => 'dashicons-palmtree', // Menu icon. Only applicable if 'parent_slug' is left empty.
'show_on' => array(
// Important, don't remove.
'options-page' => $option_key,
),
// 'menu_title' => esc_html__( 'Options', 'cmb2' ), // Falls back to 'title' (above).
// 'parent_slug' => 'themes.php', // Make options page a submenu item of the themes menu.
// 'capability' => 'manage_options', // Cap required to view options-page.
// 'position' => 1, // Menu position. Only applicable if 'parent_slug' is left empty.
// 'admin_menu_hook' => 'network_admin_menu', // 'network_admin_menu' to add network-level options page.
// 'display_cb' => false, // Override the options-page form output (CMB2_Hookup::options_page_output()).
// 'save_button' => esc_html__( 'Save Theme Options', 'cmb2' ), // The text for the options-page save button. Defaults to 'Save'.
) );

/**
Expand Down

0 comments on commit 72541e5

Please sign in to comment.