Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/05/2016 03:54:56 AM (10 years ago)
Author:
boonebgorges
Message:

Move bp-activity classes to their own files.

See #6870.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-template.php

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