get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; //$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; /* ---------------- OPTIONS ------------------ */ $wp_customize->add_section( 'amiable_layout_options', array( 'title' => __( 'Page Layout', 'amiable' ), 'priority' => 1010, ) ); $wp_customize->add_section( 'amiable_menu_options', array( 'title' => __( 'Primary Menu', 'amiable' ), 'description' => 'Choose the setting for the primary menu on screens wider than 960px. On smaller screens this menu will be automatically collapsed.', 'priority' => 1020, ) ); $wp_customize->add_section( 'amiable_sidebar_options', array( 'title' => __( 'Sidebar', 'amiable' ), 'priority' => 1030, ) ); $wp_customize->add_setting( 'amiable_page_width', array( 'default' => '80', 'sanitize_callback' => 'amiable_sanitize_page_width', ) ); $wp_customize->add_setting( 'amiable_sidebar_width', array( 'default' => '30', 'sanitize_callback' => 'amiable_sanitize_sidebar_width', ) ); $wp_customize->add_setting( 'amiable_sidebar', array( 'default' => 'left', 'sanitize_callback' => 'amiable_sanitize_sidebar', ) ); $wp_customize->add_setting( 'amiable_link_color', array( 'default' => '#243444', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_setting( 'amiable_menu', array( 'default' => 'collapse', 'sanitize_callback' => 'amiable_sanitize_menu', ) ); $wp_customize->add_control( 'amiable_page_widths', array( 'label' => __( 'Page Width', 'amiable' ), 'section' => 'amiable_layout_options', 'settings' => 'amiable_page_width', 'type' => 'select', 'choices' => array( '70' => __( '70%', 'amiable' ), '80' => __( '80%', 'amiable' ), '90' => __( '90%', 'amiable' ), ), ) ); $wp_customize->add_control( 'amiable_sidebar_widths', array( 'label' => __( 'Sidebar Width', 'amiable' ), 'section' => 'amiable_layout_options', 'settings' => 'amiable_sidebar_width', 'type' => 'select', 'choices' => array( '25' => __( '25%', 'amiable' ), '30' => __( '30%', 'amiable' ), '33' => __( '33%', 'amiable' ), ), ) ); $wp_customize->add_control( 'amiable_sidebars', array( 'label' => __( 'Sidebar', 'amiable' ), 'section' => 'amiable_sidebar_options', 'settings' => 'amiable_sidebar', 'type' => 'select', 'choices' => array( 'left' => __( 'Left', 'amiable' ), 'right' => __( 'Right', 'amiable' ), ), ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link-color', array( 'label' => __( 'Link Color', 'amiable' ), 'section' => 'colors', 'settings' => 'amiable_link_color' ) ) ); $wp_customize->add_control( 'amiable_menus', array( 'label' => __( 'Primary Menu', 'amiable' ), 'section' => 'amiable_menu_options', 'settings' => 'amiable_menu', 'type' => 'select', 'choices' => array( 'expand' => __( 'Expanded', 'amiable' ), 'collapse' => __( 'Collapsed', 'amiable' ), ), ) ); } add_action( 'customize_register', 'amiable_customize_register' ); /* ---------------- SANITIZE FUNCTIONS ------------------ */ function amiable_sanitize_page_width( $value ) { if ( ! in_array( $value, array( '70', '80', '90' ) ) ) $value = '80'; return $value; } function amiable_sanitize_sidebar_width( $value ) { if ( ! in_array( $value, array( '25', '30', '33' ) ) ) $value = '30'; return $value; } function amiable_sanitize_sidebar( $value ) { if ( ! in_array( $value, array( 'left', 'right' ) ) ) $value = 'left'; return $value; } function amiable_sanitize_menu( $value ) { if ( ! in_array( $value, array( 'expand', 'collapse' ) ) ) $value = 'collapse'; return $value; } /* ---------------- ADD STYLES TO HEAD SECTION ------------------ */ function amiable_customized_styles() { $gutter = '7'; $sidebar = get_theme_mod( 'amiable_sidebar_width', '30' ); $content = '100'; $content = $content - $gutter; $content = $content - $sidebar; $link = get_theme_mod( 'amiable_link_color','#243444' ); $menu = get_theme_mod( 'amiable_menu','expand' ); ?>