Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/12/2013 10:08:10 PM (11 years ago)
Author:
boonebgorges
Message:

Introduces BP_Activity_Feed class, and migrates existing feeds

RSS feeds for BP activity have historically been generated on a one-by-one
basis, with separate template files used for each theme. This resulted in a
huge amount of unnecessarily duplicated code. Moreover, it made the process
of customizing feeds, or providing new feeds, unnecessarily cumbersome.

BP_Activity_Feed abstracts the central parts of RSS feed building, allowing for
easier customization, and fewer points of failure.

This changeset also fixes our RSS implementation to match best practices with
respect to encoding content inside of the <description> element.

Fixes #5020

Props r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-actions.php

    r7172 r7207  
    305305add_action( 'bp_actions', 'groups_action_redirect_to_random_group' );
    306306
     307/**
     308 * Load the activity feed for the specific group.
     309 *
     310 * @since BuddyPress (v1.2)
     311 */
    307312function groups_action_group_feed() {
    308     global $bp, $wp_query;
    309 
    310     if ( !bp_is_active( 'activity' ) || !bp_is_groups_component() || !isset( $bp->groups->current_group ) || !bp_is_current_action( 'feed' ) )
    311         return false;
    312 
    313     $wp_query->is_404 = false;
    314     status_header( 200 );
    315 
    316     if ( 'public' != $bp->groups->current_group->status ) {
    317         if ( !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
    318             return false;
    319     }
    320 
    321     include_once( BP_PLUGIN_DIR . '/bp-activity/feeds/bp-activity-group-feed.php' );
    322     die;
     313
     314    // get current group
     315    $group = groups_get_current_group();
     316
     317    if ( ! bp_is_active( 'activity' ) || ! bp_is_groups_component() || ! $group || ! bp_is_current_action( 'feed' ) )
     318        return false;
     319
     320    // if group isn't public or if logged-in user is not a member of the group, do
     321    // not output the group activity feed
     322    if ( ! bp_group_is_visible( $group ) ) {
     323        return false;
     324    }
     325
     326    // setup the feed
     327    buddypress()->activity->feed = new BP_Activity_Feed( array(
     328        'id'            => 'group',
     329
     330        /* translators: Group activity RSS title - "[Site Name] | [Group Name] | Activity" */
     331        'title'         => sprintf( __( '%1$s | %2$s | Activity', 'buddypress' ), bp_get_site_name(), bp_get_current_group_name() ),
     332
     333        'link'          => bp_get_group_permalink( $group ),
     334        'description'   => sprintf( __( "Activity feed for the group, %s.", 'buddypress' ), bp_get_current_group_name() ),
     335        'activity_args' => array(
     336            'object'           => buddypress()->groups->id,
     337            'primary_id'       => bp_get_current_group_id(),
     338            'display_comments' => 'threaded'
     339        )
     340    ) );
    323341}
    324342add_action( 'bp_actions', 'groups_action_group_feed' );
Note: See TracChangeset for help on using the changeset viewer.