Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //creates the custom settings for the menu
- if ( is_admin() ) { // only proceeds is user is admin
- add_action ('admin_menu', 'visionary_create_menu');
- add_action ('admin_init', 'visionary_register_settings');
- } else { //non-admin user can't access page
- return;
- }
- function visionary_create_menu() {
- //create the submenu in here
- add_submenu_page( 'themes.php', 'Visionary Theme options', 'Visionary Options', 'administrator', 'visionary-theme-options-page', 'visionary_themes_submenu_callback' );
- }
- ?>
- <?php
- // the call back for the submenu which displays the settings
- function visionary_themes_submenu_callback() { ?>
- <div class="wrap">
- <?php screen_icon(); ?>
- <?php
- // if statement to test the active tab on the theme options
- if( isset( $_GET[ 'tab' ] )) {
- $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'display_options';
- } // end if
- ?>
- <h2 class="nav-tab-wrapper">
- <a href="?page=visionary-theme-options-page&tab=display_options" class="nav-tab <?php echo $active_tab == 'display_options' ? 'nav-tab-active' : ''; ?>">
- Display Options</a>
- <a href="?page=visionary-theme-options-page&tab=social_options" class="nav-tab <?php echo $active_tab == 'display_options' ? 'nav-tab-active' : ''; ?>"> Social Options</a>
- </h2>
- <form id="landingOptions" method="post" action="options.php">
- <?php
- function visionary_general_options_callback() {
- echo '<p>Select which areas of content you wish to display.</p>';
- } // end visionary_general_options_callback ?>
- <?php function visionary_toggle_logo_callback() {
- //first we read the options that we have made
- $options = get_option('visionary_theme_display_options');
- // Next, we need to make sure the element is defined in the options. If not, we'll set an empty string.
- $url = '';
- if( isset ( $options['v_logo'])) {
- $url = $options['v_logo'];
- } //endif
- // Render the output
- echo '<input type="text" id="twitter" name="visionary_theme_display_options[v_logo]" value="' . $options['v_logo'] . '" />';
- } ?>
- <?php function visionary_toggle_copyright_callback() {
- } ?>
- <?php function visionary_toggle_javascript_callback() {
- } ?>
- </form>
- </div>
- <?php } ?>
- <?php
- //register the settings used in the theme options
- function visionary_register_settings() {
- if( false == get_option( 'visionary_theme_display_options' ) ) {
- add_option( 'visionary_theme_display_options' );
- } // end if
- add_settings_section(
- 'general_settings_section',
- 'Display_options',
- 'visionary_general_options_callback',
- 'visionary_theme_display_options'
- ) ;
- add_settings_field (
- 'v_twitter', // ID used to identify the field throughout the theme
- 'visionary_twitter', // The label to the left of the option interface element
- 'visionary_toggle_header_callback', // The name of the function responsible for rendering the option interface
- 'visionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- add_settings_field(
- 'v_googleplus', // ID used to identify the field throughout the theme
- 'visionary_googleplus', // The label to the left of the option interface element
- 'visionary_toggle_googleplus_callback', // The name of the function responsible for rendering the option interface
- 'visionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- add_settings_field(
- 'v_pinterest', // ID used to identify the field throughout the theme
- 'visionary_pinterest', // The label to the left of the option interface element
- 'visionary_toggle_pinterest_callback', // The name of the function responsible for rendering the option interface
- 'visionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- add_settings_field(
- 'v_analytics', // ID used to identify the field throughout the theme
- 'visionary_analytics', // The label to the left of the option interface element
- 'visionary_toggle_analytics_callback', // The name of the function responsible for rendering the option interface
- 'visionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- add_settings_field(
- 'v_logo', // ID used to identify the field throughout the theme
- 'visionary_logo', // The label to the left of the option interface element
- 'visionary_toggle_logo_callback', // The name of the function responsible for rendering the option interface
- 'visionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- add_settings_field(
- 'v_copyright', // ID used to identify the field throughout the theme
- 'visionary_copyright', // The label to the left of the option interface element
- 'visionary_toggle_copyright_callback', // The name of the function responsible for rendering the option interface
- 'visionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- add_settings_field(
- 'v_javascript', // ID used to identify the field throughout the theme
- 'visionary_javascript', // The label to the left of the option interface element
- 'visonary_toggle_javascript_callback', // The name of the function responsible for rendering the option interface
- 'gvisionary_theme_display_options', // The page on which this option will be displayed
- 'general_settings_section' // The name of the section to which this field belongs
- );
- ?>
- <?php
- // sets out all the settings fields
- register_setting( 'visionary_theme_display_options', 'visionary_theme_display_options');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement