Last active
December 7, 2016 13:41
-
-
Save robneu/6408024 to your computer and use it in GitHub Desktop.
Genesis child theme front end color switcher
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
<?php | |
/** | |
* Define color choices for a Genesis Child Theme | |
* and then set up a way for them to be changed from the | |
* front end in a theme demo. | |
* | |
* @author FAT Media <http://youneedfat.com> | |
* @copyright Copyright (c) 2013, FAT Media, LLC | |
* @license GPL-2.0+ | |
*/ | |
/** | |
* Add theme support for different color styles. | |
* These theme names will then be used in the selector so | |
* users can switch the colors from the front end of a theme demo. | |
*/ | |
add_theme_support( 'genesis-style-selector', array( | |
'theme-name-color-one' => __( 'Color One', 'theme-name' ), | |
'theme-name-color-two' => __( 'Color Two', 'theme-name' ), | |
'theme-name-color-three' => __( 'Color Three', 'theme-name' ), | |
) | |
); | |
add_filter( 'body_class', 'theme_name_color_switch_class' ); | |
/** | |
* Allow the color classes to be changed from the | |
* front end of a theme demo. | |
*/ | |
function theme_name_color_switch_class( $classes ) { | |
$theme = 'theme-name'; | |
$sep = '-'; | |
$colors = array( 'color-one', 'color-two', 'color-three' ); | |
if( isset( $_GET['color'] ) & in_array( $_GET['color'], $colors ) ) | |
$classes[] = $theme . $sep . esc_attr( $_GET['color'] ); | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment