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 ); if ( isset( $_comment->comment_post_ID ) && $_comment->comment_post_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 ) ); } if ( isset( $post_id ) && $post_id ) { $_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(); if ( isset( $post_id ) && $post_id ) { ap_the_comments( $post_id, $args ); } else { ap_the_comments( -1, $args ); } $html = ob_get_clean(); if ( isset( $_post ) && $_post->post_type ) { $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:49
Add your comment