wp ajax edit comments,wp_ajax_get_comments() - WordPress 函数参考中文文档

wp_ajax_get_comments( string $action )

Ajax handler for getting comments.

描述

参数

$action

(string)

(Required)

Action to perform.

源代码

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

function wp_ajax_get_comments( $action ) {

global $post_id;

if ( empty( $action ) ) {

$action = 'get-comments';

}

check_ajax_referer( $action );

if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {

$id = absint( $_REQUEST['p'] );

if ( ! empty( $id ) ) {

$post_id = $id;

}

}

if ( empty( $post_id ) ) {

wp_die( -1 );

}

$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );

if ( ! current_user_can( 'edit_post', $post_id ) ) {

wp_die( -1 );

}

$wp_list_table->prepare_items();

if ( ! $wp_list_table->has_items() ) {

wp_die( 1 );

}

$x = new WP_Ajax_Response();

ob_start();

foreach ( $wp_list_table->items as $comment ) {

if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved )

continue;

get_comment( $comment );

$wp_list_table->single_row( $comment );

}

$comment_list_item = ob_get_clean();

$x->add( array(

'what' => 'comments',

'data' => $comment_list_item

) );

$x->send();

}

更新日志

Version

描述

3.1.0

Introduced.

相关函数

Uses

wp-admin/includes/class-wp-list-table.php:

WP_List_Table::single_row()

wp-admin/includes/class-wp-list-table.php:

WP_List_Table::prepare_items()

wp-admin/includes/class-wp-list-table.php:

WP_List_Table::has_items()

wp-admin/includes/list-table.php:

_get_list_table()

wp-includes/capabilities.php:

current_user_can()

wp-includes/pluggable.php:

check_ajax_referer()

wp-includes/functions.php:

absint()

wp-includes/functions.php:

wp_die()

wp-includes/class-wp-ajax-response.php:

WP_Ajax_Response::__construct()

wp-includes/comment.php:

get_comment()

Show 5 more uses

Hide more uses

User Contributed Notes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值