AnsPress_BP_Hooks::page_answers( $user_id = false, $paged = false, $order_by = false, $only_posts = false )
Description #
Callback for rendering questions page.
Source #
File: addons/free/buddypress.php
public static function page_answers( $user_id = false, $paged = false, $order_by = false, $only_posts = false ) {
global $answers;
$order_by = false === $order_by ? 'active' : $order_by;
$args['ap_current_user_ignore'] = true;
$args['ignore_selected_answer'] = true;
$args['showposts'] = 10;
$args['author'] = bp_displayed_user_id();
$args['ap_order_by'] = ap_sanitize_unslash( 'order_by', 'r', $order_by );
if ( false !== $paged ) {
$args['paged'] = $paged;
}
/**
* FILTER: ap_authors_questions_args
* Filter authors question list args
*
* @var array
*/
$args = apply_filters( 'ap_bp_answers_args', $args );
anspress()->answers = $answers = new Answers_Query( $args );
if ( false === $only_posts ) {
echo '<div class="ap-bp-head clearfix">';
echo '<h1>' . esc_attr__( 'Answers', 'anspress-question-answer' ) . '</h1>';
ap_answers_tab( get_the_permalink() );
echo '</div>';
echo '<div id="ap-bp-answers">';
}
if ( ap_have_answers() ) {
/* Start the Loop */
while ( ap_have_answers() ) : ap_the_answer();
ap_get_template_part( 'buddypress/answer-item' );
endwhile;
}
if ( false === $only_posts ) {
echo '</div>';
}
if ( $answers->max_num_pages > 1 && false === $only_posts ) {
$args = wp_json_encode( [ '__nonce' => wp_create_nonce( 'loadmore-answers' ), 'type' => 'answers', 'current' => 1, 'user_id' => bp_displayed_user_id(), 'order_by' => ap_sanitize_unslash( 'order_by', 'r' ) ] );
echo '<a href="#" class="ap-bp-loadmore ap-btn" ap-loadmore="' . esc_js( $args ) . '">' . esc_attr__( 'Load more answers', 'anspress-question-answer' ) . '</a>';
}
}
Expand full source code Collapse full source code View on GitHub: addons/free/buddypress.php:213
Add your comment