AnsPress_Comment_Hooks::comments_data( integer $post_id, boolean $editing = false, $offset )
Description #
Comment data.
Parameters #
- $post_idinteger (Required) Post ID.
- $editingboolean (Optional) Editing mode. Default value: false
Source #
File: includes/comments.php
public static function comments_data( $post_id, $editing = false, $offset = 0 ) {
$user_id = get_current_user_id();
$args = array(
'post_id' => $post_id,
'order' => 'ASC',
'status' => 'approve',
'number' => ap_opt( 'comment_number' ),
'offset' => $offset,
);
// Always include current user comments.
if ( ! empty( $user_id ) && $user_id > 0 ) {
$args['include_unapproved'] = [ $user_id ];
}
if ( ap_user_can_approve_comment( ) ) {
$args['status'] = 'all';
}
$comments = get_comments( $args );
$comments_arr = array();
foreach ( (array) $comments as $c ) {
$comments_arr[] = ap_comment_ajax_data( $c );
}
if ( ! empty( $comments_arr ) ) {
return $comments_arr;
}
return [];
}
Expand full source code Collapse full source code View on GitHub: includes/comments.php:25
Add your comment