Skip to:
Content

BuddyPress.org

Changeset 12907


Ignore:
Timestamp:
04/27/2021 04:56:32 AM (6 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

Location:
trunk/src
Files:
12 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' );
  • trunk/src/bp-activity/bp-activity-functions.php

    r12694 r12907  
    42664266        );
    42674267}
     4268
     4269/**
     4270 * Checks whether an activity feed is enabled.
     4271 *
     4272 * @since 8.0.0
     4273 *
     4274 * @param string $feed_id The feed identifier. Possible values are:
     4275 *                        'sitewide', 'personal', 'friends', 'mygroups', 'mentions', 'favorites'.
     4276 */
     4277function bp_activity_is_feed_enable( $feed_id = '' ) {
     4278        /**
     4279         * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
     4280         *
     4281         * @since 1.8.0
     4282         * @since 8.0.0 Adds the `$feed_id` parameter.
     4283         *
     4284         * @param bool   $value   Defaults to true aka feeds are enabled.
     4285         * @param string $feed_id The feed identifier.
     4286         */
     4287        return (bool) apply_filters( 'bp_activity_enable_feeds', true, $feed_id );
     4288}
  • trunk/src/bp-activity/classes/class-bp-activity-feed.php

    r10487 r12907  
    8888         */
    8989        public function __construct( $args = array() ) {
    90 
    91                 /**
    92                  * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
    93                  *
    94                  * @since 1.8.0
    95                  *
    96                  * @param bool true Default true aka feeds are enabled.
    97                  */
    98                 if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
     90                $feed_id = '';
     91
     92                if ( isset( $args['id'] ) ) {
     93                        $feed_id = sanitize_key( $args['id'] );
     94                }
     95
     96                if ( false === bp_activity_is_feed_enable( $feed_id ) ) {
    9997                        global $wp_query;
    10098
    … …  
    102100                        $wp_query->is_feed = false;
    103101
    104                         return false;
    105                 }
    106 
    107                 // Setup data.
    108                 $this->data = wp_parse_args( $args, array(
    109                         // Internal identifier for the RSS feed - should be alphanumeric only.
    110                         'id'               => '',
    111 
    112                         // RSS title - should be plain-text.
    113                         'title'            => '',
    114 
    115                         // Relevant link for the RSS feed.
    116                         'link'             => '',
    117 
    118                         // RSS description - should be plain-text.
    119                         'description'      => '',
    120 
    121                         // Time-to-live - number of minutes to cache the data before an aggregator
    122                         // requests it again.  This is only acknowledged if the RSS client supports it
    123                         //
    124                         // See: http://www.rssboard.org/rss-profile#element-channel-ttl.
    125                         // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl.
    126                         'ttl'              => '30',
    127 
    128                         // Syndication module - similar to ttl, but not really supported by RSS
    129                         // clients
    130                         //
    131                         // See: http://web.resource.org/rss/1.0/modules/syndication/#description.
    132                         // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule.
    133                         'update_period'    => 'hourly',
    134                         'update_frequency' => 2,
    135 
    136                         // Number of items to display.
    137                         'max'              => 50,
    138 
    139                         // Activity arguments passed to bp_has_activities().
    140                         'activity_args'    => array()
    141                 ) );
    142 
    143                 /**
    144                  * Fires before the feed is setup so plugins can modify.
    145                  *
    146                  * @since 1.8.0
    147                  *
    148                  * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
    149                  */
    150                 do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
    151 
    152                 // Setup class properties.
    153                 $this->setup_properties();
    154 
    155                 // Check if id is valid.
    156                 if ( empty( $this->id ) ) {
    157                         _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
    158                         return false;
    159                 }
    160 
    161                 /**
    162                  * Fires after the feed is setup so plugins can modify.
    163                  *
    164                  * @since 1.8.0
    165                  *
    166                  * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
    167                  */
    168                 do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
    169 
    170                 // Setup feed hooks.
    171                 $this->setup_hooks();
    172 
    173                 // Output the feed.
    174                 $this->output();
    175 
    176                 // Kill the rest of the output.
    177                 die();
     102                        $this->data = array(
     103                                'enabled' => false,
     104                        );
     105                } else {
     106                        // Setup data.
     107                        $this->data = wp_parse_args( $args, array(
     108                                // Internal identifier for the RSS feed - should be alphanumeric only.
     109                                'id'               => '',
     110
     111                                // RSS title - should be plain-text.
     112                                'title'            => '',
     113
     114                                // Relevant link for the RSS feed.
     115                                'link'             => '',
     116
     117                                // RSS description - should be plain-text.
     118                                'description'      => '',
     119
     120                                // Time-to-live - number of minutes to cache the data before an aggregator
     121                                // requests it again.  This is only acknowledged if the RSS client supports it
     122                                //
     123                                // See: http://www.rssboard.org/rss-profile#element-channel-ttl.
     124                                // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl.
     125                                'ttl'              => '30',
     126
     127                                // Syndication module - similar to ttl, but not really supported by RSS
     128                                // clients
     129                                //
     130                                // See: http://web.resource.org/rss/1.0/modules/syndication/#description.
     131                                // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule.
     132                                'update_period'    => 'hourly',
     133                                'update_frequency' => 2,
     134
     135                                // Number of items to display.
     136                                'max'              => 50,
     137
     138                                // Activity arguments passed to bp_has_activities().
     139                                'activity_args'    => array(),
     140
     141                                // The activity feed is enabled.
     142                                'enabled'          => false,
     143                        ) );
     144
     145                        /**
     146                         * Fires before the feed is setup so plugins can modify.
     147                         *
     148                         * @since 1.8.0
     149                         *
     150                         * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
     151                         */
     152                        do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
     153
     154                        // Setup class properties.
     155                        $this->setup_properties();
     156
     157                        // Check if id is valid.
     158                        if ( empty( $this->id ) ) {
     159                                _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
     160                                return false;
     161                        }
     162
     163                        /**
     164                         * Fires after the feed is setup so plugins can modify.
     165                         *
     166                         * @since 1.8.0
     167                         *
     168                         * @param BP_Activity_Feed $this Current instance of activity feed. Passed by reference.
     169                         */
     170                        do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
     171
     172                        // Setup feed hooks.
     173                        $this->setup_hooks();
     174
     175                        // Output the feed.
     176                        $this->output();
     177
     178                        // Kill the rest of the output.
     179                        die();
     180                }
    178181        }
    179182
  • trunk/src/bp-templates/bp-legacy/buddypress/activity/index.php

    r12595 r12907  
    190190        <div class="item-list-tabs no-ajax" id="subnav" aria-label="<?php esc_attr_e( 'Activity secondary navigation', 'buddypress' ); ?>" role="navigation">
    191191                <ul>
    192                         <li class="feed"><a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>" aria-label="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><?php _e( 'RSS', 'buddypress' ); ?></a></li>
     192                        <?php if ( bp_activity_is_feed_enable( 'sitewide' ) ) : ?>
     193                                <li class="feed">
     194                                        <a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>" aria-label="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>">
     195                                                <?php esc_html_e( 'RSS', 'buddypress' ); ?>
     196                                        </a>
     197                                </li>
     198                        <?php endif; ?>
    193199
    194200                        <?php
  • trunk/src/bp-templates/bp-legacy/buddypress/groups/single/activity.php

    r12082 r12907  
    1111<div class="item-list-tabs no-ajax" id="subnav" aria-label="<?php esc_attr_e( 'Group secondary navigation', 'buddypress' ); ?>" role="navigation">
    1212        <ul>
    13                 <li class="feed"><a href="<?php bp_group_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>" aria-label="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><?php _e( 'RSS', 'buddypress' ); ?></a></li>
     13                <?php if ( bp_activity_is_feed_enable( 'group' ) ) : ?>
     14                        <li class="feed">
     15                                <a href="<?php bp_group_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>" aria-label="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>">
     16                                        <?php _e( 'RSS', 'buddypress' ); ?>
     17                                </a>
     18                        </li>
     19                <?php endif; ?>
    1420
    1521                <?php
  • trunk/src/bp-templates/bp-nouveau/buddypress/common/search-and-filters-bar.php

    r12892 r12907  
    1212                <div class="subnav-search clearfix">
    1313
    14                         <?php if ( bp_get_activity_slug() === bp_current_component() ) : ?>
    15                                 <div class="feed"><a href="<?php bp_sitewide_activity_feed_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span></a></div>
     14                        <?php if ( bp_nouveau_is_feed_enable() ) : ?>
     15                                <div id="activity-rss-feed" class="feed">
     16                                        <a href="<?php bp_nouveau_activity_rss_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php bp_nouveau_activity_rss_tooltip(); ?>">
     17                                                <span class="bp-screen-reader-text"><?php bp_nouveau_activity_rss_screen_reader_text(); ?></span>
     18                                        </a>
     19                                </div>
    1620                        <?php endif; ?>
    1721
    1822                        <?php bp_nouveau_search_form(); ?>
    1923
    20                 </div>
     24                </div>
    2125        <?php endif; ?>
    2226
    23                 <?php if ( bp_is_user() && ! bp_is_current_action( 'requests' ) ) : ?>
    24                         <?php bp_get_template_part( 'common/filters/user-screens-filters' ); ?>
    25                 <?php elseif ( bp_get_groups_slug() === bp_current_component() ) : ?>
    26                         <?php bp_get_template_part( 'common/filters/groups-screens-filters' ); ?>
    27                 <?php else : ?>
    28                         <?php bp_get_template_part( 'common/filters/directory-filters' ); ?>
    29                 <?php endif; ?>
     27        <?php if ( bp_is_user() && ! bp_is_current_action( 'requests' ) ) : ?>
     28                <?php bp_get_template_part( 'common/filters/user-screens-filters' ); ?>
     29        <?php elseif ( bp_get_groups_slug() === bp_current_component() ) : ?>
     30                <?php bp_get_template_part( 'common/filters/groups-screens-filters' ); ?>
     31        <?php else : ?>
     32                <?php bp_get_template_part( 'common/filters/directory-filters' ); ?>
     33        <?php endif; ?>
    3034
    3135</div><!-- search & filters -->
  • trunk/src/bp-templates/bp-nouveau/buddypress/groups/single/activity.php

    r12156 r12907  
    44 *
    55 * @since 3.0.0
    6  * @version 3.1.0
     6 * @version 8.0.0
    77 */
    8 
    98?>
    109
    … …  
    1817
    1918        <ul>
    20 
    21                 <li class="feed"><a href="<?php bp_group_activity_feed_link(); ?>" class="bp-tooltip no-ajax" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>"><span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span></a></li>
     19                <?php if ( bp_activity_is_feed_enable( 'group' ) ) : ?>
     20                        <li class="feed">
     21                                <a href="<?php bp_group_activity_feed_link(); ?>" class="bp-tooltip no-ajax" data-bp-tooltip="<?php esc_attr_e( 'RSS Feed', 'buddypress' ); ?>">
     22                                        <span class="bp-screen-reader-text"><?php esc_html_e( 'RSS', 'buddypress' ); ?></span>
     23                                </a>
     24                        </li>
     25                <?php endif; ?>
    2226
    2327                <li class="group-act-search"><?php bp_nouveau_search_form(); ?></li>
    24 
    2528        </ul>
    2629
    27                 <?php bp_get_template_part( 'common/filters/groups-screens-filters' ); ?>
     30        <?php bp_get_template_part( 'common/filters/groups-screens-filters' ); ?>
    2831</div><!-- // .subnav-filters -->
    2932
    … …  
    3235<div id="activity-stream" class="activity single-group" data-bp-list="activity">
    3336
    34                 <li id="bp-activity-ajax-loader"><?php bp_nouveau_user_feedback( 'group-activity-loading' ); ?></li>
     37        <div id="bp-activity-ajax-loader"><?php bp_nouveau_user_feedback( 'group-activity-loading' ); ?></div>
    3538
    3639</div><!-- .activity -->
  • trunk/src/bp-templates/bp-nouveau/buddypress/members/single/activity.php

    r12082 r12907  
    44 *
    55 * @since 3.0.0
    6  * @version 3.0.0
     6 * @version 8.0.0
    77 */
    8 
    98?>
    109
    … …  
    3130        <div id="bp-ajax-loader"><?php bp_nouveau_user_feedback( 'member-activity-loading' ); ?></div>
    3231
    33         <ul  class="<?php bp_nouveau_loop_classes(); ?>" >
    34 
    35         </ul>
     32        <ul class="<?php bp_nouveau_loop_classes(); ?>"></ul>
    3633
    3734</div><!-- .activity -->
  • trunk/src/bp-templates/bp-nouveau/includes/activity/loader.php

    r12192 r12907  
    44 *
    55 * @since 3.0.0
    6  * @version 3.0.0
     6 * @version 8.0.0
    77 */
    88
    … …  
    1616 */
    1717class BP_Nouveau_Activity {
     18        /**
     19         * Nouveau Activity directory.
     20         *
     21         * @since 3.0.0
     22         * @var string
     23         */
     24        public $dir = '';
     25
     26        /**
     27         * RSS feed link data.
     28         *
     29         * @since 3.0.0
     30         * @var string
     31         */
     32        public $current_rss_feed = array();
     33
    1834        /**
    1935         * Constructor
  • trunk/src/bp-templates/bp-nouveau/includes/activity/template-tags.php

    r12358 r12907  
    44 *
    55 * @since 3.0.0
    6  * @version 5.0.0
     6 * @version 8.0.0
    77 */
    88
    … …  
    913913                return $return;
    914914        }
     915
     916/**
     917 * Outputs the Activity RSS link.
     918 *
     919 * @since 8.0.0
     920 */
     921function bp_nouveau_activity_rss_link() {
     922        echo esc_url( bp_nouveau_activity_get_rss_link() );
     923}
     924
     925        /**
     926         * Returns the Activity RSS link.
     927         *
     928         * @since 8.0.0
     929         *
     930         * @return string The Activity RSS link.
     931         */
     932        function bp_nouveau_activity_get_rss_link() {
     933                $bp_nouveau = bp_nouveau();
     934                $link       = '';
     935
     936                if ( isset( $bp_nouveau->activity->current_rss_feed['link'] ) ) {
     937                        $link = $bp_nouveau->activity->current_rss_feed['link'];
     938                }
     939
     940                /**
     941                 * Filter here to edit the Activity RSS link.
     942                 *
     943                 * @since 8.0.0
     944                 *
     945                 * @param string The Activity RSS link.
     946                 */
     947                return apply_filters( 'bp_nouveau_activity_get_rss_link', $link );
     948        }
     949
     950/**
     951 * Outputs the Activity RSS Tooltip.
     952 *
     953 * @since 8.0.0
     954 */
     955function bp_nouveau_activity_rss_tooltip() {
     956        echo esc_attr( bp_nouveau_activity_get_rss_tooltip() );
     957}
     958
     959        /**
     960         * Returns the Activity RSS Tooltip.
     961         *
     962         * @since 8.0.0
     963         *
     964         * @return string The Activity RSS Tooltip.
     965         */
     966        function bp_nouveau_activity_get_rss_tooltip() {
     967                $bp_nouveau = bp_nouveau();
     968                $tooltip       = '';
     969
     970                if ( isset( $bp_nouveau->activity->current_rss_feed['tooltip'] ) ) {
     971                        $tooltip = $bp_nouveau->activity->current_rss_feed['tooltip'];
     972                }
     973
     974                /**
     975                 * Filter here to edit the Activity RSS Tooltip.
     976                 *
     977                 * @since 8.0.0
     978                 *
     979                 * @param string The Activity RSS Tooltip.
     980                 */
     981                return apply_filters( 'bp_nouveau_activity_get_rss_tooltip', $tooltip );
     982        }
     983
     984/**
     985 * Outputs the Activity RSS screen reader text.
     986 *
     987 * @since 8.0.0
     988 */
     989function bp_nouveau_activity_rss_screen_reader_text() {
     990        echo esc_attr( bp_nouveau_activity_get_rss_screen_reader_text() );
     991}
     992
     993        /**
     994         * Returns the Activity RSS screen reader text.
     995         *
     996         * @since 8.0.0
     997         *
     998         * @return string The Activity RSS screen reader text.
     999         */
     1000        function bp_nouveau_activity_get_rss_screen_reader_text() {
     1001                $bp_nouveau         = bp_nouveau();
     1002                $screen_reader_text = '';
     1003
     1004                if ( isset( $bp_nouveau->activity->current_rss_feed['tooltip'] ) ) {
     1005                        $screen_reader_text = $bp_nouveau->activity->current_rss_feed['tooltip'];
     1006                }
     1007
     1008                /**
     1009                 * Filter here to edit the Activity RSS screen reader text.
     1010                 *
     1011                 * @since 8.0.0
     1012                 *
     1013                 * @param string The Activity RSS screen reader text.
     1014                 */
     1015                return apply_filters( 'bp_nouveau_activity_get_rss_screen_reader_text', $screen_reader_text );
     1016        }
  • 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}
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-activity.js

    r12856 r12907  
    6565                        // Inject Activities
    6666                        $( '#buddypress [data-bp-list="activity"]' ).on( 'click', 'li.load-newest, li.load-more', this.injectActivities.bind( this ) );
     67                        $( '#buddypress [data-bp-list]' ).on( 'bp_ajax_request', this.updateRssLink );
    6768
    6869                        // Hightlight new activities & clean up the stream
    … …  
    834835                                $( element ).closest( 'form' ).find( '[type=submit]' ).first().trigger( 'click' );
    835836                        }
     837                },
     838
     839                updateRssLink: function( event, data ) {
     840                        var rssLink = data.response.feed_url || '';
     841
     842                        if ( rssLink && $( '#activity-rss-feed' ).length ) {
     843                                $( '#activity-rss-feed' ).find( 'a' ).first().prop( 'href', rssLink );
     844                        }
    836845                }
    837846        };
Note: See TracChangeset for help on using the changeset viewer.