Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/27/2021 04:56:32 AM (9 months 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-templates/bp-nouveau/includes/template-tags.php

    r12892 r12907  
    44 *
    55 * @since 3.0.0
    6  * @version 8.0.0
     6 * @version 7.0.0
    77 */
    88
     
    26912691    <?php
    26922692}
     2693
     2694/**
     2695 * Checks whether the Activity RSS links should be output.
     2696 *
     2697 * @since 8.0.0
     2698 *
     2699 * @return bool True to output the Activity RSS link. False otherwise.
     2700 */
     2701function bp_nouveau_is_feed_enable() {
     2702    $retval     = false;
     2703    $bp_nouveau = bp_nouveau();
     2704
     2705    if ( bp_is_active( 'activity' ) && 'activity' === bp_current_component() ) {
     2706        if ( isset( $bp_nouveau->activity->current_rss_feed ) ) {
     2707            $bp_nouveau->activity->current_rss_feed = array(
     2708                'link'               => '',
     2709                'tooltip'            => _x( 'RSS Feed', 'BP RSS Tooltip', 'buddypress' ),
     2710                'screen_reader_text' => _x( 'RSS', 'BP RSS screen reader text', 'buddypress' ),
     2711            );
     2712
     2713            if ( ! bp_is_user() && ! bp_is_group() ) {
     2714                $retval = bp_activity_is_feed_enable( 'sitewide' );
     2715
     2716                if ( $retval ) {
     2717                    $bp_nouveau->activity->current_rss_feed['link'] = bp_get_sitewide_activity_feed_link();
     2718                }
     2719            } elseif ( bp_is_user_activity() ) {
     2720                $retval = bp_activity_is_feed_enable( 'personal' );
     2721
     2722                if ( $retval ) {
     2723                    $bp_nouveau->activity->current_rss_feed['link'] = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/feed' );
     2724                }
     2725
     2726                if ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
     2727                    $retval = bp_activity_is_feed_enable( 'friends' );
     2728
     2729                    if ( $retval ) {
     2730                        $bp_nouveau->activity->current_rss_feed['link'] = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed' );
     2731                    }
     2732                } elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
     2733                    $retval = bp_activity_is_feed_enable( 'mygroups' );
     2734
     2735                    if ( $retval ) {
     2736                        $bp_nouveau->activity->current_rss_feed['link'] = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed' );
     2737                    }
     2738                } elseif ( bp_activity_do_mentions() && bp_is_current_action( 'mentions' ) ) {
     2739                    $retval = bp_activity_is_feed_enable( 'mentions' );
     2740
     2741                    if ( $retval ) {
     2742                        $bp_nouveau->activity->current_rss_feed['link'] = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed' );
     2743                    }
     2744                } elseif ( bp_activity_can_favorite() && bp_is_current_action( 'favorites' ) ) {
     2745                    $retval = bp_activity_is_feed_enable( 'mentions' );
     2746
     2747                    if ( $retval ) {
     2748                        $bp_nouveau->activity->current_rss_feed['link'] = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed' );
     2749                    }
     2750                }
     2751            }
     2752        }
     2753    }
     2754
     2755    return $retval;
     2756}
Note: See TracChangeset for help on using the changeset viewer.