AnsPress_Comment_Hooks::load_comments()
Description #
Ajax callback for loading comments.
Changelog #
Version | Description |
---|---|
3.0.0 | Moved from AnsPress_Ajax class. |
2.0.1 | Introduced. |
Source #
File: includes/comments.php
public static function load_comments() { global $avatar_size; $paged = 1; $comment_id = ap_sanitize_unslash( 'comment_id', 'r' ); if ( ! empty( $comment_id ) ) { $_comment = get_comment( $comment_id ); $post_id = $_comment->comment_post_ID; } else { $post_id = ap_sanitize_unslash( 'post_id', 'r' ); $paged = max( 1, ap_isset_post_value( 'paged', 1 ) ); } $_post = ap_get_post( $post_id ); $args = array( 'show_more' => false, ); if ( ! empty( $_comment ) ) { $avatar_size = 60; $args['comment__in'] = $_comment->comment_ID; } ob_start(); ap_the_comments( $post_id, $args ); $html = ob_get_clean(); $type = 'question' === $_post->post_type ? __( 'Question', 'anspress-question-answer' ) : __( 'Answer', 'anspress-question-answer' ); $result = array( 'success' => true, 'html' => $html, ); ap_ajax_json( $result ); }
Expand full source code Collapse full source code View on GitHub: includes/comments.php:47
Add your comment