Instantly share code, notes, and snippets.
Created
February 27, 2014 10:05
-
Save thanh4890/9247425 to your computer and use it in GitHub Desktop.
Support: http://kopatheme.com/forums/topic/pinterest-and-youtube-icons-not-showing-in-socials-widget/
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
/** | |
* @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=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $facebook ) ) : ?> | |
<li><a href="<?php echo esc_url( $facebook ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( $rss != 'HIDE' && $rss == '' ) : ?> | |
<li><a href="<?php bloginfo( 'rss2_url' ); ?>" data-icon=""></a></li> | |
<?php elseif ( $rss != 'HIDE' ) : ?> | |
<li><a href="<?php echo esc_url( $rss ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $flickr ) ) : ?> | |
<li><a href="<?php echo esc_url( $flickr ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $pinterest ) ) : ?> | |
<li><a href="<?php echo esc_url( $pinterest ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $dribbble ) ) : ?> | |
<li><a href="<?php echo esc_url( $dribbble ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $vimeo ) ) : ?> | |
<li><a href="<?php echo esc_url( $vimeo ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $youtube ) ) : ?> | |
<li><a href="<?php echo esc_url( $youtube ); ?>" data-icon=""></a></li> | |
<?php endif; ?> | |
<?php if ( ! empty( $instagram ) ) : ?> | |
<li><a href="<?php echo esc_url( $instagram ); ?>" data-icon=""></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