| Server IP : 112.74.42.100 / Your IP : 216.73.216.142 Web Server : nginx/1.20.2 System : Linux iZwz96lx4pjqiy84w4hni7Z 5.10.134-17.3.al8.x86_64 #1 SMP Thu Oct 31 14:29:57 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/sanxuany.cn/wp-content/themes/ioswallow/inc/ |
Upload File : |
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* 评论数据
*/
function comments_data( $postid = false ) {
if ($postid) {
$comments = get_comments( 'status=approve&type=comment&post_id='.$postid ); // 当前文章评论
$count = get_comment_count($postid);
}
else {
$comments = get_comments( array( 'status' => 'approve' ) ); // 所有评论
$count = get_comment_count();
}
$admin_email = get_bloginfo( 'admin_email' );
$data = array();
$temp = array();
$user_count = 0; // 计算评论的人数
$comment_count = $count['approved']; // 获取评论数量
foreach ($comments as $comment) {
$id = $comment->comment_ID;
$author = $comment->comment_author;
$email = $comment->comment_author_email;
$url = $comment->comment_author_url;
$date = $comment->comment_date;
$content = $comment->comment_content;
$master = array($admin_email);
if ( $postid ) { // 非文章下忽略 直接调用 count
$total_comment_number = get_comments( array( 'author_email' => $email ) );
$total_count = 0; // 计算访客个人在整站的评论总数
foreach ( $total_comment_number as $comm ) {
$total_count += 1;
}
}
if ( ! in_array( $email, $temp ) ) {
$temp[] = $email;
$user_count++;
}
$m = 0;
foreach ( $master as $value ) {
if ( $email == $value ) {
$m = 1;
}
}
if ( $m == 0 ) {
$k = -1;
foreach ( $data as $item => $comm ) {
if ( $email == $comm['email'] ) {
$k = $item;
break;
}
}
if ( $k > -1 ) {
$data[$k]['number'] += 1;
}
else {
$data[] = array(
'recent_id' => $id,
'author' => $author,
'email' => $email,
'url' => $url,
'date' => $date,
'number' => 1,
'content' => $content,
'count' => array($user_count, $comment_count),
'total_count' => $total_count
);
}
}
}
return $data;
}
/**
* 头衔
*/
function site_rank( $comment_author_email, $user_id ) {
$comment_rank = io_get_option( 'comment_rank' );
if ( ! $comment_rank ) return false;
$v1 = io_get_option( 'comment_rank_1' );
$v2 = io_get_option( 'comment_rank_2' );
$v3 = io_get_option( 'comment_rank_3' );
$v4 = io_get_option( 'comment_rank_4' );
$v5 = io_get_option( 'comment_rank_5' );
$v6 = io_get_option( 'comment_rank_6' );
global $wpdb;
$adminEmail = get_option( 'admin_email' );
$num = count( $wpdb->get_results( "SELECT comment_ID as author_count FROM $wpdb->comments WHERE comment_author_email = '$comment_author_email' " ) );
if ( $num > 0 && $num < 6 ) {
$rank = $v1;
}
elseif ( $num > 5 && $num < 11 ) {
$rank = $v2;
}
elseif ( $num > 10 && $num < 16 ) {
$rank = $v3;
}
elseif ($num > 15 && $num < 21) {
$rank = $v4;
}
elseif ( $num > 20 && $num < 26 ) {
$rank = $v5;
}
elseif ( $num > 25 ) {
$rank = $v6;
}
if( $comment_author_email != $adminEmail )
return $rank = '<span class="rank" data-balloon="'.__('头衔:','i_theme') . $rank .' , '.__('全站累计评论数:','i_theme').''. $num .'" data-balloon-pos="right">( '. $rank .' )</span>';
}
/**
* 评论高亮作者
*/
function is_master($email = '') {
if( empty($email) ) return;
$handsome = array( '1' => ' ', );
$adminEmail = get_option( 'admin_email' );
if( $email == $adminEmail )
echo '<i class="iconfont is-author" data-balloon="'.__('博主','i_theme').'" data-balloon-pos="right"><i class="iconfont icon-user"></i></i>';
elseif( in_array( $email, $handsome ) )
echo '<i class="iconfont is-author" aria-label="'.__('博主','i_theme').'" data-balloon-pos="right"><i class="iconfont icon-user"></i></i>';
}