bp_nouveau_ajax_get_single_activity_content()
Fetches an activity’s full, non-excerpted content via a POST request.
Description
Used for the ‘Read More’ link on long activity items.
Return
(string) JSON reply.
Source
File: bp-templates/bp-nouveau/includes/activity/ajax.php
function bp_nouveau_ajax_get_single_activity_content() {
$response = array(
'feedback' => sprintf(
'<div class="bp-feedback bp-messages error">%s</div>',
esc_html__( 'There was a problem displaying the content. Please try again.', 'buddyboss' )
),
);
// Bail if not a POST action.
if ( ! bp_is_post_request() ) {
wp_send_json_error( $response );
}
// Nonce check!
if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_activity' ) ) {
wp_send_json_error( $response );
}
$activity_array = bp_activity_get_specific(
array(
'activity_ids' => $_POST['id'],
'display_comments' => 'stream',
)
);
if ( empty( $activity_array['activities'][0] ) ) {
wp_send_json_error( $response );
}
$activity = $activity_array['activities'][0];
/**
* Fires before the return of an activity's full, non-excerpted content via a POST request.
*
* @since BuddyPress 3.0.0
*
* @param string $activity Activity content. Passed by reference.
*/
do_action_ref_array( 'bp_nouveau_get_single_activity_content', array( &$activity ) );
// Activity content retrieved through AJAX should run through normal filters, but not be truncated.
remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry', 5 );
/** This filter is documented in bp-activity/bp-activity-template.php */
$content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $activity->content, &$activity ) );
wp_send_json_success( array( 'contents' => $content ) );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 3.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.