Last active
May 9, 2017 23:14
-
-
Save bradpotter/a1e1109b8e07a17948bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* Add custom body class for Genesis Customizer | |
* | |
*/ | |
function gc_body_class( $classes ) { | |
$classes[] = 'customizer-options'; | |
return $classes; | |
} | |
add_filter( 'body_class', 'gc_body_class', 45 ); | |
/** | |
* Load Genesis Customizer Style Sheet | |
* | |
*/ | |
function gc_customizer_style_sheet() { | |
wp_enqueue_style( 'gc-customizer-style-sheet', GENESIS_CUSTOMIZER_CSS . 'css/gc-customizer-style-sheet.css', array(), '1.0.0' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'gc_customizer_style_sheet' ); | |
/** | |
* Registers color options with the WordPress Theme Customizer | |
* | |
*/ | |
function gc_register_customizer_color( $wp_customize ) { | |
/* - - - - - Section Title - - - - - */ | |
$wp_customize->add_section( 'genesis-customizer', array( | |
'title' => __( 'Genesis Customizer', 'genesis' ), | |
'priority' => 20, | |
) ); | |
/* - - - - - Body Background Color - - - - - */ | |
$wp_customize->add_setting( | |
'gc_body_background_color', | |
array( | |
'default' => '', | |
'transport' => 'refresh' | |
) | |
); | |
$wp_customize->add_control( | |
new WP_Customize_Color_Control( | |
$wp_customize, | |
'gc_body_background_color', | |
array( | |
'label' => __( 'Background Color', 'genesis' ), | |
'section' => 'genesis-customizer', | |
'settings' => 'gc_body_background_color', | |
'priority' => 5, | |
) | |
) | |
); | |
/* - - - - - Body Text Color - - - - - */ | |
$wp_customize->add_setting( | |
'gc_body_text_color', | |
array( | |
'default' => '', | |
'transport' => 'refresh' | |
) | |
); | |
$wp_customize->add_control( | |
new WP_Customize_Color_Control( | |
$wp_customize, | |
'gc_body_text_color', | |
array( | |
'label' => __( 'Text Color', 'genesis' ), | |
'section' => 'genesis-customizer', | |
'settings' => 'gc_body_text_color', | |
'priority' => 10, | |
) | |
) | |
); | |
/* - - - - - Body Link Color - - - - - */ | |
$wp_customize->add_setting( | |
'gc_body_link_color', | |
array( | |
'default' => '', | |
'transport' => 'refresh' | |
) | |
); | |
$wp_customize->add_control( | |
new WP_Customize_Color_Control( | |
$wp_customize, | |
'gc_body_link_color', | |
array( | |
'label' => __( 'Link Color', 'genesis' ), | |
'section' => 'genesis-customizer', | |
'settings' => 'gc_body_link_color', | |
'priority' => 15, | |
) | |
) | |
); | |
/* - - - - - Body Link Hover Color - - - - - */ | |
$wp_customize->add_setting( | |
'gc_body_link_hover_color', | |
array( | |
'default' => '', | |
'transport' => 'refresh' | |
) | |
); | |
$wp_customize->add_control( | |
new WP_Customize_Color_Control( | |
$wp_customize, | |
'gc_body_link_hover_color', | |
array( | |
'label' => __( 'Link Hover Color', 'genesis' ), | |
'section' => 'genesis-customizer', | |
'settings' => 'gc_body_link_hover_color', | |
'priority' => 20, | |
) | |
) | |
); | |
} | |
add_action( 'customize_register', 'gc_register_customizer_color' ); | |
/** | |
* Add customizer CSS styles to the Head. | |
* | |
*/ | |
function gc_customizer_css() { | |
?> | |
<style type="text/css"> | |
.genesis-customizer { background-color: <?php echo get_theme_mod( 'gc_body_background_color' ); ?>; } | |
.genesis-customizer { color: <?php echo get_theme_mod( 'gc_body_text_color' ); ?>; } | |
.genesis-customizer a { color: <?php echo get_theme_mod( 'gc_body_link_color' ); ?>; } | |
.genesis-customizer a:hover { color: <?php echo get_theme_mod( 'gc_body_link_hover_color' ); ?>; } | |
} | |
</style> | |
<?php | |
} | |
add_action( 'wp_head', 'gc_customizer_css' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment