mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Reply to comments from admin, first run, see #7435
git-svn-id: https://develop.svn.wordpress.org/trunk@8720 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -422,6 +422,69 @@ case 'add-comment' :
|
||||
'data' => $comment_list_item
|
||||
) );
|
||||
}
|
||||
$x->send();
|
||||
break;
|
||||
case 'replyto-comment' :
|
||||
check_ajax_referer( $action );
|
||||
|
||||
$comment_post_ID = (int) $_POST['comment_post_ID'];
|
||||
if ( !current_user_can( 'edit_post', $comment_post_ID ) )
|
||||
die('-1');
|
||||
|
||||
$status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
|
||||
|
||||
if ( empty($status) )
|
||||
die('1');
|
||||
elseif ( in_array($status->post_status, array('draft', 'pending') ) )
|
||||
die( __('Error: you are replying to comment on a draft post.') );
|
||||
|
||||
$user = wp_get_current_user();
|
||||
if ( $user->ID ) {
|
||||
$comment_author = $wpdb->escape($user->display_name);
|
||||
$comment_author_email = $wpdb->escape($user->user_email);
|
||||
$comment_author_url = $wpdb->escape($user->user_url);
|
||||
$comment_content = trim($_POST['comment']);
|
||||
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 {
|
||||
die( __('Sorry, you must be logged in to reply to a comment.') );
|
||||
}
|
||||
|
||||
if ( '' == $comment_content )
|
||||
die( __('Error: please type a comment.') );
|
||||
|
||||
$comment_parent = absint($_POST['comment_ID']);
|
||||
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
|
||||
|
||||
$comment_id = wp_new_comment( $commentdata );
|
||||
$comment = get_comment($comment_id);
|
||||
if ( ! $comment ) die('1');
|
||||
|
||||
$mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail';
|
||||
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
|
||||
$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
|
||||
|
||||
if ( get_option('show_avatars') && 'single' != $mode )
|
||||
add_filter( 'comment_author', 'floated_admin_avatar' );
|
||||
|
||||
$x = new WP_Ajax_Response();
|
||||
|
||||
ob_start();
|
||||
_wp_comment_row( $comment->comment_ID, $mode, false, $checkbox );
|
||||
$comment_list_item = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$x->add( array(
|
||||
'what' => 'comment',
|
||||
'id' => $comment->comment_ID,
|
||||
'data' => $comment_list_item,
|
||||
'position' => $position
|
||||
));
|
||||
|
||||
$x->send();
|
||||
break;
|
||||
case 'add-meta' :
|
||||
|
||||
Reference in New Issue
Block a user