[ 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  
  24      $link = bp_get_activity_directory_permalink();
  25  
  26      // Setup the feed.
  27      buddypress()->activity->feed = new BP_Activity_Feed( array(
  28          'id'            => 'sitewide',
  29  
  30          /* translators: %s Site Name */
  31          'title'         => sprintf( __( '%s | Site-Wide Activity', 'buddypress' ), bp_get_site_name() ),
  32          'link'          => $link,
  33          'description'   => __( 'Activity feed for the entire site.', 'buddypress' ),
  34          'activity_args' => 'display_comments=threaded'
  35      ) );
  36  
  37      if ( ! buddypress()->activity->feed->enabled ) {
  38          bp_core_redirect( $link );
  39      }
  40  }
  41  add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
  42  
  43  /**
  44   * Load a user's personal activity feed.
  45   *
  46   * @since 1.0.0
  47   *
  48   * @return bool False on failure.
  49   */
  50  function bp_activity_action_personal_feed() {
  51      if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
  52          return false;
  53      }
  54  
  55      $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() );
  56  
  57      // Setup the feed.
  58      buddypress()->activity->feed = new BP_Activity_Feed( array(
  59          'id'            => 'personal',
  60  
  61          /* translators: 1: Site Name. 2: User Display Name. */
  62          'title'         => sprintf( _x( '%1$s | %2$s | Activity', 'Personal activity feed title', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
  63          'link'          => $link,
  64  
  65          /* translators: %s: User Display Name */
  66          'description'   => sprintf( __( 'Activity feed for %s.', 'buddypress' ), bp_get_displayed_user_fullname() ),
  67          'activity_args' => 'user_id=' . bp_displayed_user_id()
  68      ) );
  69  
  70      if ( ! buddypress()->activity->feed->enabled ) {
  71          bp_core_redirect( $link );
  72      }
  73  }
  74  add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
  75  
  76  /**
  77   * Load a user's friends' activity feed.
  78   *
  79   * @since 1.0.0
  80   *
  81   * @return bool False on failure.
  82   */
  83  function bp_activity_action_friends_feed() {
  84      if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
  85          return false;
  86      }
  87  
  88      $link = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() );
  89  
  90      // Setup the feed.
  91      buddypress()->activity->feed = new BP_Activity_Feed( array(
  92          'id'            => 'friends',
  93  
  94          /* translators: 1: Site Name 2: User Display Name */
  95          'title'         => sprintf( __( '%1$s | %2$s | Friends Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
  96          'link'          => $link,
  97  
  98          /* translators: %s: User Display Name */
  99          'description'   => sprintf( __( "Activity feed for %s's friends.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 100          'activity_args' => 'scope=friends'
 101      ) );
 102  
 103      if ( ! buddypress()->activity->feed->enabled ) {
 104          bp_core_redirect( $link );
 105      }
 106  }
 107  add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
 108  
 109  /**
 110   * Load the activity feed for a user's groups.
 111   *
 112   * @since 1.2.0
 113   *
 114   * @return bool False on failure.
 115   */
 116  function bp_activity_action_my_groups_feed() {
 117      if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
 118          return false;
 119      }
 120  
 121      // Get displayed user's group IDs.
 122      $groups    = groups_get_user_groups();
 123      $group_ids = implode( ',', $groups['groups'] );
 124      $link      = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() );
 125  
 126      // Setup the feed.
 127      buddypress()->activity->feed = new BP_Activity_Feed( array(
 128          'id'            => 'mygroups',
 129  
 130          /* translators: 1: Site Name 2: User Display Name */
 131          'title'         => sprintf( __( '%1$s | %2$s | Group Activity', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
 132          'link'          => $link,
 133  
 134          /* translators: %s: User Display Name */
 135          'description'   => sprintf( __( "Public group activity feed of which %s is a member.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 136          'activity_args' => array(
 137              'object'           => buddypress()->groups->id,
 138              'primary_id'       => $group_ids,
 139              'display_comments' => 'threaded'
 140          )
 141      ) );
 142  
 143      if ( ! buddypress()->activity->feed->enabled ) {
 144          bp_core_redirect( $link );
 145      }
 146  }
 147  add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
 148  
 149  /**
 150   * Load a user's @mentions feed.
 151   *
 152   * @since 1.2.0
 153   *
 154   * @return bool False on failure.
 155   */
 156  function bp_activity_action_mentions_feed() {
 157      if ( ! bp_activity_do_mentions() ) {
 158          return false;
 159      }
 160  
 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' );
 166  
 167      // Setup the feed.
 168      buddypress()->activity->feed = new BP_Activity_Feed( array(
 169          'id'            => 'mentions',
 170  
 171          /* translators: 1: Site Name 2: User Display Name */
 172          'title'         => sprintf( __( '%1$s | %2$s | Mentions', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
 173          'link'          => $link,
 174  
 175          /* translators: %s: User Display Name */
 176          'description'   => sprintf( __( "Activity feed mentioning %s.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 177          'activity_args' => array(
 178              'search_terms' => '@' . bp_core_get_username( bp_displayed_user_id() )
 179          )
 180      ) );
 181  
 182      if ( ! buddypress()->activity->feed->enabled ) {
 183          bp_core_redirect( $link );
 184      }
 185  }
 186  add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
 187  
 188  /**
 189   * Load a user's favorites feed.
 190   *
 191   * @since 1.2.0
 192   *
 193   * @return bool False on failure.
 194   */
 195  function bp_activity_action_favorites_feed() {
 196      if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
 197          return false;
 198      }
 199  
 200      // Get displayed user's favorite activity IDs.
 201      $favs    = bp_activity_get_user_favorites( bp_displayed_user_id() );
 202      $fav_ids = implode( ',', (array) $favs );
 203      $link    = trailingslashit( bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites' );
 204  
 205      // Setup the feed.
 206      buddypress()->activity->feed = new BP_Activity_Feed( array(
 207          'id'            => 'favorites',
 208  
 209          /* translators: 1: Site Name 2: User Display Name */
 210          'title'         => sprintf( __( '%1$s | %2$s | Favorites', 'buddypress' ), bp_get_site_name(), bp_get_displayed_user_fullname() ),
 211          'link'          => $link,
 212  
 213          /* translators: %s: User Display Name */
 214          'description'   => sprintf( __( "Activity feed of %s's favorites.", 'buddypress' ), bp_get_displayed_user_fullname() ),
 215          'activity_args' => 'include=' . $fav_ids
 216      ) );
 217  
 218      if ( ! buddypress()->activity->feed->enabled ) {
 219          bp_core_redirect( $link );
 220      }
 221  }
 222  add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );


Generated: Sat Dec 7 01:00:57 2024 Cross-referenced by PHPXref 0.7.1