'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()) : ?> > have_posts()) : $r->the_post(); ?>
  • ()
  • flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['sw-widget-popular-posts']) ) delete_option( 'sw-widget-popular-posts' ); return $instance; } function flush_widget_cache() { wp_cache_delete( 'sw-widget-popular-posts', 'widget' ); } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) $number = 5; $thumb = 1; if ( isset($instance['thumb']) && !$thumb = (int) $instance['thumb'] ) $thumb = 0; ?>

    />

    '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 .= ''; if ( $comments ) { foreach ( (array) $comments as $comment) { if ( ! in_array( $comment->comment_post_ID, $post_array ) ) { $post = get_post( $comment->comment_post_ID ); setup_postdata( $post ); if ( $use_thumbs ) { $the_thumb = shiword_get_the_thumb( $post->ID, 50, 50, '' ); } else { $the_thumb = ''; } $output .= '
  • ' . ' ' . $the_thumb . get_the_title( $post->ID ) . '
  • '; $post_array[] = $comment->comment_post_ID; if ( ++$counter >= $number ) break; } } } $output .= ''; $output .= $after_widget; echo $output; $cache[$args['widget_id']] = $output; wp_cache_set( 'sw-widget-latest-commented-posts', $cache, 'widget' ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['number'] = (int) $new_instance['number']; $instance['thumb'] = (int) $new_instance['thumb'] ? 1 : 0; $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['sw-widget-latest-commented-posts']) ) delete_option( 'sw-widget-latest-commented-posts' ); return $instance; } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; $thumb = 1; if ( isset($instance['thumb']) && !$thumb = (int) $instance['thumb'] ) $thumb = 0; ?>

    />

    '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 .= ''; if ( $comments ) { foreach ( (array) $comments as $comment) { if ( !in_array( $comment->comment_author_email, $post_array ) ) { if ( $comment->comment_author_url == '' ) { $output .= '
  • ' . get_avatar( $comment, $grav_dim, $default=get_option( 'avatar_default' ), $comment->comment_author ) . '' . $comment->comment_author . '
  • '; } else { $output .= '
  • ' . get_avatar( $comment, $grav_dim, $default=get_option( 'avatar_default' ), $comment->comment_author ) . '' . $comment->comment_author . '
  • '; } $post_array[] = $comment->comment_author_email; if ( ++$counter >= $number ) break; } } } $output .= '
    '; $output .= $after_widget; echo $output; $cache[$args['widget_id']] = $output; wp_cache_set( 'sw-widget-latest-commentators', $cache, 'widget' ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['number'] = (int) $new_instance['number']; $instance['thumb'] = (int) $new_instance['thumb'] ? 1 : 0; $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['sw-widget-latest-commentators']) ) delete_option( 'sw-widget-latest-commentators' ); return $instance; } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 4; $thumb = 1; if ( isset($instance['thumb']) && !$thumb = (int) $instance['thumb'] ) $thumb = 0; if ( get_option( 'require_name_email' ) != '1' ) { printf ( __( 'Comment authors must use a name and a valid e-mail in order to use this widget. Check the Discussion settings', 'shiword' ), esc_url( admin_url( 'options-discussion.php' ) ) ); return; } ?>

    />

    '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; } } ?>
    • moderated; $awaiting_mod = $awaiting_mod ? ' ( ' . number_format_i18n( $awaiting_mod ) . ' )' : ''; ?>

    />

    '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; ?>
      'count', 'show_count' => 1, 'hierarchical' => 0, 'order' => 'DESC', 'title_li' => '', 'number' => $number ); wp_list_categories(apply_filters( 'sw_widget_pop_categories_args', $cat_args)); ?>
    '' ) ); $title = esc_attr( $instance['title'] ); if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) $number = 5; ?>

    '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 ) { ?>

    class="checkbox" /> <?php echo $follow_service; ?>


    follow_urls as $follow_service => $service_name ) { $instance['show_'.$follow_service] = $new_instance['show_'.$follow_service]; $instance[$follow_service.'_account'] = $new_instance[$follow_service.'_account']; } return $instance; } function widget( $args, $instance ) { extract($args); $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title']); $icon_size = ( isset($instance['icon_size']) ) ? $instance['icon_size'] : '48px'; echo $before_widget; if (!empty($title)) { echo $before_title; echo $title; echo $after_title; } ?>
    follow_urls as $follow_service => $service_name ) { $show = ( isset($instance['show_'.$follow_service]) ) ? $instance['show_'.$follow_service] : false; $account = ( isset($instance[$follow_service.'_account']) ) ? $instance[$follow_service.'_account'] : ''; if ($follow_service == 'RSS' ) { $account = get_bloginfo( 'rss2_url' ); } if ($show && !empty($account)) { ?> <?php echo $follow_service;?>
    'sw-widget-recent-entries', 'description' => __( "The most recent posts in a single category", 'shiword' ) ); $this->WP_Widget( 'shi-recent-posts', __( 'Recent Posts in Category', 'shiword' ), $widget_ops); $this->alt_option_name = 'sw-widget-recent-entries'; 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_recent_posts', 'widget' ); if ( !is_array($cache) ) $cache = array(); if ( isset($cache[$args['widget_id']]) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $use_thumbs = ( !isset($instance['thumb']) || $thumb = (int) $instance['thumb'] ) ? 1 : 0; $category = isset( $instance['category']) ? absint($instance['category'] ) : ''; $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Recent Posts in %s', 'shiword' ) : $instance['title'], $instance, $this->id_base); $title = sprintf( $title, '' . get_cat_name( $category ) . '' ); if ( ! $number = absint( $instance['number'] ) ) $number = 10; $r = new WP_Query( array( 'cat' => $category, 'posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ); if ($r->have_posts()) : ?> > have_posts()) : $r->the_post(); ?>
  • flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['sw-widget-recent-entries']) ) delete_option( 'sw-widget-recent-entries' ); return $instance; } function flush_widget_cache() { wp_cache_delete( 'sw-widget_recent_posts', 'widget' ); } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; $category = isset($instance['category']) ? absint($instance['category']) : ''; $thumb = isset($instance['thumb']) ? absint($instance['thumb']) : 1; ?>

    '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; ?>
    ID ); // Convert the shutter speed retrieve from database to fraction if ( $imgmeta['image_meta']['shutter_speed'] && (1 / $imgmeta['image_meta']['shutter_speed']) > 1) { if ( ( number_format( ( 1 / $imgmeta['image_meta']['shutter_speed'] ), 1 ) ) == 1.3 or number_format( ( 1 / $imgmeta['image_meta']['shutter_speed'] ), 1 ) == 1.5 or number_format( ( 1 / $imgmeta['image_meta']['shutter_speed'] ), 1 ) == 1.6 or number_format( ( 1 / $imgmeta['image_meta']['shutter_speed'] ), 1 ) == 2.5 ){ $pshutter = "1/" . number_format( ( 1 / $imgmeta['image_meta']['shutter_speed'] ), 1, '.', '' ); } else { $pshutter = "1/" . number_format( ( 1 / $imgmeta['image_meta']['shutter_speed'] ), 0, '.', '' ); } } else { $pshutter = $imgmeta['image_meta']['shutter_speed']; } // Start to display EXIF and IPTC data of digital photograph echo __("Width", "shiword" ) . ": " . $imgmeta['width']."px
    "; echo __("Height", "shiword" ) . ": " . $imgmeta['height']."px
    "; if ( $imgmeta['image_meta']['created_timestamp'] ) echo __("Date Taken", "shiword" ) . ": " . date("d-M-Y H:i:s", $imgmeta['image_meta']['created_timestamp'])."
    "; if ( $imgmeta['image_meta']['copyright'] ) echo __("Copyright", "shiword" ) . ": " . $imgmeta['image_meta']['copyright']."
    "; if ( $imgmeta['image_meta']['credit'] ) echo __("Credit", "shiword" ) . ": " . $imgmeta['image_meta']['credit']."
    "; if ( $imgmeta['image_meta']['title'] ) echo __("Title", "shiword" ) . ": " . $imgmeta['image_meta']['title']."
    "; if ( $imgmeta['image_meta']['caption'] ) echo __("Caption", "shiword" ) . ": " . $imgmeta['image_meta']['caption']."
    "; if ( $imgmeta['image_meta']['camera'] ) echo __("Camera", "shiword" ) . ": " . $imgmeta['image_meta']['camera']."
    "; if ( $imgmeta['image_meta']['focal_length'] ) echo __("Focal Length", "shiword" ) . ": " . $imgmeta['image_meta']['focal_length']."mm
    "; if ( $imgmeta['image_meta']['aperture'] ) echo __("Aperture", "shiword" ) . ": f/" . $imgmeta['image_meta']['aperture']."
    "; if ( $imgmeta['image_meta']['iso'] ) echo __("ISO", "shiword" ) . ": " . $imgmeta['image_meta']['iso']."
    "; if ( $pshutter ) echo __("Shutter Speed", "shiword" ) . ": " . sprintf( __("%s seconds", "shiword" ), $pshutter) . "
    " ?>
    id_base ); ?> image_info(); ?>

    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 ) { ?> />

    'sw-widget-post-details', 'description' => __( "Show some details and links related to the current post. It's visible ONLY in single posts", 'shiword' ) ); $this->WP_Widget( 'shi-post-details', __( 'Post details', 'shiword' ), $widget_ops ); $this->alt_option_name = 'sw-widget-post-details'; } function widget($args, $instance) { if ( !is_single() || is_attachment() ) return; extract($args); $avatar_size = isset($instance['avatar_size']) ? absint( $instance['avatar_size'] ) : '48'; $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; shiword_post_details( array( 'author' => $instance['author'], 'date' => $instance['date'], 'tags' => $instance['tags'], 'categories' => $instance['categories'], 'avatar_size' => $avatar_size, 'featured' => $instance['featured'] ) ); echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['featured'] = (int) $new_instance['featured'] ? 1 : 0; $instance['author'] = (int) $new_instance['author'] ? 1 : 0; $instance['avatar_size'] = in_array( $new_instance['avatar_size'], array ( '32', '48', '64', '96', '128' ) ) ? $new_instance['avatar_size'] : '48' ; $instance['date'] = (int) $new_instance['date'] ? 1 : 0; $instance['tags'] = (int) $new_instance['tags'] ? 1 : 0; $instance['categories'] = (int) $new_instance['categories'] ? 1 : 0; return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => __( 'Post details', 'shiword' ), 'featured' => 0, 'author' => 1, 'avatar_size' => '48', 'date' => 1, 'tags' => 1, 'categories' => 1 ) ); $title = esc_attr( $instance['title'] ); $featured = absint( $instance['featured'] ); $author = absint( $instance['author'] ); $avatar_size = absint( $instance['avatar_size'] ); $date = absint( $instance['date'] ); $tags = absint( $instance['tags'] ); $categories = absint( $instance['categories'] ); ?>

    />

    />

    />

    />

    />

    '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 .= '
      '; if ( $comments ) { foreach ( (array) $comments as $comment) { $the_excerpt = $excerpt ? '
      ' . get_comment_excerpt( $comment->comment_ID ) . '
      ' : ''; $the_class = $excerpt ? ' class="small"' : ''; $output .= '
    • ' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x( '%1$s on %2$s', 'widgets', 'shiword' ), get_comment_author_link(), '' . get_the_title($comment->comment_post_ID) . '' ) . ' ' . $the_excerpt . '
    • '; } } $output .= '
    '; $output .= $after_widget; echo $output; $cache[$args['widget_id']] = $output; wp_cache_set( 'widget_recent_comments', $cache, 'widget' ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['number'] = absint( $new_instance['number'] ); $instance['excerpt'] = isset( $new_instance['excerpt'] ) ? 1 : 0; $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['widget_recent_comments']) ) delete_option( 'widget_recent_comments' ); return $instance; } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; $number = isset($instance['number']) ? absint($instance['number']) : 5; $excerpt = isset($instance['excerpt']) ? absint($instance['excerpt']) : 0; ?>

    />

    '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'; ?>
      ' . $year->year . ''; for ( $month = 1; $month <= 12; $month++ ) { if ( (int) $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND year(post_date) = '$year->year' AND month(post_date) = '$month'" ) > 0 ) { echo '' . $months_short[$month] . ''; } } echo ''; } ?>

    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 );