Skip to content

Instantly share code, notes, and snippets.

@Critter
Forked from webaware/gist:5882259
Last active August 29, 2015 14:00
Show Gist options
  • Save Critter/11193854 to your computer and use it in GitHub Desktop.
Save Critter/11193854 to your computer and use it in GitHub Desktop.
<?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__) . '/images/social';
$baseURL = dirname( get_bloginfo('stylesheet_url')) . '/images/social';
// 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment