Skip to content

Instantly share code, notes, and snippets.

@carasmo
Last active July 24, 2016 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carasmo/d702093124712b3429401442bc016946 to your computer and use it in GitHub Desktop.
Save carasmo/d702093124712b3429401442bc016946 to your computer and use it in GitHub Desktop.
Add and re-order Simple Social Icons, remove plugin css, add FontAwesome, add new styles (https://gist.github.com/carasmo/5a40a72ef6503e4545fc38a6933fab4a)
<?php
//* do not add this opening php tag above
//* this code is intended for your child theme's functions.php file or functions plugin
//* IMPORTANT: use a code editor and ftp to add code to your functions.php NOT the appearance editor
//* change yourprefix in the functions and handles
// see file https://gist.github.com/carasmo/5a40a72ef6503e4545fc38a6933fab4a for the css
/** ======================================================================================
*
* Remove Simple Social Icon Plugin Stylesheet
*
======================================================================================= */
function yourprefix_remove_simple_social_icon_font() {
if ( ( ! class_exists( 'Simple_Social_Icons_Widget') ) ) return;
wp_dequeue_style( 'simple-social-icons-font');
}
add_action( 'wp_enqueue_scripts', 'yourprefix_remove_simple_social_icon_font', 99 );
/** ======================================================================================
*
* Load Custom CSS for Simple Social Plugin
*
======================================================================================= */
function yourprefix_simple_social_css() {
if ( ( ! class_exists( 'Simple_Social_Icons_Widget') ) ) return;
$css_path = '/css/simple-social.css';
//* assumes path of theme/css change to yours
wp_enqueue_style( 'yourprefix-simple-social', CHILD_URL . $css_path, array(), CHILD_THEME_VERSION );
}
add_action( 'wp_enqueue_scripts', 'yourprefix_simple_social_css' );
/** ======================================================================================
*
* Remove FontAwesome from all plugins
* Install the latest version from CDN
* Modified from: Dequeue Font Awesome plugin
* Plugin URI: http://tiguandesign.com
*
======================================================================================= */
function yourprefix_remove_font_awesome_from_other_plugins() {
global $wp_styles;
//* we'll use preg_match to find only the following patterns as exact matches,
//* to prevent other plugin stylesheets that contain font-awesome expression to be also dequeued
$patterns = array(
'font-awesome.css',
'font-awesome.min.css'
);
//* multiple patterns hook
$regex = '/(' .implode('|', $patterns) .')/i';
foreach( $wp_styles -> registered as $registered ) {
if( preg_match( $regex, $registered->src) ) {
wp_dequeue_style( $registered->handle );
} //* end preg_match
} //* end foreach
//* FA was dequeued, so here we need to enqueue it again from CDN
wp_enqueue_style( 'yourprefix-font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css' );
}
add_action( 'wp_enqueue_scripts', 'yourprefix_remove_font_awesome_from_other_plugins', 999 );
/** ======================================================================================
*
* Simple Social Icon fields
*
======================================================================================= */
function yourprefix_simple_social_default_fields() {
if ( ( ! class_exists( 'Simple_Social_Icons_Widget') ) ) return;
$styles = array(
'title' => '',
'new_window' => 0,
'size' => 36,
'border_radius' => 50,
'border_width' => 0,
'border_color' => '#ffffff',
'border_color_hover' => '#ffffff',
'icon_color' => '#ffffff',
'icon_color_hover' => '#fc7070',
'background_color' => '#fc7070',
'background_color_hover' => '#666666',
'alignment' => 'alignleft',
//* reordered based on new order in
//* yourprefix_simple_social_default_profiles
'rss' => '',
'facebook' => '',
'twitter' => '',
'gplus' => '',
'linkedin' => '',
'snapchat' => '', //* added
'email' => '',
'bloglovin' => '',
'dribbble' => '',
'flickr' => '',
'github' => '',
'instagram' => '',
'pinterest' => '',
'stumbleupon' => '',
'tumblr' => '',
'vimeo' => '',
'youtube' => '',
);
return $styles;
}
add_filter( 'simple_social_default_styles', 'yourprefix_simple_social_default_fields' );
/** ======================================================================================
*
* Simple Social Icon $glyphs and $profiles
*
======================================================================================= */
function yourprefix_simple_social_default_profiles() {
if ( ( ! class_exists( 'Simple_Social_Icons_Widget') ) ) return;
$glyphs = array(
'rss' => '<span class="fa fa-rss" aria-hidden="true"></span>',
'facebook' => '<span class="fa fa-facebook" aria-hidden="true"></span>',
'twitter' => '<span class="fa fa-twitter" aria-hidden="true"></span>',
'gplus' => '<span class="fa fa-google-plus" aria-hidden="true"></span>',
'linkedin' => '<span class="fa fa-linkedin" aria-hidden="true"></span>',
'snapchat' => '<span class="fa fa-snapchat" aria-hidden="true"></span>', //* added
'email' => '<span class="fa fa-envelope" aria-hidden="true"></span>',
'bloglovin' => '<span class="fa fa-heart" aria-hidden="true"></span>',
'dribbble' => '<span class="fa fa-dribbble" aria-hidden="true"></span>',
'flickr' => '<span class="fa fa-flickr" aria-hidden="true"></span>',
'github' => '<span class="fa fa-github" aria-hidden="true"></span>',
'instagram' => '<span class="fa fa-instagram" aria-hidden="true"></span>',
'pinterest' => '<span class="fa fa-pinterest" aria-hidden="true"></span>',
'stumbleupon' => '<span class="fa fa-stumbleupon" aria-hidden="true"></span>',
'tumblr' => '<span class="fa fa-tumblr" aria-hidden="true"></span>',
'vimeo' => '<span class="fa fa-vimeo" aria-hidden="true"></span>',
'youtube' => '<span class="fa fa-youtube" aria-hidden="true"></span>',
);
$profiles = array(
'rss' => array(
'label' => __( 'RSS URI', 'ssiw' ),
'pattern' => '<li class="social-rss"><a href="%s" %s>' . $glyphs['rss'] . '</a></li>',
),
'facebook' => array(
'label' => __( 'Facebook URI', 'ssiw' ),
'pattern' => '<li class="social-facebook"><a href="%s" %s>' . $glyphs['facebook'] . '</a></li>',
),
'twitter' => array(
'label' => __( 'Twitter URI', 'ssiw' ),
'pattern' => '<li class="social-twitter"><a href="%s" %s>' . $glyphs['twitter'] . '</a></li>',
),
'gplus' => array(
'label' => __( 'Google+ URI', 'ssiw' ),
'pattern' => '<li class="social-gplus"><a href="%s" %s>' . $glyphs['gplus'] . '</a></li>',
),
'linkedin' => array(
'label' => __( 'Linkedin URI', 'ssiw' ),
'pattern' => '<li class="social-linkedin"><a href="%s" %s>' . $glyphs['linkedin'] . '</a></li>',
),
'snapchat' => array(
'label' => __( 'SnapChat URI', 'ssiw' ),
'pattern' => '<li class="social-snapchat"><a href="%s" %s>' . $glyphs['snapchat'] . '</a></li>', //*added
),
'email' => array(
'label' => __( 'Email URI', 'ssiw' ),
'pattern' => '<li class="social-email"><a href="%s" %s>' . $glyphs['email'] . '</a></li>',
),
'bloglovin' => array(
'label' => __( 'Bloglovin URI', 'ssiw' ),
'pattern' => '<li class="social-bloglovin"><a href="%s" %s>' . $glyphs['bloglovin'] . '</a></li>',
),
'dribbble' => array(
'label' => __( 'Dribbble URI', 'ssiw' ),
'pattern' => '<li class="social-dribbble"><a href="%s" %s>' . $glyphs['dribbble'] . '</a></li>',
),
'flickr' => array(
'label' => __( 'Flickr URI', 'ssiw' ),
'pattern' => '<li class="social-flickr"><a href="%s" %s>' . $glyphs['flickr'] . '</a></li>',
),
'github' => array(
'label' => __( 'GitHub URI', 'ssiw' ),
'pattern' => '<li class="social-github"><a href="%s" %s>' . $glyphs['github'] . '</a></li>',
),
'instagram' => array(
'label' => __( 'Instagram URI', 'ssiw' ),
'pattern' => '<li class="social-instagram"><a href="%s" %s>' . $glyphs['instagram'] . '</a></li>',
),
'pinterest' => array(
'label' => __( 'Pinterest URI', 'ssiw' ),
'pattern' => '<li class="social-pinterest"><a href="%s" %s>' . $glyphs['pinterest'] . '</a></li>',
),
'stumbleupon' => array(
'label' => __( 'StumbleUpon URI', 'ssiw' ),
'pattern' => '<li class="social-stumbleupon"><a href="%s" %s>' . $glyphs['stumbleupon'] . '</a></li>',
),
'tumblr' => array(
'label' => __( 'Tumblr URI', 'ssiw' ),
'pattern' => '<li class="social-tumblr"><a href="%s" %s>' . $glyphs['tumblr'] . '</a></li>',
),
'vimeo' => array(
'label' => __( 'Vimeo URI', 'ssiw' ),
'pattern' => '<li class="social-vimeo"><a href="%s" %s>' . $glyphs['vimeo'] . '</a></li>',
),
'youtube' => array(
'label' => __( 'YouTube URI', 'ssiw' ),
'pattern' => '<li class="social-youtube"><a href="%s" %s>' . $glyphs['youtube'] . '</a></li>',
),
);
return $profiles;
}
add_filter( 'simple_social_default_profiles', 'yourprefix_simple_social_default_profiles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment