Skip to content

Instantly share code, notes, and snippets.

@cpaul007
Last active October 1, 2015 06:13
Show Gist options
  • Save cpaul007/416ab8500c11be717667 to your computer and use it in GitHub Desktop.
Save cpaul007/416ab8500c11be717667 to your computer and use it in GitHub Desktop.
Showing different color style
<?php //* do not include this opening PHP tag
/**
* Add custom css in <head> tag
*
* @author Genesis Developer
* @license GPL-2.0+
* @link http://genesisdeveloper.me/
* @copyright Copyright ( c ) 2015, Genesis Developer.
*/
//* Add the following codes in your functions.php file
if ( class_exists( 'Simple_Social_Icons_Widget' ) ) {
add_action( 'wp_head', 'simple_social_icons_css' );
function simple_social_icons_css() {
$obj = new Simple_Social_Icons_Widget();
/** Pull widget settings */
$all_instances = $obj->get_settings();
foreach( $all_instances as $key => $options ) :
$instance = wp_parse_args( $all_instances[$key] );
$font_size = round( (int) $instance['size'] / 2 );
$icon_padding = round ( (int) $font_size / 2 );
/** The CSS to output */
$css = '#' .
$obj->id_base . '-' . $key .' ul li a,
#'. $obj->id_base . '-' . $key . ' ul li a:hover {
background-color: ' . $instance['background_color'] . ' !important;
border-radius: ' . $instance['border_radius'] . 'px;
color: ' . $instance['icon_color'] . ' !important;
border: ' . $instance['border_width'] . 'px ' . $instance['border_color'] . ' solid !important;
font-size: ' . $font_size . 'px;
padding: ' . $icon_padding . 'px;
}
#'. $obj->id_base . '-' . $key . ' ul li a:hover {
background-color: ' . $instance['background_color_hover'] . ' !important;
border-color: ' . $instance['border_color_hover'] . ' !important;
color: ' . $instance['icon_color_hover'] . ' !important;
}';
/** Minify a bit */
$css = str_replace( "\t", '', $css );
$css = str_replace( array( "\n", "\r" ), ' ', $css );
/** Echo the CSS */
echo '<style type="text/css" media="screen">' . $css . '</style>';
endforeach;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment