Instantly share code, notes, and snippets.
Created
March 22, 2013 06:59
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save spencejs/5219487 to your computer and use it in GitHub Desktop.
Social Links Widget for Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEGIN SOCIAL LINKS WIDGET | |
class basis_social_icons extends WP_Widget { | |
function basis_social_icons() { | |
$widget_ops = array('description' => 'Social Icons with Links'); | |
parent::WP_Widget(false, __('Basis: Social Icons', 'basis'), $widget_ops); | |
} | |
function widget($args, $instance) { | |
extract($args); | |
$title = $instance['title']; | |
$rss = $instance['rss']; | |
$twitter = $instance['twitter']; | |
$facebook = $instance['facebook']; | |
$linkedin = $instance['linkedin']; | |
$youtube = $instance['youtube']; | |
$vimeo = $instance['vimeo']; | |
?> | |
<?php echo $before_widget; ?> | |
<?php if ($title) echo $before_title, $title, $after_title; ?> | |
<?php if ($rss) { ?> | |
<span><a href="<?php bloginfo('rss2_url'); ?>" target="_blank" title="RSS Subscribe"><img alt="RSS" src="<?php bloginfo('template_url'); ?>/images/rss.png" /></a></span> | |
<?php } ?> | |
<?php if ($twitter) { ?> | |
<span><a href="<?php echo $twitter; ?>" target="_blank" title="Twitter"><img alt="Twitter" src="<?php bloginfo('template_url'); ?>/images/twitter.png" /></a></span> | |
<?php } ?> | |
<?php if ($facebook) { ?> | |
<span><a href="<?php echo $facebook; ?>" target="_blank" title="Facebook"><img alt="Facebook" src="<?php bloginfo('template_url'); ?>/images/facebook.png" /></a></span> | |
<?php } ?> | |
<?php if ($linkedin) { ?> | |
<span><a href="<?php echo $linkedin; ?>" target="_blank" title="LinkedIn"><img alt="LinkedIn" src="<?php bloginfo('template_url'); ?>/images/linkedin.png" /></a></span> | |
<?php } ?> | |
<?php if ($youtube) { ?> | |
<span><a href="<?php echo $youtube ?>" target="_blank" title="YouTube"><img alt="YouTube" src="<?php bloginfo('template_url'); ?>/images/youtube.png" /></a></span> | |
<?php } ?> | |
<?php if ($vimeo) { ?> | |
<span><a href="<?php echo $vimeo; ?>" target="_blank" title="Vimeo"><img alt="Vimeo" src="<?php bloginfo('template_url'); ?>/images/vimeo.png" /></a></span> | |
<?php } ?> | |
<?php echo $after_widget; ?> | |
<?php | |
} | |
function update($new_instance, $old_instance) { | |
return $new_instance; | |
} | |
function form($instance) { | |
if (isset($instance['title'])) { $title = esc_attr($instance['title']); } else { $title = ''; } | |
if (isset($instance['rss'])) { $rss = esc_attr($instance['rss']); } else { $title = ''; } | |
if (isset($instance['twitter'])) { $twitter = esc_attr($instance['twitter']); } else { $title = ''; } | |
if (isset($instance['facebook'])) { $facebook = esc_attr($instance['facebook']); } else { $facebook = ''; } | |
if (isset($instance['linkedin'])) { $linkedin = esc_attr($instance['linkedin']); } else { $linkedin = ''; } | |
if (isset($instance['youtube'])) { $youtube = esc_attr($instance['youtube']); } else { $youtube = ''; } | |
if (isset($instance['vimeo'])) { $vimeo = esc_attr($instance['vimeo']); } else { $vimeo = ''; } | |
?> | |
<p> | |
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:', 'basis'); ?></label> | |
<input type="text" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" /> | |
</p> | |
<p> | |
<label for="<?php echo $this->get_field_id('rss'); ?>"><?php _e('Include RSS?', 'basis'); ?></label> | |
<input type="checkbox" name="<?php echo $this->get_field_name('rss'); ?>" <?php if ($instance['rss']) echo 'checked="checked" '; ?> class="checkbox" id="<?php echo $this->get_field_id('rss'); ?>" /> | |
</p> | |
<p> | |
<label for="<?php echo $this->get_field_id('twitter'); ?>"><?php _e('Twitter URL:', 'basis'); ?></label> | |
<input type="text" name="<?php echo $this->get_field_name('twitter'); ?>" value="<?php echo $twitter; ?>" class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" /> | |
</p> | |
<p> | |
<label for="<?php echo $this->get_field_id('facebook'); ?>"><?php _e('Facebook URL:', 'basis'); ?></label> | |
<input type="text" name="<?php echo $this->get_field_name('facebook'); ?>" value="<?php echo $facebook; ?>" class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" /> | |
</p> | |
<p> | |
<label for="<?php echo $this->get_field_id('linkedin'); ?>"><?php _e('LinkedIn URL:', 'basis'); ?></label> | |
<input type="text" name="<?php echo $this->get_field_name('linkedin'); ?>" value="<?php echo $linkedin; ?>" class="widefat" id="<?php echo $this->get_field_id('linkedin'); ?>" /> | |
</p> | |
<p> | |
<label for="<?php echo $this->get_field_id('youtube'); ?>"><?php _e('YouTube URL:', 'basis'); ?></label> | |
<input type="text" name="<?php echo $this->get_field_name('youtube'); ?>" value="<?php echo $youtube; ?>" class="widefat" id="<?php echo $this->get_field_id('youtube'); ?>" /> | |
</p> | |
<p> | |
<label for="<?php echo $this->get_field_id('vimeo'); ?>"><?php _e('Vimeo URL:', 'basis'); ?></label> | |
<input type="text" name="<?php echo $this->get_field_name('vimeo'); ?>" value="<?php echo $vimeo; ?>" class="widefat" id="<?php echo $this->get_field_id('vimeo'); ?>" /> | |
</p> | |
<?php | |
} | |
} | |
register_widget('basis_social_icons'); | |
//END SOCIAL LINKS WIDGET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment