Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // My First Options Page = mfop
- /*-- GLOBAL VARIABLES -- */
- $mfop_options = get_option('mfop_theme_options');
- /**
- * add Theme options page - under "Appearance" submenu
- */
- function mfop_admin_page() {
- add_theme_page(
- __( 'Theme Options Page', 'mytheme' ),
- __( 'Theme Options Menu', 'mytheme' ),
- 'edit_theme_options',
- 'sections_name',
- 'mfop_options_builder');
- }
- add_action('admin_menu', 'mfop_admin_page');
- /**
- * Initialize admin pages
- */
- function mfop_admin_init(){
- register_setting( 'mfop_options', 'mfop_theme_options', 'mfop_options_validate' );
- add_settings_section('mfop_main', __( 'Main Settings Page:', 'mytheme' ), 'mfop_section_text', 'sections_name');
- add_settings_field('enable_checkbox', __( 'Enable Box:', 'mytheme' ), 'mfop_setting_checkbox', 'sections_name', 'mfop_main');
- add_settings_field('mfop_text_string', __( 'Text Input:', 'mytheme' ), 'mfop_setting_text', 'sections_name', 'mfop_main');
- add_settings_field('color_scheme', __( 'Color Scheme Selection:', 'mytheme' ), 'mfop_color_scheme_setting', 'sections_name', 'mfop_main');
- }
- add_action('admin_init', 'mfop_admin_init');
- /*
- * Options builder - using Settings API
- * No more Tables!
- */
- function mfop_options_builder() {
- ?>
- <div class="wrap">
- <?php screen_icon(); ?>
- <h2><?php _e( 'My Theme Options Page', 'mytheme' ); ?></h2>
- <form method="post" action="options.php">
- <?php
- settings_fields( 'mfop_options' );
- do_settings_sections( 'sections_name' );
- submit_button();
- ?>
- </form>
- </div>
- <?php
- }
- /**
- * Callback ee add_settings_field() waxa la waafajinayaa
- */
- // CHECKBOX
- function mfop_setting_checkbox() {
- global $mfop_options;
- if($mfop_options['enable']) { $checked = ' checked="checked" '; }
- echo "<input ".$checked." id='enable_checkbox' name='mfop_theme_options[enable]' type='checkbox' />";
- }
- // TWITTER
- function mfop_setting_text() {
- global $mfop_options;
- echo "<input id='mfop_text_string' name='mfop_theme_options[twitter_url]' size='40' type='text' value='{$mfop_options['twitter_url']}' />";
- }
- // COLOR SCHEME
- function mfop_color_scheme_setting() {
- global $mfop_options;
- $items = array("Red", "Blue");
- echo "<select name='mfop_theme_options[color_scheme]'>";
- foreach ($items as $item) {
- $selected = ( $mfop_options['color_scheme'] === $item ) ? 'selected = "selected"' : '';
- echo "<option value='$item' $selected>$item</option>";
- }
- echo "</select>";
- }
- /**
- * Validate options
- */
- function mfop_options_validate () {}
- function mfop_section_text () {}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement