/** * [mo_comments_list description] * @param [type] $comment [description] * @param [type] $args [description] * @param [type] $depth [description] * @return [type] [description] */ function mo_comments_list($comment, $args, $depth) { $GLOBALS['comment'] = $comment; global $commentcount, $wpdb, $post; if (!$commentcount) { //初始化楼层计数器 $comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = {$post->ID} AND comment_type = '' AND comment_approved = '1' AND !comment_parent"); $cnt = count($comments); //获取主评论总数量 $page = get_query_var('cpage'); //获取当前评论列表页码 $cpp = get_option('comments_per_page'); //获取每页评论显示数量 if (ceil($cnt / $cpp) == 1 || $page > 1 && $page == ceil($cnt / $cpp)) { $commentcount = $cnt + 1; //如果评论只有1页或者是最后一页,初始值为主评论总数 } else { $commentcount = $cpp * $page + 1; } } echo '<li '; comment_class(); echo ' id="comment-' . get_comment_ID() . '">'; //楼层 if (!($parent_id = $comment->comment_parent)) { echo '<span class="comt-f">'; printf('#%1$s', --$commentcount); echo '</span>'; } //头像 echo '<div class="comt-avatar">'; echo _get_the_avatar($user_id = $comment->user_id, $user_email = $comment->comment_author_email); echo '</div>'; //内容 echo '<div class="comt-main" id="div-comment-' . get_comment_ID() . '">'; // echo str_replace(' src=', ' data-src=', convert_smilies(get_comment_text())); comment_text(); if ($comment->comment_approved == '0') { echo '<span class="comt-approved">待审核</span>'; } echo '<div class="comt-meta"><span class="comt-author">' . get_comment_author_link() . '</span>'; echo _get_time_ago($comment->comment_date); if ($comment->comment_approved !== '0') { $replyText = get_comment_reply_link(array_merge($args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))); // echo str_replace(' href', ' href="javascript:;" data-href', $replyText ); if (strstr($replyText, 'reply-login')) { echo preg_replace('# class="[\\s\\S]*?" href="[\\s\\S]*?"#', ' class="signin-loader" href="javascript:;"', $replyText); } else { echo preg_replace('# href=[\\s\\S]*? onclick=#', ' href="javascript:;" onclick=', $replyText); } } echo '</div>'; echo '</div>'; }
function mod_newcomments($limit, $outpost, $outer) { global $wpdb; if (!$outer || $outer == 0) { $outer = 11111111111; } $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,100) AS com_excerpt FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) WHERE comment_post_ID!='" . $outpost . "' AND user_id!='" . $outer . "' AND comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT {$limit}"; $comments = $wpdb->get_results($sql); foreach ($comments as $comment) { $output .= '<li><a href="' . get_comment_link($comment->comment_ID) . '" title="' . $comment->post_title . '上的评论">' . _get_the_avatar($user_id = $comment->user_id, $user_email = $comment->comment_author_email) . ' <strong>' . $comment->comment_author . '</strong> ' . _get_time_ago($comment->comment_date_gmt) . '说:<br>' . str_replace(' src=', ' data-original=', convert_smilies(strip_tags($comment->com_excerpt))) . '</a></li>'; } echo $output; }
$comment_depth = 1; //为评论的 class 属性准备的 $tmp_c = $comment; while ($tmp_c->comment_parent != 0) { $comment_depth++; $tmp_c = get_comment($tmp_c->comment_parent); } //以下是評論式樣, 不含 "回覆". 要用你模板的式樣 copy 覆蓋. echo '<li '; comment_class(); echo ' id="comment-' . get_comment_ID() . '">'; echo '<span class="comt-f">#</span>'; //头像 echo '<div class="comt-avatar">'; /*global $loguser; if( $loguser ){ echo '<img src="'.$loguser->avatar.'">'; }else{*/ echo _get_the_avatar($user_id = $comment->user_id, $user_email = $comment->comment_author_email, $src = true); // } echo '</div>'; //内容 echo '<div class="comt-main" id="div-comment-' . get_comment_ID() . '">'; echo str_replace(' src=', ' data-src=', convert_smilies(get_comment_text())); echo '<div class="comt-meta"><span class="comt-author">' . get_comment_author_link() . '</span>'; echo '<time>' . _get_time_ago($comment->comment_date) . '</time>'; echo '</div>'; if ($comment->comment_approved == '0') { echo '<span class="comt-approved">待审核</span>'; } echo '</div>';