Changeset 9194 for trunk/src/bp-activity/bp-activity-actions.php
- Timestamp:
- 11/27/2014 05:13:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-actions.php
r9190 r9194 767 767 } 768 768 add_action( 'wp_ajax_bp_get_suggestions', 'bp_ajax_get_suggestions' ); 769 770 /** 771 * Detect a change in post type status, and initiate an activity update if necessary. 772 * 773 * @since BuddyPress (2.2.0) 774 * 775 * @todo Support untrashing better. 776 * 777 * @param string $new_status New status for the post. 778 * @param string $old_status Old status for the post. 779 * @param object $post Post data. 780 */ 781 function bp_activity_catch_transition_post_type_status( $new_status, $old_status, $post ) { 782 if ( ! post_type_supports( $post->post_type, 'buddypress-activity' ) ) { 783 return; 784 } 785 786 // This is an edit. 787 if ( $new_status === $old_status ) { 788 // An edit of an existing post should update the existing activity item. 789 if ( $new_status == 'publish' ) { 790 bp_activity_post_type_update( $post ); 791 } 792 793 return; 794 } 795 796 // Publishing a previously unpublished post. 797 if ( 'publish' === $new_status ) { 798 // Untrashing the post type - nothing here yet. 799 if ( 'trash' == $old_status ) { 800 do_action( 'bp_activity_post_type_untrash_' . $post->post_type, $post ); 801 } else { 802 // Record the post. 803 bp_activity_post_type_publish( $post->ID, $post ); 804 } 805 806 // Unpublishing a previously published post. 807 } else if ( 'publish' === $old_status ) { 808 // Some form of pending status - only remove the activity entry 809 bp_activity_post_type_unpublish( $post->ID, $post ); 810 } 811 } 812 add_action( 'transition_post_status', 'bp_activity_catch_transition_post_type_status', 10, 3 );
Note: See TracChangeset
for help on using the changeset viewer.