Advertisement
Guest User

sjf1

a guest
Apr 23rd, 2012
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. // Add a menu for our option page
  3. add_action('admin_menu', 'sunburst_theme_add_page');
  4. function sunburst_theme_add_page() {
  5. add_options_page( 'My Plugin', 'My Plugin', 'manage_options', 'sunburst_theme', 'sunburst_theme_option_page' );
  6. }
  7.  
  8. // Draw the option page
  9. function sunburst_theme_option_page() {
  10. ?>
  11. <div class="wrap">
  12. <?php screen_icon(); ?>
  13. <h2>My plugin</h2>
  14. <form action="options.php" method="post">
  15. <?php settings_fields('sunburst_theme_options'); ?>
  16. <?php do_settings_sections('sunburst_theme'); ?>
  17. <input name="Submit" type="submit" value="Save Changes" />
  18. </form>
  19. </div>
  20. <?php
  21. }
  22.  
  23. // Register and define the settings
  24. add_action('admin_init', 'sunburst_theme_admin_init');
  25. function sunburst_theme_admin_init(){
  26. register_setting(
  27. 'sunburst_theme_options',
  28. 'sunburst_theme_options'
  29. );
  30.  
  31. add_settings_section(
  32. 'sunburst_theme_checkbox_section',
  33. 'My Plugin Settings',
  34. 'sunburst_theme_section_text',
  35. 'sunburst_theme'
  36. );
  37. add_settings_field(
  38. 'sunburst_theme_checkbox',
  39. 'Enter text here',
  40. 'sunburst_theme_checkbox_input',
  41. 'sunburst_theme',
  42. 'sunburst_theme_checkbox_section'
  43. );
  44.  
  45.  
  46.  
  47. }
  48.  
  49. // Draw the section header
  50. function sunburst_theme_section_text() {
  51. echo '<p>Enter your settings here.</p>';
  52. }
  53.  
  54. function sunburst_theme_checkbox_input() {
  55. $options = get_option( 'sunburst_theme_options' );
  56. ?> <input id='checkbox' name='sunburst_theme_options[checkbox]' type='checkbox' value='1' <?php checked( $options['checkbox'], 1 ) ; ?> />
  57. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement