Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add a menu for our option page
- add_action('admin_menu', 'sunburst_theme_add_page');
- function sunburst_theme_add_page() {
- add_options_page( 'My Plugin', 'My Plugin', 'manage_options', 'sunburst_theme', 'sunburst_theme_option_page' );
- }
- // Draw the option page
- function sunburst_theme_option_page() {
- ?>
- <div class="wrap">
- <?php screen_icon(); ?>
- <h2>My plugin</h2>
- <form action="options.php" method="post">
- <?php settings_fields('sunburst_theme_options'); ?>
- <?php do_settings_sections('sunburst_theme'); ?>
- <input name="Submit" type="submit" value="Save Changes" />
- </form>
- </div>
- <?php
- }
- // Register and define the settings
- add_action('admin_init', 'sunburst_theme_admin_init');
- function sunburst_theme_admin_init(){
- register_setting(
- 'sunburst_theme_options',
- 'sunburst_theme_options'
- );
- add_settings_section(
- 'sunburst_theme_checkbox_section',
- 'My Plugin Settings',
- 'sunburst_theme_section_text',
- 'sunburst_theme'
- );
- add_settings_field(
- 'sunburst_theme_checkbox',
- 'Enter text here',
- 'sunburst_theme_checkbox_input',
- 'sunburst_theme',
- 'sunburst_theme_checkbox_section'
- );
- }
- // Draw the section header
- function sunburst_theme_section_text() {
- echo '<p>Enter your settings here.</p>';
- }
- function sunburst_theme_checkbox_input() {
- $options = get_option( 'sunburst_theme_options' );
- ?> <input id='checkbox' name='sunburst_theme_options[checkbox]' type='checkbox' value='1' <?php checked( $options['checkbox'], 1 ) ; ?> />
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement