Skip to content

Instantly share code, notes, and snippets.

@thanh4890
Created February 27, 2014 10:05
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 thanh4890/9247425 to your computer and use it in GitHub Desktop.
Save thanh4890/9247425 to your computer and use it in GitHub Desktop.
/**
* @since Nictitate 1.0
*/
class Kopa_Widget_Socials extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'kopa-social-widget', 'description' => __('Socials Widget', kopa_get_domain()));
$control_ops = array('width' => 'auto', 'height' => 'auto');
parent::__construct('kopa_widget_socials', __('Kopa Socials', kopa_get_domain()), $widget_ops, $control_ops);
}
function widget($args, $instance) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
$facebook = get_option( 'kopa_theme_options_social_links_facebook_url' );
$twitter = get_option( 'kopa_theme_options_social_links_twitter_url' );
$rss = get_option( 'kopa_theme_options_social_links_rss_url' );
$flickr = get_option( 'kopa_theme_options_social_links_flickr_url' );
$pinterest = get_option( 'kopa_theme_options_social_links_pinterest_url' );
$dribbble = get_option( 'kopa_theme_options_social_links_dribbble_url' );
$vimeo = get_option( 'kopa_theme_options_social_links_vimeo_url' );
$youtube = get_option( 'kopa_theme_options_social_links_youtube_url' );
$instagram = get_option( 'kopa_theme_options_social_links_instagram_url' );
echo $before_widget;
if ( ! empty( $title ) )
echo $before_title . $title . $after_title;
if ( empty( $facebook ) &&
empty( $twitter ) &&
$rss == 'HIDE' &&
empty( $flickr ) &&
empty( $pinterest ) &&
empty( $dribbble ) &&
empty( $vimeo ) &&
empty( $youtube ) &&
empty( $instagram ) ) {
echo $after_widget;
return;
}
?>
<ul class="clearfix">
<?php if ( ! empty( $twitter ) ) : ?>
<li><a href="<?php echo esc_url( $twitter ); ?>" data-icon="&#xe16c;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $facebook ) ) : ?>
<li><a href="<?php echo esc_url( $facebook ); ?>" data-icon="&#xe168;"></a></li>
<?php endif; ?>
<?php if ( $rss != 'HIDE' && $rss == '' ) : ?>
<li><a href="<?php bloginfo( 'rss2_url' ); ?>" data-icon="&#xe16f;"></a></li>
<?php elseif ( $rss != 'HIDE' ) : ?>
<li><a href="<?php echo esc_url( $rss ); ?>" data-icon="&#xe16f;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $flickr ) ) : ?>
<li><a href="<?php echo esc_url( $flickr ); ?>" data-icon="&#xe178;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $pinterest ) ) : ?>
<li><a href="<?php echo esc_url( $pinterest ); ?>" data-icon="&#xe1a5;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $dribbble ) ) : ?>
<li><a href="<?php echo esc_url( $dribbble ); ?>" data-icon="&#xe17e;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $vimeo ) ) : ?>
<li><a href="<?php echo esc_url( $vimeo ); ?>" data-icon="&#xe174;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $youtube ) ) : ?>
<li><a href="<?php echo esc_url( $youtube ); ?>" data-icon="&#xe172;"></a></li>
<?php endif; ?>
<?php if ( ! empty( $instagram ) ) : ?>
<li><a href="<?php echo esc_url( $instagram ); ?>" data-icon="&#xe16b;"></a></li>
<?php endif; ?>
</ul>
<?php
echo $after_widget;
}
function form($instance) {
$default = array(
'title' => ''
);
$instance = wp_parse_args((array) $instance, $default);
$title = strip_tags($instance['title']);
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', kopa_get_domain()); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
</p>
<?php
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment