$default_background_color, ) ) ); add_theme_support( 'custom-header', apply_filters( 'bloging_custom_header_args', array( 'default-text-color' => $default_text_color, 'width' => 1200, 'height' => 280, 'flex-height' => true, 'wp-head-callback' => 'bloging_header_style', ) ) ); } add_action( 'after_setup_theme', 'bloging_custom_header_and_background' ); if ( ! function_exists( 'bloging_header_style' ) ) : function bloging_header_style() { if ( display_header_text() ) { return; } ?> get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'container_inclusive' => false, 'render_callback' => 'bloging_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'container_inclusive' => false, 'render_callback' => 'bloging_customize_partial_blogdescription', ) ); } $wp_customize->add_setting( 'color_scheme', array( 'default' => 'default', 'sanitize_callback' => 'bloging_sanitize_color_scheme', 'transport' => 'postMessage', ) ); $wp_customize->remove_control( 'header_textcolor' ); $wp_customize->add_setting( 'link_color', array( 'default' => $color_scheme[2], 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array( 'label' => __( 'Link Color', 'bloging' ), 'section' => 'colors', ) ) ); $wp_customize->add_setting( 'main_text_color', array( 'default' => $color_scheme[3], 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'main_text_color', array( 'label' => __( 'Main Text Color', 'bloging' ), 'section' => 'colors', ) ) ); $wp_customize->add_setting( 'secondary_text_color', array( 'default' => $color_scheme[4], 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondary_text_color', array( 'label' => __( 'Secondary Text Color', 'bloging' ), 'section' => 'colors', ) ) ); /* Main option Settings Panel */ $wp_customize->add_panel('bloging_main_options', array( 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Bloging Options', 'bloging'), 'description' => __('Panel to update bloging theme options', 'bloging'), // Include html tags such as
.
'priority' => 10 // Mixed with top-level-section hierarchy.
));
/* bloging Header Options */
$wp_customize->add_section('bloging_header_options', array(
'title' => __('Header', 'bloging'),
'priority' => 31,
'panel' => 'bloging_main_options'
));
$wp_customize->add_setting('bloging[sticky_header]', array(
'default' => 0,
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_checkbox'
));
$wp_customize->add_control('bloging[sticky_header]', array(
'label' => __('Sticky Header', 'bloging'),
'description' => sprintf(__('Check to show fixed header', 'bloging')),
'section' => 'bloging_header_options',
'type' => 'checkbox',
));
$wp_customize->add_setting('bloging[nav_bg_color]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[nav_bg_color]', array(
'label' => __('Top nav background color', 'bloging'),
'description' => __('Default used if no color is selected','bloging'),
'section' => 'bloging_header_options',
)));
$wp_customize->add_setting('bloging[nav_link_color]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[nav_link_color]', array(
'label' => __('Top nav item color', 'bloging'),
'description' => __('Link color','bloging'),
'section' => 'bloging_header_options',
)));
$wp_customize->add_setting('bloging[nav_dropdown_bg]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[nav_dropdown_bg]', array(
'label' => __('Top nav dropdown background color', 'bloging'),
'description' => __('Background of dropdown item hover color','bloging'),
'section' => 'bloging_header_options',
)));
$wp_customize->add_setting('bloging[nav_dropdown_item]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[nav_dropdown_item]', array(
'label' => __('Top nav dropdown item color', 'bloging'),
'description' => __('Dropdown item color','bloging'),
'section' => 'bloging_header_options',
)));
/* bloging Footer Options */
$wp_customize->add_section('bloging_footer_options', array(
'title' => __('Footer', 'bloging'),
'priority' => 31,
'panel' => 'bloging_main_options'
));
$wp_customize->add_setting('bloging[footer_widget_bg_color]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[footer_widget_bg_color]', array(
'label' => __('Footer widget area background color', 'bloging'),
'section' => 'bloging_footer_options',
)));
$wp_customize->add_setting('bloging[footer_bg_color]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[footer_bg_color]', array(
'label' => __('Footer background color', 'bloging'),
'section' => 'bloging_footer_options',
)));
$wp_customize->add_setting('bloging[footer_text_color]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[footer_text_color]', array(
'label' => __('Footer text color', 'bloging'),
'section' => 'bloging_footer_options',
)));
$wp_customize->add_setting('bloging[footer_link_color]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_color'
));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloging[footer_link_color]', array(
'label' => __('Footer link color', 'bloging'),
'section' => 'bloging_footer_options',
)));
$wp_customize->add_setting('bloging[custom_footer_text]', array(
'default' => '',
'type' => 'option',
'sanitize_callback' => 'bloging_sanitize_strip_slashes'
));
$wp_customize->add_control('bloging[custom_footer_text]', array(
'label' => __('Footer information', 'bloging'),
'description' => sprintf(__('Copyright text in footer', 'bloging')),
'section' => 'bloging_footer_options',
'type' => 'textarea'
));
}
add_action( 'customize_register', 'bloging_customize_register', 11 );
function bloging_customize_partial_blogname() {
bloginfo( 'name' );
}
function bloging_customize_partial_blogdescription() {
bloginfo( 'description' );
}
function bloging_get_color_schemes() {
return apply_filters( 'bloging_color_schemes', array(
'default' => array(
'label' => __( 'Default', 'bloging' ),
'colors' => array(
'#f7f7f7',
'#ffffff',
'#007acc',
'#1a1a1a',
'#686868',
),
),
) );
}
if ( ! function_exists( 'bloging_get_color_scheme' ) ) :
function bloging_get_color_scheme() {
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
$color_schemes = bloging_get_color_schemes();
if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
return $color_schemes[ $color_scheme_option ]['colors'];
}
return $color_schemes['default']['colors'];
}
endif;
if ( ! function_exists( 'bloging_get_color_scheme_choices' ) ) :
function bloging_get_color_scheme_choices() {
$color_schemes = bloging_get_color_schemes();
$color_scheme_control_options = array();
foreach ( $color_schemes as $color_scheme => $value ) {
$color_scheme_control_options[ $color_scheme ] = $value['label'];
}
return $color_scheme_control_options;
}
endif;
if ( ! function_exists( 'bloging_sanitize_color_scheme' ) ) :
function bloging_sanitize_color_scheme( $value ) {
$color_schemes = bloging_get_color_scheme_choices();
if ( ! array_key_exists( $value, $color_schemes ) ) {
return 'default';
}
return $value;
}
endif;
function bloging_color_scheme_css() {
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
if ( 'default' === $color_scheme_option ) {
return;
}
$color_scheme = bloging_get_color_scheme();
$color_textcolor_rgb = bloging_hex2rgb( $color_scheme[3] );
if ( empty( $color_textcolor_rgb ) ) {
return;
}
$colors = array(
'background_color' => $color_scheme[0],
'page_background_color' => $color_scheme[1],
'link_color' => $color_scheme[2],
'main_text_color' => $color_scheme[3],
'secondary_text_color' => $color_scheme[4],
'border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.2)', $color_textcolor_rgb ),
);
$color_scheme_css = bloging_get_color_scheme_css( $colors );
wp_add_inline_style( 'bloging-style', $color_scheme_css );
}
add_action( 'wp_enqueue_scripts', 'bloging_color_scheme_css' );
function bloging_customize_control_js() {
wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20160816', true );
wp_localize_script( 'color-scheme-control', 'colorScheme', bloging_get_color_schemes() );
}
add_action( 'customize_controls_enqueue_scripts', 'bloging_customize_control_js' );
function bloging_customize_preview_js() {
wp_enqueue_script( 'bloging-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20160816', true );
}
add_action( 'customize_preview_init', 'bloging_customize_preview_js' );
function bloging_get_color_scheme_css( $colors ) {
$colors = wp_parse_args( $colors, array(
'background_color' => '',
'page_background_color' => '',
'link_color' => '',
'main_text_color' => '',
'secondary_text_color' => '',
'border_color' => '',
) );
return <<