Changeset 8191
- Timestamp:
- 03/28/2014 11:01:08 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-functions.php
r8190 r8191 360 360 * @since BuddyPress (2.0.0) 361 361 * 362 * @todo Support untrashing better 363 * 362 364 * @param string $new_status New status for the post. 363 365 * @param string $old_status Old status for the post. … … 366 368 function bp_blogs_catch_transition_post_status( $new_status, $old_status, $post ) { 367 369 368 // Do nothing for edits370 // This is an edit 369 371 if ( $new_status === $old_status ) { 370 return; 372 if ( $new_status == 'publish' ) { 373 bp_blogs_update_post( $post ); 374 return; 375 } 371 376 } 372 377 373 378 // Publishing a previously unpublished post 374 379 if ( 'publish' === $new_status ) { 375 return bp_blogs_record_post( $post->ID, $post ); 380 // Untrashing the post 381 // Nothing here yet 382 if ( 'trash' == $old_status ) {} 383 384 // Record the post 385 bp_blogs_record_post( $post->ID, $post ); 376 386 377 387 // Unpublishing a previously published post 378 388 } else if ( 'publish' === $old_status ) { 379 return bp_blogs_remove_post( $post->ID ); 389 // Some form of pending status 390 // Only remove the activity entry 391 bp_blogs_delete_activity( array( 392 'item_id' => get_current_blog_id(), 393 'secondary_item_id' => $post->ID, 394 'component' => buddypress()->blogs->id, 395 'type' => 'new_blog_post' 396 ) ); 380 397 } 381 398 } … … 472 489 473 490 do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id ); 491 } 492 493 /** 494 * Updates a blog post's corresponding activity entry during a post edit. 495 * 496 * @since BuddyPress (2.0.0) 497 * 498 * @see bp_blogs_catch_transition_post_status() 499 * 500 * @param WP_Post $post 501 */ 502 function bp_blogs_update_post( $post ) { 503 if ( ! bp_is_active( 'activity' ) ) { 504 return; 505 } 506 507 $activity_id = bp_activity_get_activity_id( array( 508 'component' => buddypress()->blogs->id, 509 'item_id' => get_current_blog_id(), 510 'secondary_item_id' => $post->ID, 511 'type' => 'new_blog_post', 512 ) ); 513 514 // activity ID doesn't exist, so stop! 515 if ( empty( $activity_id ) ) { 516 return; 517 } 518 519 // update the activity entry 520 $activity = new BP_Activity_Activity( $activity_id ); 521 $activity->content = $post->post_content; 522 $activity->save(); 523 524 // add post comment status to activity meta if closed 525 if( 'closed' == $post->comment_status ) { 526 bp_activity_update_meta( $activity_id, 'post_comment_status', $post->comment_status ); 527 } else { 528 bp_activity_delete_meta( $activity_id, 'post_comment_status' ); 529 } 474 530 } 475 531
Note: See TracChangeset
for help on using the changeset viewer.