Advertisement
Guest User

Untitled

a guest
Jun 11th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.00 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. //creates the custom settings for the menu
  5.  
  6. if ( is_admin() ) { // only proceeds is user is admin
  7. add_action ('admin_menu', 'visionary_create_menu');
  8. add_action ('admin_init', 'visionary_register_settings');
  9. } else { //non-admin user can't access page
  10. return;
  11. }
  12. function visionary_create_menu() {
  13.  
  14. //create the submenu in here
  15.  
  16. add_submenu_page( 'themes.php', 'Visionary Theme options', 'Visionary Options', 'administrator', 'visionary-theme-options-page', 'visionary_themes_submenu_callback' );
  17.  
  18. }
  19. ?>
  20. <?php
  21. // the call back for the submenu which displays the settings
  22. function visionary_themes_submenu_callback() { ?>
  23.  
  24.  
  25. <div class="wrap">
  26. <?php screen_icon(); ?>
  27.  
  28. <?php
  29.  
  30. // if statement to test the active tab on the theme options
  31. if( isset( $_GET[ 'tab' ] )) {
  32. $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'display_options';
  33. } // end if
  34. ?>
  35.  
  36. <h2 class="nav-tab-wrapper">
  37. <a href="?page=visionary-theme-options-page&tab=display_options" class="nav-tab <?php echo $active_tab == 'display_options' ? 'nav-tab-active' : ''; ?>">
  38. Display Options</a>
  39.  
  40. <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>
  41. </h2>
  42.  
  43. <form id="landingOptions" method="post" action="options.php">
  44. <?php
  45. function visionary_general_options_callback() {
  46. echo '<p>Select which areas of content you wish to display.</p>';
  47. } // end visionary_general_options_callback ?>
  48.  
  49. <?php function visionary_toggle_logo_callback() {
  50.  
  51. //first we read the options that we have made
  52. $options = get_option('visionary_theme_display_options');
  53.  
  54. // Next, we need to make sure the element is defined in the options. If not, we'll set an empty string.
  55. $url = '';
  56. if( isset ( $options['v_logo'])) {
  57. $url = $options['v_logo'];
  58. } //endif
  59.  
  60. // Render the output
  61. echo '<input type="text" id="twitter" name="visionary_theme_display_options[v_logo]" value="' . $options['v_logo'] . '" />';
  62. } ?>
  63.  
  64. <?php function visionary_toggle_copyright_callback() {
  65.  
  66. } ?>
  67.  
  68. <?php function visionary_toggle_javascript_callback() {
  69.  
  70. } ?>
  71.  
  72. </form>
  73. </div>
  74.  
  75.  
  76. <?php } ?>
  77.  
  78. <?php
  79. //register the settings used in the theme options
  80. function visionary_register_settings() {
  81.  
  82. if( false == get_option( 'visionary_theme_display_options' ) ) {
  83. add_option( 'visionary_theme_display_options' );
  84. } // end if
  85.  
  86. add_settings_section(
  87. 'general_settings_section',
  88. 'Display_options',
  89. 'visionary_general_options_callback',
  90. 'visionary_theme_display_options'
  91. ) ;
  92.  
  93. add_settings_field (
  94. 'v_twitter', // ID used to identify the field throughout the theme
  95. 'visionary_twitter', // The label to the left of the option interface element
  96. 'visionary_toggle_header_callback', // The name of the function responsible for rendering the option interface
  97. 'visionary_theme_display_options', // The page on which this option will be displayed
  98. 'general_settings_section' // The name of the section to which this field belongs
  99. );
  100.  
  101. add_settings_field(
  102. 'v_googleplus', // ID used to identify the field throughout the theme
  103. 'visionary_googleplus', // The label to the left of the option interface element
  104. 'visionary_toggle_googleplus_callback', // The name of the function responsible for rendering the option interface
  105. 'visionary_theme_display_options', // The page on which this option will be displayed
  106. 'general_settings_section' // The name of the section to which this field belongs
  107.  
  108. );
  109.  
  110. add_settings_field(
  111. 'v_pinterest', // ID used to identify the field throughout the theme
  112. 'visionary_pinterest', // The label to the left of the option interface element
  113. 'visionary_toggle_pinterest_callback', // The name of the function responsible for rendering the option interface
  114. 'visionary_theme_display_options', // The page on which this option will be displayed
  115. 'general_settings_section' // The name of the section to which this field belongs
  116.  
  117. );
  118.  
  119. add_settings_field(
  120. 'v_analytics', // ID used to identify the field throughout the theme
  121. 'visionary_analytics', // The label to the left of the option interface element
  122. 'visionary_toggle_analytics_callback', // The name of the function responsible for rendering the option interface
  123. 'visionary_theme_display_options', // The page on which this option will be displayed
  124. 'general_settings_section' // The name of the section to which this field belongs
  125.  
  126. );
  127.  
  128. add_settings_field(
  129. 'v_logo', // ID used to identify the field throughout the theme
  130. 'visionary_logo', // The label to the left of the option interface element
  131. 'visionary_toggle_logo_callback', // The name of the function responsible for rendering the option interface
  132. 'visionary_theme_display_options', // The page on which this option will be displayed
  133. 'general_settings_section' // The name of the section to which this field belongs
  134.  
  135. );
  136.  
  137. add_settings_field(
  138. 'v_copyright', // ID used to identify the field throughout the theme
  139. 'visionary_copyright', // The label to the left of the option interface element
  140. 'visionary_toggle_copyright_callback', // The name of the function responsible for rendering the option interface
  141. 'visionary_theme_display_options', // The page on which this option will be displayed
  142. 'general_settings_section' // The name of the section to which this field belongs
  143.  
  144. );
  145.  
  146. add_settings_field(
  147. 'v_javascript', // ID used to identify the field throughout the theme
  148. 'visionary_javascript', // The label to the left of the option interface element
  149. 'visonary_toggle_javascript_callback', // The name of the function responsible for rendering the option interface
  150. 'gvisionary_theme_display_options', // The page on which this option will be displayed
  151. 'general_settings_section' // The name of the section to which this field belongs
  152.  
  153. );
  154. ?>
  155. <?php
  156. // sets out all the settings fields
  157. register_setting( 'visionary_theme_display_options', 'visionary_theme_display_options');
  158.  
  159. }
  160. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement