Skip to:
Content

Changeset 8748


Ignore:
Timestamp:
08/02/2014 02:31:13 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Allow a custom string to be passed into bp_get_member_last_active()'s active_format argument.

File:
1 edited

Legend:

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

    r8683 r8748  
    795795     * @param array $args {
    796796     *     Array of optional arguments.
    797      *     @type bool $active_format If true, formatted "Active 5 minutes
    798      *           ago". If false, formatted "5 minutes ago". Default: true.
     797     *     @type mixed $active_format If true, formatted "active 5 minutes
     798     *           ago". If false, formatted "5 minutes ago". If string, should
     799     *           be sprintf'able like 'last seen %s ago'.
    799800     * }
    800801     * @return string
     
    803804        global $members_template;
    804805
    805         $r = wp_parse_args( $args, array(
    806             'active_format' => true,
     806        // Parse the activy format
     807        $r = bp_parse_args( $args, array(
     808            'active_format' => true
    807809        ) );
    808810
     811        // Backwards compatibilty for anyone forcing a 'true' active_format
     812        if ( true === $r['active_format'] ) {
     813            $r['active_format'] = __( 'active %s', 'buddypress' );
     814        }
     815
     816        // Member has logged in at least one time
    809817        if ( isset( $members_template->member->last_activity ) ) {
    810             if ( ! empty( $r['active_format'] ) ) {
    811                 $last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s', 'buddypress' ) );
    812             } else {
    813                 $last_activity = bp_core_time_since( $members_template->member->last_activity );
    814             }
     818
     819            // Backwards compatibility for pre 1.5 'ago' strings
     820            $last_activity = ! empty( $r['active_format'] )
     821                ? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] )
     822                : bp_core_time_since( $members_template->member->last_activity );
     823
     824        // Member has never logged in or been active
    815825        } else {
    816826            $last_activity = __( 'Never active', 'buddypress' );
    817827        }
    818828
    819         return apply_filters( 'bp_member_last_active', $last_activity );
     829        // Filter and return
     830        return apply_filters( 'bp_member_last_active', $last_activity, $r );
    820831    }
    821832
Note: See TracChangeset for help on using the changeset viewer.