Skip to content

Instantly share code, notes, and snippets.

@valendesigns
Last active December 22, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valendesigns/792a16075ab5c24366f5 to your computer and use it in GitHub Desktop.
Save valendesigns/792a16075ab5c24366f5 to your computer and use it in GitHub Desktop.
Deactivate OptionTree theme options & add a custom theme page.
<?php
/**
* Do not use the default Theme Options page
*/
add_filter( 'ot_use_theme_options', '__return_false' );
/**
* Hide the Default OptionTree Settings
*/
add_filter( 'ot_show_pages', '__return_false' );
/**
* Activate Theme Mode
*/
add_filter( 'ot_theme_mode', '__return_true' );
/**
* Load OptionTree
*/
load_template( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );
/**
* Hook to register admin pages
*/
add_action( 'init', 'register_options_pages' );
/**
* Registers all the required admin pages.
*/
function register_options_pages() {
if ( is_admin() ) {
// Register the pages
ot_register_settings(
array(
array(
'id' => 'custom_options',
'pages' => array(
array(
'id' => 'test_page',
'parent_slug' => 'themes.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' => 'themes',
'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' => ''
)
)
)
)
)
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment