bp_nouveau_ajax_document_get_activity()
Get activity for the document.
Description
Source
File: bp-templates/bp-nouveau/includes/document/ajax.php
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | function bp_nouveau_ajax_document_get_activity() { $response = array ( 'feedback' => sprintf( '<div class="bp-feedback bp-messages error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>' , esc_html__( 'There was a problem displaying the content. Please try again.' , 'buddyboss' ) ), ); // Nonce check! $nonce = filter_input( INPUT_POST, 'nonce' , FILTER_SANITIZE_STRING ); if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce , 'bp_nouveau_media' ) ) { wp_send_json_error( $response ); } $post_id = filter_input( INPUT_POST, 'id' , FILTER_VALIDATE_INT ); $group_id = filter_input( INPUT_POST, 'group_id' , FILTER_VALIDATE_INT ); $author_id = filter_input( INPUT_POST, 'author' , FILTER_VALIDATE_INT ); // check activity is document or not. $document_activity = bp_activity_get_meta( $post_id , 'bp_document_activity' , true ); remove_action( 'bp_activity_entry_content' , 'bp_document_activity_entry' ); add_action( 'bp_before_activity_activity_content' , 'bp_nouveau_document_activity_description' ); add_filter( 'bp_get_activity_content_body' , 'bp_nouveau_clear_activity_content_body' , 99, 2 ); if ( ! empty ( $document_activity ) ) { $args = array ( 'include' => $post_id , 'privacy' => false, 'show_hidden' => true, 'scope' => 'document' , ); } else { if ( $group_id > 0 ) { $args = array ( 'include' => $post_id , 'object' => buddypress()->groups->id, 'primary_id' => $group_id , 'privacy' => false, 'scope' => false, 'show_hidden' => (bool) ( groups_is_user_member( bp_loggedin_user_id(), $group_id ) || bp_current_user_can( 'bp_moderate' ) ), ); } else { $args = array ( 'include' => $post_id , 'privacy' => false, 'scope' => false, ); } } ob_start(); if ( bp_has_activities( $args ) ) { while ( bp_activities() ) { bp_the_activity(); bp_get_template_part( 'activity/entry' ); } } $activity = ob_get_contents(); ob_end_clean(); remove_filter( 'bp_get_activity_content_body' , 'bp_nouveau_clear_activity_content_body' , 99, 2 ); remove_action( 'bp_before_activity_activity_content' , 'bp_nouveau_document_activity_description' ); add_action( 'bp_activity_entry_content' , 'bp_document_activity_entry' ); wp_send_json_success( array ( 'activity' => $activity , ) ); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.4.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.