[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-activity/actions/ -> feeds.php (source)

   1  <?php
   2  /**
   3   * Activity: RSS feed actions
   4   *
   5   * @package BuddyPress
   6   * @subpackage ActivityActions
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Load the sitewide activity feed.
  12   *
  13   * @since 1.0.0
  14   *
  15   * @return bool False on failure.
  16   */
  17  function bp_activity_action_sitewide_feed() {
  18      $bp = buddypress();
  19  
  20      if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) )
  21          return false;
  22  
  23      // Setup the feed.
  24      buddypress()->activity->feed = new BP_Activity_Feed( array(
  25          'id'            => 'sitewide',
  26  
  27          /* translators: Sitewide activity RSS title - "[Site Name] | Site Wide Activity" */
  28          'title'         => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
  29  
  30          'link'          => bp_get_activity_directory_permalink(),
  31          'description'   => __( 'Activity feed for the entire site.', 'buddypress' ),
  32          'activity_args' => 'display_comments=threaded'
  33      ) );
  34  }
  35  add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
  36  
  37  /**
  38   * Load a user's personal activity feed.
  39   *
  40   * @since 1.0.0
  41   *
  42   * @return bool False on failure.
  43   */
  44  function bp_activity_action_personal_feed() {
  45      if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
  46          return false;
  47      }
  48  
  49      // Setup the feed.
  50      buddypress()->activity->feed = new BP_Activity_Feed( array(
  51          'id'            => 'personal',
  52  
  53          /* translators: Personal activity RSS title - "[Site Name] | [User Display Name] | Activity" */
  54          'title'         => sprintf( __( '%1$s | %2$s | Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
  55  
  56          'link'          => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() ),
  57          'description'   => sprintf( __( 'Activity feed for %s.', 'buddypress' ), bp_get_displayed_user_fullname() ),
  58          'activity_args' => 'user_id=' . bp_displayed_user_id()
  59      ) );
  60  }
  61  add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
  62  
  63  /**
  64   * Load a user's friends' activity feed.
  65   *
  66   * @since 1.0.0
  67   *
  68   * @return bool False on failure.
  69   */
  70  function bp_activity_action_friends_feed() {
  71      if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
  72          return false;
  73      }
  74  
  75      // Setup the feed.
  76      buddypress()->activity->feed = new BP_Activity_Feed( array(
  77          'id'            => 'friends',
  78  
  79          /* translators: Friends activity RSS title - "[Site Name] | [User Display Name] | Friends Activity" */
  80          'title'         => sprintf( __( '%1$s | %2$s | Friends Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
  81  
  82          'link'          => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() ),
  83          'description'   => sprintf( __( "Activity feed for %s's friends.", 'buddypress' ), bp_get_displayed_user_fullname() ),
  84          'activity_args' => 'scope=friends'
  85      ) );
  86  }
  87  add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
  88  
  89  /**
  90   * Load the activity feed for a user's groups.
  91   *
  92   * @since 1.2.0
  93   *
  94   * @return bool False on failure.
  95   */
  96  function bp_activity_action_my_groups_feed() {
  97      if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
  98          return false;
  99      }
 100  
 101      // Get displayed user's group IDs.
 102      $groups    = groups_get_user_groups();
 103      $group_ids = implode( ',', $groups['groups'] );
 104  
 105      // Setup the feed.
 106      buddypress()->activity->feed = new BP_Activity_Feed( array(
 107          'id'            => 'mygroups',
 108  
 109          /* translators: Member groups activity RSS title - "[Site Name] | [User Display Name] | Groups Activity" */
 110          'title'         => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
 111  
 112          'link'          => trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() ),
 113          'description'   => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 114          'activity_args' => array(
 115              'object'           => buddypress()->groups->id,
 116              'primary_id'       => $group_ids,
 117              'display_comments' => 'threaded'
 118          )
 119      ) );
 120  }
 121  add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
 122  
 123  /**
 124   * Load a user's @mentions feed.
 125   *
 126   * @since 1.2.0
 127   *
 128   * @return bool False on failure.
 129   */
 130  function bp_activity_action_mentions_feed() {
 131      if ( ! bp_activity_do_mentions() ) {
 132          return false;
 133      }
 134  
 135      if ( !bp_is_user_activity() || ! bp_is_current_action( 'mentions' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
 136          return false;
 137      }
 138  
 139      // Setup the feed.
 140      buddypress()->activity->feed = new BP_Activity_Feed( array(
 141          'id'            => 'mentions',
 142  
 143          /* translators: User mentions activity RSS title - "[Site Name] | [User Display Name] | Mentions" */
 144          'title'         => sprintf( __( '%1$s | %2$s | Mentions', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
 145  
 146          'link'          => bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/',
 147          'description'   => sprintf( __( "Activity feed mentioning %s.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 148          'activity_args' => array(
 149              'search_terms' => '@' . bp_core_get_username( bp_displayed_user_id() )
 150          )
 151      ) );
 152  }
 153  add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
 154  
 155  /**
 156   * Load a user's favorites feed.
 157   *
 158   * @since 1.2.0
 159   *
 160   * @return bool False on failure.
 161   */
 162  function bp_activity_action_favorites_feed() {
 163      if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
 164          return false;
 165      }
 166  
 167      // Get displayed user's favorite activity IDs.
 168      $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
 169      $fav_ids = implode( ',', (array) $favs );
 170  
 171      // Setup the feed.
 172      buddypress()->activity->feed = new BP_Activity_Feed( array(
 173          'id'            => 'favorites',
 174  
 175          /* translators: User activity favorites RSS title - "[Site Name] | [User Display Name] | Favorites" */
 176          'title'         => sprintf( __( '%1$s | %2$s | Favorites', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
 177  
 178          'link'          => bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/',
 179          'description'   => sprintf( __( "Activity feed of %s's favorites.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 180          'activity_args' => 'include=' . $fav_ids
 181      ) );
 182  }
 183  add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );


Generated: Thu Dec 12 01:01:36 2019 Cross-referenced by PHPXref 0.7.1