[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-activity/ -> bp-activity-template.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Activity Template Functions.
   4   *
   5   * @package BuddyPress
   6   * @subpackage ActivityTemplate
   7   * @since 1.5.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Output the activity component slug.
  15   *
  16   * @since 1.5.0
  17   *
  18   */
  19  function bp_activity_slug() {
  20      echo bp_get_activity_slug();
  21  }
  22      /**
  23       * Return the activity component slug.
  24       *
  25       * @since 1.5.0
  26       *
  27       *
  28       * @return string The activity component slug.
  29       */
  30  	function bp_get_activity_slug() {
  31  
  32          /**
  33           * Filters the activity component slug.
  34           *
  35           * @since 1.5.0
  36           *
  37           * @param string $slug Activity component slug.
  38           */
  39          return apply_filters( 'bp_get_activity_slug', buddypress()->activity->slug );
  40      }
  41  
  42  /**
  43   * Output the activity component root slug.
  44   *
  45   * @since 1.5.0
  46   *
  47   */
  48  function bp_activity_root_slug() {
  49      echo bp_get_activity_root_slug();
  50  }
  51      /**
  52       * Return the activity component root slug.
  53       *
  54       * @since 1.5.0
  55       *
  56       *
  57       * @return string The activity component root slug.
  58       */
  59  	function bp_get_activity_root_slug() {
  60  
  61          /**
  62           * Filters the activity component root slug.
  63           *
  64           * @since 1.5.0
  65           *
  66           * @param string $root_slug Activity component root slug.
  67           */
  68          return apply_filters( 'bp_get_activity_root_slug', buddypress()->activity->root_slug );
  69      }
  70  
  71  /**
  72   * Output activity directory permalink.
  73   *
  74   * @since 1.5.0
  75   *
  76   */
  77  function bp_activity_directory_permalink() {
  78      echo esc_url( bp_get_activity_directory_permalink() );
  79  }
  80      /**
  81       * Return activity directory permalink.
  82       *
  83       * @since 1.5.0
  84       *
  85       *
  86       * @return string Activity directory permalink.
  87       */
  88  	function bp_get_activity_directory_permalink() {
  89  
  90          /**
  91           * Filters the activity directory permalink.
  92           *
  93           * @since 1.5.0
  94           *
  95           * @param string $url Permalink url for the activity directory.
  96           */
  97          return apply_filters( 'bp_get_activity_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() ) );
  98      }
  99  
 100  /**
 101   * Initialize the activity loop.
 102   *
 103   * Based on the $args passed, bp_has_activities() populates the
 104   * $activities_template global, enabling the use of BuddyPress templates and
 105   * template functions to display a list of activity items.
 106   *
 107   * @since 1.0.0
 108   * @since 2.4.0 Introduced the `$fields` parameter.
 109   *
 110   * @global object $activities_template {@link BP_Activity_Template}
 111   *
 112   * @param array|string $args {
 113   *     Arguments for limiting the contents of the activity loop. Most arguments
 114   *     are in the same format as {@link BP_Activity_Activity::get()}. However,
 115   *     because the format of the arguments accepted here differs in a number of
 116   *     ways, and because bp_has_activities() determines some default arguments in
 117   *     a dynamic fashion, we list all accepted arguments here as well.
 118   *
 119   *     Arguments can be passed as an associative array, or as a URL querystring
 120   *     (eg, 'user_id=4&display_comments=threaded').
 121   *
 122   *     @type int               $page             Which page of results to fetch. Using page=1 without per_page will result
 123   *                                               in no pagination. Default: 1.
 124   *     @type int|bool          $per_page         Number of results per page. Default: 20.
 125   *     @type string            $page_arg         String used as a query parameter in pagination links. Default: 'acpage'.
 126   *     @type int|bool          $max              Maximum number of results to return. Default: false (unlimited).
 127   *     @type string            $fields           Activity fields to retrieve. 'all' to fetch entire activity objects,
 128   *                                               'ids' to get only the activity IDs. Default 'all'.
 129   *     @type string|bool       $count_total      If true, an additional DB query is run to count the total activity items
 130   *                                               for the query. Default: false.
 131   *     @type string            $sort             'ASC' or 'DESC'. Default: 'DESC'.
 132   *     @type array|bool        $exclude          Array of activity IDs to exclude. Default: false.
 133   *     @type array|bool        $in               Array of IDs to limit query by (IN). 'in' is intended to be used in
 134   *                                               conjunction with other filter parameters. Default: false.
 135   *     @type array|bool        $include          Array of exact activity IDs to query. Providing an 'include' array will
 136   *                                               override all other filters passed in the argument array. When viewing the
 137   *                                               permalink page for a single activity item, this value defaults to the ID of
 138   *                                               that item. Otherwise the default is false.
 139   *     @type array             $meta_query       Limit by activitymeta by passing an array of meta_query conditions. See
 140   *                                               {@link WP_Meta_Query::queries} for a description of the syntax.
 141   *     @type array             $date_query       Limit by date by passing an array of date_query conditions. See first
 142   *                                               parameter of {@link WP_Date_Query::__construct()} for syntax.
 143   *     @type array             $filter_query     Advanced activity filtering.  See {@link BP_Activity_Query::__construct()}.
 144   *     @type string            $search_terms     Limit results by a search term. Default: false.
 145   *     @type string            $scope            Use a BuddyPress pre-built filter.
 146   *                                                 - 'just-me' retrieves items belonging only to a user; this is equivalent
 147   *                                                   to passing a 'user_id' argument.
 148   *                                                 - 'friends' retrieves items belonging to the friends of a user.
 149   *                                                 - 'groups' retrieves items belonging to groups to which a user belongs to.
 150   *                                                 - 'favorites' retrieves a user's favorited activity items.
 151   *                                                 - 'mentions' retrieves items where a user has received an @-mention.
 152   *                                               The default value of 'scope' is set to one of the above if that value
 153   *                                               appears in the appropriate place in the URL; eg, 'scope' will be 'groups'
 154   *                                               when visiting http://example.com/members/joe/activity/groups/. Otherwise
 155   *                                               defaults to false.
 156   *     @type int|array|bool    $user_id          The ID(s) of user(s) whose activity should be fetched. Pass a single ID or
 157   *                                               an array of IDs. When viewing a user profile page (but not that user's
 158   *                                               activity subpages, ie My Friends, My Groups, etc), 'user_id' defaults to
 159   *                                               the ID of the displayed user. Otherwise the default is false.
 160   *     @type string|array|bool $object           Filters by the `component` column in the database, which is generally the
 161   *                                               component ID in the case of BuddyPress components, or the plugin slug in
 162   *                                               the case of plugins. For example, 'groups' will limit results to those that
 163   *                                               are associated with the BP Groups component. Accepts a single component
 164   *                                               string, or an array of multiple components. Defaults to 'groups' when
 165   *                                               viewing the page of a single group, the My Groups activity filter, or the
 166   *                                               Activity > Groups filter of a user profile. Otherwise defaults to false.
 167   *     @type string|array|bool $action           Filters by the `type` column in the database, which is a string
 168   *                                               categorizing the activity item (eg, 'new_blog_post', 'created_group').
 169   *                                               Accepts a comma-delimited string or an array of types. Default: false.
 170   *     @type int|array|bool    $primary_id       Filters by the `item_id` column in the database. The meaning of
 171   *                                               'primary_id' differs between components/types; for example, in the case of
 172   *                                               'created_group', 'primary_id' is the ID of the group. Accepts a single ID,
 173   *                                               or an array of multiple IDs. When viewing a single group, defaults to the
 174   *                                               current group ID. When viewing a user's Groups stream page, defaults to the
 175   *                                               IDs of the user's groups. Otherwise defaults to false.
 176   *     @type int|array|bool    $secondary_id     Filters by the `secondary_item_id` column in the database. The meaning of
 177   *                                               'secondary_id' differs between components/types. Accepts a single ID, or an
 178   *                                               array of multiple IDs. Defaults to false.
 179   *     @type int               $offset           Return only activity items with an ID greater than or equal to this one.
 180   *                                               Note that providing an offset will disable pagination. Default: false.
 181   *     @type string|bool       $display_comments How to handle activity comments. Possible values:
 182   *                                                 - 'threaded' - comments appear in a threaded tree, under their parent
 183   *                                                   items.
 184   *                                                 - 'stream' - the activity stream is presented in a flat manner, with
 185   *                                                   comments sorted in chronological order alongside other activity items.
 186   *                                                 - false - don't fetch activity comments at all.
 187   *                                               Default: 'threaded'.
 188   *     @type bool              $show_hidden      Whether to show items marked hide_sitewide. Defaults to false, except in
 189   *                                               the following cases:
 190   *                                                 - User is viewing his own activity stream.
 191   *                                                 - User is viewing the activity stream of a non-public group of which he
 192   *                                                   is a member.
 193   *     @type string|bool       $spam             Spam status. 'ham_only', 'spam_only', or false to show all activity
 194   *                                               regardless of spam status. Default: 'ham_only'.
 195   *     @type bool              $populate_extras  Whether to pre-fetch the activity metadata for the queried items.
 196   *                                               Default: true.
 197   * }
 198   * @return bool Returns true when activities are found, otherwise false.
 199   */
 200  function bp_has_activities( $args = '' ) {
 201      global $activities_template;
 202  
 203      // Get BuddyPress.
 204      $bp = buddypress();
 205  
 206      /*
 207       * Smart Defaults.
 208       */
 209  
 210      // User filtering.
 211      $user_id = bp_displayed_user_id()
 212          ? bp_displayed_user_id()
 213          : false;
 214  
 215      // Group filtering.
 216      if ( bp_is_group() ) {
 217          $object      = $bp->groups->id;
 218          $primary_id  = bp_get_current_group_id();
 219          $show_hidden = (bool) ( groups_is_user_member( bp_loggedin_user_id(), $primary_id ) || bp_current_user_can( 'bp_moderate' ) );
 220      } else {
 221          $object      = false;
 222          $primary_id  = false;
 223          $show_hidden = false;
 224      }
 225  
 226      // The default scope should recognize custom slugs.
 227      $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
 228          ? $bp->loaded_components[ bp_current_action() ]
 229          : bp_current_action();
 230  
 231      // Support for permalinks on single item pages: /groups/my-group/activity/124/.
 232      $include = bp_is_current_action( bp_get_activity_slug() )
 233          ? bp_action_variable( 0 )
 234          : false;
 235  
 236      $search_terms_default = false;
 237      $search_query_arg = bp_core_get_component_search_query_arg( 'activity' );
 238      if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) {
 239          $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] );
 240      }
 241  
 242      /*
 243       * Parse Args.
 244       */
 245  
 246      // Note: any params used for filtering can be a single value, or multiple
 247      // values comma separated.
 248      $r = bp_parse_args( $args, array(
 249          'display_comments'  => 'threaded',   // False for none, stream/threaded - show comments in the stream or threaded under items.
 250          'include'           => $include,     // Pass an activity_id or string of IDs comma-separated.
 251          'exclude'           => false,        // Pass an activity_id or string of IDs comma-separated.
 252          'in'                => false,        // Comma-separated list or array of activity IDs among which to search.
 253          'sort'              => 'DESC',       // Sort DESC or ASC.
 254          'page'              => 1,            // Which page to load.
 255          'per_page'          => 20,           // Number of items per page.
 256          'page_arg'          => 'acpage',     // See https://buddypress.trac.wordpress.org/ticket/3679.
 257          'max'               => false,        // Max number to return.
 258          'fields'            => 'all',
 259          'count_total'       => false,
 260          'show_hidden'       => $show_hidden, // Show activity items that are hidden site-wide?
 261          'spam'              => 'ham_only',   // Hide spammed items.
 262  
 263          // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions).
 264          'scope'             => $scope,
 265  
 266          // Filtering
 267          'user_id'           => $user_id,     // user_id to filter on.
 268          'object'            => $object,      // Object to filter on e.g. groups, profile, status, friends.
 269          'action'            => false,        // Action to filter on e.g. activity_update, profile_updated.
 270          'primary_id'        => $primary_id,  // Object ID to filter on e.g. a group_id or blog_id etc.
 271          'secondary_id'      => false,        // Secondary object ID to filter on e.g. a post_id.
 272          'offset'            => false,        // Return only items >= this ID.
 273          'since'             => false,        // Return only items recorded since this Y-m-d H:i:s date.
 274  
 275          'meta_query'        => false,        // Filter on activity meta. See WP_Meta_Query for format.
 276          'date_query'        => false,        // Filter by date. See first parameter of WP_Date_Query for format.
 277          'filter_query'      => false,        // Advanced filtering.  See BP_Activity_Query for format.
 278  
 279          // Searching.
 280          'search_terms'      => $search_terms_default,
 281          'update_meta_cache' => true,
 282      ), 'has_activities' );
 283  
 284      /*
 285       * Smart Overrides.
 286       */
 287  
 288      // Translate various values for 'display_comments'
 289      // This allows disabling comments via ?display_comments=0
 290      // or =none or =false. Final true is a strict type check. See #5029.
 291      if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
 292          $r['display_comments'] = false;
 293      }
 294  
 295      // Ignore pagination if an offset is passed.
 296      if ( ! empty( $r['offset'] ) ) {
 297          $r['page'] = 0;
 298      }
 299  
 300      // Search terms.
 301      if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
 302          $r['search_terms'] = $_REQUEST['s'];
 303      }
 304  
 305      // Do not exceed the maximum per page.
 306      if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
 307          $r['per_page'] = $r['max'];
 308      }
 309  
 310      /**
 311       * Filters whether BuddyPress should enable afilter support.
 312       *
 313       * Support for basic filters in earlier BP versions is disabled by default.
 314       * To enable, put add_filter( 'bp_activity_enable_afilter_support', '__return_true' );
 315       * into bp-custom.php or your theme's functions.php.
 316       *
 317       * @since 1.6.0
 318       *
 319       * @param bool $value True if BuddyPress should enable afilter support.
 320       */
 321      if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) ) {
 322          $r['filter'] = array(
 323              'object' => $_GET['afilter']
 324          );
 325      } elseif ( ! empty( $r['user_id'] ) || ! empty( $r['object'] ) || ! empty( $r['action'] ) || ! empty( $r['primary_id'] ) || ! empty( $r['secondary_id'] ) || ! empty( $r['offset'] ) || ! empty( $r['since'] ) ) {
 326          $r['filter'] = array(
 327              'user_id'      => $r['user_id'],
 328              'object'       => $r['object'],
 329              'action'       => $r['action'],
 330              'primary_id'   => $r['primary_id'],
 331              'secondary_id' => $r['secondary_id'],
 332              'offset'       => $r['offset'],
 333              'since'        => $r['since']
 334          );
 335      } else {
 336          $r['filter'] = false;
 337      }
 338  
 339      // If specific activity items have been requested, override the $hide_spam
 340      // argument. This prevents backpat errors with AJAX.
 341      if ( ! empty( $r['include'] ) && ( 'ham_only' === $r['spam'] ) ) {
 342          $r['spam'] = 'all';
 343      }
 344  
 345      /*
 346       * Query
 347       */
 348  
 349      $activities_template = new BP_Activity_Template( $r );
 350  
 351      /**
 352       * Filters whether or not there are activity items to display.
 353       *
 354       * @since 1.1.0
 355       *
 356       * @param bool   $value               Whether or not there are activity items to display.
 357       * @param string $activities_template Current activities template being used.
 358       * @param array  $r                   Array of arguments passed into the BP_Activity_Template class.
 359       */
 360      return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template, $r );
 361  }
 362  
 363  /**
 364   * Determine if there are still activities left in the loop.
 365   *
 366   * @since 1.0.0
 367   *
 368   * @global object $activities_template {@link BP_Activity_Template}
 369   *
 370   * @return bool Returns true when activities are found.
 371   */
 372  function bp_activities() {
 373      global $activities_template;
 374      return $activities_template->user_activities();
 375  }
 376  
 377  /**
 378   * Get the current activity object in the loop.
 379   *
 380   * @since 1.0.0
 381   *
 382   * @global object $activities_template {@link BP_Activity_Template}
 383   *
 384   * @return object The current activity within the loop.
 385   */
 386  function bp_the_activity() {
 387      global $activities_template;
 388      return $activities_template->the_activity();
 389  }
 390  
 391  /**
 392   * Output the URL for the Load More link.
 393   *
 394   * @since 2.1.0
 395   */
 396  function bp_activity_load_more_link() {
 397      echo esc_url( bp_get_activity_load_more_link() );
 398  }
 399      /**
 400       * Get the URL for the Load More link.
 401       *
 402       * @since 2.1.0
 403       *
 404       * @return string $link
 405       */
 406  	function bp_get_activity_load_more_link() {
 407          global $activities_template;
 408  
 409          $url  = bp_get_requested_url();
 410          $link = add_query_arg( $activities_template->pag_arg, $activities_template->pag_page + 1, $url );
 411  
 412          /**
 413           * Filters the Load More link URL.
 414           *
 415           * @since 2.1.0
 416           *
 417           * @param string $link                The "Load More" link URL with appropriate query args.
 418           * @param string $url                 The original URL.
 419           * @param object $activities_template The activity template loop global.
 420           */
 421          return apply_filters( 'bp_get_activity_load_more_link', $link, $url, $activities_template );
 422      }
 423  
 424  /**
 425   * Output the activity pagination count.
 426   *
 427   * @since 1.0.0
 428   *
 429   * @global object $activities_template {@link BP_Activity_Template}
 430   */
 431  function bp_activity_pagination_count() {
 432      echo bp_get_activity_pagination_count();
 433  }
 434  
 435      /**
 436       * Return the activity pagination count.
 437       *
 438       * @since 1.2.0
 439       *
 440       * @global object $activities_template {@link BP_Activity_Template}
 441       *
 442       * @return string The pagination text.
 443       */
 444  	function bp_get_activity_pagination_count() {
 445          global $activities_template;
 446  
 447          $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
 448          $from_num  = bp_core_number_format( $start_num );
 449          $to_num    = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
 450          $total     = bp_core_number_format( $activities_template->total_activity_count );
 451  
 452          if ( 1 == $activities_template->total_activity_count ) {
 453              $message = __( 'Viewing 1 item', 'buddypress' );
 454          } else {
 455              /* translators: 1: the from number item. 2: the to number item. 3: the total number of items. */
 456              $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s item', 'Viewing %1$s - %2$s of %3$s items', $activities_template->total_activity_count, 'buddypress' ), $from_num, $to_num, $total );
 457          }
 458  
 459          return $message;
 460      }
 461  
 462  /**
 463   * Output the activity pagination links.
 464   *
 465   * @since 1.0.0
 466   *
 467   */
 468  function bp_activity_pagination_links() {
 469      echo bp_get_activity_pagination_links();
 470  }
 471  
 472      /**
 473       * Return the activity pagination links.
 474       *
 475       * @since 1.0.0
 476       *
 477       * @global object $activities_template {@link BP_Activity_Template}
 478       *
 479       * @return string The pagination links.
 480       */
 481  	function bp_get_activity_pagination_links() {
 482          global $activities_template;
 483  
 484          /**
 485           * Filters the activity pagination link output.
 486           *
 487           * @since 1.0.0
 488           *
 489           * @param string $pag_links Output for the activity pagination links.
 490           */
 491          return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
 492      }
 493  
 494  /**
 495   * Return true when there are more activity items to be shown than currently appear.
 496   *
 497   * @since 1.5.0
 498   *
 499   * @global object $activities_template {@link BP_Activity_Template}
 500   *
 501   * @return bool $has_more_items True if more items, false if not.
 502   */
 503  function bp_activity_has_more_items() {
 504      global $activities_template;
 505  
 506      if ( ! empty( $activities_template->has_more_items )  ) {
 507          $has_more_items = true;
 508      } else {
 509          $remaining_pages = 0;
 510  
 511          if ( ! empty( $activities_template->pag_page ) ) {
 512              $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) );
 513          }
 514  
 515          $has_more_items = (int) $remaining_pages > 0;
 516      }
 517  
 518      /**
 519       * Filters whether there are more activity items to display.
 520       *
 521       * @since 1.5.0
 522       *
 523       * @param bool $has_more_items Whether or not there are more activity items to display.
 524       */
 525      return apply_filters( 'bp_activity_has_more_items', $has_more_items );
 526  }
 527  
 528  /**
 529   * Output the activity count.
 530   *
 531   * @since 1.2.0
 532   *
 533   */
 534  function bp_activity_count() {
 535      echo bp_get_activity_count();
 536  }
 537  
 538      /**
 539       * Return the activity count.
 540       *
 541       * @since 1.2.0
 542       *
 543       * @global object $activities_template {@link BP_Activity_Template}
 544       *
 545       * @return int The activity count.
 546       */
 547  	function bp_get_activity_count() {
 548          global $activities_template;
 549  
 550          /**
 551           * Filters the activity count for the activity template.
 552           *
 553           * @since 1.2.0
 554           *
 555           * @param int $activity_count The count for total activity.
 556           */
 557          return apply_filters( 'bp_get_activity_count', (int) $activities_template->activity_count );
 558      }
 559  
 560  /**
 561   * Output the number of activities per page.
 562   *
 563   * @since 1.2.0
 564   *
 565   */
 566  function bp_activity_per_page() {
 567      echo bp_get_activity_per_page();
 568  }
 569  
 570      /**
 571       * Return the number of activities per page.
 572       *
 573       * @since 1.2.0
 574       *
 575       * @global object $activities_template {@link BP_Activity_Template}
 576       *
 577       * @return int The activities per page.
 578       */
 579  	function bp_get_activity_per_page() {
 580          global $activities_template;
 581  
 582          /**
 583           * Filters the activity posts per page value.
 584           *
 585           * @since 1.2.0
 586           *
 587           * @param int $pag_num How many post should be displayed for pagination.
 588           */
 589          return apply_filters( 'bp_get_activity_per_page', (int) $activities_template->pag_num );
 590      }
 591  
 592  /**
 593   * Output the activities title.
 594   *
 595   * @since 1.0.0
 596   *
 597   * @todo Deprecate.
 598   */
 599  function bp_activities_title() {
 600      echo bp_get_activities_title();
 601  }
 602  
 603      /**
 604       * Return the activities title.
 605       *
 606       * @since 1.0.0
 607       *
 608       * @global string $bp_activity_title
 609       * @todo Deprecate.
 610       *
 611       * @return string The activities title.
 612       */
 613  	function bp_get_activities_title() {
 614          global $bp_activity_title;
 615  
 616          /**
 617           * Filters the activities title for the activity template.
 618           *
 619           * @since 1.0.0
 620           *
 621           * @param string $bp_activity_title The title to be displayed.
 622           */
 623          return apply_filters( 'bp_get_activities_title', $bp_activity_title );
 624      }
 625  
 626  /**
 627   * {@internal Missing Description}
 628   *
 629   * @since 1.0.0
 630   *
 631   * @todo Deprecate.
 632   */
 633  function bp_activities_no_activity() {
 634      echo bp_get_activities_no_activity();
 635  }
 636  
 637      /**
 638       * {@internal Missing Description}
 639       *
 640       * @since 1.0.0
 641       *
 642       * @global string $bp_activity_no_activity
 643       * @todo Deprecate.
 644       *
 645       * @return string
 646       */
 647  	function bp_get_activities_no_activity() {
 648          global $bp_activity_no_activity;
 649  
 650          /**
 651           * Filters the text used when there is no activity to display.
 652           *
 653           * @since 1.0.0
 654           *
 655           * @param string $bp_activity_no_activity Text to display for no activity.
 656           */
 657          return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
 658      }
 659  
 660  /**
 661   * Output the activity ID.
 662   *
 663   * @since 1.2.0
 664   *
 665   */
 666  function bp_activity_id() {
 667      echo bp_get_activity_id();
 668  }
 669  
 670      /**
 671       * Return the activity ID.
 672       *
 673       * @since 1.2.0
 674       *
 675       * @global object $activities_template {@link BP_Activity_Template}
 676       *
 677       * @return int The activity ID.
 678       */
 679  	function bp_get_activity_id() {
 680          global $activities_template;
 681  
 682          /**
 683           * Filters the activity ID being displayed.
 684           *
 685           * @since 1.2.0
 686           *
 687           * @param int $id The activity ID.
 688           */
 689          return apply_filters( 'bp_get_activity_id', $activities_template->activity->id );
 690      }
 691  
 692  /**
 693   * Output the activity item ID.
 694   *
 695   * @since 1.2.0
 696   *
 697   */
 698  function bp_activity_item_id() {
 699      echo bp_get_activity_item_id();
 700  }
 701  
 702      /**
 703       * Return the activity item ID.
 704       *
 705       * @since 1.2.0
 706       *
 707       * @global object $activities_template {@link BP_Activity_Template}
 708       *
 709       * @return int The activity item ID.
 710       */
 711  	function bp_get_activity_item_id() {
 712          global $activities_template;
 713  
 714          /**
 715           * Filters the activity item ID being displayed.
 716           *
 717           * @since 1.2.0
 718           *
 719           * @param int $item_id The activity item ID.
 720           */
 721          return apply_filters( 'bp_get_activity_item_id', $activities_template->activity->item_id );
 722      }
 723  
 724  /**
 725   * Output the activity secondary item ID.
 726   *
 727   * @since 1.2.0
 728   *
 729   */
 730  function bp_activity_secondary_item_id() {
 731      echo bp_get_activity_secondary_item_id();
 732  }
 733  
 734      /**
 735       * Return the activity secondary item ID.
 736       *
 737       * @since 1.2.0
 738       *
 739       * @global object $activities_template {@link BP_Activity_Template}
 740       *
 741       * @return int The activity secondary item ID.
 742       */
 743  	function bp_get_activity_secondary_item_id() {
 744          global $activities_template;
 745  
 746          /**
 747           * Filters the activity secondary item ID being displayed.
 748           *
 749           * @since 1.2.0
 750           *
 751           * @param int $secondary_item_id The activity secondary item ID.
 752           */
 753          return apply_filters( 'bp_get_activity_secondary_item_id', $activities_template->activity->secondary_item_id );
 754      }
 755  
 756  /**
 757   * Output the date the activity was recorded.
 758   *
 759   * @since 1.2.0
 760   *
 761   */
 762  function bp_activity_date_recorded() {
 763      echo bp_get_activity_date_recorded();
 764  }
 765  
 766      /**
 767       * Return the date the activity was recorded.
 768       *
 769       * @since 1.2.0
 770       *
 771       * @global object $activities_template {@link BP_Activity_Template}
 772       *
 773       * @return string The date the activity was recorded.
 774       */
 775  	function bp_get_activity_date_recorded() {
 776          global $activities_template;
 777  
 778          /**
 779           * Filters the date the activity was recorded.
 780           *
 781           * @since 1.2.0
 782           *
 783           * @param int $date_recorded The activity's date.
 784           */
 785          return apply_filters( 'bp_get_activity_date_recorded', $activities_template->activity->date_recorded );
 786      }
 787  
 788  /**
 789   * Output the display name of the member who posted the activity.
 790   *
 791   * @since 2.1.0
 792   *
 793   */
 794  function bp_activity_member_display_name() {
 795      echo bp_get_activity_member_display_name();
 796  }
 797  
 798      /**
 799       * Return the display name of the member who posted the activity.
 800       *
 801       * @since 2.1.0
 802       *
 803       * @global object $activities_template {@link BP_Activity_Template}
 804       *
 805       * @return string The date the activity was recorded.
 806       */
 807  	function bp_get_activity_member_display_name() {
 808          global $activities_template;
 809  
 810          $retval = isset( $activities_template->activity->display_name )
 811              ? $activities_template->activity->display_name
 812              : '';
 813  
 814          /**
 815           * Filters the display name of the member who posted the activity.
 816           *
 817           * @since 2.1.0
 818           *
 819           * @param int $retval Display name for the member who posted.
 820           */
 821          return apply_filters( 'bp_get_activity_member_display_name', $retval );
 822      }
 823  
 824  /**
 825   * Output the activity object name.
 826   *
 827   * @since 1.2.0
 828   *
 829   */
 830  function bp_activity_object_name() {
 831      echo bp_get_activity_object_name();
 832  }
 833  
 834      /**
 835       * Return the activity object name.
 836       *
 837       * @since 1.2.0
 838       *
 839       * @global object $activities_template {@link BP_Activity_Template}
 840       *
 841       * @return string The activity object name.
 842       */
 843  	function bp_get_activity_object_name() {
 844          global $activities_template;
 845  
 846          /**
 847           * Filters the activity object name.
 848           *
 849           * @since 1.2.0
 850           *
 851           * @param string $activity_component The activity object name.
 852           */
 853          return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component );
 854      }
 855  
 856  /**
 857   * Output the activity type.
 858   *
 859   * @since 1.2.0
 860   *
 861   */
 862  function bp_activity_type() {
 863      echo bp_get_activity_type();
 864  }
 865  
 866      /**
 867       * Return the activity type.
 868       *
 869       * @since 1.2.0
 870       *
 871       * @global object $activities_template {@link BP_Activity_Template}
 872       *
 873       * @return string The activity type.
 874       */
 875  	function bp_get_activity_type() {
 876          global $activities_template;
 877  
 878          /**
 879           * Filters the activity type.
 880           *
 881           * @since 1.2.0
 882           *
 883           * @param string $activity_type The activity type.
 884           */
 885          return apply_filters( 'bp_get_activity_type', $activities_template->activity->type );
 886      }
 887  
 888      /**
 889       * Output the activity action name.
 890       *
 891       * Just a wrapper for bp_activity_type().
 892       *
 893       * @since 1.2.0
 894       * @deprecated 1.5.0
 895       *
 896       * @todo Properly deprecate in favor of bp_activity_type() and
 897       *       remove redundant echo
 898       *
 899       */
 900  	function bp_activity_action_name() { echo bp_activity_type(); }
 901  
 902      /**
 903       * Return the activity type.
 904       *
 905       * Just a wrapper for bp_get_activity_type().
 906       *
 907       * @since 1.2.0
 908       * @deprecated 1.5.0
 909       *
 910       * @todo Properly deprecate in favor of bp_get_activity_type().
 911       *
 912       *
 913       * @return string The activity type.
 914       */
 915  	function bp_get_activity_action_name() { return bp_get_activity_type(); }
 916  
 917  /**
 918   * Output the activity user ID.
 919   *
 920   * @since 1.1.0
 921   *
 922   */
 923  function bp_activity_user_id() {
 924      echo bp_get_activity_user_id();
 925  }
 926  
 927      /**
 928       * Return the activity user ID.
 929       *
 930       * @since 1.1.0
 931       *
 932       * @global object $activities_template {@link BP_Activity_Template}
 933       *
 934       * @return int The activity user ID.
 935       */
 936  	function bp_get_activity_user_id() {
 937          global $activities_template;
 938  
 939          /**
 940           * Filters the activity user ID.
 941           *
 942           * @since 1.1.0
 943           *
 944           * @param int $user_id The activity user ID.
 945           */
 946          return apply_filters( 'bp_get_activity_user_id', $activities_template->activity->user_id );
 947      }
 948  
 949  /**
 950   * Output the activity user link.
 951   *
 952   * @since 1.2.0
 953   *
 954   */
 955  function bp_activity_user_link() {
 956      echo bp_get_activity_user_link();
 957  }
 958  
 959      /**
 960       * Return the activity user link.
 961       *
 962       * @since 1.2.0
 963       *
 964       * @global object $activities_template {@link BP_Activity_Template}
 965       *
 966       * @return string $link The activity user link.
 967       */
 968  	function bp_get_activity_user_link() {
 969          global $activities_template;
 970  
 971          if ( empty( $activities_template->activity->user_id ) || empty( $activities_template->activity->user_nicename ) || empty( $activities_template->activity->user_login ) ) {
 972              $link = $activities_template->activity->primary_link;
 973          } else {
 974              $link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
 975          }
 976  
 977          /**
 978           * Filters the activity user link.
 979           *
 980           * @since 1.2.0
 981           *
 982           * @param string $link The activity user link.
 983           */
 984          return apply_filters( 'bp_get_activity_user_link', $link );
 985      }
 986  
 987  /**
 988   * Output the avatar of the user that performed the action.
 989   *
 990   * @since 1.1.0
 991   *
 992   * @see bp_get_activity_avatar() for description of arguments.
 993   *
 994   * @param array|string $args See {@link bp_get_activity_avatar()} for description.
 995   */
 996  function bp_activity_avatar( $args = '' ) {
 997      echo bp_get_activity_avatar( $args );
 998  }
 999      /**
1000       * Return the avatar of the user that performed the action.
1001       *
1002       * @since 1.1.0
1003       *
1004       * @see bp_core_fetch_avatar() For a description of the arguments.
1005       * @global object $activities_template {@link BP_Activity_Template}
1006       *
1007       * @param array|string $args  {
1008       *     Arguments are listed here with an explanation of their defaults.
1009       *     For more information about the arguments, see
1010       *     {@link bp_core_fetch_avatar()}.
1011       *     @type string      $alt     Default: 'Profile picture of [user name]' if
1012       *                                activity user name is available, otherwise 'Profile picture'.
1013       *     @type string      $class   Default: 'avatar'.
1014       *     @type string|bool $email   Default: Email of the activity's
1015       *                                associated user, if available. Otherwise false.
1016       *     @type string      $type    Default: 'full' when viewing a single activity
1017       *                                permalink page, otherwise 'thumb'.
1018       *     @type int|bool    $user_id Default: ID of the activity's user.
1019       * }
1020       * @return string User avatar string.
1021       */
1022  	function bp_get_activity_avatar( $args = '' ) {
1023          global $activities_template;
1024  
1025          $bp = buddypress();
1026  
1027          // On activity permalink pages, default to the full-size avatar.
1028          $type_default = bp_is_single_activity() ? 'full' : 'thumb';
1029  
1030          // Within the activity comment loop, the current activity should be set
1031          // to current_comment. Otherwise, just use activity.
1032          $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
1033  
1034          // Activity user display name.
1035          $dn_default  = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
1036  
1037          // Prepend some descriptive text to alt.
1038          $alt_default = __( 'Profile picture', 'buddypress' );
1039          if ( ! empty( $dn_default ) ) {
1040              /* translators: %s: member name */
1041              $alt_default = sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default );
1042          }
1043  
1044          $defaults = array(
1045              'alt'     => $alt_default,
1046              'class'   => 'avatar',
1047              'email'   => false,
1048              'type'    => $type_default,
1049              'user_id' => false
1050          );
1051  
1052          $r = wp_parse_args( $args, $defaults );
1053          extract( $r, EXTR_SKIP );
1054  
1055          if ( !isset( $height ) && !isset( $width ) ) {
1056  
1057              // Backpat.
1058              if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) {
1059                  $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height;
1060              } else {
1061                  $height = 20;
1062              }
1063  
1064              // Backpat.
1065              if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) {
1066                  $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width;
1067              } else {
1068                  $width = 20;
1069              }
1070          }
1071  
1072          /**
1073           * Filters the activity avatar object based on current activity item component.
1074           *
1075           * This is a variable filter dependent on the component used.
1076           * Possible hooks are bp_get_activity_avatar_object_blog,
1077           * bp_get_activity_avatar_object_group, and bp_get_activity_avatar_object_user.
1078           *
1079           * @since 1.1.0
1080           *
1081           * @param string $component Component being displayed.
1082           */
1083          $object  = apply_filters( 'bp_get_activity_avatar_object_' . $current_activity_item->component, 'user' );
1084          $item_id = !empty( $user_id ) ? $user_id : $current_activity_item->user_id;
1085  
1086          /**
1087           * Filters the activity avatar item ID.
1088           *
1089           * @since 1.2.10
1090           *
1091           * @param int $item_id Item ID for the activity avatar.
1092           */
1093          $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $item_id );
1094  
1095          // If this is a user object pass the users' email address for Gravatar so we don't have to prefetch it.
1096          if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $current_activity_item->user_email ) ) {
1097              $email = $current_activity_item->user_email;
1098          }
1099  
1100          /**
1101           * Filters the value returned by bp_core_fetch_avatar.
1102           *
1103           * @since 1.1.3
1104           *
1105           * @param array $value HTML image element containing the activity avatar.
1106           */
1107          return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array(
1108              'item_id' => $item_id,
1109              'object'  => $object,
1110              'type'    => $type,
1111              'alt'     => $alt,
1112              'class'   => $class,
1113              'width'   => $width,
1114              'height'  => $height,
1115              'email'   => $email
1116          ) ) );
1117      }
1118  
1119  /**
1120   * Output the avatar of the object that action was performed on.
1121   *
1122   * @since 1.2.0
1123   *
1124   * @see bp_get_activity_secondary_avatar() for description of arguments.
1125   *
1126   * @param array|string $args See {@link bp_get_activity_secondary_avatar} for description.
1127   */
1128  function bp_activity_secondary_avatar( $args = '' ) {
1129      echo bp_get_activity_secondary_avatar( $args );
1130  }
1131  
1132      /**
1133       * Return the avatar of the object that action was performed on.
1134       *
1135       * @since 1.2.0
1136       *
1137       * @see bp_core_fetch_avatar() for description of arguments.
1138       * @global object $activities_template {@link BP_Activity_Template}
1139       *
1140       * @param array|string $args  {
1141       *     For a complete description of arguments, see {@link bp_core_fetch_avatar()}.
1142       *     @type string      $alt     Default value varies based on current activity
1143       *                                item component.
1144       *     @type string      $type    Default: 'full' when viewing a single activity
1145       *                                permalink page, otherwise 'thumb'.
1146       *     @type string      $class   Default: 'avatar'.
1147       *     @type string|bool $email   Default: email of the activity's user.
1148       *     @type int|bool    $user_id Default: ID of the activity's user.
1149       * }
1150       * @return string The secondary avatar.
1151       */
1152  	function bp_get_activity_secondary_avatar( $args = '' ) {
1153          global $activities_template;
1154  
1155          $r = wp_parse_args( $args, array(
1156              'alt'        => '',
1157              'type'       => 'thumb',
1158              'width'      => 20,
1159              'height'     => 20,
1160              'class'      => 'avatar',
1161              'link_class' => '',
1162              'linked'     => true,
1163              'email'      => false
1164          ) );
1165          extract( $r, EXTR_SKIP );
1166  
1167          // Set item_id and object (default to user).
1168          switch ( $activities_template->activity->component ) {
1169              case 'groups' :
1170                  if ( bp_disable_group_avatar_uploads() ) {
1171                      return false;
1172                  }
1173  
1174                  $object  = 'group';
1175                  $item_id = $activities_template->activity->item_id;
1176                  $link    = '';
1177                  $name    = '';
1178  
1179                  // Only if groups is active.
1180                  if ( bp_is_active( 'groups' ) ) {
1181                      $group = groups_get_group( $item_id );
1182                      $link  = bp_get_group_permalink( $group );
1183                      $name  = $group->name;
1184                  }
1185  
1186                  if ( empty( $alt ) ) {
1187                      $alt = __( 'Group logo', 'buddypress' );
1188  
1189                      if ( ! empty( $name ) ) {
1190                          /* translators: %s: the Group name */
1191                          $alt = sprintf( __( 'Group logo of %s', 'buddypress' ), $name );
1192                      }
1193                  }
1194  
1195                  break;
1196              case 'blogs' :
1197                  $object  = 'blog';
1198                  $item_id = $activities_template->activity->item_id;
1199                  $link    = home_url();
1200  
1201                  if ( empty( $alt ) ) {
1202                      /* translators: %s: the blog name */
1203                      $alt = sprintf( __( 'Profile picture of the author of the site %s', 'buddypress' ), get_blog_option( $item_id, 'blogname' ) );
1204                  }
1205  
1206                  break;
1207              case 'friends' :
1208                  $object  = 'user';
1209                  $item_id = $activities_template->activity->secondary_item_id;
1210                  $link    = bp_core_get_userlink( $item_id, false, true );
1211  
1212                  if ( empty( $alt ) ) {
1213                      /* translators: %s: member name */
1214                      $alt = sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $activities_template->activity->secondary_item_id ) );
1215                  }
1216  
1217                  break;
1218              default :
1219                  $object  = 'user';
1220                  $item_id = $activities_template->activity->user_id;
1221                  $email   = $activities_template->activity->user_email;
1222                  $link    = bp_core_get_userlink( $item_id, false, true );
1223  
1224                  if ( empty( $alt ) ) {
1225                      /* translators: %s: member name */
1226                      $alt = sprintf( __( 'Profile picture of %s', 'buddypress' ), $activities_template->activity->display_name );
1227                  }
1228  
1229                  break;
1230          }
1231  
1232          /**
1233           * Filters the activity secondary avatar object based on current activity item component.
1234           *
1235           * This is a variable filter dependent on the component used. Possible hooks are
1236           * bp_get_activity_secondary_avatar_object_blog, bp_get_activity_secondary_avatar_object_group,
1237           * and bp_get_activity_secondary_avatar_object_user.
1238           *
1239           * @since 1.2.10
1240           *
1241           * @param string $object Component being displayed.
1242           */
1243          $object  = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object );
1244  
1245          /**
1246           * Filters the activity secondary avatar item ID.
1247           *
1248           * @since 1.2.10
1249           *
1250           * @param int $item_id ID for the secondary avatar item.
1251           */
1252          $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
1253  
1254          // If we have no item_id or object, there is no avatar to display.
1255          if ( empty( $item_id ) || empty( $object ) ) {
1256              return false;
1257          }
1258  
1259          // Get the avatar.
1260          $avatar = bp_core_fetch_avatar( array(
1261              'item_id' => $item_id,
1262              'object'  => $object,
1263              'type'    => $type,
1264              'alt'     => $alt,
1265              'class'   => $class,
1266              'width'   => $width,
1267              'height'  => $height,
1268              'email'   => $email
1269          ) );
1270  
1271          if ( !empty( $linked ) ) {
1272  
1273              /**
1274               * Filters the secondary avatar link for current activity.
1275               *
1276               * @since 1.7.0
1277               *
1278               * @param string $link      Link to wrap the avatar image in.
1279               * @param string $component Activity component being acted on.
1280               */
1281              $link = apply_filters( 'bp_get_activity_secondary_avatar_link', $link, $activities_template->activity->component );
1282  
1283              /**
1284               * Filters the determined avatar for the secondary activity item.
1285               *
1286               * @since 1.2.10
1287               *
1288               * @param string $avatar Formatted HTML <img> element, or raw avatar URL.
1289               */
1290              $avatar = apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1291  
1292              return sprintf( '<a href="%s" class="%s">%s</a>',
1293                  $link,
1294                  $link_class,
1295                  $avatar
1296              );
1297          }
1298  
1299          /** This filter is documented in bp-activity/bp-activity-template.php */
1300          return apply_filters( 'bp_get_activity_secondary_avatar', $avatar );
1301      }
1302  
1303  /**
1304   * Output the activity action.
1305   *
1306   * @since 1.2.0
1307   *
1308   * @param array $args See bp_get_activity_action().
1309   */
1310  function bp_activity_action( $args = array() ) {
1311      echo bp_get_activity_action( $args );
1312  }
1313  
1314      /**
1315       * Return the activity action.
1316       *
1317       * @since 1.2.0
1318       * @since 1.7.0 Introduce function parameter, $args.
1319       *
1320       * @global object $activities_template {@link BP_Activity_Template}
1321       *
1322       * @param array $args {
1323       *     @type bool $no_timestamp Whether to exclude the timestamp.
1324       * }
1325       *
1326       * @return string The activity action.
1327       */
1328  	function bp_get_activity_action( $args = array() ) {
1329          global $activities_template;
1330  
1331          $r = wp_parse_args( $args, array(
1332              'no_timestamp' => false,
1333          ) );
1334  
1335          /**
1336           * Filters the activity action before the action is inserted as meta.
1337           *
1338           * @since 1.2.10
1339           *
1340           * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
1341           */
1342          $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array(
1343              $activities_template->activity->action,
1344              &$activities_template->activity,
1345              $r
1346          ) );
1347  
1348          // Prepend the activity action meta (link, time since, etc...).
1349          if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
1350              $action = bp_insert_activity_meta( $action );
1351          }
1352  
1353          /**
1354           * Filters the activity action after the action has been inserted as meta.
1355           *
1356           * @since 1.2.0
1357           * @since 1.7.0 Now passes a 3rd parameter, $r, an array of arguments from the function.
1358           *
1359           * @param array $value Array containing the current action, the current activity, and the $r array passed into the function.
1360           */
1361          return apply_filters_ref_array( 'bp_get_activity_action', array(
1362              $action,
1363              &$activities_template->activity,
1364              $r
1365          ) );
1366      }
1367  
1368  /**
1369   * Output the activity content body.
1370   *
1371   * @since 1.2.0
1372   *
1373   */
1374  function bp_activity_content_body() {
1375      echo bp_get_activity_content_body();
1376  }
1377  
1378      /**
1379       * Return the activity content body.
1380       *
1381       * @since 1.2.0
1382       *
1383       * @global object $activities_template {@link BP_Activity_Template}
1384       *
1385       * @return string The activity content body.
1386       */
1387  	function bp_get_activity_content_body() {
1388          global $activities_template;
1389  
1390          // Backwards compatibility if action is not being used.
1391          if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
1392              $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
1393          }
1394  
1395          /**
1396           * Filters the activity content body.
1397           *
1398           * @since 1.2.0
1399           *
1400           * @param string $content  Content body.
1401           * @param object $activity Activity object. Passed by reference.
1402           */
1403          return apply_filters_ref_array( 'bp_get_activity_content_body', array( $activities_template->activity->content, &$activities_template->activity ) );
1404      }
1405  
1406  /**
1407   * Does the activity have content?
1408   *
1409   * @since 1.2.0
1410   *
1411   * @global object $activities_template {@link BP_Activity_Template}
1412   *
1413   * @return bool True if activity has content, false otherwise.
1414   */
1415  function bp_activity_has_content() {
1416      global $activities_template;
1417  
1418      if ( ! empty( $activities_template->activity->content ) ) {
1419          return true;
1420      }
1421  
1422      return false;
1423  }
1424  
1425  /**
1426   * Output the activity content.
1427   *
1428   * @since 1.0.0
1429   * @deprecated 1.5.0
1430   *
1431   * @todo properly deprecate this function.
1432   *
1433   */
1434  function bp_activity_content() {
1435      echo bp_get_activity_content();
1436  }
1437  
1438      /**
1439       * Return the activity content.
1440       *
1441       * @since 1.0.0
1442       * @deprecated 1.5.0
1443       *
1444       * @todo properly deprecate this function.
1445       *
1446       *
1447       * @return string The activity content.
1448       */
1449  	function bp_get_activity_content() {
1450  
1451          /**
1452           * If you want to filter activity update content, please use
1453           * the filter 'bp_get_activity_content_body'.
1454           *
1455           * This function is mainly for backwards compatibility.
1456           */
1457          $content = bp_get_activity_action() . ' ' . bp_get_activity_content_body();
1458          return apply_filters( 'bp_get_activity_content', $content );
1459      }
1460  
1461  /**
1462   * Attach metadata about an activity item to the activity content.
1463   *
1464   * This metadata includes the time since the item was posted (which will appear
1465   * as a link to the item's permalink).
1466   *
1467   * @since 1.2.0
1468   *
1469   * @global object $activities_template {@link BP_Activity_Template}
1470   *
1471   * @param string $content The activity content.
1472   * @return string The activity content with the metadata string attached.
1473   */
1474  function bp_insert_activity_meta( $content = '' ) {
1475      global $activities_template;
1476  
1477      // Strip any legacy time since placeholders from BP 1.0-1.1.
1478      $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
1479  
1480      // Get the time since this activity was recorded.
1481      $date_recorded  = bp_core_time_since( $activities_template->activity->date_recorded );
1482  
1483      // Set up 'time-since' <span>.
1484      $time_since = sprintf(
1485          '<span class="time-since" data-livestamp="%1$s">%2$s</span>',
1486          bp_core_get_iso8601_date( $activities_template->activity->date_recorded ),
1487          $date_recorded
1488      );
1489  
1490      /**
1491       * Filters the activity item time since markup.
1492       *
1493       * @since 1.2.0
1494       *
1495       * @param array $value Array containing the time since markup and the current activity component.
1496       */
1497      $time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
1498          $time_since,
1499          &$activities_template->activity
1500      ) );
1501  
1502      // Insert the permalink.
1503      if ( ! bp_is_single_activity() ) {
1504  
1505          // Setup variables for activity meta.
1506          $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
1507          $activity_meta      = sprintf( '%1$s <a href="%2$s" class="view activity-time-since bp-tooltip" data-bp-tooltip="%3$s">%4$s</a>',
1508              $new_content,
1509              $activity_permalink,
1510              esc_attr__( 'View Discussion', 'buddypress' ),
1511              $time_since
1512          );
1513  
1514          /**
1515           * Filters the activity permalink to be added to the activity content.
1516           *
1517           * @since 1.2.0
1518           *
1519           * @param array $value Array containing the html markup for the activity permalink, after being parsed by
1520           *                     sprintf and current activity component.
1521           */
1522          $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
1523              $activity_meta,
1524              &$activities_template->activity
1525          ) );
1526      } else {
1527          $new_content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
1528      }
1529  
1530      /**
1531       * Filters the activity content after activity metadata has been attached.
1532       *
1533       * @since 1.2.0
1534       *
1535       * @param string $content Activity content with the activity metadata added.
1536       */
1537      return apply_filters( 'bp_insert_activity_meta', $new_content, $content );
1538  }
1539  
1540  /**
1541   * Determine if the current user can delete an activity item.
1542   *
1543   * @since 1.2.0
1544   *
1545   * @global object $activities_template {@link BP_Activity_Template}
1546   *
1547   * @param false|BP_Activity_Activity $activity Optional. Falls back on the current item in the loop.
1548   * @return bool True if can delete, false otherwise.
1549   */
1550  function bp_activity_user_can_delete( $activity = false ) {
1551      global $activities_template;
1552  
1553      // Try to use current activity if none was passed.
1554      if ( empty( $activity ) && ! empty( $activities_template->activity ) ) {
1555          $activity = $activities_template->activity;
1556      }
1557  
1558      // If current_comment is set, we'll use that in place of the main activity.
1559      if ( isset( $activity->current_comment ) ) {
1560          $activity = $activity->current_comment;
1561      }
1562  
1563      // Assume the user cannot delete the activity item.
1564      $can_delete = false;
1565  
1566      // Only logged in users can delete activity.
1567      if ( is_user_logged_in() ) {
1568  
1569          // Community moderators can always delete activity (at least for now).
1570          if ( bp_current_user_can( 'bp_moderate' ) ) {
1571              $can_delete = true;
1572          }
1573  
1574          // Users are allowed to delete their own activity. This is actually
1575          // quite powerful, because doing so also deletes all comments to that
1576          // activity item. We should revisit this eventually.
1577          if ( isset( $activity->user_id ) && ( $activity->user_id === bp_loggedin_user_id() ) ) {
1578              $can_delete = true;
1579          }
1580  
1581          // Viewing a single item, and this user is an admin of that item.
1582          if ( bp_is_single_item() && bp_is_item_admin() ) {
1583              $can_delete = true;
1584          }
1585      }
1586  
1587      /**
1588       * Filters whether the current user can delete an activity item.
1589       *
1590       * @since 1.5.0
1591       *
1592       * @param bool   $can_delete Whether the user can delete the item.
1593       * @param object $activity   Current activity item object.
1594       */
1595      return (bool) apply_filters( 'bp_activity_user_can_delete', $can_delete, $activity );
1596  }
1597  
1598  /**
1599   * Output the activity parent content.
1600   *
1601   * @since 1.2.0
1602   *
1603   * @see bp_get_activity_parent_content() for a description of arguments.
1604   *
1605   * @param array|string $args See {@link bp_get_activity_parent_content} for description.
1606   */
1607  function bp_activity_parent_content( $args = '' ) {
1608      echo bp_get_activity_parent_content($args);
1609  }
1610  
1611      /**
1612       * Return the activity content.
1613       *
1614       * @since 1.2.0
1615       *
1616       * @global object $activities_template {@link BP_Activity_Template}
1617       *
1618       * @param string $args Unused. Left over from an earlier implementation.
1619       * @return mixed False on failure, otherwise the activity parent content.
1620       */
1621  	function bp_get_activity_parent_content( $args = '' ) {
1622          global $activities_template;
1623  
1624          // Bail if no activity on no item ID.
1625          if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
1626              return false;
1627          }
1628  
1629          // Get the ID of the parent activity content.
1630          $parent_id = $activities_template->activity->item_id;
1631  
1632          // Bail if no parent content.
1633          if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
1634              return false;
1635          }
1636  
1637          // Bail if no action.
1638          if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
1639              return false;
1640          }
1641  
1642          // Content always includes action.
1643          $content = $activities_template->activity_parents[ $parent_id ]->action;
1644  
1645          // Maybe append activity content, if it exists.
1646          if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
1647              $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
1648          }
1649  
1650          // Remove the time since content for backwards compatibility.
1651          $content = str_replace( '<span class="time-since">%s</span>', '', $content );
1652  
1653          // Remove images.
1654          $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
1655  
1656          /**
1657           * Filters the activity parent content.
1658           *
1659           * @since 1.2.0
1660           *
1661           * @param string $content Content set to be displayed as parent content.
1662           */
1663          return apply_filters( 'bp_get_activity_parent_content', $content );
1664      }
1665  
1666  /**
1667   * Output the parent activity's user ID.
1668   *
1669   * @since 1.7.0
1670   */
1671  function bp_activity_parent_user_id() {
1672      echo bp_get_activity_parent_user_id();
1673  }
1674  
1675      /**
1676       * Return the parent activity's user ID.
1677       *
1678       * @since 1.7.0
1679       *
1680       * @global BP_Activity_Template $activities_template
1681       *
1682       * @return bool|int False if parent activity can't be found, otherwise
1683       *                  the parent activity's user ID.
1684       */
1685  	function bp_get_activity_parent_user_id() {
1686          global $activities_template;
1687  
1688          // Bail if no activity on no item ID.
1689          if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
1690              return false;
1691          }
1692  
1693          // Get the ID of the parent activity content.
1694          $parent_id = $activities_template->activity->item_id;
1695  
1696          // Bail if no parent item.
1697          if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
1698              return false;
1699          }
1700  
1701          // Bail if no parent user ID.
1702          if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
1703              return false;
1704          }
1705  
1706          $retval = $activities_template->activity_parents[ $parent_id ]->user_id;
1707  
1708          /**
1709           * Filters the activity parent item's user ID.
1710           *
1711           * @since 1.7.0
1712           *
1713           * @param int $retval ID for the activity parent's user.
1714           */
1715          return (int) apply_filters( 'bp_get_activity_parent_user_id', $retval );
1716      }
1717  
1718  /**
1719   * Output whether or not the current activity is in a current user's favorites.
1720   *
1721   * @since 1.2.0
1722   *
1723   */
1724  function bp_activity_is_favorite() {
1725      echo bp_get_activity_is_favorite();
1726  }
1727  
1728      /**
1729       * Return whether the current activity is in a current user's favorites.
1730       *
1731       * @since 1.2.0
1732       *
1733       * @global object $activities_template {@link BP_Activity_Template}
1734       *
1735       * @return bool True if user favorite, false otherwise.
1736       */
1737  	function bp_get_activity_is_favorite() {
1738          global $activities_template;
1739  
1740          /**
1741           * Filters whether the current activity item is in the current user's favorites.
1742           *
1743           * @since 1.2.0
1744           *
1745           * @param bool $value Whether or not the current activity item is in the current user's favorites.
1746           */
1747          return (bool) apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
1748      }
1749  
1750  /**
1751   * Output the comment markup for an activity item.
1752   *
1753   * @since 1.2.0
1754   *
1755   * @todo deprecate $args param
1756   *
1757   * @param array|string $args See {@link bp_activity_get_comments} for description.
1758   */
1759  function bp_activity_comments( $args = '' ) {
1760      echo bp_activity_get_comments( $args );
1761  }
1762  
1763      /**
1764       * Get the comment markup for an activity item.
1765       *
1766       * @since 1.2.0
1767       *
1768       * @todo deprecate $args param
1769       * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
1770       *       this function can probably be streamlined or removed.
1771       *
1772       * @global object $activities_template {@link BP_Activity_Template}
1773       *
1774       * @param string $args Unused. Left over from an earlier implementation.
1775       * @return bool
1776       */
1777  	function bp_activity_get_comments( $args = '' ) {
1778          global $activities_template;
1779  
1780          if ( empty( $activities_template->activity->children ) ) {
1781              return false;
1782          }
1783  
1784          bp_activity_recurse_comments( $activities_template->activity );
1785      }
1786  
1787          /**
1788           * Loops through a level of activity comments and loads the template for each.
1789           *
1790           * Note: The recursion itself used to happen entirely in this function. Now it is
1791           * split between here and the comment.php template.
1792           *
1793           * @since 1.2.0
1794           *
1795           * @global object $activities_template {@link BP_Activity_Template}
1796           *
1797           * @param object $comment The activity object currently being recursed.
1798           * @return bool|string
1799           */
1800  		function bp_activity_recurse_comments( $comment ) {
1801              global $activities_template;
1802  
1803              if ( empty( $comment ) ) {
1804                  return false;
1805              }
1806  
1807              if ( empty( $comment->children ) ) {
1808                  return false;
1809              }
1810  
1811              /**
1812               * Filters the opening tag for the template that lists activity comments.
1813               *
1814               * @since 1.6.0
1815               *
1816               * @param string $value Opening tag for the HTML markup to use.
1817               */
1818              echo apply_filters( 'bp_activity_recurse_comments_start_ul', '<ul>' );
1819              foreach ( (array) $comment->children as $comment_child ) {
1820  
1821                  // Put the comment into the global so it's available to filters.
1822                  $activities_template->activity->current_comment = $comment_child;
1823  
1824                  $template = bp_locate_template( 'activity/comment.php', false, false );
1825  
1826                  // Backward compatibility. In older versions of BP, the markup was
1827                  // generated in the PHP instead of a template. This ensures that
1828                  // older themes (which are not children of bp-default and won't
1829                  // have the new template) will still work.
1830                  if ( !$template ) {
1831                      $template = buddypress()->plugin_dir . '/bp-themes/bp-default/activity/comment.php';
1832                  }
1833  
1834                  load_template( $template, false );
1835  
1836                  unset( $activities_template->activity->current_comment );
1837              }
1838  
1839              /**
1840               * Filters the closing tag for the template that list activity comments.
1841               *
1842               * @since  1.6.0
1843               *
1844               * @param string $value Closing tag for the HTML markup to use.
1845               */
1846              echo apply_filters( 'bp_activity_recurse_comments_end_ul', '</ul>' );
1847          }
1848  
1849  /**
1850   * Utility function that returns the comment currently being recursed.
1851   *
1852   * @since 1.5.0
1853   *
1854   * @global object $activities_template {@link BP_Activity_Template}
1855   *
1856   * @return object|bool $current_comment The activity comment currently being
1857   *                                      displayed. False on failure.
1858   */
1859  function bp_activity_current_comment() {
1860      global $activities_template;
1861  
1862      $current_comment = !empty( $activities_template->activity->current_comment )
1863          ? $activities_template->activity->current_comment
1864          : false;
1865  
1866      /**
1867       * Filters the current comment being recursed.
1868       *
1869       * @since 1.5.0
1870       *
1871       * @param object|bool $current_comment The activity comment currently being displayed. False on failure.
1872       */
1873      return apply_filters( 'bp_activity_current_comment', $current_comment );
1874  }
1875  
1876  
1877  /**
1878   * Output the ID of the activity comment currently being displayed.
1879   *
1880   * @since 1.5.0
1881   *
1882   */
1883  function bp_activity_comment_id() {
1884      echo bp_get_activity_comment_id();
1885  }
1886  
1887      /**
1888       * Return the ID of the activity comment currently being displayed.
1889       *
1890       * @since 1.5.0
1891       *
1892       * @global object $activities_template {@link BP_Activity_Template}
1893       *
1894       * @return int|bool $comment_id The ID of the activity comment currently
1895       *                              being displayed, false if none is found.
1896       */
1897  	function bp_get_activity_comment_id() {
1898          global $activities_template;
1899  
1900          $comment_id = isset( $activities_template->activity->current_comment->id ) ? $activities_template->activity->current_comment->id : false;
1901  
1902          /**
1903           * Filters the ID of the activity comment currently being displayed.
1904           *
1905           * @since 1.5.0
1906           *
1907           * @param int|bool $comment_id ID for the comment currently being displayed.
1908           */
1909          return apply_filters( 'bp_activity_comment_id', $comment_id );
1910      }
1911  
1912  /**
1913   * Output the ID of the author of the activity comment currently being displayed.
1914   *
1915   * @since 1.5.0
1916   *
1917   */
1918  function bp_activity_comment_user_id() {
1919      echo bp_get_activity_comment_user_id();
1920  }
1921  
1922      /**
1923       * Return the ID of the author of the activity comment currently being displayed.
1924       *
1925       * @since 1.5.0
1926       *
1927       * @global object $activities_template {@link BP_Activity_Template}
1928       *
1929       * @return int|bool $user_id The user_id of the author of the displayed
1930       *                           activity comment. False on failure.
1931       */
1932  	function bp_get_activity_comment_user_id() {
1933          global $activities_template;
1934  
1935          $user_id = isset( $activities_template->activity->current_comment->user_id ) ? $activities_template->activity->current_comment->user_id : false;
1936  
1937          /**
1938           * Filters the ID of the author of the activity comment currently being displayed.
1939           *
1940           * @since 1.5.0
1941           *
1942           * @param int|bool $user_id ID for the author of the comment currently being displayed.
1943           */
1944          return apply_filters( 'bp_activity_comment_user_id', $user_id );
1945      }
1946  
1947  /**
1948   * Output the author link for the activity comment currently being displayed.
1949   *
1950   * @since 1.5.0
1951   *
1952   */
1953  function bp_activity_comment_user_link() {
1954      echo bp_get_activity_comment_user_link();
1955  }
1956  
1957      /**
1958       * Return the author link for the activity comment currently being displayed.
1959       *
1960       * @since 1.5.0
1961       *
1962       *
1963       * @return string $user_link The URL of the activity comment author's profile.
1964       */
1965  	function bp_get_activity_comment_user_link() {
1966          $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() );
1967  
1968          /**
1969           * Filters the author link for the activity comment currently being displayed.
1970           *
1971           * @since 1.5.0
1972           *
1973           * @param string $user_link Link for the author of the activity comment currently being displayed.
1974           */
1975          return apply_filters( 'bp_activity_comment_user_link', $user_link );
1976      }
1977  
1978  /**
1979   * Output the author name for the activity comment currently being displayed.
1980   *
1981   * @since 1.5.0
1982   *
1983   */
1984  function bp_activity_comment_name() {
1985      echo bp_get_activity_comment_name();
1986  }
1987  
1988      /**
1989       * Return the author name for the activity comment currently being displayed.
1990       *
1991       * The use of the 'bp_acomment_name' filter is deprecated. Please use
1992       * 'bp_activity_comment_name'.
1993       *
1994       * @since 1.5.0
1995       *
1996       * @global object $activities_template {@link BP_Activity_Template}
1997       *
1998       * @return string $name The full name of the activity comment author.
1999       */
2000  	function bp_get_activity_comment_name() {
2001          global $activities_template;
2002  
2003          if ( isset( $activities_template->activity->current_comment->user_fullname ) ) {
2004  
2005              $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment );  // Backward compatibility.
2006          } else {
2007              $name = $activities_template->activity->current_comment->display_name;
2008          }
2009  
2010          /**
2011           * Filters the name of the author for the activity comment.
2012           *
2013           * @since 1.5.0
2014           *
2015           * @param string $name Name to be displayed with the activity comment.
2016           */
2017          return apply_filters( 'bp_activity_comment_name', $name );
2018      }
2019  
2020  /**
2021   * Output the formatted date_recorded of the activity comment currently being displayed.
2022   *
2023   * @since 1.5.0
2024   *
2025   */
2026  function bp_activity_comment_date_recorded() {
2027      echo bp_get_activity_comment_date_recorded();
2028  }
2029  
2030      /**
2031       * Return the formatted date_recorded for the activity comment currently being displayed.
2032       *
2033       * @since 1.5.0
2034       *
2035       *
2036       * @return string|bool $date_recorded Time since the activity was recorded,
2037       *                                    in the form "%s ago". False on failure.
2038       */
2039  	function bp_get_activity_comment_date_recorded() {
2040  
2041          /**
2042           * Filters the recorded date of the activity comment currently being displayed.
2043           *
2044           * @since 1.5.0
2045           *
2046           * @param string|bool Date for the activity comment currently being displayed.
2047           */
2048          return apply_filters( 'bp_activity_comment_date_recorded', bp_core_time_since( bp_get_activity_comment_date_recorded_raw() ) );
2049      }
2050  
2051  /**
2052   * Output the date_recorded of the activity comment currently being displayed.
2053   *
2054   * @since 2.3.0
2055   *
2056   */
2057  function bp_activity_comment_date_recorded_raw() {
2058      echo bp_get_activity_comment_date_recorded_raw();
2059  }
2060  
2061      /**
2062       * Return the date_recorded for the activity comment currently being displayed.
2063       *
2064       * @since 2.3.0
2065       *
2066       * @global object $activities_template {@link BP_Activity_Template}
2067       *
2068       * @return string|bool $date_recorded Time since the activity was recorded,
2069       *                                    in the form "%s ago". False on failure.
2070       */
2071  	function bp_get_activity_comment_date_recorded_raw() {
2072          global $activities_template;
2073  
2074          /**
2075           * Filters the raw recorded date of the activity comment currently being displayed.
2076           *
2077           * @since 2.3.0
2078           *
2079           * @param string|bool Raw date for the activity comment currently being displayed.
2080           */
2081          return apply_filters( 'bp_activity_comment_date_recorded', $activities_template->activity->current_comment->date_recorded );
2082      }
2083  
2084  /**
2085   * Output the 'delete' URL for the activity comment currently being displayed.
2086   *
2087   * @since 1.5.0
2088   *
2089   */
2090  function bp_activity_comment_delete_link() {
2091      echo bp_get_activity_comment_delete_link();
2092  }
2093  
2094      /**
2095       * Gets the 'delete' URL for the activity comment currently being displayed.
2096       *
2097       * @since 1.5.0
2098       *
2099       *
2100       * @return string $link The nonced URL for deleting the current
2101       *                      activity comment.
2102       */
2103  	function bp_get_activity_comment_delete_link() {
2104          $link = wp_nonce_url( trailingslashit( bp_get_activity_directory_permalink() . 'delete/' . bp_get_activity_comment_id() ) . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
2105  
2106          /**
2107           * Filters the link used for deleting the activity comment currently being displayed.
2108           *
2109           * @since 1.5.0
2110           *
2111           * @param string $link Link to use for deleting the currently displayed activity comment.
2112           */
2113          return apply_filters( 'bp_activity_comment_delete_link', $link );
2114      }
2115  
2116  /**
2117   * Output the content of the activity comment currently being displayed.
2118   *
2119   * @since 1.5.0
2120   *
2121   */
2122  function bp_activity_comment_content() {
2123      echo bp_get_activity_comment_content();
2124  }
2125  
2126      /**
2127       * Return the content of the activity comment currently being displayed.
2128       *
2129       * The content is run through two filters. 'bp_get_activity_content'
2130       * will apply all filters applied to activity items in general. Use
2131       * 'bp_activity_comment_content' to modify the content of activity
2132       * comments only.
2133       *
2134       * @since 1.5.0
2135       *
2136       * @global object $activities_template {@link BP_Activity_Template}
2137       *
2138       * @return string $content The content of the current activity comment.
2139       */
2140  	function bp_get_activity_comment_content() {
2141          global $activities_template;
2142  
2143          /** This filter is documented in bp-activity/bp-activity-template.php */
2144          $content = apply_filters( 'bp_get_activity_content', $activities_template->activity->current_comment->content );
2145  
2146          /**
2147           * Filters the content of the current activity comment.
2148           *
2149           * @since 1.2.0
2150           * @since 3.0.0 Added $context parameter to disambiguate from bp_get_activity_comment_content().
2151           *
2152           * @param string $content The content of the current activity comment.
2153           * @param string $context This filter's context ("get").
2154           */
2155          return apply_filters( 'bp_activity_comment_content', $content, 'get' );
2156      }
2157  
2158  /**
2159   * Output the activity comment count.
2160   *
2161   * @since 1.2.0
2162   *
2163   */
2164  function bp_activity_comment_count() {
2165      echo bp_activity_get_comment_count();
2166  }
2167  
2168      /**
2169       * Return the comment count of an activity item.
2170       *
2171       * @since 1.2.0
2172       *
2173       * @global object $activities_template {@link BP_Activity_Template}
2174       *
2175       * @param array|null $deprecated Deprecated.
2176       * @return int $count The activity comment count.
2177       */
2178  	function bp_activity_get_comment_count( $deprecated = null ) {
2179          global $activities_template;
2180  
2181          // Deprecated notice about $args.
2182          if ( ! empty( $deprecated ) ) {
2183              _deprecated_argument(
2184                  __FUNCTION__,
2185                  '1.2',
2186                  sprintf(
2187                      /* translators: 1: the name of the function. 2: the name of the file. */
2188                      __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ),
2189                      __FUNCTION__,
2190                      __FILE__
2191                  )
2192              );
2193          }
2194  
2195          // Get the count using the purpose-built recursive function.
2196          $count = ! empty( $activities_template->activity->children )
2197              ? bp_activity_recurse_comment_count( $activities_template->activity )
2198              : 0;
2199  
2200          /**
2201           * Filters the activity comment count.
2202           *
2203           * @since 1.2.0
2204           *
2205           * @param int $count The activity comment count.
2206           */
2207          return apply_filters( 'bp_activity_get_comment_count', (int) $count );
2208      }
2209  
2210          /**
2211           * Return the total number of comments to the current comment.
2212           *
2213           * This function recursively adds the total number of comments each
2214           * activity child has, and returns them.
2215           *
2216           * @since 1.2.0
2217           *
2218           *
2219           * @param object $comment Activity comment object.
2220           * @param int    $count The current iteration count.
2221           * @return int $count The activity comment count.
2222           */
2223  		function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
2224  
2225              // Copy the count.
2226              $new_count = $count;
2227  
2228              // Loop through children and recursively count comments.
2229              if ( ! empty( $comment->children ) ) {
2230                  foreach ( (array) $comment->children as $comment ) {
2231                      $new_count++;
2232                      $new_count = bp_activity_recurse_comment_count( $comment, $new_count );
2233                  }
2234              }
2235  
2236              /**
2237               * Filters the total number of comments for the current comment.
2238               *
2239               * @since 2.1.0
2240               *
2241               * @param int    $new_count New total count for the current comment.
2242               * @param object $comment   Activity comment object.
2243               * @param int    $count     Current iteration count for the current comment.
2244               */
2245              return apply_filters( 'bp_activity_recurse_comment_count', $new_count, $comment, $count );
2246          }
2247  
2248  /**
2249   * Output the depth of the current activity comment.
2250   *
2251   * @since 2.0.0
2252   * @since 2.8.0 Added $comment as a parameter.
2253   *
2254   * @param object|int $comment Object of the activity comment or activity comment ID. Usually unnecessary
2255   *                            when used in activity comment loop.
2256   */
2257  function bp_activity_comment_depth( $comment = 0 ) {
2258      echo bp_activity_get_comment_depth( $comment );
2259  }
2260  
2261      /**
2262       * Return the current activity comment depth.
2263       *
2264       * @since 2.0.0
2265       * @since 2.8.0 Added $comment as a parameter.
2266       *
2267       * @param  object|int $comment Object of the activity comment or activity comment ID. Usually unnecessary
2268       *                             when used in activity comment loop.
2269       * @return int
2270       */
2271  	function bp_activity_get_comment_depth( $comment = 0 ) {
2272          $depth = 0;
2273  
2274          // Activity comment loop takes precedence.
2275          if ( isset( $GLOBALS['activities_template']->activity->current_comment->depth ) ) {
2276              $depth = $GLOBALS['activities_template']->activity->current_comment->depth;
2277  
2278          // Get depth for activity comment manually.
2279          } elseif ( ! empty( $comment ) ) {
2280              // We passed an activity ID, so fetch the activity object.
2281              if ( is_int( $comment ) ) {
2282                  $comment = new BP_Activity_Activity( $comment );
2283              }
2284  
2285              // Recurse through activity tree to find the depth.
2286              if ( is_object( $comment ) && isset( $comment->type ) && 'activity_comment' === $comment->type ) {
2287                  // Fetch the entire root comment tree... ugh.
2288                  $comments = BP_Activity_Activity::get_activity_comments( $comment->item_id, 1, constant( 'PHP_INT_MAX' ) );
2289  
2290                  // Recursively find our comment object from the comment tree.
2291                  $iterator  = new RecursiveArrayIterator( $comments );
2292                  $recursive = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::SELF_FIRST );
2293                  foreach ( $recursive as $cid => $cobj ) {
2294                      // Skip items that are not a comment object.
2295                      if ( ! is_numeric( $cid ) || ! is_object( $cobj ) ) {
2296                          continue;
2297                      }
2298  
2299                      // We found the activity comment! Set the depth.
2300                      if ( $cid === $comment->id && isset( $cobj->depth ) ) {
2301                          $depth = $cobj->depth;
2302                          break;
2303                      }
2304                  }
2305              }
2306          }
2307  
2308          /**
2309           * Filters the comment depth of the current activity comment.
2310           *
2311           * @since 2.0.0
2312           *
2313           * @param int $depth Depth for the current activity comment.
2314           */
2315          return apply_filters( 'bp_activity_get_comment_depth', $depth );
2316      }
2317  
2318  /**
2319   * Output the activity comment link.
2320   *
2321   * @since 1.2.0
2322   *
2323   */
2324  function bp_activity_comment_link() {
2325      echo bp_get_activity_comment_link();
2326  }
2327  
2328      /**
2329       * Return the activity comment link.
2330       *
2331       * @since 1.2.0
2332       *
2333       * @global object $activities_template {@link BP_Activity_Template}
2334       *
2335       * @return string The activity comment link.
2336       */
2337  	function bp_get_activity_comment_link() {
2338          global $activities_template;
2339  
2340          /**
2341           * Filters the comment link for the current activity comment.
2342           *
2343           * @since 1.2.0
2344           *
2345           * @param string $value Constructed URL parameters with activity IDs.
2346           */
2347          return apply_filters( 'bp_get_activity_comment_link', '?ac=' . $activities_template->activity->id . '/#ac-form-' . $activities_template->activity->id );
2348      }
2349  
2350  /**
2351   * Output the activity comment form no JavaScript display CSS.
2352   *
2353   * @since 1.2.0
2354   *
2355   */
2356  function bp_activity_comment_form_nojs_display() {
2357      echo bp_get_activity_comment_form_nojs_display();
2358  }
2359  
2360      /**
2361       * Return the activity comment form no JavaScript display CSS.
2362       *
2363       * @since 1.2.0
2364       *
2365       * @global object $activities_template {@link BP_Activity_Template}
2366       *
2367       * @return string|false The activity comment form no JavaScript
2368       *                      display CSS. False on failure.
2369       */
2370  	function bp_get_activity_comment_form_nojs_display() {
2371          global $activities_template;
2372  
2373          if ( isset( $_GET['ac'] ) && ( $_GET['ac'] === ( $activities_template->activity->id . '/' ) ) ) {
2374              return 'style="display: block"';
2375          }
2376  
2377          return false;
2378      }
2379  
2380  /**
2381   * Output the activity comment form action.
2382   *
2383   * @since 1.2.0
2384   *
2385   */
2386  function bp_activity_comment_form_action() {
2387      echo bp_get_activity_comment_form_action();
2388  }
2389  
2390      /**
2391       * Return the activity comment form action.
2392       *
2393       * @since 1.2.0
2394       *
2395       *
2396       * @return string The activity comment form action.
2397       */
2398  	function bp_get_activity_comment_form_action() {
2399  
2400          /**
2401           * Filters the activity comment form action URL.
2402           *
2403           * @since 1.2.0
2404           *
2405           * @param string $value URL to use in the comment form's action attribute.
2406           */
2407          return apply_filters( 'bp_get_activity_comment_form_action', home_url( bp_get_activity_root_slug() . '/reply/' ) );
2408      }
2409  
2410  /**
2411   * Output the activity permalink ID.
2412   *
2413   * @since 1.2.0
2414   *
2415   */
2416  function bp_activity_permalink_id() {
2417      echo bp_get_activity_permalink_id();
2418  }
2419  
2420      /**
2421       * Return the activity permalink ID.
2422       *
2423       * @since 1.2.0
2424       *
2425       *
2426       * @return string The activity permalink ID.
2427       */
2428  	function bp_get_activity_permalink_id() {
2429  
2430          /**
2431           * Filters the activity action permalink ID.
2432           *
2433           * @since 1.2.0
2434           *
2435           * @param string $value Current action for the activity item.
2436           */
2437          return apply_filters( 'bp_get_activity_permalink_id', bp_current_action() );
2438      }
2439  
2440  /**
2441   * Output the activity thread permalink.
2442   *
2443   * @since 1.2.0
2444   *
2445   */
2446  function bp_activity_thread_permalink() {
2447      echo esc_url( bp_get_activity_thread_permalink() );
2448  }
2449  
2450      /**
2451       * Return the activity thread permalink.
2452       *
2453       * @since 1.2.0
2454       *
2455       *
2456       * @return string $link The activity thread permalink.
2457       */
2458  	function bp_get_activity_thread_permalink() {
2459          global $activities_template;
2460  
2461          $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
2462  
2463          /**
2464           * Filters the activity thread permalink.
2465           *
2466           * @since 1.2.0
2467           *
2468           * @param string $link The activity thread permalink.
2469           */
2470          return apply_filters( 'bp_get_activity_thread_permalink', $link );
2471      }
2472  
2473  /**
2474   * Output the activity comment permalink.
2475   *
2476   * @since 1.8.0
2477   *
2478   */
2479  function bp_activity_comment_permalink() {
2480      echo esc_url( bp_get_activity_comment_permalink() );
2481  }
2482      /**
2483       * Return the activity comment permalink.
2484       *
2485       * @since 1.8.0
2486       *
2487       * @return string $link The activity comment permalink.
2488       */
2489  	function bp_get_activity_comment_permalink() {
2490          global $activities_template;
2491  
2492          $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
2493  
2494          // Used for filter below.
2495          $comment_id = isset( $activities_template->activity->current_comment->id )
2496              ? $activities_template->activity->current_comment->id
2497              : 0;
2498  
2499          /**
2500           * Filters the activity comment permalink.
2501           *
2502           * @since 1.8.0
2503           *
2504           * @param string $link       Activity comment permalink.
2505           * @param int    $comment_id ID for the current activity comment.
2506           */
2507          return apply_filters( 'bp_get_activity_comment_permalink', $link, $comment_id );
2508      }
2509  
2510  /**
2511   * Output the activity favorite link.
2512   *
2513   * @since 1.2.0
2514   *
2515   */
2516  function bp_activity_favorite_link() {
2517      echo bp_get_activity_favorite_link();
2518  }
2519  
2520      /**
2521       * Return the activity favorite link.
2522       *
2523       * @since 1.2.0
2524       *
2525       * @global object $activities_template {@link BP_Activity_Template}
2526       *
2527       * @return string The activity favorite link.
2528       */
2529  	function bp_get_activity_favorite_link() {
2530          global $activities_template;
2531  
2532          /**
2533           * Filters the activity favorite link.
2534           *
2535           * @since 1.2.0
2536           *
2537           * @param string $value Constructed link for favoriting the activity comment.
2538           */
2539          return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) );
2540      }
2541  
2542  /**
2543   * Output the activity unfavorite link.
2544   *
2545   * @since 1.2.0
2546   *
2547   */
2548  function bp_activity_unfavorite_link() {
2549      echo bp_get_activity_unfavorite_link();
2550  }
2551  
2552      /**
2553       * Return the activity unfavorite link.
2554       *
2555       * @since 1.2.0
2556       *
2557       * @global object $activities_template {@link BP_Activity_Template}
2558       *
2559       * @return string The activity unfavorite link.
2560       */
2561  	function bp_get_activity_unfavorite_link() {
2562          global $activities_template;
2563  
2564          /**
2565           * Filters the activity unfavorite link.
2566           *
2567           * @since 1.2.0
2568           *
2569           * @param string $value Constructed link for unfavoriting the activity comment.
2570           */
2571          return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) );
2572      }
2573  
2574  /**
2575   * Output the activity CSS class.
2576   *
2577   * @since 1.0.0
2578   *
2579   */
2580  function bp_activity_css_class() {
2581      echo bp_get_activity_css_class();
2582  }
2583  
2584      /**
2585       * Return the current activity item's CSS class.
2586       *
2587       * @since 1.0.0
2588       *
2589       * @global object $activities_template {@link BP_Activity_Template}
2590       *
2591       * @return string The activity item's CSS class.
2592       */
2593  	function bp_get_activity_css_class() {
2594          global $activities_template;
2595  
2596          /**
2597           * Filters the available mini activity actions available as CSS classes.
2598           *
2599           * @since 1.2.0
2600           *
2601           * @param array $value Array of classes used to determine classes applied to HTML element.
2602           */
2603          $mini_activity_actions = apply_filters( 'bp_activity_mini_activity_types', array(
2604              'friendship_accepted',
2605              'friendship_created',
2606              'new_blog',
2607              'joined_group',
2608              'created_group',
2609              'new_member'
2610          ) );
2611  
2612          $class = ' activity-item';
2613  
2614          if ( in_array( $activities_template->activity->type, (array) $mini_activity_actions ) || empty( $activities_template->activity->content ) ) {
2615              $class .= ' mini';
2616          }
2617  
2618          if ( bp_activity_get_comment_count() && bp_activity_can_comment() ) {
2619              $class .= ' has-comments';
2620          }
2621  
2622          /**
2623           * Filters the determined classes to add to the HTML element.
2624           *
2625           * @since 1.0.0
2626           *
2627           * @param string $value Classes to be added to the HTML element.
2628           */
2629          return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class );
2630      }
2631  
2632  /**
2633   * Output the activity delete link.
2634   *
2635   * @since 1.1.0
2636   *
2637   */
2638  function bp_activity_delete_link() {
2639      echo bp_get_activity_delete_link();
2640  }
2641  
2642      /**
2643       * Return the activity delete link.
2644       *
2645       * @since 1.1.0
2646       *
2647       * @global object $activities_template {@link BP_Activity_Template}
2648       *
2649       * @return string $link Activity delete link. Contains $redirect_to arg
2650       *                      if on single activity page.
2651       */
2652  	function bp_get_activity_delete_link() {
2653  
2654          $url   = bp_get_activity_delete_url();
2655          $class = 'delete-activity';
2656  
2657          // Determine if we're on a single activity page, and customize accordingly.
2658          if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
2659              $class = 'delete-activity-single';
2660          }
2661  
2662          $link = '<a href="' . esc_url( $url ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>';
2663  
2664          /**
2665           * Filters the activity delete link.
2666           *
2667           * @since 1.1.0
2668           *
2669           * @param string $link Activity delete HTML link.
2670           */
2671          return apply_filters( 'bp_get_activity_delete_link', $link );
2672      }
2673  
2674  /**
2675   * Output the URL to delete a single activity stream item.
2676   *
2677   * @since 2.1.0
2678   *
2679   */
2680  function bp_activity_delete_url() {
2681      echo esc_url( bp_get_activity_delete_url() );
2682  }
2683      /**
2684       * Return the URL to delete a single activity item.
2685       *
2686       * @since 2.1.0
2687       *
2688       * @global object $activities_template {@link BP_Activity_Template}
2689       *
2690       * @return string $link Activity delete link. Contains $redirect_to arg
2691       *                      if on single activity page.
2692       */
2693  	function bp_get_activity_delete_url() {
2694          global $activities_template;
2695  
2696          $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
2697  
2698          // Determine if we're on a single activity page, and customize accordingly.
2699          if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
2700              $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
2701          }
2702  
2703          $url = wp_nonce_url( $url, 'bp_activity_delete_link' );
2704  
2705          /**
2706           * Filters the activity delete URL.
2707           *
2708           * @since 2.1.0
2709           *
2710           * @param string $url Activity delete URL.
2711           */
2712          return apply_filters( 'bp_get_activity_delete_url', $url );
2713      }
2714  
2715  /**
2716   * Output the activity latest update link.
2717   *
2718   * @since 1.2.0
2719   *
2720   * @see bp_get_activity_latest_update() for description of parameters.
2721   *
2722   * @param int $user_id See {@link bp_get_activity_latest_update()} for description.
2723   */
2724  function bp_activity_latest_update( $user_id = 0 ) {
2725      echo bp_get_activity_latest_update( $user_id );
2726  }
2727  
2728      /**
2729       * Return the activity latest update link.
2730       *
2731       * @since 1.2.0
2732       *
2733       *
2734       * @param int $user_id If empty, will fall back on displayed user.
2735       * @return string|bool $latest_update The activity latest update link.
2736       *                                    False on failure.
2737       */
2738  	function bp_get_activity_latest_update( $user_id = 0 ) {
2739  
2740          if ( empty( $user_id ) ) {
2741              $user_id = bp_displayed_user_id();
2742          }
2743  
2744          if ( bp_is_user_inactive( $user_id ) ) {
2745              return false;
2746          }
2747  
2748          if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) {
2749              return false;
2750          }
2751  
2752          /**
2753           * Filters the latest update excerpt.
2754           *
2755           * @since 1.2.10
2756           * @since 2.6.0  Added the `$user_id` parameter.
2757           *
2758           * @param string $value   The excerpt for the latest update.
2759           * @param int    $user_id ID of the queried user.
2760           */
2761          $latest_update = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], bp_activity_get_excerpt_length() ) ) ), $user_id );
2762  
2763          $latest_update = sprintf(
2764              '%s <a href="%s">%s</a>',
2765              $latest_update,
2766              esc_url_raw( bp_activity_get_permalink( $update['id'] ) ),
2767              esc_attr__( 'View', 'buddypress' )
2768          );
2769  
2770          /**
2771           * Filters the latest update excerpt with view link appended to the end.
2772           *
2773           * @since 1.2.0
2774           * @since 2.6.0 Added the `$user_id` parameter.
2775           *
2776           * @param string $latest_update The latest update with "view" link appended to it.
2777           * @param int    $user_id       ID of the queried user.
2778           */
2779          return apply_filters( 'bp_get_activity_latest_update', $latest_update, $user_id );
2780      }
2781  
2782  /**
2783   * Output the activity filter links.
2784   *
2785   * @since 1.1.0
2786   *
2787   * @see bp_get_activity_filter_links() for description of parameters.
2788   *
2789   * @param array|bool $args See {@link bp_get_activity_filter_links()} for description.
2790   */
2791  function bp_activity_filter_links( $args = false ) {
2792      echo bp_get_activity_filter_links( $args );
2793  }
2794  
2795      /**
2796       * Return the activity filter links.
2797       *
2798       * @since 1.1.0
2799       *
2800       *
2801       * @param array|bool $args {
2802       *     @type string $style The type of markup to use for the links.
2803       *                         'list', 'paragraph', or 'span'. Default: 'list'.
2804       * }
2805       * @return string|bool $component_links The activity filter links.
2806       *         False on failure.
2807       */
2808  	function bp_get_activity_filter_links( $args = false ) {
2809  
2810          $r = wp_parse_args( $args, array(
2811              'style' => 'list'
2812          ) );
2813  
2814          // Define local variable.
2815          $component_links = array();
2816  
2817          // Fetch the names of components that have activity recorded in the DB.
2818          $components = BP_Activity_Activity::get_recorded_components();
2819  
2820          if ( empty( $components ) ) {
2821              return false;
2822          }
2823  
2824          foreach ( (array) $components as $component ) {
2825  
2826              // Skip the activity comment filter.
2827              if ( 'activity' == $component ) {
2828                  continue;
2829              }
2830  
2831              if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] ) {
2832                  $selected = ' class="selected"';
2833              } else {
2834                  $selected = '';
2835              }
2836  
2837              $component = esc_attr( $component );
2838  
2839              switch ( $r['style'] ) {
2840                  case 'list':
2841                      $tag = 'li';
2842                      $before = '<li id="afilter-' . $component . '"' . $selected . '>';
2843                      $after = '</li>';
2844                  break;
2845                  case 'paragraph':
2846                      $tag = 'p';
2847                      $before = '<p id="afilter-' . $component . '"' . $selected . '>';
2848                      $after = '</p>';
2849                  break;
2850                  case 'span':
2851                      $tag = 'span';
2852                      $before = '<span id="afilter-' . $component . '"' . $selected . '>';
2853                      $after = '</span>';
2854                  break;
2855              }
2856  
2857              $link = add_query_arg( 'afilter', $component );
2858              $link = remove_query_arg( 'acpage' , $link );
2859  
2860              /**
2861               * Filters the activity filter link URL for the current activity component.
2862               *
2863               * @since 1.1.0
2864               *
2865               * @param string $link      The URL for the current component.
2866               * @param string $component The current component getting links constructed for.
2867               */
2868              $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
2869  
2870              $component_links[] = $before . '<a href="' . esc_url( $link ) . '">' . ucwords( $component ) . '</a>' . $after;
2871          }
2872  
2873          $link = remove_query_arg( 'afilter' , $link );
2874  
2875          if ( isset( $_GET['afilter'] ) ) {
2876              $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_url( $link ) . '">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
2877          }
2878  
2879          /**
2880           * Filters all of the constructed filter links.
2881           *
2882           * @since 1.1.0
2883           * @since 2.6.0 Added the `$r` parameter.
2884           *
2885           * @param string $value All of the links to be displayed to the user.
2886           * @param array  $r     Array of parsed arguments.
2887           */
2888          return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ), $r );
2889      }
2890  
2891  /**
2892   * Determine if a comment can be made on an activity item.
2893   *
2894   * @since 1.2.0
2895   *
2896   * @global object $activities_template {@link BP_Activity_Template}
2897   *
2898   * @return bool $can_comment True if item can receive comments.
2899   */
2900  function bp_activity_can_comment() {
2901      global $activities_template;
2902      $bp = buddypress();
2903  
2904      // Determine ability to comment based on activity type name.
2905      $activity_type = bp_get_activity_type();
2906  
2907      // Get the 'comment-reply' support for the current activity type.
2908      $can_comment = bp_activity_type_supports( $activity_type, 'comment-reply' );
2909  
2910      // Neutralize activity_comment.
2911      if ( 'activity_comment' === $activity_type ) {
2912          $can_comment = false;
2913      }
2914  
2915      /**
2916       * Filters whether a comment can be made on an activity item.
2917       *
2918       * @since 1.5.0
2919       * @since 2.5.0 Use $activity_type instead of $activity_name for the second parameter.
2920       *
2921       * @param bool   $can_comment     Status on if activity can be commented on.
2922       * @param string $activity_type   Current activity type being checked on.
2923       */
2924      return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_type );
2925  }
2926  
2927  /**
2928   * Determine whether a comment can be made on an activity reply item.
2929   *
2930   * @since 1.5.0
2931   *
2932   * @param  bool|object $comment     Activity comment.
2933   * @return bool        $can_comment True if comment can receive comments,
2934   *                                  otherwise false.
2935   */
2936  function bp_activity_can_comment_reply( $comment = false ) {
2937  
2938      // Assume activity can be commented on.
2939      $can_comment = true;
2940  
2941      // Check that comment exists.
2942      if ( empty( $comment ) ) {
2943          $comment = bp_activity_current_comment();
2944      }
2945  
2946      if ( ! empty( $comment ) ) {
2947  
2948          // Fall back on current comment in activity loop.
2949          $comment_depth = isset( $comment->depth )
2950              ? intval( $comment->depth )
2951              : bp_activity_get_comment_depth( $comment );
2952  
2953          // Threading is turned on, so check the depth.
2954          if ( get_option( 'thread_comments' ) ) {
2955              $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
2956  
2957          // No threading for comment replies if no threading for comments.
2958          } else {
2959              $can_comment = false;
2960          }
2961      }
2962  
2963      /**
2964       * Filters whether a comment can be made on an activity reply item.
2965       *
2966       * @since 1.5.0
2967       *
2968       * @param bool   $can_comment Status on if activity reply can be commented on.
2969       * @param object $comment     Current comment object being checked on.
2970       */
2971      return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
2972  }
2973  
2974  /**
2975   * Determine whether favorites are allowed.
2976   *
2977   * Defaults to true, but can be modified by plugins.
2978   *
2979   * @since 1.5.0
2980   *
2981   * @return bool True if comment can receive comments.
2982   */
2983  function bp_activity_can_favorite() {
2984  
2985      /**
2986       * Filters whether or not users can favorite activity items.
2987       *
2988       * @since 1.5.0
2989       *
2990       * @param bool $value Whether or not favoriting is enabled.
2991       */
2992      return apply_filters( 'bp_activity_can_favorite', true );
2993  }
2994  
2995  /**
2996   * Output the total favorite count for a specified user.
2997   *
2998   * @since 1.2.0
2999   *
3000   * @see bp_get_total_favorite_count_for_user() for description of parameters.
3001   *
3002   * @param int $user_id See {@link bp_get_total_favorite_count_for_user()}.
3003   */
3004  function bp_total_favorite_count_for_user( $user_id = 0 ) {
3005      echo bp_get_total_favorite_count_for_user( $user_id );
3006  }
3007  
3008      /**
3009       * Return the total favorite count for a specified user.
3010       *
3011       * @since 1.2.0
3012       *
3013       *
3014       * @param int $user_id ID of user being queried. Default: displayed user ID.
3015       * @return int The total favorite count for the specified user.
3016       */
3017  	function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
3018          $retval = false;
3019  
3020          if ( bp_activity_can_favorite() ) {
3021              // Default to displayed user if none is passed.
3022              $user_id = empty( $user_id )
3023                  ? bp_displayed_user_id()
3024                  : $user_id;
3025  
3026              // Get user meta if user ID exists.
3027              if ( ! empty( $user_id ) ) {
3028                  $retval = bp_activity_total_favorites_for_user( $user_id );
3029              }
3030          }
3031  
3032          /**
3033           * Filters the total favorite count for a user.
3034           *
3035           * @since 1.2.0
3036           * @since 2.6.0 Added the `$user_id` parameter.
3037           *
3038           * @param int|bool $retval  Total favorite count for a user. False on no favorites.
3039           * @param int      $user_id ID of the queried user.
3040           */
3041          return apply_filters( 'bp_get_total_favorite_count_for_user', $retval, $user_id );
3042      }
3043  
3044  
3045  /**
3046   * Output the total mention count for a specified user.
3047   *
3048   * @since 1.2.0
3049   *
3050   * @see bp_get_total_mention_count_for_user() for description of parameters.
3051   *
3052   * @param int $user_id See {@link bp_get_total_mention_count_for_user()}.
3053   */
3054  function bp_total_mention_count_for_user( $user_id = 0 ) {
3055      echo bp_get_total_mention_count_for_user( $user_id );
3056  }
3057  
3058      /**
3059       * Return the total mention count for a specified user.
3060       *
3061       * @since 1.2.0
3062       *
3063       *
3064       * @param int $user_id ID of user being queried. Default: displayed user ID.
3065       * @return int The total mention count for the specified user.
3066       */
3067  	function bp_get_total_mention_count_for_user( $user_id = 0 ) {
3068  
3069          // Default to displayed user if none is passed.
3070          $user_id = empty( $user_id )
3071              ? bp_displayed_user_id()
3072              : $user_id;
3073  
3074          // Get user meta if user ID exists.
3075          $retval = ! empty( $user_id )
3076              ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
3077              : false;
3078  
3079          /**
3080           * Filters the total mention count for a user.
3081           *
3082           * @since 1.2.0
3083           * @since 2.6.0 Added the `$user_id` parameter.
3084           *
3085           * @param int|bool $retval  Total mention count for a user. False on no mentions.
3086           * @param int      $user_id ID of the queried user.
3087           */
3088          return apply_filters( 'bp_get_total_mention_count_for_user', $retval, $user_id );
3089      }
3090  
3091  /**
3092   * Output the public message link for displayed user.
3093   *
3094   * @since 1.2.0
3095   *
3096   */
3097  function bp_send_public_message_link() {
3098      echo esc_url( bp_get_send_public_message_link() );
3099  }
3100  
3101      /**
3102       * Return the public message link for the displayed user.
3103       *
3104       * @since 1.2.0
3105       *
3106       *
3107       * @return string The public message link for the displayed user.
3108       */
3109  	function bp_get_send_public_message_link() {
3110  
3111          // No link if not logged in, not looking at someone else's profile.
3112          if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
3113              $retval = '';
3114          } else {
3115              $args   = array( 'r' => bp_get_displayed_user_mentionname() );
3116              $url    = add_query_arg( $args, bp_get_activity_directory_permalink() );
3117              $retval = wp_nonce_url( $url );
3118          }
3119  
3120          /**
3121           * Filters the public message link for the displayed user.
3122           *
3123           * @since 1.2.0
3124           *
3125           * @param string $retval The URL for the public message link.
3126           */
3127          return apply_filters( 'bp_get_send_public_message_link', $retval );
3128      }
3129  
3130  /**
3131   * Recurse through all activity comments and return the activity comment IDs.
3132   *
3133   * @since 2.0.0
3134   *
3135   * @param array $activity Array of activities generated from {@link bp_activity_get()}.
3136   * @param array $activity_ids Used for recursion purposes in this function.
3137   * @return array
3138   */
3139  function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
3140      if ( is_array( $activity ) && ! empty( $activity['activities'] ) ) {
3141          $activity = $activity['activities'][0];
3142      }
3143  
3144      if ( ! empty( $activity->children ) ) {
3145          foreach ($activity->children as $child ) {
3146              $activity_ids[] = $child->id;
3147  
3148              if( ! empty( $child->children ) ) {
3149                  $activity_ids = bp_activity_recurse_comments_activity_ids( $child, $activity_ids );
3150              }
3151          }
3152      }
3153  
3154      return $activity_ids;
3155  }
3156  
3157  /**
3158   * Output the mentioned user display name.
3159   *
3160   * @since 1.2.0
3161   *
3162   * @see bp_get_mentioned_user_display_name() for description of parameters.
3163   *
3164   * @param int|string|bool $user_id_or_username See {@link bp_get_mentioned_user_display_name()}.
3165   */
3166  function bp_mentioned_user_display_name( $user_id_or_username = false ) {
3167      echo bp_get_mentioned_user_display_name( $user_id_or_username );
3168  }
3169  
3170      /**
3171       * Returns the mentioned user display name.
3172       *
3173       * @since 1.2.0
3174       *
3175       *
3176       * @param int|string|bool $user_id_or_username User ID or username.
3177       * @return string The mentioned user's display name.
3178       */
3179  	function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
3180  
3181          // Get user display name.
3182          $name = bp_core_get_user_displayname( $user_id_or_username );
3183  
3184          // If user somehow has no name, return this really lame string.
3185          if ( empty( $name ) ) {
3186              $name = __( 'a user', 'buddypress' );
3187          }
3188  
3189          /**
3190           * Filters the mentioned user display name.
3191           *
3192           * @since 1.2.0
3193           *
3194           * @param string     $name                Display name for the mentioned user.
3195           * @param int|string $user_id_or_username User ID or username use for query.
3196           */
3197          return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
3198      }
3199  
3200  /**
3201   * Output button for sending a public message (an @-mention).
3202   *
3203   * @since 1.2.0
3204   *
3205   * @see bp_get_send_public_message_button() for description of parameters.
3206   *
3207   * @param array|string $args See {@link bp_get_send_public_message_button()}.
3208   */
3209  function bp_send_public_message_button( $args = '' ) {
3210      echo bp_get_send_public_message_button( $args );
3211  }
3212  
3213      /**
3214       * Return button for sending a public message (an @-mention).
3215       *
3216       * @since 1.2.0
3217       *
3218       *
3219       * @param array|string $args {
3220       *     All arguments are optional. See {@link BP_Button} for complete
3221       *     descriptions.
3222       *     @type string $id                Default: 'public_message'.
3223       *     @type string $component         Default: 'activity'.
3224       *     @type bool   $must_be_logged_in Default: true.
3225       *     @type bool   $block_self        Default: true.
3226       *     @type string $wrapper_id        Default: 'post-mention'.
3227       *     @type string $link_href         Default: the public message link for
3228       *                                     the current member in the loop.
3229       *     @type string $link_text         Default: 'Public Message'.
3230       *     @type string $link_class        Default: 'activity-button mention'.
3231       * }
3232       * @return string The button for sending a public message.
3233       */
3234  	function bp_get_send_public_message_button( $args = '' ) {
3235  
3236          $r = bp_parse_args( $args, array(
3237              'id'                => 'public_message',
3238              'component'         => 'activity',
3239              'must_be_logged_in' => true,
3240              'block_self'        => true,
3241              'wrapper_id'        => 'post-mention',
3242              'link_href'         => bp_get_send_public_message_link(),
3243              'link_text'         => __( 'Public Message', 'buddypress' ),
3244              'link_class'        => 'activity-button mention'
3245          ) );
3246  
3247          /**
3248           * Filters the public message button HTML.
3249           *
3250           * @since 1.2.10
3251           *
3252           * @param array $r Array of arguments for the public message button HTML.
3253           */
3254          return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $r ) );
3255      }
3256  
3257  /**
3258   * Output the activity post form action.
3259   *
3260   * @since 1.2.0
3261   *
3262   */
3263  function bp_activity_post_form_action() {
3264      echo bp_get_activity_post_form_action();
3265  }
3266  
3267      /**
3268       * Return the activity post form action.
3269       *
3270       * @since 1.2.0
3271       *
3272       *
3273       * @return string The activity post form action.
3274       */
3275  	function bp_get_activity_post_form_action() {
3276  
3277          /**
3278           * Filters the action url used for the activity post form.
3279           *
3280           * @since 1.2.0
3281           *
3282           * @param string $value URL to be used for the activity post form.
3283           */
3284          return apply_filters( 'bp_get_activity_post_form_action', home_url( bp_get_activity_root_slug() . '/post/' ) );
3285      }
3286  
3287  /**
3288   * Echo a list of linked avatars of users who have commented on the current activity item.
3289   *
3290   * Use this function to easily output activity comment authors' avatars.
3291   *
3292   * Avatars are wrapped in <li> elements, but you've got to provide your own
3293   * <ul> or <ol> wrapper markup.
3294   *
3295   * @since 1.7.0
3296   *
3297   * @see bp_core_fetch_avatar() for a description of arguments.
3298   *
3299   * @param array $args See {@link bp_core_fetch_avatar()}.
3300   */
3301  function bp_activity_comments_user_avatars( $args = array() ) {
3302  
3303      $r = bp_parse_args( $args, array(
3304          'height' => false,
3305          'html'   => true,
3306          'type'   => 'thumb',
3307          'width'  => false,
3308      ) );
3309  
3310      // Get the user IDs of everyone who has left a comment to the current activity item.
3311      $user_ids = bp_activity_get_comments_user_ids();
3312      $output   = array();
3313      $retval   = '';
3314  
3315      if ( ! empty( $user_ids ) ) {
3316          foreach ( (array) $user_ids as $user_id ) {
3317  
3318              // Skip an empty user ID.
3319              if ( empty( $user_id ) ) {
3320                  continue;
3321              }
3322  
3323              // Get profile link for this user.
3324              $profile_link = bp_core_get_user_domain( $user_id );
3325  
3326              // Get avatar for this user.
3327              $image_html   = bp_core_fetch_avatar( array(
3328                  'item_id' => $user_id,
3329                  'height'  => $r['height'],
3330                  'html'    => $r['html'],
3331                  'type'    => $r['type'],
3332                  'width'   => $r['width']
3333              ) );
3334  
3335              // If user has link & avatar, add them to the output array.
3336              if ( ! empty( $profile_link ) && ! empty( $image_html ) ) {
3337                  $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html );
3338              }
3339          }
3340  
3341          // If output array is not empty, wrap everything in some list items.
3342          if ( ! empty( $output ) ) {
3343              $retval = '<li>' . implode( '</li><li>', $output ) . '</li>';
3344          }
3345      }
3346  
3347      /**
3348       * Filters the list of linked avatars for users who have commented on the current activity item.
3349       *
3350       * @since 1.7.0
3351       *
3352       * @param string $retval HTML markup for the list of avatars.
3353       * @param array  $r      Array of arguments used for each avatar.
3354       * @param array  $output Array of each avatar found, before imploded into single string.
3355       */
3356      echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );
3357  }
3358  
3359  /**
3360   * Return the IDs of every user who's left a comment on the current activity item.
3361   *
3362   * @since 1.7.0
3363   *
3364   * @return bool|array An array of IDs, or false if none are found.
3365   */
3366  function bp_activity_get_comments_user_ids() {
3367      global $activities_template;
3368  
3369      $user_ids = ! empty( $activities_template->activity->children )
3370          ? (array) bp_activity_recurse_comments_user_ids( $activities_template->activity->children )
3371          : array();
3372  
3373      /**
3374       * Filters the list of user IDs for the current activity item.
3375       *
3376       * @since 1.7.0
3377       *
3378       * @param array $value Array of unique user IDs for the current activity item.
3379       */
3380      return apply_filters( 'bp_activity_get_comments_user_ids', array_unique( $user_ids ) );
3381  }
3382  
3383      /**
3384       * Recurse through all activity comments and collect the IDs of the users who wrote them.
3385       *
3386       * @since 1.7.0
3387       *
3388       * @param array $comments Array of {@link BP_Activity_Activity} items.
3389       * @return array Array of user IDs.
3390       */
3391  	function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
3392  
3393          // Default user ID's array.
3394          $user_ids = array();
3395  
3396          // Loop through comments and try to get user ID's.
3397          if ( ! empty( $comments ) ) {
3398              foreach ( $comments as $comment ) {
3399  
3400                  // If a user is a spammer, their activity items will have been
3401                  // automatically marked as spam. Skip these.
3402                  if ( ! empty( $comment->is_spam ) ) {
3403                      continue;
3404                  }
3405  
3406                  // Add user ID to array.
3407                  $user_ids[] = $comment->user_id;
3408  
3409                  // Check for commentception.
3410                  if ( ! empty( $comment->children ) ) {
3411                      $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
3412                  }
3413              }
3414          }
3415  
3416          /**
3417           * Filters the list of user IDs for the current activity comment item.
3418           *
3419           * @since 2.1.0
3420           *
3421           * @param array $user_ids Array of user IDs for the current activity comment item.
3422           * @param array $comments Array of comments being checked for user IDs.
3423           */
3424          return apply_filters( 'bp_activity_recurse_comments_user_ids', $user_ids, $comments );
3425      }
3426  
3427  /**
3428   * Output the mentionname for the displayed user.
3429   *
3430   * @since 1.9.0
3431   */
3432  function bp_displayed_user_mentionname() {
3433      echo bp_get_displayed_user_mentionname();
3434  }
3435      /**
3436       * Get the mentionname for the displayed user.
3437       *
3438       * @since 1.9.0
3439       *
3440       * @return string Mentionname for the displayed user, if available.
3441       */
3442  	function bp_get_displayed_user_mentionname() {
3443  
3444          /**
3445           * Filters the mentionname for the displayed user.
3446           *
3447           * @since 1.9.0
3448           *
3449           * @param string $value The mentionanme for the displayed user.
3450           */
3451          return apply_filters( 'bp_get_displayed_user_mentionname', bp_activity_get_user_mentionname( bp_displayed_user_id() ) );
3452      }
3453  
3454  /**
3455   * Echo a list of all registered activity types for use in dropdowns or checkbox lists.
3456   *
3457   * @since 1.7.0
3458   *
3459   * @param string       $output Optional. Either 'select' or 'checkbox'. Default: 'select'.
3460   * @param array|string $args {
3461   *     Optional extra arguments.
3462   *     @type string       $checkbox_name When returning checkboxes, sets the 'name'
3463   *                                       attribute.
3464   *     @type array|string $selected      A list of types that should be checked/
3465   *                                       selected.
3466   * }
3467   */
3468  function bp_activity_types_list( $output = 'select', $args = '' ) {
3469  
3470      $args = bp_parse_args( $args, array(
3471          'checkbox_name' => 'bp_activity_types',
3472          'selected'      => array(),
3473      ) );
3474  
3475      $activities = bp_activity_get_types();
3476      natsort( $activities );
3477  
3478      // Loop through the activity types and output markup.
3479      foreach ( $activities as $type => $description ) {
3480  
3481          // See if we need to preselect the current type.
3482          $checked  = checked(  true, in_array( $type, (array) $args['selected'] ), false );
3483          $selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
3484  
3485          // Switch output based on the element.
3486          switch ( $output ) {
3487              case 'select' :
3488                  printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $type ), $selected, esc_html( $description ) );
3489                  break;
3490              case 'checkbox' :
3491                  printf( '<label style="" for="%1$s[]">%2$s<input type="checkbox" id="%1$s[]" name="%1$s[]" value="%3$s" %4$s/></label>', esc_attr( $args['checkbox_name'] ), esc_html( $description ), esc_attr( $args['checkbox_name'] ), esc_attr( $args['checkbox_name'] ), esc_attr( $type ), $checked );
3492                  break;
3493          }
3494  
3495          /**
3496           * Fires at the end of the listing of activity types.
3497           *
3498           * This is a variable action hook. The actual hook to use will depend on the output type specified.
3499           * Two default hooks are bp_activity_types_list_select and bp_activity_types_list_checkbox.
3500           *
3501           * @since 1.7.0
3502           *
3503           * @param array  $args        Array of arguments passed into function.
3504           * @param string $type        Activity type being rendered in the output.
3505           * @param string $description Description of the activity type being rendered.
3506           */
3507          do_action( 'bp_activity_types_list_' . $output, $args, $type, $description );
3508      }
3509  
3510      // Backpat with BP-Default for dropdown boxes only.
3511      if ( 'select' === $output ) {
3512          do_action( 'bp_activity_filter_options' );
3513      }
3514  }
3515  
3516  
3517  /* RSS Feed Template Tags ****************************************************/
3518  
3519  /**
3520   * Output the sitewide activity feed link.
3521   *
3522   * @since 1.0.0
3523   *
3524   */
3525  function bp_sitewide_activity_feed_link() {
3526      echo bp_get_sitewide_activity_feed_link();
3527  }
3528  
3529      /**
3530       * Returns the sitewide activity feed link.
3531       *
3532       * @since 1.0.0
3533       *
3534       *
3535       * @return string The sitewide activity feed link.
3536       */
3537  	function bp_get_sitewide_activity_feed_link() {
3538  
3539          /**
3540           * Filters the sidewide activity feed link.
3541           *
3542           * @since 1.0.0
3543           *
3544           * @param string $value The feed link for sitewide activity.
3545           */
3546          return apply_filters( 'bp_get_sitewide_activity_feed_link', bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/feed/' );
3547      }
3548  
3549  /**
3550   * Output the member activity feed link.
3551   *
3552   * @since 1.2.0
3553   *
3554   */
3555  function bp_member_activity_feed_link() {
3556      echo bp_get_member_activity_feed_link();
3557  }
3558  
3559  /**
3560   * Output the member activity feed link.
3561   *
3562   * @since 1.0.0
3563   * @deprecated 1.2.0
3564   *
3565   * @todo properly deprecate in favor of bp_member_activity_feed_link().
3566   *
3567   */
3568  function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link(); }
3569  
3570      /**
3571       * Return the member activity feed link.
3572       *
3573       * @since 1.2.0
3574       *
3575       *
3576       * @return string $link The member activity feed link.
3577       */
3578  	function bp_get_member_activity_feed_link() {
3579  
3580          // Single member activity feed link.
3581          if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
3582              $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
3583  
3584          // Friend feed link.
3585          } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
3586              $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
3587  
3588          // Group feed link.
3589          } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) {
3590              $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
3591  
3592          // Favorites activity feed link.
3593          } elseif ( 'favorites' === bp_current_action() ) {
3594              $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
3595  
3596          // Mentions activity feed link.
3597          } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
3598              $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
3599  
3600          // No feed link.
3601          } else {
3602              $link = '';
3603          }
3604  
3605          /**
3606           * Filters the member activity feed link.
3607           *
3608           * @since 1.0.0
3609           *
3610           * @param string $link URL for the member activity feed.
3611           */
3612          return apply_filters( 'bp_get_activities_member_rss_link', $link );
3613      }
3614  
3615      /**
3616       * Return the member activity feed link.
3617       *
3618       * @since 1.0.0
3619       * @deprecated 1.2.0
3620       *
3621       * @todo properly deprecate in favor of bp_get_member_activity_feed_link().
3622       *
3623       *
3624       * @return string The member activity feed link.
3625       */
3626  	function bp_get_activities_member_rss_link() { return bp_get_member_activity_feed_link(); }
3627  
3628  
3629  /** Template tags for RSS feed output ****************************************/
3630  
3631  /**
3632   * Outputs the activity feed item guid.
3633   *
3634   * @since 1.0.0
3635   *
3636   */
3637  function bp_activity_feed_item_guid() {
3638      echo bp_get_activity_feed_item_guid();
3639  }
3640  
3641      /**
3642       * Returns the activity feed item guid.
3643       *
3644       * @since 1.2.0
3645       *
3646       * @global object $activities_template {@link BP_Activity_Template}
3647       *
3648       * @return string The activity feed item guid.
3649       */
3650  	function bp_get_activity_feed_item_guid() {
3651          global $activities_template;
3652  
3653          /**
3654           * Filters the activity feed item guid.
3655           *
3656           * @since 1.1.3
3657           *
3658           * @param string $value Calculated md5 value for the activity feed item.
3659           */
3660          return apply_filters( 'bp_get_activity_feed_item_guid', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );
3661      }
3662  
3663  /**
3664   * Output the activity feed item title.
3665   *
3666   * @since 1.0.0
3667   *
3668   */
3669  function bp_activity_feed_item_title() {
3670      echo bp_get_activity_feed_item_title();
3671  }
3672  
3673      /**
3674       * Return the activity feed item title.
3675       *
3676       * @since 1.0.0
3677       *
3678       * @global object $activities_template {@link BP_Activity_Template}
3679       *
3680       * @return string $title The activity feed item title.
3681       */
3682  	function bp_get_activity_feed_item_title() {
3683          global $activities_template;
3684  
3685          if ( !empty( $activities_template->activity->action ) ) {
3686              $content = $activities_template->activity->action;
3687          } else {
3688              $content = $activities_template->activity->content;
3689          }
3690  
3691          $content = explode( '<span', $content );
3692          $title   = strip_tags( ent2ncr( trim( convert_chars( $content[0] ) ) ) );
3693  
3694          if ( ':' === substr( $title, -1 ) ) {
3695              $title = substr( $title, 0, -1 );
3696          }
3697  
3698          if ( 'activity_update' === $activities_template->activity->type ) {
3699              $title .= ': ' . strip_tags( ent2ncr( trim( convert_chars( bp_create_excerpt( $activities_template->activity->content, 70, array( 'ending' => " [&#133;]" ) ) ) ) ) );
3700          }
3701  
3702          /**
3703           * Filters the activity feed item title.
3704           *
3705           * @since 1.0.0
3706           *
3707           * @param string $title The title for the activity feed item.
3708           */
3709          return apply_filters( 'bp_get_activity_feed_item_title', $title );
3710      }
3711  
3712  /**
3713   * Output the activity feed item link.
3714   *
3715   * @since 1.0.0
3716   *
3717   */
3718  function bp_activity_feed_item_link() {
3719      echo bp_get_activity_feed_item_link();
3720  }
3721  
3722      /**
3723       * Return the activity feed item link.
3724       *
3725       * @since 1.0.0
3726       *
3727       * @global object $activities_template {@link BP_Activity_Template}
3728       *
3729       * @return string The activity feed item link.
3730       */
3731  	function bp_get_activity_feed_item_link() {
3732          global $activities_template;
3733  
3734          $retval = ! empty( $activities_template->activity->primary_link )
3735              ? $activities_template->activity->primary_link
3736              : '';
3737  
3738          /**
3739           * Filters the activity feed item link.
3740           *
3741           * @since 1.0.0
3742           *
3743           * @param string $retval The URL for the activity feed item.
3744           */
3745          return apply_filters( 'bp_get_activity_feed_item_link', $retval );
3746      }
3747  
3748  /**
3749   * Output the activity feed item date.
3750   *
3751   * @since 1.0.0
3752   *
3753   */
3754  function bp_activity_feed_item_date() {
3755      echo bp_get_activity_feed_item_date();
3756  }
3757  
3758      /**
3759       * Return the activity feed item date.
3760       *
3761       * @since 1.0.0
3762       *
3763       * @global object $activities_template {@link BP_Activity_Template}
3764       *
3765       * @return string The activity feed item date.
3766       */
3767  	function bp_get_activity_feed_item_date() {
3768          global $activities_template;
3769  
3770          $retval = ! empty( $activities_template->activity->date_recorded )
3771              ? $activities_template->activity->date_recorded
3772              : '';
3773  
3774          /**
3775           * Filters the activity feed item date.
3776           *
3777           * @since 1.0.0
3778           *
3779           * @param string $retval The date for the activity feed item.
3780           */
3781          return apply_filters( 'bp_get_activity_feed_item_date', $retval );
3782      }
3783  
3784  /**
3785   * Output the activity feed item description.
3786   *
3787   * @since 1.0.0
3788   *
3789   */
3790  function bp_activity_feed_item_description() {
3791      echo bp_get_activity_feed_item_description();
3792  }
3793  
3794      /**
3795       * Return the activity feed item description.
3796       *
3797       * @since 1.0.0
3798       *
3799       * @global object $activities_template {@link BP_Activity_Template}
3800       *
3801       * @return string The activity feed item description.
3802       */
3803  	function bp_get_activity_feed_item_description() {
3804          global $activities_template;
3805  
3806          // Get the content, if exists.
3807          $content = ! empty( $activities_template->activity->content )
3808              ? $activities_template->activity->content
3809              : '';
3810  
3811          // Perform a few string conversions on the content, if it's not empty.
3812          if ( ! empty( $content ) ) {
3813              $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
3814          }
3815  
3816          /**
3817           * Filters the activity feed item description.
3818           *
3819           * @since 1.0.0
3820           *
3821           * @param string $content The description for the activity feed item.
3822           */
3823          return apply_filters( 'bp_get_activity_feed_item_description', $content );
3824      }
3825  
3826  /**
3827   * Template tag so we can hook activity feed to <head>.
3828   *
3829   * @since 1.5.0
3830   *
3831   */
3832  function bp_activity_sitewide_feed() {
3833  ?>
3834  
3835      <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
3836  
3837  <?php
3838  }
3839  add_action( 'bp_head', 'bp_activity_sitewide_feed' );
3840  
3841  /**
3842   * Display available filters depending on the scope.
3843   *
3844   * @since 2.1.0
3845   *
3846   * @param string $context The current context. 'activity', 'member',
3847   *                        'member_groups', 'group'.
3848   */
3849  function bp_activity_show_filters( $context = '' ) {
3850      echo bp_get_activity_show_filters( $context );
3851  }
3852      /**
3853       * Get available filters depending on the scope.
3854       *
3855       * @since 2.1.0
3856       *
3857       * @param string $context The current context. 'activity', 'member',
3858       *                        'member_groups', 'group'.
3859       *
3860       * @return string HTML for <option> values.
3861       */
3862  	function bp_get_activity_show_filters( $context = '' ) {
3863          $filters = array();
3864          $actions = bp_activity_get_actions_for_context( $context );
3865          foreach ( $actions as $action ) {
3866              // Friends activity collapses two filters into one.
3867              if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
3868                  $action['key'] = 'friendship_accepted,friendship_created';
3869              }
3870  
3871              // The 'activity_update' filter is already used by the Activity component.
3872              if ( 'bp_groups_format_activity_action_group_activity_update' === $action['format_callback'] ) {
3873                  continue;
3874              }
3875  
3876              $filters[ $action['key'] ] = $action['label'];
3877          }
3878  
3879          /**
3880           * Filters the options available in the activity filter dropdown.
3881           *
3882           * @since 2.2.0
3883           *
3884           * @param array  $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
3885           * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
3886           */
3887          $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
3888  
3889          // Build the options output.
3890          $output = '';
3891  
3892          if ( ! empty( $filters ) ) {
3893              foreach ( $filters as $value => $filter ) {
3894                  $output .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $filter ) . '</option>' . "\n";
3895              }
3896          }
3897  
3898          /**
3899           * Filters the HTML markup result for the activity filter dropdown.
3900           *
3901           * @since 2.1.0
3902           *
3903           * @param string $output  HTML output for the activity filter dropdown.
3904           * @param array  $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
3905           * @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
3906           */
3907          return apply_filters( 'bp_get_activity_show_filters', $output, $filters, $context );
3908      }


Generated: Sun Apr 5 01:01:30 2020 Cross-referenced by PHPXref 0.7.1