'footer-copyright')); add_settings_field('footer-text', __('Footer Text', 'betheme'), 'be_settings_field_footer_text', 'theme_options', 'footer', array('label_for' => 'footer-text')); } add_action('admin_init', 'be_theme_options_init'); /** * change capability to save be_options */ function be_options_page_capability($capability) { return 'edit_theme_options'; } add_filter('option_page_capability_be_options', 'be_options_page_capability'); /** * Add options page */ function be_theme_options_add_page() { $theme_page = add_theme_page( __('Theme Options', 'betheme'), // name of page __('Theme Options', 'betheme'), // label in menu 'edit_theme_options', // capability required 'theme_options', // unique menu slug 'be_theme_options_render_page' // render function ); if (!$theme_page) return; add_action("load-$theme_page", 'be_theme_options_help'); } add_action('admin_menu', 'be_theme_options_add_page'); /** * @betodo: add options page help tabs */ function be_theme_options_help() { } /** * returns an array of layout options */ function be_layouts() { $layout_options = array( 'content-sidebar' => array( 'value' => 'content-sidebar', 'label' => __('Content on left', 'betheme'), 'thumbnail' => get_template_directory_uri() . '/includes/images/content-sidebar.png' ), 'sidebar-content' => array( 'value' => 'sidebar-content', 'label' => __('Content on right', 'betheme'), 'thumbnail' => get_template_directory_uri() . '/includes/images/sidebar-content.png' ), 'content' => array( 'value' => 'content', 'label' => __('One-column, no sidebar', 'betheme'), 'thumbnail' => get_template_directory_uri() . '/includes/images/content.png' ) ); return apply_filters('be_layouts', $layout_options); } /** * return default theme options */ function be_get_default_theme_options() { $default_theme_options = array( 'logo' => '', 'color_scheme' => '', 'link_color' => '', 'link_color_hover' => '', 'theme_layout' => 'content-sidebar', 'footer_copyright' => 'Copyright © 2012 ' . get_bloginfo('name') . '', 'footer_text' => 'Powered by WordPress' ); return apply_filters('be_default_theme_options', $default_theme_options); } /** * @return array of theme options */ function be_get_theme_options() { return get_option('be_theme_options', be_get_default_theme_options()); } /** * render the default layout setting field */ function be_settings_field_layout() { $options = be_get_theme_options(); foreach (be_layouts() as $layout): ?>

get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; $options = be_get_theme_options(); $defaults = be_get_default_theme_options(); // Default Layout $wp_customize->add_section('be_layout', array( 'title' => __('Layout', 'betheme'), 'priority' => 50, )); $wp_customize->add_setting('be_theme_options[theme_layout]', array( 'type' => 'option', 'default' => $defaults['theme_layout'], 'sanitize_callback' => 'sanitize_key', )); $layouts = be_layouts(); $choices = array(); foreach ($layouts as $layout) { $choices[$layout['value']] = $layout['label']; } $wp_customize->add_control('be_theme_options[theme_layout]', array( 'section' => 'be_layout', 'type' => 'radio', 'choices' => $choices, )); // Footer Section $wp_customize->add_section('footer', array( 'title' => __('Footer Settings', 'betheme'), 'priority' => 50 )); // copyright text $wp_customize->add_setting('be_theme_options[footer_copyright]', array( 'type' => 'option', 'default' => $defaults['footer_copyright'], )); $wp_customize->add_control('be_theme_options[footer_copyright]', array( 'label' => __('Copyright Text', 'betheme'), 'section' => 'footer', 'settings' => 'be_theme_options[footer_copyright]', )); // footer text $wp_customize->add_setting('be_theme_options[footer_text]', array( 'type' => 'option', 'default' => $defaults['footer_text'], )); $wp_customize->add_control('be_theme_options[footer_text]', array( 'label' => __('Footer Text', 'betheme'), 'section' => 'footer', 'settings' => 'be_theme_options[footer_text]', )); } add_action('customize_register', 'be_customize_register'); /** * Bind JS handlers to make Theme Customizer preview reload changes asynchronously. * Used with blogname and blogdescription. */ function be_customize_preview_js() { wp_enqueue_script('be_customizer', get_template_directory_uri() . '/includes/theme-customizer.js', array('customize-preview'), '1.0', true); } add_action('customize_preview_init', 'be_customize_preview_js');