bp_dtheme_activity_template_loader()
Load the activity loop template when activity is requested via AJAX,
Description Description
Return Return
(string) JSON object containing 'contents' (output of the template loop for the Activity component) and 'feed_url' (URL to the relevant RSS feed).
Source Source
File: bp-themes/bp-default/_inc/ajax.php
function bp_dtheme_activity_template_loader() { // Bail if not a POST action if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) return; $scope = ''; if ( ! empty( $_POST['scope'] ) ) $scope = $_POST['scope']; // We need to calculate and return the feed URL for each scope switch ( $scope ) { case 'friends': $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/friends/feed/'; break; case 'groups': $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/groups/feed/'; break; case 'favorites': $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/feed/'; break; case 'mentions': $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/feed/'; if ( isset( $_POST['_wpnonce_activity_filter'] ) && wp_verify_nonce( wp_unslash( $_POST['_wpnonce_activity_filter'] ), 'activity_filter' ) ) { bp_activity_clear_new_mentions( bp_loggedin_user_id() ); } break; default: $feed_url = home_url( bp_get_activity_root_slug() . '/feed/' ); break; } // Buffer the loop in the template to a var for JS to spit out. ob_start(); locate_template( array( 'activity/activity-loop.php' ), true ); $result['contents'] = ob_get_contents(); $result['feed_url'] = apply_filters( 'bp_dtheme_activity_feed_url', $feed_url, $scope ); ob_end_clean(); exit( json_encode( $result ) ); }
Changelog Changelog
Version | Description |
---|---|
BuddyPress (1.2) | Introduced. |