Advertisement
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
- //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;
- }
- //menu/submenu/theme options page
- function fuckinround_create_menu_page(){
- add_menu_page(
- 'Aw Yiss. Motha. Fuckin. Menu',
- 'Click here hoe',
- 'administrator',
- 'fuckinround',
- 'fuckinround_menu_page_display',
- ''
- );
- add_submenu_page(
- 'fuckinround',
- 'Aw Yiss. Motha. Fuckin. Sub Menu.',
- '#YOLO420SWAG',
- 'administrator',
- 'fuckinround_options',
- 'fuckinround_options_display'
- );
- add_theme_page(
- 'Aw Yiss. Motha. Fuckin. Options.',
- 'Aw Yiss. Motha. Fuckin. Options.',
- 'administrator',
- 'fuckinround_theme_options',
- 'fuckinround_theme_display'
- );
- }
- add_action('admin_menu', 'fuckinround_create_menu_page');
- function fuckinround_menu_page_display(){
- $html = '<div class="wrap">';
- $html .= '<h2>' . wp_get_theme()->Name . ' Awesome Ass Menu</h2>';
- $html .= '</div>';
- echo $html;
- }
- function fuckinround_options_display(){
- $html = '<div class="wrap">';
- $html .= '<h2>' . wp_get_theme()->Name . ' Awesome Ass SubMenu</h2>';
- $html .= '</div>';
- echo $html;
- }
- function fuckinround_theme_display(){
- $html = '<div class="wrap">';
- $html .= '<h2>' . wp_get_theme()->Name . ' Awesome Ass Options</h2>';
- $html .= '</div>';
- echo $html;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement