Created
April 16, 2017 12:09
-
-
Save Yeadh/c2718dad2c2619e214c8db2c6e47470e to your computer and use it in GitHub Desktop.
adding Color picker on customize area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Customize Appearance Options | |
function learningWordPress_customize_register( $wp_customize ) { | |
$wp_customize->add_setting('lwp_link_color', array( | |
'default' => '#fff', | |
'transport' => 'refresh', | |
)); | |
$wp_customize->add_setting('lwp_btn_color', array( | |
'default' => '#000000', | |
'transport' => 'refresh', | |
)); | |
$wp_customize->add_setting('lwp_btn_hover_color', array( | |
'default' => '#7e7e7e', | |
'transport' => 'refresh', | |
)); | |
$wp_customize->add_section('lwp_standard_colors', array( | |
'title' => __('Choose Fonts Colors', 'LearningWordPress'), | |
'priority' => 10, | |
)); | |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'lwp_link_color_control', array( | |
'label' => __('Link Color', 'LearningWordPress'), | |
'section' => 'lwp_standard_colors', | |
'settings' => 'lwp_link_color', | |
) ) ); | |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'lwp_btn_color_control', array( | |
'label' => __('Headline Color', 'LearningWordPress'), | |
'section' => 'lwp_standard_colors', | |
'settings' => 'lwp_btn_color', | |
) ) ); | |
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'lwp_btn_hover_color_control', array( | |
'label' => __('Text Color', 'LearningWordPress'), | |
'section' => 'lwp_standard_colors', | |
'settings' => 'lwp_btn_hover_color', | |
) ) ); | |
} | |
add_action('customize_register', 'learningWordPress_customize_register'); | |
// Output Customize CSS | |
function learningWordPress_customize_css() { ?> | |
<style type="text/css"> | |
a:link, | |
a:visited { | |
color: <?php echo get_theme_mod('lwp_link_color'); ?>; | |
} | |
.section-header h2, h3{ | |
color: <?php echo get_theme_mod('lwp_btn_color'); ?>; | |
} | |
.p-btn.hero-btn:after{ | |
background-color: <?php echo get_theme_mod('lwp_btn_color'); ?>; | |
} | |
.shared_content, p, blockquote{ | |
color: <?php echo get_theme_mod('lwp_btn_hover_color'); ?>!important; | |
} | |
</style> | |
<?php } | |
add_action('wp_head', 'learningWordPress_customize_css'); | |
//end of color section of customizer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment