예제 #1
0
/**
 * Registers the theme setting controls with the Theme Customizer
 * 
 * @author	Konstantin Obenland
 * @since	1.4.0 - 05.05.2012
 * 
 * @param	WP_Customize	$wp_customize
 * 
 * @return	void
 */
function the_bootstrap_customize_register($wp_customize)
{
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    $wp_customize->add_section('the_bootstrap_theme_layout', array('title' => __('Layout', 'the-bootstrap'), 'priority' => 99));
    $wp_customize->add_section('the_bootstrap_navbar_options', array('title' => __('Navbar Options', 'the-bootstrap'), 'priority' => 101));
    // Add settings
    foreach (array_keys(the_bootstrap_get_default_theme_options()) as $setting) {
        $wp_customize->add_setting("the_bootstrap_theme_options[{$setting}]", array('default' => the_bootstrap_options()->{$setting}, 'type' => 'option', 'transport' => 'postMessage'));
    }
    // New special settings <ir> #########################################################
    $wp_customize->add_setting('special_background_color', array('default' => '#FFFFFF', 'transport' => 'refresh'));
    // New special settings <ir> #########################################################
    $wp_customize->add_setting('special_menu_color', array('default' => '#1B1B1B', 'transport' => 'refresh'));
    // New special settings <ir> #########################################################
    $wp_customize->add_setting('special_title_align', array('default' => '#left', 'transport' => 'refresh'));
    // New special settings <ir> #########################################################
    $wp_customize->add_setting('special_menu_align', array('default' => '#left', 'transport' => 'refresh'));
    // New special settings <ir> #########################################################
    $wp_customize->add_setting('special_sidebar', array('default' => 'true', 'transport' => 'refresh'));
    // Theme Layout
    $wp_customize->add_control('the_bootstrap_theme_layout', array('label' => __('Default Layout', 'the-bootstrap'), 'section' => 'the_bootstrap_theme_layout', 'settings' => 'the_bootstrap_theme_options[theme_layout]', 'type' => 'radio', 'choices' => array('content-sidebar' => __('Content on left', 'the-bootstrap'), 'sidebar-content' => __('Content on right', 'the-bootstrap'))));
    // Sitename in Navbar
    $wp_customize->add_control('the_bootstrap_navbar_site_name', array('label' => __('Add site name to navigation bar.', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_site_name]', 'type' => 'checkbox'));
    // Searchform in Navbar
    $wp_customize->add_control('the_bootstrap_navbar_searchform', array('label' => __('Add searchform to navigation bar.', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_searchform]', 'type' => 'checkbox'));
    // Navbar Colors
    $wp_customize->add_control('the_bootstrap_navbar_inverse', array('label' => __('Use inverse color on navigation bar.', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_inverse]', 'type' => 'checkbox'));
    // Navbar Position
    $wp_customize->add_control('the_bootstrap_navbar_position', array('label' => __('Navigation Bar Position', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_position]', 'type' => 'radio', 'choices' => array('static' => __('Static.', 'the-bootstrap'), 'navbar-fixed-top' => __('Fixed on top.', 'the-bootstrap'), 'navbar-fixed-bottom' => __('Fixed at bottom.', 'the-bootstrap'))));
    // New special control <ir> ##########################################################
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'link_color', array('label' => __('Color del fondo', 'the_bootstrap'), 'section' => 'colors', 'settings' => 'special_background_color')));
    // New special control <ir> ##########################################################
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'link_color2', array('label' => __('Color del menú', 'the_bootstrap'), 'section' => 'colors', 'settings' => 'special_menu_color')));
    // New special control <ir> ##########################################################
    $wp_customize->add_control('special_title_align', array('choices' => array('left' => 'Izquierda', 'center' => 'Centrar', 'right' => 'Derecha'), 'label' => __('Alineación del título'), 'section' => 'title_tagline', 'type' => 'select'));
    // New special control <ir> ##########################################################
    $wp_customize->add_control('special_menu_align', array('choices' => array('left' => 'Izquierda', 'center' => 'Centrar', 'right' => 'Derecha'), 'label' => __('Alineación del menú principal'), 'section' => 'the_bootstrap_navbar_options', 'type' => 'select'));
    // New special control <ir> ##########################################################
    $wp_customize->add_control('special_sidebar', array('label' => __('Barra lateral'), 'section' => 'the_bootstrap_theme_layout', 'type' => 'checkbox'));
}
/**
 * Registers the theme setting controls with the Theme Customizer
 * 
 * @author	Konstantin Obenland
 * @since	1.4.0 - 05.05.2012
 * 
 * @param	WP_Customize	$wp_customize
 * 
 * @return	void
 */
function the_bootstrap_customize_register($wp_customize)
{
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    $wp_customize->add_section('the_bootstrap_theme_layout', array('title' => __('Layout', 'the-bootstrap'), 'priority' => 99));
    $wp_customize->add_section('the_bootstrap_navbar_options', array('title' => __('Navbar Options', 'the-bootstrap'), 'priority' => 101));
    // Add settings
    foreach (array_keys(the_bootstrap_get_default_theme_options()) as $setting) {
        $wp_customize->add_setting("the_bootstrap_theme_options[{$setting}]", array('default' => the_bootstrap_options()->{$setting}, 'type' => 'option', 'transport' => 'postMessage'));
    }
    // Theme Layout
    $wp_customize->add_control('the_bootstrap_theme_layout', array('label' => __('Default Layout', 'the-bootstrap'), 'section' => 'the_bootstrap_theme_layout', 'settings' => 'the_bootstrap_theme_options[theme_layout]', 'type' => 'radio', 'choices' => array('content-sidebar' => __('Content on left', 'the-bootstrap'), 'sidebar-content' => __('Content on right', 'the-bootstrap'))));
    // Sitename in Navbar
    $wp_customize->add_control('the_bootstrap_navbar_site_name', array('label' => __('Add site name to navigation bar.', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_site_name]', 'type' => 'checkbox'));
    // Searchform in Navbar
    $wp_customize->add_control('the_bootstrap_navbar_searchform', array('label' => __('Add searchform to navigation bar.', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_searchform]', 'type' => 'checkbox'));
    // Navbar Colors
    $wp_customize->add_control('the_bootstrap_navbar_inverse', array('label' => __('Use inverse color on navigation bar.', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_inverse]', 'type' => 'checkbox'));
    // Navbar Position
    $wp_customize->add_control('the_bootstrap_navbar_position', array('label' => __('Navigation Bar Position', 'the-bootstrap'), 'section' => 'the_bootstrap_navbar_options', 'settings' => 'the_bootstrap_theme_options[navbar_position]', 'type' => 'radio', 'choices' => array('static' => __('Static.', 'the-bootstrap'), 'navbar-fixed-top' => __('Fixed on top.', 'the-bootstrap'), 'navbar-fixed-bottom' => __('Fixed at bottom.', 'the-bootstrap'))));
}
 /**
  * Register the theme customizations.
  *
  * @param WP_Customize $wp_customize The theme customization object.
  * @return void
  */
 public function register($wp_customize)
 {
     foreach ($this->_sections as $section) {
         $wp_customize->add_section($section['id'], array('title' => $section['label'], 'priority' => $section['priority']));
         foreach ($section['settings'] as $setting) {
             $value = get_theme_mod($setting['key']);
             $wp_customize->add_setting($setting['key'], array('default' => $setting['default'], 'transport' => $setting['transport']));
             $wp_customize->add_control(new $setting['type']($wp_customize, $setting['key'], array('label' => $setting['label'], 'section' => $section['id'], 'settings' => $setting['key'], 'priority' => $setting['priority'])));
         }
     }
     $this->appendCustomizerScripts($wp_customize);
 }