Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/27/2021 04:56:32 AM (2 years ago)
Author:
imath
Message:

Improve ways to disable BP RSS feeds

Returning false to the filter bp_activity_enable_feeds is completely disabling all RSS feeds and will now avoid the output of an empty link.

A second argument has been added to the filter to allow to disable a specific feed in particular, one of these feed identifiers:

  • 'sitewide',
  • 'personal',
  • 'friends',
  • 'mygroups',
  • 'mentions',
  • 'favorites'.

The BP Nouveau Template pack has also been improved to update the user's profile activity RSS feed links according to the context.

Props sippis

Fixes #8454

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/actions/feeds.php

    r12586 r12907  
    1818    $bp = buddypress();
    1919
    20     if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
    21         return false;
     20    if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) ) {
     21        return false;
     22    }
     23
     24    $link = bp_get_activity_directory_permalink();
    2225
    2326    // Setup the feed.
     
    2730        /* translators: %s Site Name */
    2831        'title'         => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
    29         'link'          => bp_get_activity_directory_permalink(),
     32        'link'          => $link,
    3033        'description'   => __( 'Activity feed for the entire site.', 'buddypress' ),
    3134        'activity_args' => 'display_comments=threaded'
    3235    ) );
     36
     37    if ( ! buddypress()->activity->feed->enabled ) {
     38        bp_core_redirect( $link );
     39    }
    3340}
    3441add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
     
    4653    }
    4754
     55    $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
     56
    4857    // Setup the feed.
    4958    buddypress()->activity->feed = new BP_Activity_Feed( array(
     
    5261        /* translators: 1: Site Name. 2: User Display Name. */
    5362        'title'         => sprintf( _x( '%1$s | %2$s | Activity', 'Personal activity feed title', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
    54         'link'          => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() ),
     63        'link'          => $link,
    5564
    5665        /* translators: %s: User Display Name */
     
    5867        'activity_args' => 'user_id=' . bp_displayed_user_id()
    5968    ) );
     69
     70    if ( ! buddypress()->activity->feed->enabled ) {
     71        bp_core_redirect( $link );
     72    }
    6073}
    6174add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
     
    7386    }
    7487
     88    $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() );
     89
    7590    // Setup the feed.
    7691    buddypress()->activity->feed = new BP_Activity_Feed( array(
     
    7994        /* translators: 1: Site Name 2: User Display Name */
    8095        'title'         => sprintf( __( '%1$s | %2$s | Friends Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
    81         'link'          => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() ),
     96        'link'          => $link,
    8297
    8398        /* translators: %s: User Display Name */
     
    85100        'activity_args' => 'scope=friends'
    86101    ) );
     102
     103    if ( ! buddypress()->activity->feed->enabled ) {
     104        bp_core_redirect( $link );
     105    }
    87106}
    88107add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
     
    103122    $groups    = groups_get_user_groups();
    104123    $group_ids = implode( ',', $groups['groups'] );
     124    $link      = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() );
    105125
    106126    // Setup the feed.
     
    110130        /* translators: 1: Site Name 2: User Display Name */
    111131        'title'         => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
    112         'link'          => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
     132        'link'          => $link,
    113133
    114134        /* translators: %s: User Display Name */
     
    120140        )
    121141    ) );
     142
     143    if ( ! buddypress()->activity->feed->enabled ) {
     144        bp_core_redirect( $link );
     145    }
    122146}
    123147add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
     
    135159    }
    136160
    137     if ( !bp_is_user_activity() || ! bp_is_current_action( 'mentions' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
    138         return false;
    139     }
     161    if ( ! bp_is_user_activity() || ! bp_is_current_action( 'mentions' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
     162        return false;
     163    }
     164
     165    $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions' );
    140166
    141167    // Setup the feed.
     
    145171        /* translators: 1: Site Name 2: User Display Name */
    146172        'title'         => sprintf( __( '%1$s | %2$s | Mentions', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
    147         'link'          => bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/',
     173        'link'          => $link,
    148174
    149175        /* translators: %s: User Display Name */
     
    153179        )
    154180    ) );
     181
     182    if ( ! buddypress()->activity->feed->enabled ) {
     183        bp_core_redirect( $link );
     184    }
    155185}
    156186add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
     
    169199
    170200    // Get displayed user's favorite activity IDs.
    171     $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
     201    $favs    = bp_activity_get_user_favorites( bp_displayed_user_id() );
    172202    $fav_ids = implode( ',', (array) $favs );
     203    $link    = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites' );
    173204
    174205    // Setup the feed.
     
    178209        /* translators: 1: Site Name 2: User Display Name */
    179210        'title'         => sprintf( __( '%1$s | %2$s | Favorites', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
    180         'link'          => bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/',
     211        'link'          => $link,
    181212
    182213        /* translators: %s: User Display Name */
     
    184215        'activity_args' => 'include=' . $fav_ids
    185216    ) );
     217
     218    if ( ! buddypress()->activity->feed->enabled ) {
     219        bp_core_redirect( $link );
     220    }
    186221}
    187222add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
Note: See TracChangeset for help on using the changeset viewer.