first version of socialiconeco fork from social-media-icons-widget

This commit is contained in:
2026-06-29 11:36:31 -03:00
commit 46fbe448bd
123 changed files with 1186 additions and 0 deletions

60
lib/form.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
global $siw_social_accounts;
foreach ($siw_social_accounts as $site => $id) {
if(!isset($instance[$id])) { $instance[$id] = ''; }
elseif($instance[$id] == 'http://') { $instance[$id] = ''; }
}
if(!isset($instance['title'])) { $instance['title'] = ''; }
if(!isset($instance['icons'])) { $instance['icons'] = 'medium'; }
if(!isset($instance['labels'])) { $instance['labels'] = ''; }
if(!isset($instance['show_title'])) { $instance['show_title'] = ''; }
?>
<div class="social_icons_widget">
<p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" /></p>
<?php
$siw_sizes = array(
'None' => 'none',
'Small (16px)' => 'small',
'Medium (32px)' => 'medium',
'Large (64px)' => 'large',
'Custom (Small)' => 'custom_small',
'Custom (Medium)' => 'custom_medium',
'Custom (Large)' => 'custom_large'
);
?>
<p class="icon_options"><label for="<?php echo $this->get_field_id('icons'); ?>">Icon Type:</label>
<select id="<?php echo $this->get_field_id('icons'); ?>" name="<?php echo $this->get_field_name('icons'); ?>">
<?php
foreach($siw_sizes as $option => $value) :
if(esc_attr($instance['icons'] == $value)) { $selected = ' selected="selected"'; }
else { $selected = ''; }
?>
<option value="<?php echo $value; ?>"<?php echo $selected; ?>><?php echo $option; ?></option>
<?php endforeach; ?>
</select>
</p>
<?php if(esc_attr($instance['labels'] == 'show')) { $checked = ' checked="checked"'; } else { $checked = ''; } ?>
<p class="label_options"><input type="checkbox" id="<?php echo $this->get_field_id('labels'); ?>" name="<?php echo $this->get_field_name('labels'); ?>" value="show"<?php echo $checked; ?> /> <label for="<?php echo $this->get_field_id('labels'); ?>">Show Labels</label></p>
<?php if(esc_attr($instance['show_title'] == 'show')) { $checked = ' checked="checked"'; } else { $checked = ''; } ?>
<p class="label_options"><input type="checkbox" id="<?php echo $this->get_field_id('show_title'); ?>" name="<?php echo $this->get_field_name('show_title'); ?>" value="show"<?php echo $checked; ?> /> <label for="<?php echo $this->get_field_id('show_title'); ?>">Hide Title</label></p>
<ul class="social_accounts">
<?php foreach ($siw_social_accounts as $site => $id) : ?>
<li><label for="<?php echo $this->get_field_id($id); ?>" class="<?php echo $id; ?>"><?php echo $site; ?>:</label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id($id); ?>" name="<?php echo $this->get_field_name($id); ?>" value="<?php echo esc_attr($instance[$id]); ?>" placeholder="http://" /></li>
<?php endforeach; ?>
</ul>
</div>

57
lib/social-networks.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
/*
Declare supported social media websites
By default, the Social Icons Widget provides a variety of popular social media websites. Developers can easily add more social media websites by creating a filter in the active theme's functions.php file like such:
`function add_new_icons($icon_list) {
$icon_list['Full Website Name'] = 'full-website-id';
return $icon_list;
}
add_filter('social_icon_accounts', 'add_new_icons');`
The full-website-id should reflect the name of the image you create in each of the icon folder sizes, or in your custom icon directory. It is also used to populate the class field of the icon when the widget displays. The Social Icon Widget looks for .gif, .jpg, .jpeg, and .png in order and returns the first extention it finds.
*/
global $siw_social_accounts;
$siw_social_accounts = array(
'500px' => 'fivehundredpx',
'About.me' => 'aboutme',
'Behance' => 'behance',
'Codepen' => 'codepen',
'dailymotion' => 'dailymotion',
'Dribbble' => 'dribbble',
'Email' => 'email',
'Envato' => 'envato',
'Facebook' => 'facebook',
'Flickr' => 'flickr',
'Foursquare' => 'foursquare',
'GitHub' => 'github',
'Google+' => 'googleplus',
'Instagram' => 'instagram',
'Kickstarter' => 'kickstarter',
'Klout' => 'klout',
'LinkedIn' => 'linkedin',
'Medium' => 'medium',
'Path' => 'path',
'Pinterest' => 'pinterest',
'RSS Feed' => 'rss',
'SoundCloud' => 'soundcloud',
'Speaker Deck' => 'speakerdeck',
'StumbleUpon' => 'stumbleupon',
'Tumblr' => 'tumblr',
'Twitter' => 'twitter',
'Twitch' => 'twitch',
'Vimeo' => 'vimeo',
'Vine' => 'vine',
'WordPress' => 'wordpress',
'Yelp' => 'yelp',
'YouTube' => 'youtube',
'Zerply' => 'zerply'
);
if( has_filter('social_icon_accounts') ) {
$siw_social_accounts = apply_filters('social_icon_accounts', $siw_social_accounts);
}
?>

