'ds-widget-recent-comments', 'description' => '最新评论(由多说提供)' ); parent::__construct('ds-recent-comments', '最新评论(多说)', $widget_ops); $this->alt_option_name = 'duoshuo_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') ); $this->duoshuoPlugin = Duoshuo_WordPress::getInstance(); } function recent_comments_style() { if ( ! current_theme_supports( 'widgets' ) )// Temp hack #14876 return; } function widget( $args, $instance ) { global $comments, $comment; if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; extract($args, EXTR_SKIP); $output = ''; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base ); if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 10; $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $data = array( 'num_items' => $number, 'show_avatars'=>isset($instance['show_avatars']) ? $instance['show_avatars'] : 1, 'show_time'=> isset($instance['show_time']) ? $instance['show_time'] : 1, 'show_title'=> isset($instance['show_title']) ? $instance['show_title'] : 1, 'show_admin'=> isset($instance['show_admin']) ? $instance['show_admin'] : 1, 'avatar_size'=> 30, 'excerpt_length'=> isset($instance['excerpt_length']) ? $instance['excerpt_length'] : 70, ); $attribs = ''; foreach ($data as $key => $value) $attribs .= ' data-' . str_replace('_','-',$key) . '="' . esc_attr($value) . '"'; $output .= '
/>
/>
/>
/>
'ds-widget-top-threads', 'description' => '热评文章(由多说提供)'); parent::__construct('ds-top-threads', '热评文章(多说)', $widget_ops); $this->alt_option_name = 'duoshuo_widget_top_threads'; $this->duoshuoPlugin = Duoshuo_WordPress::getInstance(); } function widget( $args, $instance ) { global $comments, $comment; if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; extract($args, EXTR_SKIP); $output = ''; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '热评文章' : $instance['title'], $instance, $this->id_base ); if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 5; $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $data = array( 'num_items' => $number, 'range' => isset($instance['range']) ? $instance['range'] : 'weekly', //'show_avatars'=>isset($instance['show_avatars']) ? $instance['show_avatars'] : 1, //'avatar_size'=> 30, ); $attribs = ''; foreach ($data as $key => $value) $attribs .= ' data-' . str_replace('_','-',$key) . '="' . esc_attr($value) . '"'; $output .= '
'ds-widget-recent-visitors', 'description' => '最近访客(由多说提供)' ); parent::__construct('ds-recent-visitors', '最近访客(多说)', $widget_ops); $this->alt_option_name = 'duoshuo_widget_recent_visitors'; if ( is_active_widget(false, false, $this->id_base) ) add_action( 'wp_head', array(&$this, 'printScripts') ); //add_action( 'comment_post', array(&$this, 'flush_widget_cache') ); //add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') ); $this->duoshuoPlugin = Duoshuo_WordPress::getInstance(); } function printScripts() { if ( ! current_theme_supports( 'widgets' ) )// Temp hack #14876 return; } function widget( $args, $instance ) { global $comments, $comment; if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; extract($args, EXTR_SKIP); $output = ''; $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '最近访客' : $instance['title'], $instance, $this->id_base ); if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) $number = 12; $output .= $before_widget; if ( $title ) $output .= $before_title . $title . $after_title; $data = array( 'num_items' => $number, 'show_time'=> isset($instance['show_time']) ? $instance['show_time'] : 1, 'avatar_size'=> isset($instance['avatar_size']) ? $instance['avatar_size'] : 50, ); $attribs = ''; foreach ($data as $key => $value) $attribs .= ' data-' . str_replace('_','-',$key) . '="' . esc_attr($value) . '"'; $output .= '
px
'ds-widget-qqt-follow', 'description' => '腾讯微博-收听组件(由多说提供)' ); parent::__construct('ds-qqt-follow', '腾讯微博-收听(多说)', $widget_ops); $this->alt_option_name = 'duoshuo_widget_qqt_follow'; } function widget( $args, $instance ) { if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; extract($args, EXTR_SKIP); $output = $before_widget; $title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '', $instance, $this->id_base ); if ( $title ) $output .= $before_title . $title . $after_title; $params = array( 'c' => 'follow', 'a' => 'quick', 'name'=>isset($instance['qqt_name']) ? $instance['qqt_name'] : 'duo-shuo', 'style'=>isset($instance['qqt_style']) ? $instance['qqt_style'] : 1, 't' => time() . sprintf("%03d", microtime() * 1000), 'f' => isset($instance['qqt_followers']) ? $instance['qqt_followers'] : 1, ); switch($params['style']){ case 1: $width = $params['f'] ? 227 : 167; $height = 75; break; case 2: $width = $params['f'] ? 191 : 136; $height = 38; break; case 3: $width = $params['f'] ? 168 : 125; $height = 20; break; case 4: $width = $params['f'] ? 182 : 125; $height = 27; break; case 5: $width = $params['f'] ? 178 : 125; $height = 24; break; default: } $attribs = array( 'scrolling' => 'no', 'width' => $width, 'height' => $height, 'frameborder'=> 0, 'allowtransparency'=>'true', 'marginheight'=>0, 'marginwidth'=> 0, 'src' => (is_ssl()?'https':'http').'://follow.v.t.qq.com/index.php?' . http_build_query($params, null, '&'), ); $output .= '' . $after_widget; echo $output; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['qqt_name'] = strip_tags($new_instance['qqt_name']); $instance['qqt_style'] = absint( $new_instance['qqt_style'] ); $instance['qqt_followers'] = absint( $new_instance['qqt_followers'] ); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['duoshuo_widget_qqt_follow']) ) delete_option('duoshuo_widget_qqt_follow'); return $instance; } function form( $instance ) { $title = isset($instance['title']) ? $instance['title'] : ''; $qqt_name = isset($instance['qqt_name']) ? $instance['qqt_name'] : ''; $qqt_style = isset($instance['qqt_style']) ? absint( $instance['qqt_style']) : 1; $qqt_followers = isset($instance['qqt_followers']) ? absint( $instance['qqt_followers']) : 1; ?>
/>