第一,将comments-ajax.js 及 comments-ajax.php 放在你所使用主题的文件夹内;
comments-ajax.js
代码如下 | 复制代码 |
var i = 0, got = -1, len = document.getElementsByTagName('script').length; while ( i <= len && got == -1){ var js_url = document.getElementsByTagName('script')[i].src, got = js_url.indexOf('comments-ajax.js'); i++ ; } var edit_mode = '1', // 再??模式 ( '1'=?; '0'=不? ) ajax_php_url = js_url.replace('-ajax.js','-ajax.php'), wp_url = js_url.substr(0, js_url.indexOf('wp-content')), pic_sb = wp_url + 'wp-admin/images/wpspin_dark.gif', // 提交 icon pic_no = wp_url + 'wp-admin/images/no.png', // ?? icon pic_ys = wp_url + 'wp-admin/images/yes.png', // 成功 icon txt1 = '<div id="loading"><img src="' + pic_sb + '" style="vertical-align:middle;" alt=""/> 正在提交, ?稍候...</div>', txt2 = '<div id="error">#</div>', txt3 = '"><img src="' + pic_ys + '" style="vertical-align:middle;" alt=""/> 提交成功', edt1 = ', 刷新页面之前可以<a rel="nofollow" class="comment-reply-link" href="#edit" onclick='return addComment.moveForm("', edt2 = ')'>再编辑</a>', cancel_edit = '取消编辑', edit, num = 1, comm_array=[]; comm_array.push(''); jQuery(document).ready(function($) { /** submit */ /** Ajax */ error: function(request) { success: function(data) { // comments // show comment ok_htm = 'n<span id="success_' + num + txt3; $('#respond').before(new_htm); $body.animate( { scrollTop: $('#new_comm_' + num).offset().top - 200}, 900); /** comment-reply.dev.js */ t.respondId = respondId; if ( !t.I('wp-temp-form-div') ) { !comm ? ( $body.animate( { scrollTop: $('#respond').offset().top - 180 }, 400); if ( post && postId ) post.value = postId; cancel.onclick = function() { t.I('comment_parent').value = '0'; try { t.I('comment').focus(); } return false; I : function(e) { function exit_prev_edit() { var wait = 15, submit_val = $submit.val(); });// end jQ |
comments-ajax.php
代码如下 | 复制代码 |
<?php /** * WordPress ?戎们短自u??S Ajax comments >> WordPress-jQuery-Ajax-Comments v1.3 by Willin Kan. * www.111cn.net * ?明: ???文件是由 WP 3.0 根目?的 wp-comment-post.php 修改的, 修改的地方有注解. ? WP 升?, ?注意可能有所不同. */ if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) { /** Sets up the WordPress Environment. */ 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) ) { // get_post_status() will get the parent status for attachments. $status_obj = get_post_status_object($status); if ( !comments_open($comment_post_ID) ) { $comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null; // If the user is logged in $comment_type = ''; if ( get_option('require_name_email') && !$user->ID ) { if ( '' == $comment_content ) // 增加: ??提示功能 // 增加: ?z查重覆??功能 // 增加: ?z查??太快功能 $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'); // 增加: ?z查??是否正被??, 更新或新建?? $comment = get_comment($comment_id); //$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id; //取消原有的刷新重定向 //wp_redirect($location); $comment_depth = 1; //为评论的 class 属性准备的 //以下是??式?? 不含 "回覆". 要用你模板的式? copy 覆?. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ' ); ?></div> <div class="comment-body"><?php comment_text(); ?></div> </div> |
第二,在主题文件夹中打开header.php,找到:
代码如下 | 复制代码 |
<?php if ( is_singular() ) wp_enqueue_script( ‘comment-reply’ ); ?> 修改为: <?php if ( is_singular() ){ ?> |
好了,就是这么简单。清除缓存,刷新。