93
lib/widget.php Normal file
View File

@@ -0,0 +1,93 @@
<?php
global $siw_social_accounts;
extract($args);
$siw_title = empty($instance['title']) ? 'Follow Us' : apply_filters('widget_title', $instance['title']);
$siw_icons = $instance['icons'];
$siw_labels = $instance['labels'];
$siw_show_title = $instance['show_title'];
echo $before_widget;
if($siw_show_title == '') {
echo $before_title;
echo $siw_title;
echo $after_title;
}
if($siw_labels == 'show') { $ul_class = 'show-labels '; }
else { $ul_class = ''; }
$ul_class .= 'icons-'.$siw_icons;
?>
<?php echo apply_filters('social_icon_opening_tag', '<ul class="'.$ul_class.'">'); ?>
<?php foreach($siw_social_accounts as $siw_title => $id) : ?>
<?php if($instance[$id] != '' && $instance[$id] != 'http://') :
global $siw_data;
global $siw_icon_output;
$imgsize = '';
$siw_data['id'] = $id;
$siw_data['url'] = $instance[$id];
$siw_custom_sizes = array('custom_small','custom_medium','custom_large');
if (in_array($siw_icons, $siw_custom_sizes)) {
$size = str_replace("custom_","",$siw_icons);
$siw_icon_path = get_stylesheet_directory() .'/social_icons/'.$size.'/'.$id.'.{gif,jpg,jpeg,png}';
}
else {
$siw_abs_path = str_replace('lib/', '', plugin_dir_path( __FILE__ ));
/* Fix for Windows/XAMPP where the slash goes the wrong way.
Thanks to VictoriousK */
$siw_abs_path = str_replace('\\', '/', $siw_abs_path);
$siw_icon_path = $siw_abs_path . 'icons/'.$siw_icons.'/'.$id.'.{gif,jpg,jpeg,png}';
if($siw_icons == 'large') { $imgsize = 'height="64" width="64"'; }
elseif($siw_icons == 'medium') { $imgsize = 'height="32" width="32"'; }
elseif($siw_icons == 'small') { $imgsize = 'height="16" width="16"'; }
}
$result = glob( $siw_icon_path, GLOB_BRACE );
if($result) {
if (in_array($siw_icons, $siw_custom_sizes)) {
$siw_path = explode('themes', $result[0]);
$siw_icon = site_url().'/wp-content/themes'.$siw_path[1];
}
else {
$siw_path = explode('plugins', $result[0]);
$siw_icon = plugins_url().''.$siw_path[1];
}
}
elseif( $siw_labels != 'show' && $siw_icons != 'small' ) {
$siw_icon = plugins_url().'/social-media-icons-widget/icons/'.$siw_icons.'/_unknown.jpg';
}
else {
$siw_icon = '';
}
if ( $siw_icon ) { $siw_data['image'] = '<img class="site-icon" src="'.$siw_icon.'" alt="'.$siw_title.'" title="'.$siw_title.'" '.$imgsize.' />'; }
else { $siw_data['image'] = ''; }
if($siw_labels != 'show') { $siw_data['title'] = ''; }
else { $siw_data['title'] = '<span class="site-label">'.$siw_title.'</span>'; }
$format = '<li class="%1$s"><a href="%2$s" target="_blank">%3$s%4$s</a></li>';
$siw_icon_output = apply_filters('social_icon_output', $format);
echo vsprintf($siw_icon_output, $siw_data);
?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo apply_filters('social_icon_closing_tag', '</ul>'); ?>
<?php
echo $after_widget;
?>