Skip to:
Content

BuddyPress.org

Ticket #6937: 6937.patch

File 6937.patch, 4.0 KB (added by imath, 6 years ago)
  • src/bp-blogs/bp-blogs-functions.php

    diff --git src/bp-blogs/bp-blogs-functions.php src/bp-blogs/bp-blogs-functions.php
    index a608107..c5383f5 100644
    function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) { 
    279279        $is_private = !empty( $_POST['blog_public'] ) && (int) $_POST['blog_public'] ? false : true;
    280280        $is_private = !apply_filters( 'bp_is_new_blog_public', !$is_private );
    281281
    282         // Only record this activity if the blog is public.
    283         if ( !$is_private && !$no_activity && bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) {
     282        // Only record this activity if the activity component is active and the blog is public.
     283        if ( bp_is_active( 'activity' ) && !$is_private && !$no_activity && bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) {
    284284
    285285                // Record this in activity streams.
    286286                bp_blogs_record_activity( array(
    function bp_blogs_remove_blog( $blog_id ) { 
    815815
    816816        BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    817817
    818         // Delete activity stream item.
    819         bp_blogs_delete_activity( array(
    820                 'item_id'   => $blog_id,
    821                 'component' => buddypress()->blogs->id,
    822                 'type'      => 'new_blog'
    823         ) );
     818        /**
     819         * Delete activity stream item only if the Activity component is active
     820         *
     821         * @see https://buddypress.trac.wordpress.org/ticket/6937
     822         */
     823        if ( bp_is_active( 'activity' ) ) {
     824                bp_blogs_delete_activity( array(
     825                        'item_id'   => $blog_id,
     826                        'component' => buddypress()->blogs->id,
     827                        'type'      => 'new_blog'
     828                ) );
     829        }
    824830
    825831        /**
    826832         * Fires after a "blog created" item has been removed from blogs
    function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 
    857863
    858864        BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
    859865
    860         // Delete activity stream item.
    861         bp_blogs_delete_activity( array(
    862                 'item_id'   => $blog_id,
    863                 'component' => buddypress()->blogs->id,
    864                 'type'      => 'new_blog'
    865         ) );
     866        /**
     867         * Delete activity stream item only if the Activity component is active
     868         *
     869         * @see https://buddypress.trac.wordpress.org/ticket/6937
     870         */
     871        if ( bp_is_active( 'activity' ) ) {
     872                bp_blogs_delete_activity( array(
     873                        'item_id'   => $blog_id,
     874                        'component' => buddypress()->blogs->id,
     875                        'type'      => 'new_blog'
     876                ) );
     877        }
    866878
    867879        /**
    868880         * Fires after a blog has been removed from the tracker for a specific user.
    function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) { 
    910922         */
    911923        do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
    912924
    913         // Delete activity stream item.
    914         bp_blogs_delete_activity( array(
    915                 'item_id'           => $blog_id,
    916                 'secondary_item_id' => $post_id,
    917                 'component'         => buddypress()->blogs->id,
    918                 'type'              => 'new_blog_post'
    919         ) );
     925        /**
     926         * Delete activity stream item only if the Activity component is active
     927         *
     928         * @see https://buddypress.trac.wordpress.org/ticket/6937
     929         */
     930        if ( bp_is_active( 'activity' ) ) {
     931                bp_blogs_delete_activity( array(
     932                        'item_id'           => $blog_id,
     933                        'secondary_item_id' => $post_id,
     934                        'component'         => buddypress()->blogs->id,
     935                        'type'              => 'new_blog_post'
     936                ) );
     937        }
    920938
    921939        /**
    922940         * Fires after removal of a blog post activity item from the activity stream.
    function bp_blogs_remove_data_for_blog( $blog_id ) { 
    11081126        // If this is regular blog, delete all data for that blog.
    11091127        BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    11101128
    1111         // Delete activity stream item.
    1112         bp_blogs_delete_activity( array(
    1113                 'item_id'   => $blog_id,
    1114                 'component' => buddypress()->blogs->id,
    1115                 'type'      => false
    1116         ) );
     1129        /**
     1130         * Delete activity stream item only if the Activity component is active
     1131         *
     1132         * @see https://buddypress.trac.wordpress.org/ticket/6937
     1133         */
     1134        if ( bp_is_active( 'activity' ) ) {
     1135                bp_blogs_delete_activity( array(
     1136                        'item_id'   => $blog_id,
     1137                        'component' => buddypress()->blogs->id,
     1138                        'type'      => false
     1139                ) );
     1140        }
    11171141
    11181142        /**
    11191143         * Fires after all data related to a given blog has been removed from blogs tracker