BuddyPress::bp_loadmore()
Description #
Ajax callback for loading more posts.
Source #
File: addons/buddypress/buddypress.php
public function bp_loadmore() {
$type = ap_sanitize_unslash( 'type', 'r' );
$order_by = ap_sanitize_unslash( 'order_by', 'r' );
$user_id = (int) ap_sanitize_unslash( 'user_id', 'r' );
$paged = (int) ap_sanitize_unslash( 'current', 'r' ) + 1;
check_ajax_referer( 'loadmore-' . $type, '__nonce' );
if ( 'questions' === $type ) {
ob_start();
$this->page_questions( $user_id, $paged, true );
$html = ob_get_clean();
$paged = anspress()->questions->max_num_pages > $paged ? $paged : false;
ap_ajax_json(
array(
'success' => true,
'element' => '#ap-bp-questions',
'args' => array(
'__nonce' => wp_create_nonce( 'loadmore-questions' ),
'type' => 'questions',
'current' => $paged,
'user_id' => bp_displayed_user_id(),
),
'html' => $html,
)
);
} elseif ( 'answers' === $type ) {
ob_start();
$this->page_answers( $user_id, $paged, $order_by, true );
$html = ob_get_clean();
global $answers;
$paged = $answers->max_num_pages > $paged ? $paged : false;
ap_ajax_json(
array(
'success' => true,
'element' => '#ap-bp-answers',
'args' => array(
'__nonce' => wp_create_nonce( 'loadmore-answers' ),
'type' => 'answers',
'current' => $paged,
'user_id' => bp_displayed_user_id(),
'order_by' => $order_by,
),
'html' => $html,
)
);
}
}
Expand full source code Collapse full source code View on GitHub: addons/buddypress/buddypress.php:646
Add your comment