wp_ajax_edit_comment() - WordPress 函数参考中文文档

返回介绍

wp_ajax_edit_comment()

发布于 2017-09-11 字数2358 浏览 769 评论 0

wp_ajax_edit_comment()

Ajax handler for editing a comment.


描述


源代码

File: wp-admin/includes/ajax-actions.php

function wp_ajax_edit_comment() {
	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );

	$comment_id = (int) $_POST['comment_ID'];
	if ( ! current_user_can( 'edit_comment', $comment_id ) )
		wp_die( -1 );

	if ( '' == $_POST['content'] )
		wp_die( __( 'ERROR: please type a comment.' ) );

	if ( isset( $_POST['status'] ) )
		$_POST['comment_status'] = $_POST['status'];
	edit_comment();

	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
	$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );

	$comment = get_comment( $comment_id );
	if ( empty( $comment->comment_ID ) )
		wp_die( -1 );

	ob_start();
	$wp_list_table->single_row( $comment );
	$comment_list_item = ob_get_clean();

	$x = new WP_Ajax_Response();

	$x->add( array(
		'what' => 'edit_comment',
		'id' => $comment->comment_ID,
		'data' => $comment_list_item,
		'position' => $position
	));

	$x->send();
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-admin/includes/class-wp-list-table.php:
    WP_List_Table::single_row()
  • wp-admin/includes/list-table.php:
    _get_list_table()
  • wp-admin/includes/comment.php:
    edit_comment()
  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/l10n.php:
    __()
  • wp-includes/pluggable.php:
    check_ajax_referer()
  • wp-includes/functions.php:
    wp_die()
  • wp-includes/class-wp-ajax-response.php:
    WP_Ajax_Response::__construct()
  • wp-includes/comment.php:
    get_comment()
  • Show 4 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!