$default_background_color,
) ) );
/**
* Filter the arguments used when adding 'custom-header' support in car dealer.
*
* @since car dealer 1.0
*
* @param array $args {
* An array of custom-header support arguments.
*
* @type string $default-text-color Default color of the header text.
* @type int $width Width in pixels of the custom header image. Default 1200.
* @type int $height Height in pixels of the custom header image. Default 280.
* @type bool $flex-height Whether to allow flexible-height header images. Default true.
* @type callable $wp-head-callback Callback function used to style the header image and text
* displayed on the blog.
* }
*/
add_theme_support( 'custom-header', apply_filters( 'kardealer_custom_header_args', array(
'default-text-color' => $default_text_color,
'width' => 1200,
'height' => 280,
'flex-height' => true,
'wp-head-callback' => 'kardealer_header_style',
) ) );
}
add_action( 'after_setup_theme', 'kardealer_custom_header_and_background' );
if ( ! function_exists( 'kardealer_header_style' ) ) :
/**
* Styles the header text displayed on the site.
*
* Create your own kardealer_header_style() function to override in a child theme.
*
* @since car dealer 1.0
*
* @see kardealer_custom_header_and_background().
*/
function kardealer_header_style() {
// If the header text option is untouched, let's bail.
if ( display_header_text() ) {
return;
}
// If the header text has been hidden.
?>
add_panel( 'settings', array(
'title' => 'Settings',
'description' => 'Settings Panel',
'priority' => 20,
) );
$wp_customize->add_panel( 'general', array(
'title' => 'Theme Options',
'description' => 'General Settings Panel',
'priority' => 10,
) );
// Margin-logo
$wp_customize->add_setting( 'kardealer_logo_margin_top', array(
'sanitize_callback' =>'kardealer_sanitize_text',
'default' => '00'
) );
$wp_customize->add_control( 'kardealer_logo_margin_top', array(
'label' => __( 'Branding Margin From Top','kardealer' ),
'section' => 'title_tagline',
'type' => 'range',
'description' => __( 'Choose from -20px to 100px', 'kardealer' ),
'priority' => 9,
'input_attrs' => array(
'min' => -20,
'max' => 100,
'step' => 10
),
) );
// Lay Out
$wp_customize->add_section(
'general_settings_section',
array(
'title' => __( 'Layout', 'kardealer' ),
'priority' => 1,
'capability' => 'edit_theme_options',
'description' => __('Change General options here.', 'kardealer'),
'panel' => 'general', )
);
$wp_customize->add_setting('kardealer_entry_title', array(
'sanitize_callback' =>'kardealer_sanitize_checkbox',
'default' => '1',
));
$wp_customize->add_control(
'kardealer_entry_title',
array(
'settings' => 'kardealer_entry_title',
'section' => 'general_settings_section',
'type' => 'checkbox',
'label' => __( 'Show entry-title', 'kardealer' ),
'description' => '',
)
);
$wp_customize->add_setting('kardealer_show_sidebar_singlepage', array(
'sanitize_callback' =>'kardealer_sanitize_checkbox',
'default' => '1'
));
$wp_customize->add_control(
'kardealer_show_sidebar_singlepage',
array(
'settings' => 'kardealer_show_sidebar_singlepage',
'section' => 'general_settings_section',
'type' => 'checkbox',
'label' => __( 'Show Sidebar at blog homepage.', 'kardealer' ),
'description' => '',
'sanitize_callback' => 'kardealer_sanitize_checkbox',
)
);
$wp_customize->add_setting('kardealer_layout_type', array(
'sanitize_callback' =>'kardealer_sanitize_text',
'default' => '2'
));
$wp_customize->add_control(
'kardealer_layout_type',
array(
'settings' => 'kardealer_layout_type',
'section' => 'general_settings_section',
'type' => 'radio',
'label' => __( 'Website Layout', 'kardealer' ) ,
'description' => '',
'choices' => array(
'1' => 'Boxed Width 1000px',
'2' => 'Wide'
)
)
);
$wp_customize->add_setting( 'kardealer_opacity',
array(
'default' => '10',
'sanitize_callback' => 'kardealer_sanitize_number', )
);
$wp_customize->add_control( 'kardealer_opacity', array(
'type' => 'range',
'section' => 'general_settings_section',
'label' => __( 'Background transparency (opacity)', 'kardealer' ),
'description' => __( 'Choose from .6 to 1', 'kardealer' ),
'sanitize_callback' => 'kardealer_sanitize_number',
'input_attrs' => array(
'min' => 6,
'max' => 10,
'step' => 1,
),
) );
// Top Header Settings
$wp_customize->add_section(
'top_header_settings_section',
array(
'title' => __( 'Top Header Settings', 'kardealer' ),
'priority' => 81,
'capability' => 'edit_theme_options',
'description' => '',
'panel' => 'general',
)
);
$wp_customize->add_setting('kardealer_show_top_header', array(
'sanitize_callback' =>'kardealer_sanitize_text',
'default' => ''
));
$wp_customize->add_control(
'kardealer_show_top_header',
array(
'settings' => 'kardealer_show_top_header',
'section' => 'top_header_settings_section',
'type' => 'checkbox',
'label' => __( 'Show', 'kardealer' ),
'description' => __( 'Show Top Header Info (email, phone, hours) and Social Media Menu at top header.', 'kardealer' ),
'sanitize_callback' => 'kardealer_sanitize_checkbox',
)
);
$wp_customize->add_setting('kardealer_topinfo_phone', array(
'sanitize_callback' =>'kardealer_sanitize_html',
'default' => '',
));
$wp_customize->add_control('kardealer_topinfo_phone', array(
'label' => __( 'Top Info Phone', 'kardealer' ),
'section' => 'top_header_settings_section',
'type' => 'text',
));
$wp_customize->add_setting('kardealer_topinfo_email', array(
'sanitize_callback' =>'kardealer_sanitize_email',
'default' => '',
));
$wp_customize->add_control('kardealer_topinfo_email', array(
'label' => __( 'Top Info eMail', 'kardealer' ),
'section' => 'top_header_settings_section',
'type' => 'text',
));
$wp_customize->add_setting('kardealer_topinfo_hours', array(
'sanitize_callback' =>'kardealer_sanitize_html',
'default' => '',
));
$wp_customize->add_control('kardealer_topinfo_hours', array(
'label' => __( 'Top Info Hours', 'kardealer' ),
'section' => 'top_header_settings_section',
'type' => 'text',
));
$wp_customize->add_setting( 'kardealer_topinfo_color',
array(
'default' => '#808080',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_topinfo_color', array(
'label' => __( 'Header Top Info Color', 'kardealer' ),
'section' => 'top_header_settings_section',
'settings' => 'kardealer_topinfo_color',
'priority' => 60,
)
)
);
// End Top Page Settings
// Header Settings
$wp_customize->add_section(
'header_settings_section',
array(
'title' => __( 'Header Settings', 'kardealer' ),
'priority' => 100,
'capability' => 'edit_theme_options',
'description' => 'Configure Header Bottom 1px Border and Header Background Color.',
'panel' => 'general',
)
);
$wp_customize->add_setting( 'kardealer_header_background_color',
array(
'default' => '#333333',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_copyright_color', array(
'label' => __( 'Header Background Color', 'kardealer' ),
'section' => 'header_settings_section',
'settings' => 'kardealer_header_background_color',
'priority' => 10,
)
)
);
$wp_customize->add_setting('kardealer_header_border', array(
'sanitize_callback' =>'kardealer_sanitize_checkbox',
'default' => '',
));
$wp_customize->add_control(
'kardealer_header_border',
array(
'settings' => 'kardealer_header_border',
'section' => 'header_settings_section',
'type' => 'checkbox',
'label' => __( 'Show border', 'kardealer' ),
'description' => '',
// )
)
);
$wp_customize->add_setting( 'kardealer_header_border_color',
array(
'default' => '#f1f1f1',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_header_border_color', array(
'label' => __( 'Header Bottom Border Color', 'kardealer' ),
'section' => 'header_settings_section',
'settings' => 'kardealer_header_border_color',
'priority' => 20,
)
)
);
$wp_customize->add_setting( 'kardealer_header_background_color',
array(
'default' => '#f1f1f1',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_header_background_color', array(
'label' => __( 'Header Background Color', 'kardealer' ),
'section' => 'header_settings_section',
'settings' => 'kardealer_header_background_color',
'priority' => 20,
)
)
);
$wp_customize->add_setting( 'kardealer_header_text_color',
array(
'default' => '#000000',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_header_text_color', array(
'label' => __( 'Header Text Color', 'kardealer' ),
'section' => 'header_settings_section',
'settings' => 'kardealer_header_text_color',
'priority' => 40,
)
)
);
// WooCommerce
$all_plugins = apply_filters('active_plugins', get_option('active_plugins'));
if (stripos(implode($all_plugins), 'woocommerce.php')) {
$wp_customize->add_setting( 'kardealer_header_cart_color',
array(
'default' => '#000000',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_header_cart_color', array(
'label' => __( 'Shopping Cart Text Color', 'kardealer' ),
'section' => 'header_settings_section',
'settings' => 'kardealer_header_cart_color',
'description' => 'If you use WooCommerce plugin',
'priority' => 40,
)
)
);
}
/* End Header */
/////////// Navigation Details
$wp_customize->add_section(
'navigation_colors_section',
array(
'title' => __( 'Main Navigation Design', 'kardealer' ),
'priority' => 101,
'capability' => 'edit_theme_options',
'panel' => 'general',
'description' => __('Change Navigation detais here.', 'kardealer'),
)
);
$wp_customize->add_setting( 'kardealer_menu_margin_top',
array(
'default' => '30',
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control( 'kardealer_menu_margin_top', array(
'type' => 'range',
'section' => 'navigation_colors_section',
'label' => __( 'Menu Margin Top', 'kardealer' ),
'description' => __( 'Choose from -20 to 50 Pixels.', 'kardealer' ),
'input_attrs' => array(
'min' => -20,
'max' => 50,
'step' => 1,
),
) );
$wp_customize->add_setting( 'kardealer_menu_margin_right',
array(
'default' => '0',
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control( 'kardealer_menu_margin_right', array(
'type' => 'range',
'section' => 'navigation_colors_section',
'label' => __( 'Menu Margin Right', 'kardealer' ),
'description' => __( 'Choose from -20 to 30 Pixels.', 'kardealer' ),
'input_attrs' => array(
'min' => -20,
'max' => 30,
'step' => 1,
),
) );
$wp_customize->add_setting( 'menu_font_size',
array(
'default' => '16',
'sanitize_callback' => 'kardealer_sanitize_number', )
);
$wp_customize->add_control( 'menu_font_size', array(
'type' => 'range',
'section' => 'navigation_colors_section',
'label' => __( 'Menu Font Size', 'kardealer' ),
'description' => __( 'Choose from 12 to 20 Pixels.', 'kardealer' ),
'sanitize_callback' => 'kardealer_sanitize_number',
'input_attrs' => array(
'min' => 12,
'max' => 20,
'step' => 1,
),
) );
$wp_customize->add_setting( 'kardealer_navigation_background',
array(
'default' => '#e65e23',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_navigation_background', array(
'label' =>__( 'Background Navigation Color', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_navigation_background',
'priority' => 10,
)
)
);
$wp_customize->add_setting( 'kardealer_menu_color',
array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_menu_color', array(
'label' =>__( 'Menu Text Color', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_menu_color',
'priority' => 10,
)
)
);
$wp_customize->add_setting( 'kardealer_menu_hover_color',
array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_menu_hover_color', array(
'label' =>__( 'Menu Text Hover Color', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_menu_hover_color',
'priority' => 10,
)
)
);
$wp_customize->add_setting( 'kardealer_submenu_background',
array(
'default' => '#e65e23',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_submenu_background', array(
'label' =>__( 'Sub Menu Background', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_submenu_background',
'priority' => 10,
)
)
);
$wp_customize->add_setting( 'kardealer_submenu_color',
array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_submenu_color', array(
'label' =>__( 'Sub Menu Text Color', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_submenu_color',
'priority' => 10,
)
)
);
$wp_customize->add_setting( 'kardealer_submenu_hover_color',
array(
'default' => '#e65e23',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_submenu_hover_color', array(
'label' =>__( 'Sub Menu Hover color', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_submenu_hover_color',
'priority' => 10,
)
)
);
$wp_customize->add_setting( 'kardealer_submenu_hover_background',
array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_submenu_hover_background', array(
'label' =>__( 'Sub Menu Hover Background', 'kardealer' ),
'section' => 'navigation_colors_section',
'settings' => 'kardealer_submenu_hover_background',
'priority' => 10,
)
)
);
/////////// End Navigation Colors
/////////// Social Menu
$wp_customize->add_section(
'social_navigation_section',
array(
'title' => __( 'Social Navigation Design', 'kardealer' ),
'priority' => 101,
'capability' => 'edit_theme_options',
'panel' => 'general',
'description' => '',
)
);
$wp_customize->add_setting( 'kardealer_social_menu', array(
'default' =>'White' ,
'sanitize_callback' =>'kardealer_sanitize_text',
));
$wp_customize->add_control(
'kardealer_social_menu',
array(
'settings' => 'kardealer_social_menu',
'section' => 'social_navigation_section',
'type' => 'radio',
'label' => __( 'Social Menu Color', 'kardealer' ),
'description' => '',
'choices' => array(
'white' => __( 'White', 'kardealer' ),
'lightgray' => __( 'Gray', 'kardealer' ),
'darkgray' => __( 'Dark', 'kardealer' )
)
)
);
// End Social
// Footer
$wp_customize->add_section(
'footer_settings_section',
array(
'title' => __( 'Footer Copyright', 'kardealer' ),
'priority' => 100,
'capability' => 'edit_theme_options',
'description' => '',
'panel' => 'general',
)
);
$wp_customize->add_setting('kardealer_footer_copyright', array(
'sanitize_callback' =>'kardealer_sanitize_html',
'default' => '',
));
$wp_customize->add_control('kardealer_footer_copyright', array(
'label' => __( 'Copyright Footer Text Here', 'kardealer' ),
'section' => 'footer_settings_section',
'type' => 'textarea',
));
$wp_customize->add_setting( 'kardealer_copyright_background',
array(
'default' => '#f1f1f1',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_copyright_background', array(
'label' => __( 'Copyright Background Color', 'kardealer' ),
'section' => 'footer_settings_section',
'settings' => 'kardealer_copyright_background',
'priority' => 50,
)
)
);
$wp_customize->add_setting( 'kardealer_copyright_color',
array(
'default' => '#333333',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'kardealer_copyright_color', array(
'label' => __( 'Copyright Text Color', 'kardealer' ),
'section' => 'footer_settings_section',
'settings' => 'kardealer_copyright_color',
'priority' => 60,
)
)
);
//First Footer Widget
//1-footer
function kardealer_is_sidebar_active($index) {
global $wp_registered_sidebars;
$widgetcolums = wp_get_sidebars_widgets();
if ($widgetcolums[$index])
return true;
return false;
}
if ( function_exists('kardealer_is_sidebar_active')) {
if( kardealer_is_sidebar_active('1-footer') or kardealer_is_sidebar_active('2-footer') or kardealer_is_sidebar_active('3-footer') ) {
$wp_customize->add_section(
'footer_background_section',
array(
'title' => __( 'Footer Background', 'kardealer' ),
'priority' => 100,
'capability' => 'edit_theme_options',
'description' => '',
'panel' => 'general',
)
);
$wp_customize->add_setting( 'kardealer_footer_background', array(
'default' =>'White' ,
'sanitize_callback' =>'kardealer_sanitize_text',
));
$wp_customize->add_control(
'kardealer_footer_background',
array(
'settings' => 'kardealer_footer_background',
'section' => 'footer_background_section',
'type' => 'radio',
'label' => __( 'Footer Background Color', 'kardealer' ),
'description' => 'To see the footer, you need add some widget there.',
'choices' => array(
'white' => __( 'White', 'kardealer' ),
'lightgray' => __( 'Gray', 'kardealer' ),
'darkgray' => __( 'Dark', 'kardealer' )
)
)
);
}
}
/* End Footer */
/* Sanitize with absint */
function kardealer_sanitize_phone ( $str ) {
$str = sanitize_text_field( $str );
if(empty ($str))
return "";
$str = sanitize_text_field( $str );
$size = strlen($str);
$r = '';
for($i=0; $i < $size; $i++)
{
$w = substr($str, $i, 1);
if($w != '.' and $w != '-')
$w = absint($w);
$r .= $w;
}
Return $r;
}
function kardealer_sanitize_html( $str ) {
$allowed_html = array(
'a' => array(
'href' => true,
'title' => true,
),
'abbr' => array(
'title' => true,
),
'acronym' => array(
'title' => true,
),
'b' => array(),
'blockquote' => array(
'cite' => true,
),
'cite' => array(),
'code' => array(),
'del' => array(
'datetime' => true,
),
'em' => array(),
'i' => array(),
'q' => array(
'cite' => true,
),
'strike' => array(),
'strong' => array(),
);
wp_kses($str, $allowed_html);
return $str ;
}
function kardealer_sanitize_url( $str ) {
return esc_url( $str );
}
function kardealer_sanitize_text( $str ) {
return sanitize_text_field( $str );
}
function kardealer_sanitize_number( $str ) {
return sanitize_text_field( $str );
}
function kardealer_sanitize_textarea( $text ) {
return esc_textarea( $text );
}
function kardealer_sanitize_email( $text ) {
return sanitize_email( $text );
}
function kardealer_sanitize_checkbox( $input ) {
return absint($input);
}
}
//add_action( 'after_setup_theme', 'kardealer_custom_site' );
add_action( 'customize_register', 'kardealer_custom_site', 11 );
if ( ! function_exists( 'kardealer_header_style' ) ) :
/**
* Styles the header text displayed on the site.
*
* Create your own kardealer_header_style() function to override in a child theme.
*
* @since car dealer 1.0
*
* @see kardealer_custom_header_and_background().
*/
function kardealer_header_style() {
// If the header text option is untouched, let's bail.
if ( display_header_text() ) {
return;
}
// If the header text has been hidden.
?>
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' => 'kardealer_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'container_inclusive' => false,
'render_callback' => 'kardealer_customize_partial_blogdescription',
) );
}
// Add color scheme setting and control.
$wp_customize->add_setting( 'color_scheme', array(
'default' => 'default',
'sanitize_callback' => 'kardealer_sanitize_color_scheme',
'transport' => 'postMessage',
) );
$wp_customize->add_control( 'color_scheme', array(
'label' => __( 'Base Color Scheme', 'kardealer' ),
'section' => 'colors',
'type' => 'select',
'choices' => kardealer_get_color_scheme_choices(),
'priority' => 1,
) );
// Add page background color setting and control.
$wp_customize->add_setting( 'page_background_color', array(
'default' => $color_scheme[1],
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'postMessage',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'page_background_color', array(
'label' => __( 'Page Background Color', 'kardealer' ),
'section' => 'colors',
) ) );
// Remove the core header textcolor control, as it shares the main text color.
$wp_customize->remove_control( 'header_textcolor' );
// Add link color setting and control.
$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', 'kardealer' ),
'section' => 'colors',
) ) );
// Add main text color setting and control.
$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', 'kardealer' ),
'section' => 'colors',
) ) );
// Add secondary text color setting and control.
$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', 'kardealer' ),
'section' => 'colors',
) ) );
}
add_action( 'customize_register', 'kardealer_customize_register', 11 );
/**
* Render the site title for the selective refresh partial.
*
* @since car dealer 1.2
* @see kardealer_customize_register()
*
* @return void
*/
function kardealer_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @since car dealer 1.2
* @see kardealer_customize_register()
*
* @return void
*/
function kardealer_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Registers color schemes for car dealer.
*
* Can be filtered with {@see 'kardealer_color_schemes'}.
*
* The order of colors in a colors array:
* 1. Main Background Color.
* 2. Page Background Color.
* 3. Link Color.
* 4. Main Text Color.
* 5. Secondary Text Color.
* 6. Footer Color
*
* @since car dealer 1.0
*
* @return array An associative array of color scheme options.
*/
function kardealer_get_color_schemes() {
/**
* Filter the color schemes registered for use with car dealer.
*
* The default schemes include 'default', 'dark', 'gray', 'red', and 'yellow'.
*
* @since car dealer 1.0
*
* @param array $schemes {
* Associative array of color schemes data.
*
* @type array $slug {
* Associative array of information for setting up the color scheme.
*
* @type string $label Color scheme label.
* @type array $colors HEX codes for default colors prepended with a hash symbol ('#').
* Colors are defined in the following order: Main background, page
* background, link, main text, secondary text.
* }
* }
*/
return apply_filters( 'kardealer_color_schemes', array(
'default' => array(
'label' => __( 'Default', 'kardealer' ),
'colors' => array(
'#1a1a1a',
'#ffffff',
'#007acc',
'#1a1a1a',
'#686868',
'#F1F0F0',
),
),
'dark' => array(
'label' => __( 'Dark', 'kardealer' ),
'colors' => array(
'#262626',
'#1a1a1a',
'#9adffd',
'#e5e5e5',
'#c1c1c1',
'#616a73',
),
),
'gray' => array(
'label' => __( 'Gray', 'kardealer' ),
'colors' => array(
'#616a73',
'#4d545c',
'#c7c7c7',
'#f2f2f2',
'#f2f2f2',
'#F1F0F0',
),
),
'red' => array(
'label' => __( 'Orange', 'kardealer' ),
'colors' => array(
'#E65E23',
'#ffffff',
'#640c1f',
'#402b30',
'#402b30',
'#F1F0F0',
),
),
'yellow' => array(
'label' => __( 'Blue', 'kardealer' ),
'colors' => array(
'#005681',
'#ffffff',
'#774e24',
'#3b3721',
'#5b4d3e',
'#F1F0F0',
),
),
) );
}
if ( ! function_exists( 'kardealer_get_color_scheme' ) ) :
/**
* Retrieves the current car dealer color scheme.
*
* Create your own kardealer_get_color_scheme() function to override in a child theme.
*
* @since car dealer 1.0
*
* @return array An associative array of either the current or default color scheme HEX values.
*/
function kardealer_get_color_scheme() {
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
$color_schemes = kardealer_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; // kardealer_get_color_scheme
if ( ! function_exists( 'kardealer_get_color_scheme_choices' ) ) :
/**
* Retrieves an array of color scheme choices registered for car dealer.
*
* Create your own kardealer_get_color_scheme_choices() function to override
* in a child theme.
*
* @since car dealer 1.0
*
* @return array Array of color schemes.
*/
function kardealer_get_color_scheme_choices() {
$color_schemes = kardealer_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; // kardealer_get_color_scheme_choices
if ( ! function_exists( 'kardealer_sanitize_color_scheme' ) ) :
/**
* Handles sanitization for car dealer color schemes.
*
* Create your own kardealer_sanitize_color_scheme() function to override
* in a child theme.
*
* @since car dealer 1.0
*
* @param string $value Color scheme name value.
* @return string Color scheme name.
*/
function kardealer_sanitize_color_scheme( $value ) {
$color_schemes = kardealer_get_color_scheme_choices();
if ( ! array_key_exists( $value, $color_schemes ) ) {
return 'default';
}
return $value;
}
endif; // kardealer_sanitize_color_scheme
/**
* Enqueues front-end CSS for color scheme.
*
* @since car dealer 1.0
*
* @see wp_add_inline_style()
*/
function kardealer_color_scheme_css() {
$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
// Don't do anything if the default color scheme is selected.
if ( 'default' === $color_scheme_option ) {
return;
}
$color_scheme = kardealer_get_color_scheme();
// Convert main text hex color to rgba.
$color_textcolor_rgb = kardealer_hex2rgb( $color_scheme[3] );
// If the rgba values are empty return early.
if ( empty( $color_textcolor_rgb ) ) {
return;
}
// If we get this far, we have a custom color scheme.
$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],
'footer_color' => $color_scheme[5],
'border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.2)', $color_textcolor_rgb ),
);
$color_scheme_css = kardealer_get_color_scheme_css( $colors );
wp_add_inline_style( 'kardealer-style', $color_scheme_css );
}
add_action( 'wp_enqueue_scripts', 'kardealer_color_scheme_css' );
/**
* Binds the JS listener to make Customizer color_scheme control.
*
* Passes color scheme data as colorScheme global.
*
* @since car dealer 1.0
*/
function kardealer_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', kardealer_get_color_schemes() );
}
add_action( 'customize_controls_enqueue_scripts', 'kardealer_customize_control_js' );
/**
* Binds JS handlers to make the Customizer preview reload changes asynchronously.
*
* @since car dealer 1.0
*/
function kardealer_customize_preview_js() {
wp_enqueue_script( 'kardealer-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20160816', true );
}
add_action( 'customize_preview_init', 'kardealer_customize_preview_js' );
/**
* Returns CSS for the color schemes.
*
* @since car dealer 1.0
*
* @param array $colors Color scheme colors.
* @return string Color scheme CSS.
*/
function kardealer_get_color_scheme_css( $colors ) {
$colors = wp_parse_args( $colors, array(
'background_color' => '',
'page_background_color' => '',
'link_color' => '',
'main_text_color' => '',
'secondary_text_color' => '',
'footer_color' => '',
'border_color' => '',
) );
return << .page-links-title,
.comment-author,
.comment-reply-title small a:hover,
.comment-reply-title small a:focus {
color: {$colors['main_text_color']};
}
blockquote,
.menu-toggle.toggled-on,
.menu-toggle.toggled-on:hover,
.menu-toggle.toggled-on:focus,
.post-navigation,
.post-navigation div + div,
.pagination,
.widget,
.page-header,
.page-links a,
.comments-title,
.comment-reply-title {
border-color: {$colors['main_text_color']};
}
button,
button[disabled]:hover,
button[disabled]:focus,
input[type="button"],
input[type="button"][disabled]:hover,
input[type="button"][disabled]:focus,
input[type="reset"],
input[type="reset"][disabled]:hover,
input[type="reset"][disabled]:focus,
input[type="submit"],
input[type="submit"][disabled]:hover,
input[type="submit"][disabled]:focus,
.menu-toggle.toggled-on,
.menu-toggle.toggled-on:hover,
.menu-toggle.toggled-on:focus,
.pagination:before,
.pagination:after,
.pagination .prev,
.pagination .next,
.page-links a {
background-color: {$colors['main_text_color']};
}
/* Secondary Text Color */
/**
* IE8 and earlier will drop any block with CSS3 selectors.
* Do not combine these styles with the next block.
*/
body:not(.search-results) .entry-summary {
color: {$colors['secondary_text_color']};
}
blockquote,
.post-password-form label,
a:hover,
a:focus,
a:active,
.post-navigation .meta-nav,
.image-navigation,
.comment-navigation,
.widget_recent_entries .post-date,
.widget_rss .rss-date,
.widget_rss cite,
.site-description,
.author-bio,
.entry-footer,
.entry-footer a,
.sticky-post,
.taxonomy-description,
.entry-caption,
.comment-metadata,
.pingback .edit-link,
.comment-metadata a,
.pingback .comment-edit-link,
.comment-form label,
.comment-notes,
.comment-awaiting-moderation,
.logged-in-as,
.form-allowed-tags,
.site-info,
.site-info a,
.wp-caption .wp-caption-text,
.gallery-caption,
.widecolumn label,
.widecolumn .mu_register label {
color: {$colors['secondary_text_color']};
}
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus {
background-color: {$colors['secondary_text_color']};
}
/* Border Color */
fieldset,
pre,
abbr,
acronym,
table,
th,
td,
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="week"],
input[type="month"],
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="number"],
textarea,
.main-navigation li,
.main-navigation .primary-menu,
.menu-toggle,
.dropdown-toggle:after,
.social-navigation a,
.image-navigation,
.comment-navigation,
.tagcloud a,
.entry-content,
.entry-summary,
.page-links a,
.page-links > span,
.comment-list article,
.comment-list .pingback,
.comment-list .trackback,
.comment-reply-link,
.no-comments,
.widecolumn .mu_register .mu_alert {
border-color: {$colors['main_text_color']}; /* Fallback for IE7 and IE8 */
border-color: {$colors['border_color']};
}
hr,
code {
background-color: {$colors['main_text_color']}; /* Fallback for IE7 and IE8 */
background-color: {$colors['border_color']};
}
/* Footer ///// */
.site-footer {
background: {$colors['border_color']};
}
@media screen and (min-width: 56.875em) {
.main-navigation li:hover > a,
.main-navigation li.focus > a {
color: {$colors['link_color']};
}
.main-navigation ul ul,
.main-navigation ul ul li {
border-color: {$colors['border_color']};
}
.main-navigation ul ul:before {
border-top-color: {$colors['border_color']};
border-bottom-color: {$colors['border_color']};
}
.main-navigation ul ul li {
background-color: {$colors['page_background_color']};
}
.main-navigation ul ul:after {
border-top-color: {$colors['page_background_color']};
border-bottom-color: {$colors['page_background_color']};
}
}
CSS;
}
/**
* Outputs an Underscore template for generating CSS for the color scheme.
*
* The template generates the css dynamically for instant display in the
* Customizer preview.
*
* @since car dealer 1.0
*/
function kardealer_color_scheme_css_template() {
$colors = array(
'background_color' => '{{ data.background_color }}',
'page_background_color' => '{{ data.page_background_color }}',
'link_color' => '{{ data.link_color }}',
'main_text_color' => '{{ data.main_text_color }}',
'secondary_text_color' => '{{ data.secondary_text_color }}',
'border_color' => '{{ data.border_color }}',
);
?>
a,
.main-navigation li.focus > a {
color: %1$s;
}
}
';
wp_add_inline_style( 'kardealer-style', sprintf( $css, $link_color ) );
}
add_action( 'wp_enqueue_scripts', 'kardealer_link_color_css', 11 );
/**
* Enqueues front-end CSS for the main text color.
*
* @since car dealer 1.0
*
* @see wp_add_inline_style()
*/
function kardealer_main_text_color_css() {
$color_scheme = kardealer_get_color_scheme();
$default_color = $color_scheme[3];
$main_text_color = get_theme_mod( 'main_text_color', $default_color );
// Don't do anything if the current color is the default.
if ( $main_text_color === $default_color ) {
return;
}
// Convert main text hex color to rgba.
$main_text_color_rgb = kardealer_hex2rgb( $main_text_color );
// If the rgba values are empty return early.
if ( empty( $main_text_color_rgb ) ) {
return;
}
// If we get this far, we have a custom color scheme.
$border_color = vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.2)', $main_text_color_rgb );
$css = '
/* Custom Main Text Color */
body,
blockquote cite,
blockquote small,
.main-navigation a,
.menu-toggle,
.dropdown-toggle,
.social-navigation a,
.post-navigation a,
.pagination a:hover,
.pagination a:focus,
.widget-title a,
.site-branding .site-title a,
.entry-title a,
.page-links > .page-links-title,
.comment-author,
.comment-reply-title small a:hover,
.comment-reply-title small a:focus {
color: %1$s
}
blockquote,
.menu-toggle.toggled-on,
.menu-toggle.toggled-on:hover,
.menu-toggle.toggled-on:focus,
.post-navigation,
.post-navigation div + div,
.pagination,
.widget,
.page-header,
.page-links a,
.comments-title,
.comment-reply-title {
border-color: %1$s;
}
button,
button[disabled]:hover,
button[disabled]:focus,
input[type="button"],
input[type="button"][disabled]:hover,
input[type="button"][disabled]:focus,
input[type="reset"],
input[type="reset"][disabled]:hover,
input[type="reset"][disabled]:focus,
input[type="submit"],
input[type="submit"][disabled]:hover,
input[type="submit"][disabled]:focus,
.menu-toggle.toggled-on,
.menu-toggle.toggled-on:hover,
.menu-toggle.toggled-on:focus,
.pagination:before,
.pagination:after,
.pagination .prev,
.pagination .next,
.page-links a {
background-color: %1$s;
}
/* Border Color */
fieldset,
pre,
abbr,
acronym,
table,
th,
td,
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="week"],
input[type="month"],
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="number"],
textarea,
.main-navigation li,
.main-navigation .primary-menu,
.menu-toggle,
.dropdown-toggle:after,
.social-navigation a,
.image-navigation,
.comment-navigation,
.tagcloud a,
.entry-content,
.entry-summary,
.page-links a,
.page-links > span,
.comment-list article,
.comment-list .pingback,
.comment-list .trackback,
.comment-reply-link,
.no-comments,
.widecolumn .mu_register .mu_alert {
border-color: %1$s; /* Fallback for IE7 and IE8 */
border-color: %2$s;
}
hr,
code {
background-color: %1$s; /* Fallback for IE7 and IE8 */
background-color: %2$s;
}
@media screen and (min-width: 56.875em) {
.main-navigation ul ul,
.main-navigation ul ul li {
border-color: %2$s;
}
.main-navigation ul ul:before {
border-top-color: %2$s;
border-bottom-color: %2$s;
}
}
';
wp_add_inline_style( 'kardealer-style', sprintf( $css, $main_text_color, $border_color ) );
}
add_action( 'wp_enqueue_scripts', 'kardealer_main_text_color_css', 11 );
/**
* Enqueues front-end CSS for the secondary text color.
*
* @since car dealer 1.0
*
* @see wp_add_inline_style()
*/
function kardealer_secondary_text_color_css() {
$color_scheme = kardealer_get_color_scheme();
$default_color = $color_scheme[4];
$secondary_text_color = get_theme_mod( 'secondary_text_color', $default_color );
// Don't do anything if the current color is the default.
if ( $secondary_text_color === $default_color ) {
return;
}
$css = '
/* Custom Secondary Text Color */
/**
* IE8 and earlier will drop any block with CSS3 selectors.
* Do not combine these styles with the next block.
*/
body:not(.search-results) .entry-summary {
color: %1$s;
}
blockquote,
.post-password-form label,
a:hover,
a:focus,
a:active,
.post-navigation .meta-nav,
.image-navigation,
.comment-navigation,
.widget_recent_entries .post-date,
.widget_rss .rss-date,
.widget_rss cite,
.site-description,
.author-bio,
.entry-footer,
.entry-footer a,
.sticky-post,
.taxonomy-description,
.entry-caption,
.comment-metadata,
.pingback .edit-link,
.comment-metadata a,
.pingback .comment-edit-link,
.comment-form label,
.comment-notes,
.comment-awaiting-moderation,
.logged-in-as,
.form-allowed-tags,
.site-info,
.site-info a,
.wp-caption .wp-caption-text,
.gallery-caption,
.widecolumn label,
.widecolumn .mu_register label {
color: %1$s;
}
.widget_calendar tbody a:hover,
.widget_calendar tbody a:focus {
background-color: %1$s;
}
';
wp_add_inline_style( 'kardealer-style', sprintf( $css, $secondary_text_color ) );
}
add_action( 'wp_enqueue_scripts', 'kardealer_secondary_text_color_css', 11 );
add_action( 'wp_head' , 'kardealer_dynamic_css' );
function kardealer_dynamic_css() { ?>