'sw-widget-popular-posts', 'description' => __( 'The most commented posts on your site', 'shiword' ) ); $this->WP_Widget( 'shi-popular-posts', __( 'Popular Posts', 'shiword' ), $widget_ops); $this->alt_option_name = 'sw-widget-popular-posts'; add_action( 'save_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array(&$this, 'flush_widget_cache' ) ); } function widget($args, $instance) { $cache = wp_cache_get( 'sw-widget-popular-posts', 'widget' ); if ( !is_array($cache) ) $cache = array(); if ( isset($cache[$args['widget_id']]) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Popular Posts', 'shiword' ) : $instance['title'], $instance, $this->id_base); if ( !$number = (int) $instance['number'] ) $number = 10; else if ( $number < 1 ) $number = 1; else if ( $number > 15 ) $number = 15; $use_thumbs = ( !isset($instance['thumb']) || $thumb = (int) $instance['thumb'] ) ? 1 : 0; $r = new WP_Query(array( 'showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count' )); if ($r->have_posts()) : ?>
/>
'sw-widget-latest-commented-posts', 'description' => __( 'The latest commented posts/pages of your site', 'shiword' ) ); $this->WP_Widget( 'shi-recent-comments', __( 'Latest activity', 'shiword' ), $widget_ops); $this->alt_option_name = 'sw-widget-latest-commented-posts'; add_action( 'comment_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache' ) ); } function flush_widget_cache() { wp_cache_delete( 'sw-widget-latest-commented-posts', 'widget' ); } function widget( $args, $instance ) { global $comments, $comment; $cache = wp_cache_get( 'sw-widget-latest-commented-posts', 'widget' ); if ( ! is_array( $cache ) ) $cache = array(); if ( isset( $cache[$args['widget_id']] ) ) { echo $cache[$args['widget_id']]; return; } extract($args, EXTR_SKIP); $output = ''; $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Latest activity', 'shiword' ) : $instance['title']); if ( ! $number = (int) $instance['number'] ) $number = 5; else if ( $number < 1 ) $number = 1; $use_thumbs = ( !isset($instance['thumb']) || $thumb = (int) $instance['thumb'] ) ? 1 : 0; $comments = get_comments( array( 'status' => 'approve', 'type' => 'comment', 'number' => 200 ) ); $post_array = array(); $counter = 0; $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $ul_class = $use_thumbs ? ' class="with-thumbs"' : ''; $output .= '
/>
'sw-widget-latest-commentators', 'description' => __( 'The latest comment authors', 'shiword' ) ); $this->WP_Widget( 'shi-recent-commentators', __( 'Latest comment authors', 'shiword' ), $widget_ops); $this->alt_option_name = 'sw-widget-latest-commentators'; add_action( 'comment_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache' ) ); } function flush_widget_cache() { wp_cache_delete( 'sw-widget-latest-commentators', 'widget' ); } function widget( $args, $instance ) { global $comments, $comment; if ( get_option( 'require_name_email' ) != '1' ) return; //commentors must be identifiable $cache = wp_cache_get( 'sw-widget-latest-commentators', 'widget' ); if ( ! is_array( $cache ) ) $cache = array(); if ( isset( $cache[$args['widget_id']] ) ) { echo $cache[$args['widget_id']]; return; } extract($args, EXTR_SKIP); $output = ''; $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Latest comment authors', 'shiword' ) : $instance['title']); if ( ! $number = (int) $instance['number'] ) $number = 4; else if ( $number < 1 ) $number = 1; $use_thumbs = ( !isset($instance['thumb']) || $thumb = (int) $instance['thumb'] ) ? 1 : 0; $comments = get_comments( array( 'status' => 'approve', 'type' => 'comment', 'number' => 200 ) ); $post_array = array(); $counter = 0; $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $ul_class = $use_thumbs ? ' class="social-like"' : ''; $grav_dim = $use_thumbs ? 40 : 32; $output .= '
/>
'sw-widget-user-quick-links', 'description' => __( 'Some useful links for users', 'shiword' ) ); $this->WP_Widget( 'shi-user-quick-links', __( 'User quick links', 'shiword' ), $widget_ops); $this->alt_option_name = 'sw-widget-user-quick-links'; } function widget( $args, $instance ) { global $current_user; extract($args, EXTR_SKIP); $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Welcome %s', 'shiword' ) : $instance['title'], $instance, $this->id_base); $title = sprintf ( $title, $current_user->display_name ); $use_thumbs = ( !isset($instance['thumb']) || $thumb = (int) $instance['thumb'] ) ? 1 : 0; if ( $use_thumbs ) { if ( is_user_logged_in() ) { //fix for notice when user not log-in $email = $current_user->user_email; $title = get_avatar( $email, 32, $default = get_template_directory_uri() . '/images/user.png', 'user-avatar' ) . ' ' . $title; } else { $title = get_avatar( 'dummyemail', 32, $default = get_template_directory_uri() . '/images/user.png', 'user-avatar' ) . ' ' . $title; } } ?>
/>
'sw-widget-categories', 'description' => __( 'A list of popular categories', 'shiword' ) ); $this->WP_Widget( 'shi-categories', __( 'Popular Categories', 'shiword' ), $widget_ops); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Popular Categories', 'shiword' ) : $instance['title'], $instance, $this->id_base); if ( !$number = (int) $instance['number'] ) $number = 10; else if ( $number < 1 ) $number = 1; else if ( $number > 15 ) $number = 15; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?>
'sw-widget-social', 'description' => __("This widget lets visitors of your blog subscribe to it and follow you on popular social networks like Twitter, FaceBook etc.", "shiword")); $control_ops = array( 'width' => 650); $this->WP_Widget("shi-social", __("Follow Me", "shiword"), $widget_ops, $control_ops); $this->follow_urls = array( 'Blogger' => 'Blogger', 'Delicious' => 'Delicious', 'Deviantart' => 'deviantART', 'Digg' => 'Digg', 'Dropbox' => 'Dropbox', 'Facebook' => 'Facebook', 'Flickr' => 'Flickr', 'Github' => 'GitHub', 'GooglePlus' => 'Google+', 'Hi5' => 'Hi5', 'LinkedIn' => 'LinkedIn', 'Myspace' => 'Myspace', 'Odnoklassniki' => 'Odnoklassniki', 'Orkut' => 'Orkut', 'Picasa' => 'Picasa', 'pinterest' => 'Pinterest', 'Qzone' => 'Qzone', 'Reddit' => 'Reddit', 'StumbleUpon' => 'StumbleUpon', 'Technorati' => 'Technorati', 'Tencent' => 'Tencent', 'Twitter' => 'Twitter', 'Vimeo' => 'Vimeo', 'VKontakte' => 'VKontakte', 'Weibo' => 'Weibo', 'WindowsLive' => 'Windows Live', 'Youtube' => 'Youtube', 'RSS' => 'RSS' ); } function form($instance) { $defaults = array("title" => __("Follow Me", "shiword"), "icon_size" => '48px', ); foreach ($this->follow_urls as $follow_service => $service_name ) { $defaults[$follow_service."_icon"] = $follow_service; $defaults["show_".$follow_service] = false; } $instance = wp_parse_args((array)$instance, $defaults); ?>
full addresses ( with http:// )', 'shiword' ); ?>
follow_urls as $follow_service => $service_name ) { ?>
'ID', 'order' => 'ASC', 'show_count' => 1, 'hide_empty' => 0, 'hide_if_empty' => false, 'echo' => 1, 'selected' => $category, 'hierarchical' => 1, 'name' => $this->get_field_name( 'category' ), 'id' => $this->get_field_id( 'category' ), 'class' => 'widefat', 'taxonomy' => 'category', ) ); ?>
/>
'sw-widget-image-details', 'description' => __( "Display image details. It's visible ONLY in single attachments", 'shiword' ) ); $this->WP_Widget( 'shi-image-details', __( 'Image details', 'shiword' ), $widget_ops ); $this->alt_option_name = 'sw-widget-image-details'; } function image_info(){ global $post; ?>array( 'NAME', 'LINK' ), // LINK -> %1$s: title, %2$s: url, %3$s: image/thumbnail 'Twitter' => array( 'Twitter', 'http://twitter.com/home?status=%1$s - %2$s' ), 'Facebook' => array( 'Facebook', 'http://www.facebook.com/sharer.php?u=%2$s&t=%1$s' ), 'Weibo' => array( 'Weibo', 'http://v.t.sina.com.cn/share/share.php?url=%2$s' ), 'Tencent' => array( 'Tencent', 'http://v.t.qq.com/share/share.php?url=%2$s&title=%1$s&pic=%3$s' ), 'Qzone' => array( 'Qzone', 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=%2$s' ), 'Reddit' => array( 'Reddit', 'http://reddit.com/submit?url=%2$s&title=%1$s' ), 'StumbleUpon' => array( 'StumbleUpon', 'http://www.stumbleupon.com/submit?url=%2$s&title=%1$s' ), 'Digg' => array( 'Digg', 'http://digg.com/submit?url=%2$s' ), 'Orkut' => array( 'Orkut', 'http://promote.orkut.com/preview?nt=orkut.com&tt=%1$s&du=%2$s&tn=%3$s' ), 'Bookmarks' => array( 'Bookmarks', 'https://www.google.com/bookmarks/mark?op=edit&bkmk=%2$s&title=%1$s' ), 'Blogger' => array( 'Blogger', 'http://www.blogger.com/blog_this.pyra?t&u=%2$s&n=%1$s&pli=1' ), ); var $default_icon_size = array ( '16', '24', '32', '48', '64' ); function shiword_Widget_share_this() { $widget_ops = array( 'classname' => 'sw-widget-share-this', 'description' => __( "Show some popular sharing services links. It's visible ONLY in single posts, pages and attachments", 'shiword' ) ); $this->WP_Widget( 'shi-share-this', __( 'Share this', 'shiword' ), $widget_ops ); $this->alt_option_name = 'sw-widget-share-this'; } function widget( $args, $instance ) { global $post; if ( !is_singular() ) return; extract( $args ); $icon_size = !empty( $instance['icon_size'] ) ? absint( $instance['icon_size'] ) : '24'; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $pName = rawurlencode( $post->post_title ); $pHref = rawurlencode( home_url() . '/?p=' . get_the_ID() ); //shorturl $pPict = rawurlencode( wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ) ); $services = $this->default_services; $outer = ''; foreach( $services as $key => $service ) { $href = sprintf( $service[1], $pName, $pHref, $pPict ); if ( $instance[$key] ) $outer .= '
';
}
?>
default_icon_size ) ? $new_instance["icon_size"] : '16' ;
$services = $this->default_services;
foreach( $services as $key => $service ) {
$instance[$key] = (int) $new_instance[$key] ? 1 : 0;
}
return $instance;
}
function form( $instance ) {
$size_array = $this->default_icon_size;
$services = $this->default_services;
foreach( $services as $key => $service ) {
$def_instance[$key] = 1;
}
$def_instance['title'] = __( 'Share this', 'shiword' );
$def_instance['icon_size'] = '24';
//Defaults
$instance = wp_parse_args( (array) $instance, $def_instance );
$title = esc_attr( $instance['title'] );
$icon_size = absint( $instance['icon_size'] );
?>
$service ) { ?>
/>
/>
/>
/>
/>
/>
'widget_recent_comments', 'description' => __( 'The most recent comments', 'shiword' ) ); parent::__construct( 'recent-comments', __( 'Recent Comments (Enhanced)', 'shiword' ), $widget_ops); $this->alt_option_name = 'widget_recent_comments'; if ( is_active_widget(false, false, $this->id_base) ) add_action( 'wp_head', array(&$this, 'recent_comments_style' ) ); add_action( 'comment_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache' ) ); } function recent_comments_style() { if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) return; ?> id; if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } extract($args, EXTR_SKIP); $output = ''; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments', 'shiword' ) : $instance['title'], $instance, $this->id_base ); if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 5; if ( ! isset($instance['excerpt']) || empty( $instance['excerpt'] ) || ! $excerpt = absint( $instance['excerpt'] ) ) $excerpt = 0; $comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ); $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $output .= '
/>
'sw-Widget_clean_archives', 'description' => __( "Show archives in a cleaner way", 'shiword' ) ); $this->WP_Widget( 'shi-clean-archives', __( 'Clean Archives', 'shiword' ), $widget_ops); $this->alt_option_name = 'sw-Widget_clean_archives'; } function widget($args, $instance) { extract($args); global $wpdb; // Wordpress Database $years = $wpdb->get_results( "SELECT distinct year(post_date) AS year, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year(post_date) ORDER BY post_date DESC" ); if ( empty( $years ) ) { return; // empty archive } $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base); $month_style = ( isset($instance['month_style']) && in_array( $instance['month_style'], array ( 'number', 'acronym' ) ) ) ? $instance['month_style'] : 'number'; ?>
1, 'shiword_Widget_latest_commented_posts' => 1, 'shiword_Widget_latest_commentators' => 1, 'shiword_Widget_user_quick_links' => 1, 'shiword_Widget_pop_categories' => 1, 'shiword_Widget_social' => 1, 'shiword_Widget_recent_posts' => 1, 'shiword_Widget_image_details' => 1, 'shiword_Widget_share_this' => 1, 'shiword_Widget_post_details' => 1, 'shiword_Widget_Recent_Comments' => 1, 'shiword_Widget_clean_archives' => 1 ); $widgets = apply_filters( 'shiword_filter_widgets', $value ); foreach( $widgets as $widget => $is_on ) { if ( $is_on ) register_widget( $widget ); } } add_action( 'widgets_init', 'shiword_register_widgets', 1 );