'Sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); /* end Widget Settings */ /* 分页 */ function fvcity_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { global $request, $posts_per_page, $wpdb, $paged; if(empty($prelabel)) { $prelabel = '«'; } if(empty($nxtlabel)) { $nxtlabel = '»'; } $half_pages_to_show = round($pages_to_show/2); if (!is_single()) { if(!is_category()) { preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); $max_page = ceil($numposts /$posts_per_page); if(empty($paged)) { $paged = 1; } if($max_page > 1 || $always_show) { echo "$before Pages ($max_page): "; if ($paged >= ($pages_to_show-1)) { echo '« First ... '; } previous_posts_link($prelabel); for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) { echo "$i"; } else { echo ' '.$i.' '; } } } next_posts_link($nxtlabel, $max_page); if (($paged+$half_pages_to_show) < ($max_page)) { echo ' ... Last »'; } echo "$after"; } } } /* 结束分页 */ /* 判断是否为管理员 */ // Template tag: echoes semantic classes for a comment
  • function comment_class() { global $comment, $post; $c = array($comment->comment_type, "c$comment_count"); if ( $comment->user_id > 0 ) { $user = get_userdata($comment->user_id); $c[] = "byuser commentauthor-$user->user_login"; if ( $comment->user_id === $post->post_author ) { $c[] = 'bypostauthor'; } } echo join(' ', apply_filters('comment_class', $c)); } /* 结束判断是否为管理员 */ /**************** get_gravatar With icon ********************/ function gr_all_icons($rating = false, $size = false, $default = false, $border = false, $threshhold = false) { global $wpdb; $comments = $wpdb->get_results("SELECT comment_author, comment_author_email, comment_author_url, user_id, COUNT(comment_ID) AS 'comment_total' FROM $wpdb->comments WHERE comment_approved = '1' AND user_id != 1 GROUP BY comment_author ORDER BY comment_total DESC"); $cont = 1; foreach ($comments as $comment) { $comment_author_email = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email); $comment_author = htmlspecialchars(stripslashes($comment->comment_author)); $comment_author_url =stripslashes($comment->comment_author_url); $comment_total = (int) $comment->comment_total; if($rating && $rating != '') $comment_author_email .= "&rating=".$rating; if($size && $size != '') $comment_author_email .="&size=".$size; if($default && $default != '') $comment_author_email .= "&default=".urlencode($default); if($border && $border != '') $comment_author_email .= "&border=".$border; echo "\"$comment_author\""; if($comment_total <= $threshhold && $threshhold != -1) { return; } } } function gr_recent_comments($rating = false, $size = false, $default = false, $border = false, $no_comments = false) { global $wpdb; $request = "SELECT ID, comment_ID, comment_author_email, comment_content, comment_author FROM $wpdb->posts, $wpdb->comments WHERE $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish'"; $request .= "AND comment_approved = '1' ORDER BY $wpdb->comments.comment_date DESC LIMIT $no_comments"; $comments = $wpdb->get_results($request); foreach ($comments as $comment) { $comment_author_email = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email); $comment_author = stripslashes($comment->comment_author); $comment_content = strip_tags($comment->comment_content); $comment_content = stripslashes($comment_content); $comment_excerpt =substr($comment_content,0,32); $comment_excerpt = gr_utf8_trim($comment_excerpt); $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID; if($rating && $rating != '') $comment_author_email .= "&rating=".$rating; if($size && $size != '') $comment_author_email .="&size=".$size; if($default && $default != '') $comment_author_email .= "&default=".urlencode($default); if($border && $border != '') $comment_author_email .= "&border=".$border; echo "\"$comment_author\""; } return; } function gr_utf8_trim($str) { $len = strlen($str); for ($i=strlen($str)-1; $i>=0; $i-=1){ $hex .= ' '.ord($str[$i]); $ch = ord($str[$i]); if (($ch & 128)==0) return(substr($str,0,$i)); if (($ch & 192)==192) return(substr($str,0,$i)); } return($str.$hex); } /* end get_gravatar With icon */ ?>