Skip to:
Content

BuddyPress.org

Ticket #5333: 5333-1.patch

File 5333-1.patch, 3.1 KB (added by DJPaul, 10 years ago)
  • bp-blogs/bp-blogs-functions.php

    diff --git a/bp-blogs/bp-blogs-functions.php b/bp-blogs/bp-blogs-functions.php
    index d032cfb..cf9b9a7 100644
    a b function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) { 
    247247add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 );
    248248
    249249/**
    250  * Detect a change in post status, and initiate an activity update if necessary.
     250 * Detect a publish change in post status, and initiate an activity update if necessary.
    251251 *
    252252 * Posts get new activity updates when (a) they are being published, and (b)
    253253 * they have not already been published. This enables proper posting for
    add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescrip 
    259259 *
    260260 * @param string $new_status New status for the post.
    261261 * @param string $old_status Old status for the post.
    262  * @param object $post Post data.
     262 * @param WP_Post $post Post data.
    263263 */
    264264function bp_blogs_catch_published_post( $new_status, $old_status, $post ) {
    265265
    function bp_blogs_catch_published_post( $new_status, $old_status, $post ) { 
    278278add_action( 'transition_post_status', 'bp_blogs_catch_published_post', 10, 3 );
    279279
    280280/**
     281 * Detect a un-publish change in post status, and initiate an activity update if necessary.
     282 *
     283 * Posts have their activity updates removed when (a) they are being trashed or set to draft, and (b) they were already published.
     284 * See #4090, #3746, #2546 for background.
     285 *
     286 * @since BuddyPress (2.0.0)
     287 *
     288 * @param string $new_status New status for the post.
     289 * @param string $old_status Old status for the post.
     290 * @param WP_Post $post Post data.
     291 */
     292function bp_blogs_catch_withdrawn_posts( $new_status, $old_status, $post ) {
     293
     294        // If the post wasn't already published, it won't have an activity stream item.
     295        if ( 'publish' !== $old_status )
     296                return;
     297
     298        // Only handle if the post is being trashed or set back to draft.
     299        if ( ! in_array( $new_status, array( 'draft', 'trash' ) ) )
     300                return;
     301
     302        bp_blogs_remove_post( $post->ID );
     303}
     304add_action( 'transition_post_status', 'bp_blogs_catch_withdrawn_posts', 10, 3 );
     305add_action( 'delete_post', 'bp_blogs_remove_post' );
     306
     307/**
    281308 * Record a new blog post in the BuddyPress activity stream.
    282309 *
    283310 * @param int $post_id ID of the post being recorded.
    add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 ); 
    595622 * @param int $blog_id Optional. Defaults to current blog ID.
    596623 * @param int $user_id Optional. Defaults to the logged-in user ID. This param
    597624 *        is currently unused in the function (but is passed to hooks).
     625 * @param WP_Post $post The post's object which is being removed. Optional.
    598626 */
    599627function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
    600628        global $wpdb, $bp;
    function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) { 
    617645
    618646        do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $user_id );
    619647}
    620 add_action( 'delete_post', 'bp_blogs_remove_post' );
    621648
    622649/**
    623650 * Remove a blog comment activity item from the activity stream.