Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //this is better-options. a successor to the non-working theme-options.php
- //format for select args: 'options'..., 'label text'
- //format for text input args: 'id', 'label text'
- //settings registration
- add_action('admin_init', 'fuckinround_initialize_theme_options');
- function fuckinround_initialize_theme_options() {
- //register sections
- add_settings_section(
- 'general_settings_section',
- 'General Settings',
- 'fuckinround_general_options_callback',
- 'general'
- );
- //register fields
- add_settings_field(
- 'type_of_logo',
- 'Type of Logo',
- 'fuckinround_type_of_logo_callback',
- 'general',
- 'general_settings_section',
- array(
- 'text', 'logo',
- 'Choose whether you\'d like a text or image logo.'
- )
- );
- add_settings_field(
- 'logo_text',
- 'Logo Text',
- 'fuckinround_logo_text_input_callback',
- 'general',
- 'general_settings_section',
- array(
- 'logo_text',
- 'Enter text for the logo.'
- )
- );
- add_settings_field(
- 'logo_slogan',
- 'Logo Slogan',
- 'fuckinround_logo_text_input_callback',
- 'general',
- 'general_settings_section',
- array(
- 'logo_slogan',
- 'Enter text for the slogan'
- )
- );
- //register fields w/ wp
- register_setting(
- 'general',
- 'type_of_logo'
- );
- register_setting(
- 'general',
- 'logo_text'
- );
- register_setting(
- 'general',
- 'logo_slogan'
- );
- }
- //section callbacks
- function fuckinround_general_options_callback(){
- echo '<p>This is the general settings area.</p>';
- }
- //field callbacks
- function fuckinround_type_of_logo_callback($args){
- $html = '<select id="type_of_logo" name="type_of_logo">';
- foreach($args as $arg){
- if ($args[Count($args)-1] != $arg){
- $html .= '<option value="' . $arg . '"' . selected(get_option('type_of_logo'), $arg, false) . '>' . $arg . '</option>';
- }
- }
- $html .= '</select>';
- $html .= '<label for="type_of_logo">' . $args[Count($args)-1] . '</label>';
- echo $html;
- }
- function fuckinround_logo_text_input_callback($args){
- $html = '<input type="text" id="' . $args[0] . '" name="' . $args[0] . '" value="' . get_option($args[0]) . '" />';
- $html .= '<label for="' . $args[0] . '">' . $args[1] . '</label>';
- echo $html;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment