get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
}
/**
* Registers all theme related options to the Customizer.
*/
add_action( 'customize_register', 'alstromeria_customize_register' );
function alstromeria_customizer( $wp_customize ) {
class alstromeria_image_radio_control extends WP_Customize_Control {
public function render_content() {
if ( empty( $this->choices ) )
return;
$name = '_customize-radio-' . $this->id;
?>
label ); ?>
add_panel ('alstromeria_panel', array(
'title' => __('alstromeria Theme Options', 'alstromeria'),
'priority' => '1'));
// add new section
$wp_customize->add_section( 'alstromeria_theme_colors', array(
'panel' => 'alstromeria_panel',
'title' => __( 'Theme Colors', 'alstromeria' ),
'priority' => 2,
) );
//primary colors option
$wp_customize->add_setting( 'link_color', array(
'sanitize_callback' => 'alstromeria_sanitize_hexcolor',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
'label' => __( 'primary colors', 'alstromeria' ),
'section' => 'alstromeria_theme_colors',
'settings' => 'link_color',
) ) );
//Custom css
class alstromeria_custom_css_Control extends WP_Customize_Control {
public $type = 'custom_css';
public function render_content() {
?>
add_section( 'alstromeria_sidebar_position', array(
'panel' => 'alstromeria_panel',
'title' => __( 'Layout Design', 'alstromeria' ),
'priority' => 2,
) );
$wp_customize->add_setting('alstromeria_sidebar_position', array(
'default' => 'left',
'sanitize_callback' => 'alstromeria_sanitize_layout',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'alstromeria_sidebar_position',
array(
'label' => __( 'Select sidebar position', 'alstromeria' ),
'section' => 'alstromeria_sidebar_position',
'settings' => 'alstromeria_sidebar_position',
'type' => 'select',
'choices' => array(
'right' => __( 'Left','alstromeria' ),
'left' => __( 'Right','alstromeria' ),
'none'=> __( 'No Sidebar','alstromeria' ),
'boxed'=> __( 'Boxed Layout','alstromeria' ),
)
)
)
);
$wp_customize->add_setting( 'alstromeria_lite_color_message',
array(
'sanitize_callback' => 'alstromeria_lite_sanitize_text'
)
);
$wp_customize->add_control( new alstromeria_Lite_Misc_Control( $wp_customize, 'alstromeria_lite_color_message',
array(
'section' => 'colors',
'type' => 'custom_message',
)
));
$wp_customize->add_section( 'alstromeria_content_setting', array(
'panel' => 'alstromeria_panel',
'title' => __( 'Content Options', 'alstromeria' ),
) );
// Embed JS file for Customizer Controls
add_action( 'customize_controls_enqueue_scripts', 'dynamicnews_customize_controls_js' );
//Show or hide Post excerp
$wp_customize->add_setting(
'bl_post_excerpt' , array(
'default' => 1,
'sanitize_callback' => 'alstromeria_sanitize_checkbox',
)
);
$wp_customize->add_control(
new alstromeria_Customizer_Switcher_Control(
$wp_customize,
'bl_post_excerpt', array(
'label' => __('Post Excerpt','alstromeria'),
'section' => 'alstromeria_content_setting',
)
)
);
//Post excerp length
$wp_customize->add_setting( 'excerpt_length', array(
'default' => 55,
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( 'excerpt_length', array(
'type' => 'number',
'input_attrs' => array(
'min' => 10,
'step' => 1,
),
'section' => 'alstromeria_content_setting',
'label' => esc_html__( 'Excerpt Length', 'alstromeria' ),
) );
//Footer copyright text
$wp_customize->add_section( 'footer_Copyright', array(
'title' => __( 'Footer Copyright', 'alstromeria' ),
'priority' => 70,
) );
$wp_customize->add_setting( 'Copyright_text', array(
'sanitize_callback' => 'alstromeria_sanitize_text'
) );
$wp_customize->add_control('Copyright_text', array(
'type' => 'textarea',
'label' => __('Footer Copyright', 'alstromeria'),
'section' => 'footer_Copyright',
'settings' => 'Copyright_text',
) );
//Header background color
$wp_customize->add_setting( 'head_back_color', array(
'sanitize_callback' => 'alstromeria_sanitize_hexcolor',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'head_back_color', array(
'label' => __( 'Header Background', 'alstromeria' ),
'section' => 'colors',
'settings' => 'head_back_color',
) ) );
}
add_action( 'customize_register', 'alstromeria_customizer' );
/**
* Sanitzie checkbox for WordPress customizer
*/
function alstromeria_sanitize_checkbox( $input ) {
if ( $input == 1 ) {
return 1;
} else {
return '';
}
}
/* Sanitize number */
function bl_sanitize_number( $int ) {
return absint( $int );
}
function alstromeria_lite_sanitize_text( $string ) {
return wp_kses_post( force_balance_tags( $string ) );
}
/**
*Sanitization callback function: colors
*/
function alstromeria_sanitize_hexcolor($color) {
if ($unhashed = sanitize_hex_color_no_hash($color))
return '#' . $unhashed;
return $color;
}
// Sanitize text
function alstromeria_sanitize_text( $input ) {
return strip_tags( $input);
}
/**
* Adds sanitization callback function: Sidebar Layout
*/
function alstromeria_sanitize_layout( $input ) {
$valid = array(
'right' => __( 'Left','alstromeria' ),
'left' => __( 'Right','alstromeria' ),
'none'=> __( 'No Sidebar','alstromeria' ),
'boxed'=> __( 'Boxed Layout','alstromeria' ),
);
if ( array_key_exists( $input, $valid ) ) {
return $input;
} else {
return '';
}
}
function alstromeria_lite_customize_js() {
wp_enqueue_script( 'alstromeria_lite_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-controls' ), '20130508', true );
}
add_action( 'customize_controls_print_scripts', 'alstromeria_lite_customize_js' );