Skip to content

Instantly share code, notes, and snippets.

@webaware
Last active December 19, 2015 02:19
Show Gist options
  • Save webaware/5882259 to your computer and use it in GitHub Desktop.
Save webaware/5882259 to your computer and use it in GitHub Desktop.
replace icons in Social Media Feather plugin with custom icons; see http://wordpress.org/plugins/social-media-feather/
<?php
/*
* replace icons in Social Media Feather with custom icons
* @ref: http://wordpress.org/plugins/social-media-feather/
*/
add_filter('synved_social_skin_image_list', 'custom_social_feather_icons');
function custom_social_feather_icons($image_list) {
// set up file and URI paths
$path = dirname(__FILE__) . '/image/social';
$baseURL = plugins_url('image/social', __FILE__);
// get list of sizes
$dirs = glob($path . '/*', GLOB_ONLYDIR);
$dirs = array_map('basename', $dirs);
$sizes = array();
foreach ($dirs as $dirname) {
$parts = explode('x', $dirname);
if (!empty($parts[0])) {
$sizes[] = (int) $parts[0];
}
}
sort($sizes, SORT_NUMERIC);
// search path for icons replacing the regular icons
foreach (array_keys($image_list) as $site) {
$icons = array();
foreach ($sizes as $size) {
$imagepath = "$path/{$size}x{$size}/$site.png";
if (file_exists($imagepath)) {
$icons[$size] = array (
'name' => "{$size}x{$size}",
'sub' => "/$site.png",
'path' => $imagepath,
'uri' => "$baseURL/{$size}x{$size}/$site.png",
);
}
}
if (count($icons) > 0) {
$image_list[$site] = $icons;
}
}
return $image_list;
}
@Sea-Wing-designs
Copy link

I would love to use this script. What directory do I put the new icons in? does it go in the theme directory(where I added this code to the function.php file) or does it go in the content directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment