How to have more than one Theme Options page with OptionTree?

OptionTree ( GitHub ) allows you to create a Theme Theme page for very simple themes.

How can I extend OptionTree to create a Plugin Settings page for my plugin?

Thanks!

+2
source share
1 answer

It is actually quite simple. The following code will create a page below the Test Page settings page . This is how OptionTree creates its own pages.

/** * Hook to register admin pages */ add_action( 'init', 'register_options_pages' ); /** * Registers all the required admin pages. */ function register_options_pages() { // Only execute in admin & if OT is installed if ( is_admin() && function_exists( 'ot_register_settings' ) ) { // Register the pages ot_register_settings( array( array( 'id' => 'custom_options', 'pages' => array( array( 'id' => 'test_page', 'parent_slug' => 'options-general.php', 'page_title' => 'Test Page', 'menu_title' => 'Test Page', 'capability' => 'edit_theme_options', 'menu_slug' => 'test-page', 'icon_url' => null, 'position' => null, 'updated_message' => 'Test Page updated.', 'reset_message' => 'Test Page reset.', 'button_text' => 'Save Changes', 'show_buttons' => true, 'screen_icon' => 'options-general', 'contextual_help' => null, 'sections' => array( array( 'id' => 'test_section', 'title' => __( 'Test Section', 'motif-core' ) ) ), 'settings' => array( array( 'id' => 'test_section_input', 'label' => 'Test Input', 'desc' => 'Pretty freaking awesome!', 'std' => '', 'type' => 'text', 'section' => 'test_section', 'class' => '' ) ) ) ) ) ) ); } } 
+9
source

Source: https://habr.com/ru/post/1498533/


All Articles