'bz_widget_popular_posts', 'description' => __( 'The most commented posts on your site','boozurk') ); $this->WP_Widget('bz-popular-posts', __('Popular Posts','boozurk'), $widget_ops); $this->alt_option_name = 'bz_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('bz_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', $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()) : ?>
flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['bz_widget_popular_posts']) ) delete_option('bz_widget_popular_posts'); return $instance; } function flush_widget_cache() { wp_cache_delete('bz_widget_popular_posts', 'widget'); } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Popular Posts','boozurk'); if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) $number = 5; $thumb = 1; if ( isset($instance['thumb']) && !$thumb = (int) $instance['thumb'] ) $thumb = 0; ?>
/>
'bz_widget_latest_commented_posts', 'description' => __( 'The latest commented posts/pages of your site','boozurk' ) ); $this->WP_Widget('bz-recent-comments', __('Latest activity','boozurk'), $widget_ops); $this->alt_option_name = 'bz_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('bz_widget_latest_commented_posts', 'widget'); } function widget( $args, $instance ) { global $comments, $comment; $cache = wp_cache_get('bz_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', $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 .= '
/>
'bz_widget_latest_commentators', 'description' => __( 'The latest comment authors','boozurk' ) ); $this->WP_Widget('bz-recent-commentators', __('Latest comment authors','boozurk'), $widget_ops); $this->alt_option_name = 'bz_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('bz_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('bz_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', $instance['title']); $icon_size = isset($instance['icon_size']) ? absint($instance['icon_size']) : '32'; if ( ! $number = (int) $instance['number'] ) $number = 5; else if ( $number < 1 ) $number = 1; $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; $output .= '
'bz-widget-social', 'description' => __("This widget lets visitors of your blog to subscribe to it and follow you on popular social networks like Twitter, FaceBook etc.", "boozurk")); $control_ops = array('width' => 650); $this->WP_Widget("bz-social", __("Follow Me", "boozurk"), $widget_ops, $control_ops); $this->follow_urls = array( 'Buzz', 'Delicious', 'Deviantart', 'Digg', 'Dropbox', 'Facebook', 'Flickr', 'Github', 'GooglePlus', 'Hi5', 'LinkedIn', 'Myspace', 'Odnoklassniki', 'Orkut', 'Qzone', 'Reddit', 'Sina', 'StumbleUpon', 'Technorati', 'Tencent', 'Twitter', 'Vimeo', 'VKontakte', 'WindowsLive', 'Youtube', 'Mail', 'RSS'); } function form($instance) { $defaults = array("title" => __("Follow Me", "boozurk"), "icon_size" => 48, ); foreach ($this->follow_urls as $follow_service ) { $defaults[$follow_service."_icon"] = $follow_service; $defaults["show_".$follow_service] = false; } $instance = wp_parse_args((array)$instance, $defaults); ?>
'bz_widget_recent_entries', 'description' => __( "The most recent posts in a single category", 'boozurk' ) ); $this->WP_Widget('bz-recent-posts', __('Recent Posts in Category', 'boozurk' ), $widget_ops); $this->alt_option_name = 'bz_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('bz_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); $category = isset( $instance['category']) ? intval($instance['category'] ) : ''; if ( $category === -1 ) { if ( !is_single() || is_attachment() ) return; global $post; $category = get_the_category( $post->ID ); $category = ( $category ) ? $category[0]->cat_ID : ''; } $use_thumbs = ( !isset($instance['thumb']) || $thumb = (int) $instance['thumb'] ) ? 1 : 0; $description = ( !isset($instance['description']) || $description = (int) $instance['description'] ) ? 1 : 0; $title = apply_filters('widget_title', $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()) : ?> ' . category_description( $category ) . ''; ?> flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['bz_widget_recent_entries']) ) delete_option('bz_widget_recent_entries'); return $instance; } function flush_widget_cache() { wp_cache_delete('bz_widget_recent_posts', 'widget'); } function form( $instance ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Recent Posts in %s', 'boozurk' ); $number = isset($instance['number']) ? absint($instance['number']) : 5; $category = isset($instance['category']) ? intval($instance['category']) : ''; $thumb = isset($instance['thumb']) ? absint($instance['thumb']) : 1; $description = isset($instance['description']) ? absint($instance['description']) : 1; ?>
'ID', 'order' => 'ASC', 'show_count' => 1, 'hide_empty' => 0, 'hide_if_empty' => true, 'echo' => 0, 'selected' => $category, 'hierarchical' => 1, 'name' => $this->get_field_name('category'), 'id' => $this->get_field_id('category'), 'class' => 'widefat', 'taxonomy' => 'category', ) ); ?> ', '', $dropdown_categories ); ?>
/>
/>
'bz_Widget_navbuttons', 'description' => __( 'Some usefull buttons for an easier navigation experience','boozurk') ); $this->WP_Widget('bz-navbuttons', __('Navigation buttons','boozurk'), $widget_ops); $this->alt_option_name = 'bz_Widget_navbuttons'; } function widget($args, $instance) { extract($args); ?>/> /> /> /> /> /> /> />
'bz_Widget_post_details', 'description' => __( "Show some details and links related to the current post. It's visible ONLY in single posts",'boozurk') ); $this->WP_Widget('bz-post-details', __('Post details','boozurk'), $widget_ops); $this->alt_option_name = 'bz_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; boozurk_post_details( $instance['author'], $instance['date'], $instance['tags'], $instance['categories'], false, $avatar_size, $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 ) { $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Post details','boozurk'); $featured = isset($instance['featured']) ? absint($instance['featured']) : 0; $author = isset($instance['author']) ? absint($instance['author']) : 1; $avatar_size = isset($instance['avatar_size']) ? absint($instance['avatar_size']) : '48'; $date = isset($instance['date']) ? absint($instance['date']) : 1; $tags = isset($instance['tags']) ? absint($instance['tags']) : 1; $categories = isset($instance['categories']) ? absint($instance['categories']) : 1; ?>
/>
/>
/>
/>
/>
'bz_widget_post_formats', 'description' => __( 'A list of Post Formats','boozurk' ) ); $this->WP_Widget('bz-widget-post-formats', __('Post Formats','boozurk'), $widget_ops); $this->alt_option_name = 'bz_widget_post_formats'; 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 flush_widget_cache() { wp_cache_delete('bz_widget_post_formats', 'widget'); } function widget( $args, $instance ) { $cache = wp_cache_get('bz_widget_post_formats', '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', $instance['title'], $instance, $this->id_base); $c = $instance['count'] ? '1' : '0'; $i = in_array( $instance['icon'], array ('1', '2', '3') ) ? $instance['icon'] : '3' ; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?>
/>
'bz_widget_user_quick_links', 'description' => __( "Some useful links for users. It's a kind of enhanced meta widget",'boozurk' ) ); $this->WP_Widget('bz-user-quick-links', __('User quick links','boozurk'), $widget_ops); $this->alt_option_name = 'bz_widget_user_quick_links'; } function widget( $args, $instance ) { global $current_user; extract($args, EXTR_SKIP); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $nick = ( isset($instance['nick']) && ( $instance['nick'] == 1 ) ) ? boozurk_random_nick() : __('guest','boozurk'); $name = is_user_logged_in() ? $current_user->display_name : $nick; $title = sprintf ( $title, $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_option('avatar_default') ) . ' ' . $title; } } ?>
/>
/>
'bz_Widget_share_this', 'description' => __( "Show some popular sharing services links. It's visible ONLY in single posts, pages and attachments",'boozurk') ); $this->WP_Widget('bz-share-this', __('Share this','boozurk'), $widget_ops); $this->alt_option_name = 'bz_Widget_share_this'; } function widget($args, $instance) { if ( !is_singular() ) return; extract($args); $icon_size = isset($instance['icon_size']) ? absint($instance['icon_size']) : '16'; $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); ?>
'bz_Widget_clean_archives', 'description' => __( "Show archives in a cleaner way",'boozurk') ); $this->WP_Widget('bz-clean-archives', __('Clean Archives','boozurk'), $widget_ops); $this->alt_option_name = 'bz_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'; ?>