Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/12/2015 05:45:14 AM (11 years ago)
Author:
tw2113
Message:

Further documentation cleanup for Activity Component.

See #6396.

File:
1 edited

Legend:

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

    r10248 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    114114 */
    115115class BP_Activity_Template {
     116
    116117        /**
    117118         * The loop iterator.
     
    232233                $bp = buddypress();
    233234
    234                 // Backward compatibility with old method of passing arguments
     235                // Backward compatibility with old method of passing arguments.
    235236                if ( !is_array( $args ) || func_num_args() > 1 ) {
    236237                        _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     
    285286                $this->pag_num  = bp_sanitize_pagination_arg( 'num',          $r['per_page'] );
    286287
    287                 // Check if blog/forum replies are disabled
     288                // Check if blog/forum replies are disabled.
    288289                $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
    289290
    290                 // Get an array of the logged in user's favorite activities
     291                // Get an array of the logged in user's favorite activities.
    291292                $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
    292293
    293                 // Fetch specific activity items based on ID's
     294                // Fetch specific activity items based on ID's.
    294295                if ( !empty( $include ) ) {
    295296                        $this->activities = bp_activity_get_specific( array(
     
    306307                        ) );
    307308
    308                 // Fetch all activity items
     309                // Fetch all activity items.
    309310                } else {
    310311                        $this->activities = bp_activity_get( array(
     
    330331
    331332                // The total_activity_count property will be set only if a
    332                 // 'count_total' query has taken place
     333                // 'count_total' query has taken place.
    333334                if ( ! is_null( $this->activities['total'] ) ) {
    334335                        if ( ! $max || $max >= (int) $this->activities['total'] ) {
     
    355356                $this->full_name = bp_get_displayed_user_fullname();
    356357
    357                 // Fetch parent content for activity comments so we do not have to query in the loop
     358                // Fetch parent content for activity comments so we do not have to query in the loop.
    358359                foreach ( (array) $this->activities as $activity ) {
    359360                        if ( 'activity_comment' != $activity->type ) {
     
    451452                        do_action( 'activity_loop_end' );
    452453
    453                         // Do some cleaning up after the loop
     454                        // Do some cleaning up after the loop.
    454455                        $this->rewind_activities();
    455456                }
     
    478479                }
    479480
    480                 // loop has just started
     481                // Loop has just started.
    481482                if ( $this->current_activity == 0 ) {
    482483
     
    605606        global $activities_template;
    606607
    607         // Get BuddyPress
     608        // Get BuddyPress.
    608609        $bp = buddypress();
    609610
    610         /** Smart Defaults ********************************************************/
    611 
    612         // User filtering
     611        /*
     612         * Smart Defaults.
     613         */
     614
     615        // User filtering.
    613616        $user_id = bp_displayed_user_id()
    614617                ? bp_displayed_user_id()
    615618                : false;
    616619
    617         // Group filtering
     620        // Group filtering.
    618621        if ( bp_is_group() ) {
    619622                $object      = $bp->groups->id;
     
    626629        }
    627630
    628         // The default scope should recognize custom slugs
     631        // The default scope should recognize custom slugs.
    629632        $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
    630633                ? $bp->loaded_components[ bp_current_action() ]
    631634                : bp_current_action();
    632635
    633         // Support for permalinks on single item pages: /groups/my-group/activity/124/
     636        // Support for permalinks on single item pages: /groups/my-group/activity/124/.
    634637        $include = bp_is_current_action( bp_get_activity_slug() )
    635638                ? bp_action_variable( 0 )
     
    642645        }
    643646
    644         /** Parse Args ************************************************************/
     647        /*
     648         * Parse Args.
     649         */
    645650
    646651        // Note: any params used for filtering can be a single value, or multiple
    647652        // values comma separated.
    648653        $r = bp_parse_args( $args, array(
    649                 'display_comments'  => 'threaded',   // false for none, stream/threaded - show comments in the stream or threaded under items
    650                 'include'           => $include,     // pass an activity_id or string of IDs comma-separated
    651                 'exclude'           => false,        // pass an activity_id or string of IDs comma-separated
    652                 'in'                => false,        // comma-separated list or array of activity IDs among which to search
    653                 'sort'              => 'DESC',       // sort DESC or ASC
    654                 'page'              => 1,            // which page to load
    655                 'per_page'          => 20,           // number of items per page
    656                 'page_arg'          => 'acpage',     // See https://buddypress.trac.wordpress.org/ticket/3679
    657                 'max'               => false,        // max number to return
     654                'display_comments'  => 'threaded',   // False for none, stream/threaded - show comments in the stream or threaded under items.
     655                'include'           => $include,     // Pass an activity_id or string of IDs comma-separated.
     656                'exclude'           => false,        // Pass an activity_id or string of IDs comma-separated.
     657                'in'                => false,        // Comma-separated list or array of activity IDs among which to search.
     658                'sort'              => 'DESC',       // Sort DESC or ASC.
     659                'page'              => 1,            // Which page to load.
     660                'per_page'          => 20,           // Number of items per page.
     661                'page_arg'          => 'acpage',     // See https://buddypress.trac.wordpress.org/ticket/3679.
     662                'max'               => false,        // Max number to return.
    658663                'fields'            => 'all',
    659664                'count_total'       => false,
    660665                'show_hidden'       => $show_hidden, // Show activity items that are hidden site-wide?
    661                 'spam'              => 'ham_only',   // Hide spammed items
    662 
    663                 // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
     666                'spam'              => 'ham_only',   // Hide spammed items.
     667
     668                // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions).
    664669                'scope'             => $scope,
    665670
    666671                // Filtering
    667                 'user_id'           => $user_id,     // user_id to filter on
    668                 'object'            => $object,      // object to filter on e.g. groups, profile, status, friends
    669                 'action'            => false,        // action to filter on e.g. activity_update, new_forum_post, profile_updated
    670                 'primary_id'        => $primary_id,  // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    671                 'secondary_id'      => false,        // secondary object ID to filter on e.g. a post_id
    672                 'offset'            => false,        // return only items >= this ID
    673                 'since'             => false,        // return only items recorded since this Y-m-d H:i:s date
    674 
    675                 'meta_query'        => false,        // filter on activity meta. See WP_Meta_Query for format
    676                 'date_query'        => false,        // filter by date. See first parameter of WP_Date_Query for format
    677                 'filter_query'      => false,        // advanced filtering.  See BP_Activity_Query for format
    678 
    679                 // Searching
     672                'user_id'           => $user_id,     // user_id to filter on.
     673                'object'            => $object,      // Object to filter on e.g. groups, profile, status, friends.
     674                'action'            => false,        // Action to filter on e.g. activity_update, new_forum_post, profile_updated.
     675                'primary_id'        => $primary_id,  // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
     676                'secondary_id'      => false,        // Secondary object ID to filter on e.g. a post_id.
     677                'offset'            => false,        // Return only items >= this ID.
     678                'since'             => false,        // Return only items recorded since this Y-m-d H:i:s date.
     679
     680                'meta_query'        => false,        // Filter on activity meta. See WP_Meta_Query for format.
     681                'date_query'        => false,        // Filter by date. See first parameter of WP_Date_Query for format.
     682                'filter_query'      => false,        // Advanced filtering.  See BP_Activity_Query for format.
     683
     684                // Searching.
    680685                'search_terms'      => $search_terms_default,
    681686                'update_meta_cache' => true,
    682687        ), 'has_activities' );
    683688
    684         /** Smart Overrides *******************************************************/
     689        /*
     690         * Smart Overrides.
     691         */
    685692
    686693        // Translate various values for 'display_comments'
    687694        // This allows disabling comments via ?display_comments=0
    688         // or =none or =false. Final true is a strict type check. See #5029
     695        // or =none or =false. Final true is a strict type check. See #5029.
    689696        if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
    690697                $r['display_comments'] = false;
    691698        }
    692699
    693         // Ignore pagination if an offset is passed
     700        // Ignore pagination if an offset is passed.
    694701        if ( ! empty( $r['offset'] ) ) {
    695702                $r['page'] = 0;
    696703        }
    697704
    698         // Search terms
     705        // Search terms.
    699706        if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
    700707                $r['search_terms'] = $_REQUEST['s'];
    701708        }
    702709
    703         // Do not exceed the maximum per page
     710        // Do not exceed the maximum per page.
    704711        if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
    705712                $r['per_page'] = $r['max'];
     
    741748        }
    742749
    743         /** Query *****************************************************************/
     750        /*
     751         * Query
     752         */
    744753
    745754        $activities_template = new BP_Activity_Template( $r );
     
    799808         *
    800809         * @since 2.1.0
     810         *
     811         * @return string $link
    801812         */
    802813        function bp_get_activity_load_more_link() {
     
    13171328         *
    13181329         * @todo Properly deprecate in favor of bp_activity_type() and
    1319          *              remove redundant echo
     1330         *      remove redundant echo
    13201331         *
    13211332         * @uses bp_activity_type()
     
    14611472                $bp = buddypress();
    14621473
    1463                 // On activity permalink pages, default to the full-size avatar
     1474                // On activity permalink pages, default to the full-size avatar.
    14641475                $type_default = bp_is_single_activity() ? 'full' : 'thumb';
    14651476
     
    14681479                $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
    14691480
    1470                 // Activity user display name
     1481                // Activity user display name.
    14711482                $dn_default  = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
    14721483
    1473                 // Prepend some descriptive text to alt
     1484                // Prepend some descriptive text to alt.
    14741485                $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' );
    14751486
     
    14871498                if ( !isset( $height ) && !isset( $width ) ) {
    14881499
    1489                         // Backpat
     1500                        // Backpat.
    14901501                        if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) {
    14911502                                $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height;
     
    14941505                        }
    14951506
    1496                         // Backpat
     1507                        // Backpat.
    14971508                        if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) {
    14981509                                $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width;
     
    15871598         *     @type int|bool    $user_id Default: ID of the activity's user.
    15881599         * }
    1589          * @return string The secondary avatar
     1600         * @return string The secondary avatar.
    15901601         */
    15911602        function bp_get_activity_secondary_avatar( $args = '' ) {
     
    16041615                extract( $r, EXTR_SKIP );
    16051616
    1606                 // Set item_id and object (default to user)
     1617                // Set item_id and object (default to user).
    16071618                switch ( $activities_template->activity->component ) {
    16081619                        case 'groups' :
     
    16161627                                $name    = '';
    16171628
    1618                                 // Only if groups is active
     1629                                // Only if groups is active.
    16191630                                if ( bp_is_active( 'groups' ) ) {
    16201631                                        $group = groups_get_group( array(
     
    16911702                $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
    16921703
    1693                 // If we have no item_id or object, there is no avatar to display
     1704                // If we have no item_id or object, there is no avatar to display.
    16941705                if ( empty( $item_id ) || empty( $object ) ) {
    16951706                        return false;
    16961707                }
    16971708
    1698                 // Get the avatar
     1709                // Get the avatar.
    16991710                $avatar = bp_core_fetch_avatar( array(
    17001711                        'item_id' => $item_id,
     
    17451756 * @since 1.2.0
    17461757 *
    1747  * @param array $args See bp_get_activity_action()
     1758 * @param array $args See bp_get_activity_action().
    17481759 * @uses bp_get_activity_action()
    17491760 */
     
    17581769         *
    17591770         * @global object $activities_template {@link BP_Activity_Template}
    1760          * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
    17611771         * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook.
    17621772         * @uses bp_insert_activity_meta()
     
    17891799                ) );
    17901800
    1791                 // Prepend the activity action meta (link, time since, etc...)
     1801                // Prepend the activity action meta (link, time since, etc...).
    17921802                if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
    17931803                        $action = bp_insert_activity_meta( $action );
     
    18331843                global $activities_template;
    18341844
    1835                 // Backwards compatibility if action is not being used
     1845                // Backwards compatibility if action is not being used.
    18361846                if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
    18371847                        $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
     
    19251935 *
    19261936 * @param string $content The activity content.
    1927  *
    19281937 * @return string The activity content with the metadata string attached.
    19291938 */
     
    19311940        global $activities_template;
    19321941
    1933         // Strip any legacy time since placeholders from BP 1.0-1.1
     1942        // Strip any legacy time since placeholders from BP 1.0-1.1.
    19341943        $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
    19351944
    1936         // Get the time since this activity was recorded
     1945        // Get the time since this activity was recorded.
    19371946        $date_recorded  = bp_core_time_since( $activities_template->activity->date_recorded );
    19381947
     
    19491958        ) );
    19501959
    1951         // Insert the permalink
     1960        // Insert the permalink.
    19521961        if ( ! bp_is_single_activity() ) {
    19531962
    1954                 // Setup variables for activity meta
     1963                // Setup variables for activity meta.
    19551964                $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
    19561965                $activity_meta      = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
     
    19661975                 * @since 1.2.0
    19671976                 *
    1968                  * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
     1977                 * @param array $value Array containing the html markup for the activity permalink, after being parsed by
     1978                 *                     sprintf and current activity component.
    19691979                 */
    19701980                $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
     
    19952005 *
    19962006 * @param object|bool $activity Optional. Falls back on the current item in the loop.
    1997  *
    19982007 * @return bool True if can delete, false otherwise.
    19992008 */
     
    20012010        global $activities_template;
    20022011
    2003         // Try to use current activity if none was passed
     2012        // Try to use current activity if none was passed.
    20042013        if ( empty( $activity ) && ! empty( $activities_template->activity ) ) {
    20052014                $activity = $activities_template->activity;
    20062015        }
    20072016
    2008         // If current_comment is set, we'll use that in place of the main activity
     2017        // If current_comment is set, we'll use that in place of the main activity.
    20092018        if ( isset( $activity->current_comment ) ) {
    20102019                $activity = $activity->current_comment;
    20112020        }
    20122021
    2013         // Assume the user cannot delete the activity item
     2022        // Assume the user cannot delete the activity item.
    20142023        $can_delete = false;
    20152024
    2016         // Only logged in users can delete activity
     2025        // Only logged in users can delete activity.
    20172026        if ( is_user_logged_in() ) {
    20182027
    2019                 // Community moderators can always delete activity (at least for now)
     2028                // Community moderators can always delete activity (at least for now).
    20202029                if ( bp_current_user_can( 'bp_moderate' ) ) {
    20212030                        $can_delete = true;
     
    20292038                }
    20302039
    2031                 // Viewing a single item, and this user is an admin of that item
     2040                // Viewing a single item, and this user is an admin of that item.
    20322041                if ( bp_is_single_item() && bp_is_item_admin() ) {
    20332042                        $can_delete = true;
     
    20692078         *
    20702079         * @param string $args Unused. Left over from an earlier implementation.
    2071          *
    20722080         * @return mixed False on failure, otherwise the activity parent content.
    20732081         */
     
    20752083                global $activities_template;
    20762084
    2077                 // Bail if no activity on no item ID
     2085                // Bail if no activity on no item ID.
    20782086                if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
    20792087                        return false;
    20802088                }
    20812089
    2082                 // Get the ID of the parent activity content
     2090                // Get the ID of the parent activity content.
    20832091                $parent_id = (int) $activities_template->activity->item_id;
    20842092
    2085                 // Bail if no parent content
     2093                // Bail if no parent content.
    20862094                if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
    20872095                        return false;
    20882096                }
    20892097
    2090                 // Bail if no action
     2098                // Bail if no action.
    20912099                if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
    20922100                        return false;
    20932101                }
    20942102
    2095                 // Content always includes action
     2103                // Content always includes action.
    20962104                $content = $activities_template->activity_parents[ $parent_id ]->action;
    20972105
    2098                 // Maybe append activity content, if it exists
     2106                // Maybe append activity content, if it exists.
    20992107                if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
    21002108                        $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
    21012109                }
    21022110
    2103                 // Remove the time since content for backwards compatibility
     2111                // Remove the time since content for backwards compatibility.
    21042112                $content = str_replace( '<span class="time-since">%s</span>', '', $content );
    21052113
    2106                 // Remove images
     2114                // Remove images.
    21072115                $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
    21082116
     
    21392147                global $activities_template;
    21402148
    2141                 // Bail if no activity on no item ID
     2149                // Bail if no activity on no item ID.
    21422150                if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
    21432151                        return false;
    21442152                }
    21452153
    2146                 // Get the ID of the parent activity content
     2154                // Get the ID of the parent activity content.
    21472155                $parent_id = (int) $activities_template->activity->item_id;
    21482156
    2149                 // Bail if no parent item
     2157                // Bail if no parent item.
    21502158                if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
    21512159                        return false;
    21522160                }
    21532161
    2154                 // Bail if no parent user ID
     2162                // Bail if no parent user ID.
    21552163                if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
    21562164                        return false;
     
    22222230         *
    22232231         * @todo deprecate $args param
    2224          *
    22252232         * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
    2226          *    this function can probably be streamlined or removed.
    2227          *
    2228          * @param string $args Unused. Left over from an earlier implementation.
     2233         *       this function can probably be streamlined or removed.
    22292234         *
    22302235         * @global object $activities_template {@link BP_Activity_Template}
    22312236         * @uses bp_activity_recurse_comments()
    22322237         *
     2238         * @param string $args Unused. Left over from an earlier implementation.
    22332239         * @return bool
    22342240         */
     
    22512257                 * @since 1.2.0
    22522258                 *
    2253                  * @param object $comment The activity object currently being recursed.
    2254                  *
    22552259                 * @global object $activities_template {@link BP_Activity_Template}
    22562260                 * @uses locate_template()
    22572261                 *
     2262                 * @param object $comment The activity object currently being recursed.
    22582263                 * @return bool|string
    22592264                 */
     
    22792284                        foreach ( (array) $comment->children as $comment_child ) {
    22802285
    2281                                 // Put the comment into the global so it's available to filters
     2286                                // Put the comment into the global so it's available to filters.
    22822287                                $activities_template->activity->current_comment = $comment_child;
    22832288
     
    24752480                if ( isset( $activities_template->activity->current_comment->user_fullname ) ) {
    24762481
    2477                         $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment );  // backward compatibility
     2482                        $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment );  // Backward compatibility.
    24782483                } else {
    24792484                        $name = $activities_template->activity->current_comment->display_name;
     
    26612666         * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
    26622667         *
    2663          * @param array $deprecated Deprecated.
    2664          *
     2668         * @param array|null $deprecated Deprecated.
    26652669         * @return int $count The activity comment count.
    26662670         */
     
    26682672                global $activities_template;
    26692673
    2670                 // Deprecated notice about $args
     2674                // Deprecated notice about $args.
    26712675                if ( ! empty( $deprecated ) ) {
    26722676                        _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__ ) );
    26732677                }
    26742678
    2675                 // Get the count using the purpose-built recursive function
     2679                // Get the count using the purpose-built recursive function.
    26762680                $count = ! empty( $activities_template->activity->children )
    26772681                        ? bp_activity_recurse_comment_count( $activities_template->activity )
     
    27012705                 * @param object $comment Activity comment object.
    27022706                 * @param int    $count The current iteration count.
    2703                  *
    27042707                 * @return int $count The activity comment count.
    27052708                 */
    27062709                function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
    27072710
    2708                         // Copy the count
     2711                        // Copy the count.
    27092712                        $new_count = $count;
    27102713
    2711                         // Loop through children and recursively count comments
     2714                        // Loop through children and recursively count comments.
    27122715                        if ( ! empty( $comment->children ) ) {
    27132716                                foreach ( (array) $comment->children as $comment ) {
     
    29472950                global $activities_template;
    29482951
    2949                 // Check that comment exists
     2952                // Check that comment exists.
    29502953                $comment_id = isset( $activities_template->activity->current_comment->id )
    29512954                        ? $activities_template->activity->current_comment->id
    29522955                        : 0;
    29532956
    2954                 // Setup the comment link
     2957                // Setup the comment link.
    29552958                $comment_link = ! empty( $comment_id )
    29562959                        ? '#acomment-' .$comment_id
    29572960                        : false;
    29582961
    2959                 // Append comment ID to end of activity permalink
     2962                // Append comment ID to end of activity permalink.
    29602963                $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
    29612964
     
    31413144                $class = 'delete-activity';
    31423145
    3143                 // Determine if we're on a single activity page, and customize accordingly
     3146                // Determine if we're on a single activity page, and customize accordingly.
    31443147                if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
    31453148                        $class = 'delete-activity-single';
     
    31913194                $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
    31923195
    3193                 // Determine if we're on a single activity page, and customize accordingly
     3196                // Determine if we're on a single activity page, and customize accordingly.
    31943197                if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
    31953198                        $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
     
    32373240         *
    32383241         * @param int $user_id If empty, will fall back on displayed user.
    3239          *
    32403242         * @return string|bool $latest_update The activity latest update link.
    32413243         *                                    False on failure.
     
    33213323                ) );
    33223324
    3323                 // Define local variable
     3325                // Define local variable.
    33243326                $component_links = array();
    33253327
    3326                 // Fetch the names of components that have activity recorded in the DB
     3328                // Fetch the names of components that have activity recorded in the DB.
    33273329                $components = BP_Activity_Activity::get_recorded_components();
    33283330
     
    33333335                foreach ( (array) $components as $component ) {
    33343336
    3335                         // Skip the activity comment filter
     3337                        // Skip the activity comment filter.
    33363338                        if ( 'activity' == $component ) {
    33373339                                continue;
     
    34113413        $bp = buddypress();
    34123414
    3413         // Assume activity can be commented on
     3415        // Assume activity can be commented on.
    34143416        $can_comment = true;
    34153417
    3416         // Determine ability to comment based on activity action name
     3418        // Determine ability to comment based on activity action name.
    34173419        $activity_action = bp_get_activity_action_name();
    34183420
     
    34663468function bp_activity_can_comment_reply( $comment = false ) {
    34673469
    3468         // Assume activity can be commented on
     3470        // Assume activity can be commented on.
    34693471        $can_comment = true;
    34703472
    3471         // Check that comment exists
     3473        // Check that comment exists.
    34723474        if ( empty( $comment ) ) {
    34733475                $comment = bp_activity_current_comment();
     
    34763478        if ( ! empty( $comment ) ) {
    34773479
    3478                 // Fall back on current comment in activity loop
     3480                // Fall back on current comment in activity loop.
    34793481                $comment_depth = isset( $comment->depth )
    34803482                        ? intval( $comment->depth )
    34813483                        : bp_activity_get_comment_depth();
    34823484
    3483                 // Threading is turned on, so check the depth
     3485                // Threading is turned on, so check the depth.
    34843486                if ( get_option( 'thread_comments' ) ) {
    34853487                        $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
    34863488
    3487                 // No threading for comment replies if no threading for comments
     3489                // No threading for comment replies if no threading for comments.
    34883490                } else {
    34893491                        $can_comment = false;
     
    35483550         *
    35493551         * @param int $user_id ID of user being queried. Default: displayed user ID.
    3550          *
    35513552         * @return int The total favorite count for the specified user.
    35523553         */
     
    35553556
    35563557                if ( bp_activity_can_favorite() ) {
    3557                         // Default to displayed user if none is passed
     3558                        // Default to displayed user if none is passed.
    35583559                        $user_id = empty( $user_id )
    35593560                                ? bp_displayed_user_id()
    35603561                                : $user_id;
    35613562
    3562                         // Get user meta if user ID exists
     3563                        // Get user meta if user ID exists.
    35633564                        if ( ! empty( $user_id ) ) {
    35643565                                $retval = bp_activity_total_favorites_for_user( $user_id );
     
    36003601         *
    36013602         * @param int $user_id ID of user being queried. Default: displayed user ID.
    3602          *
    36033603         * @return int The total mention count for the specified user.
    36043604         */
    36053605        function bp_get_total_mention_count_for_user( $user_id = 0 ) {
    36063606
    3607                 // Default to displayed user if none is passed
     3607                // Default to displayed user if none is passed.
    36083608                $user_id = empty( $user_id )
    36093609                        ? bp_displayed_user_id()
    36103610                        : $user_id;
    36113611
    3612                 // Get user meta if user ID exists
     3612                // Get user meta if user ID exists.
    36133613                $retval = ! empty( $user_id )
    36143614                        ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
     
    36523652        function bp_get_send_public_message_link() {
    36533653
    3654                 // No link if not logged in, not looking at someone else's profile
     3654                // No link if not logged in, not looking at someone else's profile.
    36553655                if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
    36563656                        $retval = '';
     
    36783678 * @param array $activity Array of activities generated from {@link bp_activity_get()}.
    36793679 * @param array $activity_ids Used for recursion purposes in this function.
    3680  *
    36813680 * @return array
    36823681 */
     
    37213720         * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
    37223721         *
    3723          * @param int|string|bool User ID or username.
    3724          *
     3722         * @param int|string|bool $user_id_or_username User ID or username.
    37253723         * @return string The mentioned user's display name.
    37263724         */
    37273725        function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
    37283726
    3729                 // Get user display name
     3727                // Get user display name.
    37303728                $name = bp_core_get_user_displayname( $user_id_or_username );
    37313729
    3732                 // If user somehow has no name, return this really lame string
     3730                // If user somehow has no name, return this really lame string.
    37333731                if ( empty( $name ) ) {
    37343732                        $name = __( 'a user', 'buddypress' );
     
    38683866        ) );
    38693867
    3870         // Get the user IDs of everyone who has left a comment to the current activity item
     3868        // Get the user IDs of everyone who has left a comment to the current activity item.
    38713869        $user_ids = bp_activity_get_comments_user_ids();
    38723870        $output   = array();
     
    38763874                foreach ( (array) $user_ids as $user_id ) {
    38773875
    3878                         // Skip an empty user ID
     3876                        // Skip an empty user ID.
    38793877                        if ( empty( $user_id ) ) {
    38803878                                continue;
    38813879                        }
    38823880
    3883                         // Get profile link for this user
     3881                        // Get profile link for this user.
    38843882                        $profile_link = bp_core_get_user_domain( $user_id );
    38853883
    3886                         // Get avatar for this user
     3884                        // Get avatar for this user.
    38873885                        $image_html   = bp_core_fetch_avatar( array(
    38883886                                'item_id' => $user_id,
     
    38933891                        ) );
    38943892
    3895                         // If user has link & avatar, add them to the output array
     3893                        // If user has link & avatar, add them to the output array.
    38963894                        if ( ! empty( $profile_link ) && ! empty( $image_html ) ) {
    38973895                                $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html );
     
    38993897                }
    39003898
    3901                 // If output array is not empty, wrap everything in some list items
     3899                // If output array is not empty, wrap everything in some list items.
    39023900                if ( ! empty( $output ) ) {
    39033901                        $retval = '<li>' . implode( '</li><li>', $output ) . '</li>';
     
    39473945         *
    39483946         * @param array $comments Array of {@link BP_Activity_Activity} items.
    3949          *
    39503947         * @return array Array of user IDs.
    39513948         */
    39523949        function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
    39533950
    3954                 // Default user ID's array
     3951                // Default user ID's array.
    39553952                $user_ids = array();
    39563953
    3957                 // Loop through comments and try to get user ID's
     3954                // Loop through comments and try to get user ID's.
    39583955                if ( ! empty( $comments ) ) {
    39593956                        foreach ( $comments as $comment ) {
     
    39653962                                }
    39663963
    3967                                 // Add user ID to array
     3964                                // Add user ID to array.
    39683965                                $user_ids[] = $comment->user_id;
    39693966
    3970                                 // Check for commentception
     3967                                // Check for commentception.
    39713968                                if ( ! empty( $comment->children ) ) {
    39723969                                        $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
     
    40374034        natsort( $activities );
    40384035
    4039         // Loop through the activity types and output markup
     4036        // Loop through the activity types and output markup.
    40404037        foreach ( $activities as $type => $description ) {
    40414038
    4042                 // See if we need to preselect the current type
     4039                // See if we need to preselect the current type.
    40434040                $checked  = checked(  true, in_array( $type, (array) $args['selected'] ), false );
    40444041                $selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
    40454042
    4046                 // Switch output based on the element
     4043                // Switch output based on the element.
    40474044                switch ( $output ) {
    40484045                        case 'select' :
     
    40694066        }
    40704067
    4071         // Backpat with BP-Default for dropdown boxes only
     4068        // Backpat with BP-Default for dropdown boxes only.
    40724069        if ( 'select' === $output ) {
    40734070                do_action( 'bp_activity_filter_options' );
     
    41534150        function bp_get_member_activity_feed_link() {
    41544151
    4155                 // Single member activity feed link
     4152                // Single member activity feed link.
    41564153                if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
    41574154                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
    41584155
    4159                 // Friend feed link
     4156                // Friend feed link.
    41604157                } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
    41614158                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
    41624159
    4163                 // Group feed link
     4160                // Group feed link.
    41644161                } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) {
    41654162                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
    41664163
    4167                 // Favorites activity feed link
     4164                // Favorites activity feed link.
    41684165                } elseif ( 'favorites' === bp_current_action() ) {
    41694166                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    41704167
    4171                 // Mentions activity feed link
     4168                // Mentions activity feed link.
    41724169                } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
    41734170                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    41744171
    4175                 // No feed link
     4172                // No feed link.
    41764173                } else {
    41774174                        $link = '';
     
    43954392                global $activities_template;
    43964393
    4397                 // Get the content, if exists
     4394                // Get the content, if exists.
    43984395                $content = ! empty( $activities_template->activity->content )
    43994396                        ? $activities_template->activity->content
    44004397                        : '';
    44014398
    4402                 // Perform a few string conversions on the content, if it's not empty
     4399                // Perform a few string conversions on the content, if it's not empty.
    44034400                if ( ! empty( $content ) ) {
    44044401                        $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
     
    44384435 *
    44394436 * @param string $context The current context. 'activity', 'member',
    4440  *                            'member_groups', 'group'.
     4437 *                        'member_groups', 'group'.
    44414438 * @uses bp_get_activity_show_filters()
    44424439 */
     
    44504447         *
    44514448         * @param string $context The current context. 'activity', 'member',
    4452          *                            'member_groups', 'group'.
     4449         *                        'member_groups', 'group'.
    44534450         *
    44544451         * @return string HTML for <option> values.
    44554452         */
    44564453        function bp_get_activity_show_filters( $context = '' ) {
    4457                 // Set default context based on current page
     4454                // Set default context based on current page.
    44584455                if ( empty( $context ) ) {
    44594456
    44604457                        // On member pages, default to 'member', unless this
    4461                         // is a user's Groups activity
     4458                        // is a user's Groups activity.
    44624459                        if ( bp_is_user() ) {
    44634460                                if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
     
    44674464                                }
    44684465
    4469                         // On individual group pages, default to 'group'
     4466                        // On individual group pages, default to 'group'.
    44704467                        } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
    44714468                                $context = 'group';
    44724469
    4473                         // 'activity' everywhere else
     4470                        // 'activity' everywhere else.
    44744471                        } else {
    44754472                                $context = 'activity';
     
    44874484                                }
    44884485
    4489                                 // Friends activity collapses two filters into one
     4486                                // Friends activity collapses two filters into one.
    44904487                                if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
    44914488                                        $action['key'] = 'friendship_accepted,friendship_created';
     
    45064503                $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
    45074504
    4508                 // Build the options output
     4505                // Build the options output.
    45094506                $output = '';
    45104507
Note: See TracChangeset for help on using the changeset viewer.