Example #1
0
function fun_comment($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    ?>
<li <?php 
    comment_class();
    ?>
 id="comment-<?php 
    comment_ID();
    ?>
">
	<div id="div-comment-<?php 
    comment_ID();
    ?>
" class="comment-body">
	<?php 
    echo fun_get_avatar($comment->user_id, '54', fun_get_avatar_type($comment->user_id));
    ?>
	<?php 
    $add_below = 'div-comment';
    ?>
	<div class="comment-main">
		<?php 
    if ($comment->comment_approved == '0') {
        ?>
			<span style="color:#C00; font-style:inherit; margin-top:5px; line-height:25px;"><?php 
        $cpid = $comment->comment_parent;
        if ($cpid != 0) {
            echo '@';
        }
        comment_author_link($cpid);
        _e('您的评论正在等待审核中...', 'tinection');
        ?>
</span>
			<br />			
		<?php 
    }
    ?>
		<?php 
    if ($comment->comment_approved == '1') {
        ?>
		<?php 
        comment_text();
        ?>
		<?php 
    }
    ?>
		<div class="comment-author">
			<div class="comment-info">
				<span class="comment_author_link"><?php 
    if ($comment->user_id != 0) {
        echo '<a href="' . get_author_posts_url($comment->user_id) . '" class="name">' . $comment->comment_author . '</a>';
    } else {
        comment_author_link();
    }
    ?>
</span>
				<?php 
    if (ot_get_option('comment_vip') == 'on') {
        get_author_class($comment->comment_author_email, $comment->user_id);
    }
    ?>
				<?php 
    if (ot_get_option('comment_ua') == 'on') {
        echo outputbrowser($comment->comment_agent);
    }
    ?>
				<?php 
    if (ot_get_option('comment_ip') == 'on') {
        ?>
<span class="comment_author_ip tooltip-trigger" title="<?php 
        echo sprintf(__('来自%1$s', 'tinection'), convertip(get_comment_author_ip()));
        ?>
"><img class="ip_img" src="<?php 
        echo THEME_URI . '/images/ua/ip.png';
        ?>
"></span><?php 
    }
    ?>
				<span class="datetime">
					<?php 
    echo timeago(get_gmt_from_date(get_comment_date('Y-m-d G:i:s')));
    ?>
				</span>
				<span class="reply">
					<?php 
    if (is_user_logged_in()) {
        comment_reply_link(array_merge($args, array('reply_text' => __('回复', 'tinection'), 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'])));
    } else {
        echo '<a rel="nofollow" class="comment-reply-login user-login" href="javascript:">' . __('登录以回复', 'tinection') . '</a>';
    }
    ?>
				</span>
				<span class="cmt-vote">
					<?php 
    $c_name = 'fun_comment_vote_' . $comment->comment_ID;
    $cookie = isset($_COOKIE[$c_name]) ? $_COOKIE[$c_name] : '';
    ?>
					<i class="fa fa-thumbs-o-up <?php 
    if ($cookie == 1) {
        echo 'voted';
    }
    ?>
" title="<?php 
    _e('顶一下', 'tinection');
    ?>
" data="<?php 
    echo $comment->comment_ID;
    ?>
" data-type="1" data-num="<?php 
    echo (int) get_comment_meta($comment->comment_ID, 'fun_comment_voteyes', true);
    ?>
"><?php 
    echo ' [' . (int) get_comment_meta($comment->comment_ID, 'fun_comment_voteyes', true) . ']';
    ?>
</i>
					<i class="fa fa-thumbs-o-down <?php 
    if ($cookie == 2) {
        echo 'voted';
    }
    ?>
" title="<?php 
    _e('踩一下', 'tinection');
    ?>
" data="<?php 
    echo $comment->comment_ID;
    ?>
" data-type="2" data-num="<?php 
    echo (int) get_comment_meta($comment->comment_ID, 'fun_comment_voteno', true);
    ?>
"><?php 
    echo ' [' . (int) get_comment_meta($comment->comment_ID, 'fun_comment_voteno', true) . ']';
    ?>
</i>
				</span>
				<!-- edit_comment_link(__('编辑','tinection'));--> 	
			</div>
		</div>
	<div class="clear"></div>
	</div>
</div>
  
<?php 
}
Example #2
0
function aurelius_comment($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    ?>
    
<li class="comment-item" id="li-comment-<?php 
    comment_ID();
    ?>
">
	<div class="head-image">
    <?php 
    if (function_exists('get_avatar') && get_option('show_avatars')) {
        echo get_avatar($comment, 48);
        // 头像尺寸为48
    }
    ?>
	</div>
	<div class="comment-content" id="comment-<?php 
    comment_ID();
    ?>
">
		<div class="comment-info">
			<div class="comment-author-name"><?php 
    echo get_comment_author_link();
    get_author_class($comment->comment_author_email, $comment->user_id);
    if (user_can($comment->user_id, 1)) {
        echo "<a title='博主' class='vip'></a>";
    }
    ?>
</div>
			<div class="comment-text">
				<?php 
    if ($comment->comment_approved == '0') {
        ?>
                    <em>改评论正在审核!</em><br />
                <?php 
    }
    ?>
                <?php 
    comment_text();
    ?>
			</div>
			<span class="comment-time"><?php 
    echo get_comment_time('Y-m-d H:i');
    ?>
</span>
			<?php 
    comment_reply_link(array_merge($args, array('reply_text' => '回复', 'depth' => $depth, 'max_depth' => $args['max_depth'])));
    ?>
			<?php 
    edit_comment_link('修改');
    ?>
            <?php 
    if (is_user_logged_in()) {
        $url = get_bloginfo('url');
        echo '<a id="delete-' . $comment->comment_ID . '" href="' . wp_nonce_url("{$url}/wp-admin/comment.php?action=deletecomment&amp;p=" . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '"" >删除</a>';
    }
    ?>
  
            <a href="javascript:;" data-action="comment_like" data-id="<?php 
    echo $comment->comment_ID;
    ?>
" class="comment-like <?php 
    if (isset($_COOKIE['c_comment_like' . $comment->comment_ID])) {
        echo 'done';
    }
    ?>
">顶 <span class="count"><?php 
    echo get_comment_like($comment->comment_ID);
    ?>
</span></a>
            <a href="javascript:;" data-action="comment_dislike" data-id="<?php 
    echo $comment->comment_ID;
    ?>
" class="comment-dislike <?php 
    if (isset($_COOKIE['c_comment_dislike' . $comment->comment_ID])) {
        echo 'done';
    }
    ?>
">踩 <span class="count"><?php 
    echo get_comment_dislike($comment->comment_ID);
    ?>
</span></a>
			
		</div>
	</div>
  
  <!-- 
    </li> 
    -->
  
  <?php 
}
Example #3
0
    function amativeness_comment($comment, $args, $depth)
    {
        $GLOBALS['comment'] = $comment;
        switch ($comment->comment_type) {
            case 'pingback':
            case 'trackback':
                // Display trackbacks differently than normal comments.
                ?>
                <li <?php 
                comment_class();
                ?>
 id="comment-<?php 
                comment_ID();
                ?>
">
                <p><?php 
                _e('Pingback:', 'amativeness');
                ?>
 <?php 
                comment_author_link();
                ?>
 <?php 
                edit_comment_link(__('(Edit)', 'amativeness'), '<span class="edit-link">', '</span>');
                ?>
</p>
                <?php 
                break;
            default:
                // Proceed with normal comments.
                global $post;
                ?>
                <li <?php 
                comment_class();
                ?>
 id="li-comment-<?php 
                comment_ID();
                ?>
">
                <article id="comment-<?php 
                comment_ID();
                ?>
" class="comment-b">
                    <header class="comment-meta comment-author vcard">
                        <?php 
                echo get_avatar($comment, 44);
                printf('<div class="comments-authore-title"><div class="comments-name">%1$s %2$s</div>', get_comment_author_link(), $comment->user_id === $post->post_author ? '<span class="comment-master">' . __('一只萌萌哒博主', 'amativeness') . '</span>' : '');
                get_author_class($comment->comment_author_email, $comment->user_id);
                echo '<div class="comments-ua">';
                if (function_exists(useragent_output_custom) === true) {
                    useragent_output_custom();
                }
                echo '</div></div>';
                printf('<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', esc_url(get_comment_link($comment->comment_ID)), get_comment_time('c'), sprintf(__('%1$s %2$s', 'amativeness'), get_comment_date(), get_comment_time()));
                ?>
                    </header>
                    <!-- .comment-meta -->
                    <?php 
                if ('0' == $comment->comment_approved) {
                    ?>
                        <p class="comment-awaiting-moderation"><?php 
                    _e('Your comment is awaiting moderation.', 'amativeness');
                    ?>
</p>
                    <?php 
                }
                ?>
                    <section class="comment-content comment">
                        <?php 
                comment_text();
                ?>
                        <?php 
                edit_comment_link(__('Edit', 'amativeness'), '<p class="edit-link">', '</p>');
                ?>
                        <div class="comment-reply"">
                            <?php 
                comment_reply_link(array_merge($args, array('reply_text' => __('Reply', 'amativeness'), 'depth' => $depth, 'max_depth' => $args['max_depth'])));
                ?>
                        </div>
                        <!-- .reply -->
                    </section>
                    <!-- .comment-content -->
                </article>
                <!-- #comment-## -->
                <?php 
                break;
        }
        // end comment_type check
    }
Example #4
0
function bymt_ajax_comment()
{
    if (isset($_POST['action']) && $_POST['action'] == 'bymt_ajax_comment' && 'POST' == $_SERVER['REQUEST_METHOD']) {
        global $wpdb;
        nocache_headers();
        $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
        $post = get_post($comment_post_ID);
        if (empty($post->comment_status)) {
            do_action('comment_id_not_found', $comment_post_ID);
            err(__('无效的评论状态'));
            // 將 exit 改為錯誤提示
        }
        // get_post_status() will get the parent status for attachments.
        $status = get_post_status($post);
        $status_obj = get_post_status_object($status);
        if (!comments_open($comment_post_ID)) {
            do_action('comment_closed', $comment_post_ID);
            err(__('评论已关闭!'));
            // 將 wp_die 改為錯誤提示
        } elseif ('trash' == $status) {
            do_action('comment_on_trash', $comment_post_ID);
            err(__('无效的评论状态'));
            // 將 exit 改為錯誤提示
        } elseif (!$status_obj->public && !$status_obj->private) {
            do_action('comment_on_draft', $comment_post_ID);
            err(__('无效的评论状态'));
            // 將 exit 改為錯誤提示
        } elseif (post_password_required($comment_post_ID)) {
            do_action('comment_on_password_protected', $comment_post_ID);
            err(__('受密码保护请先输入密码'));
            // 將 exit 改為錯誤提示
        } else {
            do_action('pre_comment_on_post', $comment_post_ID);
        }
        $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null;
        $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null;
        $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null;
        $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null;
        $edit_id = isset($_POST['edit_id']) ? $_POST['edit_id'] : null;
        // 提取 edit_id
        // If the user is logged in
        $user = wp_get_current_user();
        if ($user->exists()) {
            if (empty($user->display_name)) {
                $user->display_name = $user->user_login;
            }
            $comment_author = esc_sql($user->display_name);
            $comment_author_email = esc_sql($user->user_email);
            $comment_author_url = esc_sql($user->user_url);
            if (current_user_can('unfiltered_html')) {
                if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) {
                    kses_remove_filters();
                    // start with a clean slate
                    kses_init_filters();
                    // set up the filters
                }
            }
        } else {
            if (get_option('comment_registration') || 'private' == $status) {
                err(__('您必须先登陆才可以发表评论'));
            }
            // 將 wp_die 改為錯誤提示
        }
        $comment_type = '';
        if (get_option('require_name_email') && !$user->exists()) {
            if (6 > strlen($comment_author_email) || '' == $comment_author) {
                err(__('请填写昵称和邮箱'));
            } elseif (!is_email($comment_author_email)) {
                err(__('请填写一个有效的邮箱'));
            }
            // 將 wp_die 改為錯誤提示
        }
        if ('' == $comment_content) {
            err(__('请输入评论内容'));
        }
        // 將 wp_die 改為錯誤提示
        // 增加: 檢查重覆評論功能
        $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
        if ($comment_author_email) {
            $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
        }
        $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
        if ($wpdb->get_var($dupe)) {
            err(__('您已经发布过一条相同的评论!'));
        }
        // 增加: 檢查評論太快功能
        if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) {
            $time_lastcomment = mysql2date('U', $lasttime, false);
            $time_newcomment = mysql2date('U', current_time('mysql', 1), false);
            $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
            if ($flood_die) {
                err(__('请过一会再发表评论'));
            }
        }
        $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
        $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
        // 增加: 檢查評論是否正被編輯, 更新或新建評論
        if ($edit_id) {
            // 判断当前用户是否具有编辑该评论权限
            if (current_user_can("edit_comment", $edit_id)) {
                // 判断当前用户的邮箱是否与评论邮箱相同
                if ($current_user->user_email == $comment_author_email) {
                    $comment_id = $commentdata['comment_ID'] = $edit_id;
                    wp_update_comment($commentdata);
                } else {
                    err(__('您不能修改为他人评论!'));
                }
            } else {
                err(__('您没有权限编辑该评论!'));
            }
        } else {
            $comment_id = wp_new_comment($commentdata);
        }
        $comment = get_comment($comment_id);
        do_action('set_comment_cookies', $comment, $user);
        $comment_depth = 1;
        //为评论的 class 属性准备的
        $tmp_c = $comment;
        while ($tmp_c->comment_parent != 0) {
            $comment_depth++;
            $tmp_c = get_comment($tmp_c->comment_parent);
        }
        //此处非常必要,无此处下面的评论无法输出 by mufeng
        $GLOBALS['comment'] = $comment;
        global $depth;
        //以下是評論式樣, 不含 "回覆". 要用你模板的式樣 copy 覆蓋.
        ?>
		<li <?php 
        comment_class();
        ?>
 id="comment-<?php 
        comment_ID();
        ?>
" <?php 
        if ($depth > get_option('thread_comments_depth') && !wp_is_mobile()) {
            echo ' style="margin-left:0px;"';
        }
        ?>
>
			<div id="div-comment-<?php 
        comment_ID();
        ?>
" class="comment-body">
			<?php 
        $add_below = 'div-comment';
        ?>
			<div class="comment-author vcard gravatar"><?php 
        echo bymt_avatar($comment->comment_author_email);
        ?>
</div>
			<div class="floor">新楼</div>
			<div class="commenttext">
				<span class="commentid"><?php 
        comment_author_link();
        ?>
</span>
				<?php 
        get_author_class($comment->comment_author_email, $comment->comment_author_url);
        ?>
		 		<span class="datetime"><?php 
        bymt_time_diff($time_type = 'comment');
        ?>
</span>
		 		<span class="edit_comment"><?php 
        edit_comment_link('[编辑]');
        ?>
</span>
			<div class="comment_text">
			<?php 
        if ($comment->comment_approved == '0') {
            ?>
				<span style="color:#f00;">您的评论正在等待审核中...</span>		
				<?php 
            comment_text();
            ?>
			<?php 
        } else {
            ?>
				<?php 
            comment_text();
            ?>
			<?php 
        }
        ?>
			</div>
			</div>
			</div>
		<?php 
        die;
        //以上是評論式樣, 不含 "回覆". 要用你模板的式樣 copy 覆蓋.
    } else {
        return;
    }
}