Skip to content

Options

Noah Mason edited this page Oct 22, 2022 · 6 revisions

WP Backstage can create new custom options, theme, and tools pages with deeply integrated custom fields.

Arguments

  • type settings | theme | tools ― The type of options page to be rendered. This will determine which menu item in the admin menu to place this page. The page will appear under "Settings" when set to "settings". The page will appear under "Appearance" when set to "theme". The page will appear under "Tools" when set to "tools" and will also render a tool card on the tools archive page.
  • title string ― The page's title.
  • menu_title string ― The page's title in the admin menu.
  • description string ― The page's d.escription.
  • show_in_rest string ― Whether the page's field values should show in the REST API or not.
  • sections array ― The page's sections.
    • id string ― The section's unique ID.
    • title string ― The section's title.
    • description string ― The section's description.
    • fields array ― The section's fields.

Add

WP_Backstage_Options::add(
    'wp_backstage_options',
    array(
        'type'         => 'settings',
        'title'        => __( 'Test Options', 'wp_backstage_examples' ),
        'menu_title'   => __( 'Test Options', 'wp_backstage_examples' ),
        'description'  => __( 'A test custom options page containing all field types.', 'wp_backstage_examples' ),
        'show_in_rest' => true,
        'sections'     => array(
            array(
                'id'          => 'wp_backstage_options_fields',
                'title'       => __( 'All Fields', 'wp_backstage_examples' ),
                'description' => __( 'These extra meta fields control further options. <a href="#">Example Link</a>', 'wp_backstage_examples' ),
                'fields'      => array(),
            ),
            array(
                'id'          => 'wp_backstage_options_extras',
                'title'       => __( 'Extras', 'wp_backstage_examples' ),
                'description' => __( 'These extra meta fields control further options. <a href="#">Example Link</a>', 'wp_backstage_examples' ),
                'fields'      => array(),
            ),
        ),
    )
);
Clone this wiki locally