コード例 #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->add_section('the_bootstrap_theme_options', array('title' => __('Theme Options', 'the-bootstrap'), 'priority' => 99));
    // 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_options', '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_theme_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_theme_options', 'settings' => 'the_bootstrap_theme_options[navbar_searchform]', 'type' => 'checkbox'));
    // Navbar Position
    $wp_customize->add_control('the_bootstrap_navbar_position', array('label' => __('Navigation Bar Position', 'the-bootstrap'), 'section' => 'the_bootstrap_theme_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'))));
}
コード例 #2
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'));
}
コード例 #3
0
/**
 * Returns the options object for The Bootstrap.
 *
 * @author	Automattic
 * @since	1.3.0 - 06.04.2012
 *
 * @return	stdClass	Theme Options
 */
function the_bootstrap_options()
{
    return (object) wp_parse_args(get_option('the_bootstrap_theme_options', array()), the_bootstrap_get_default_theme_options());
}
コード例 #4
0
/**
 * Sanitize and validate form input. Accepts an array, return a sanitized array.
 *
 * @see the_bootstrap_theme_options_init()
 *
 * @author	Automattic
 * @since	1.3.0 - 06.04.2012
 * 
 * @return	void
 */
function the_bootstrap_theme_options_validate($input)
{
    $output = $defaults = the_bootstrap_get_default_theme_options();
    if (isset($input['theme_layout']) and array_key_exists($input['theme_layout'], the_bootstrap_layouts())) {
        $output['theme_layout'] = $input['theme_layout'];
    }
    $output['navbar_site_name'] = (bool) $input['navbar_site_name'];
    $output['navbar_searchform'] = (bool) $input['navbar_searchform'];
    if (!get_settings_errors()) {
        add_settings_error('the-bootstrap-options', 'settings_updated', sprintf(__('Settings saved. <a href="%s">Visit your site</a> to see how it looks.', 'the-bootstrap'), home_url('/')), 'updated');
    }
    return apply_filters('the_bootstrap_theme_options_validate', $output, $input, $defaults);
}