Skip to:
Content

BuddyPress.org

Changeset 8407


Ignore:
Timestamp:
05/10/2014 01:13:22 AM (6 years ago)
Author:
boonebgorges
Message:

Introduce 'active_format' param for bp_get_blog_last_active()

This allows themers to skip the 'active %s' wrapper that BP puts around the
date of last activity for a blog.

See #5392

Props lenasterg

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r8142 r8407  
    634634/**
    635635 * Output the last active date of the current blog in the loop.
    636  */
    637 function bp_blog_last_active() {
    638     echo bp_get_blog_last_active();
     636 *
     637 * @param array $args See {@link bp_get_blog_last_active()}.
     638 */
     639function bp_blog_last_active( $args = array() ) {
     640    echo bp_get_blog_last_active( $args );
    639641}
    640642    /**
    641643     * Return the last active date of the current blog in the loop.
    642644     *
     645     * @param array $args {
     646     *     Array of optional arguments.
     647     *     @type bool $active_format If true, formatted "Active 5 minutes
     648     *           ago". If false, formatted "5 minutes ago". Default: true.
     649     * }
    643650     * @return string Last active date.
    644651     */
    645     function bp_get_blog_last_active() {
     652    function bp_get_blog_last_active( $args = array() ) {
    646653        global $blogs_template;
    647654
    648         return apply_filters( 'bp_blog_last_active', bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s', 'buddypress' ) ) );
     655        $r = wp_parse_args( $args, array(
     656            'active_format' => true,
     657        ) );
     658
     659        if ( isset( $blogs_template->blog->last_activity ) ) {
     660            if ( ! empty( $r['active_format'] ) ) {
     661                $last_activity = bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s', 'buddypress' ) );
     662            } else {
     663                $last_activity = bp_core_time_since( $blogs_template->blog->last_activity );
     664            }
     665        } else {
     666            $last_activity = __( 'Never active', 'buddypress' );
     667        }
     668
     669        return apply_filters( 'bp_blog_last_active', $last_activity, $r );
    649670    }
    650671
Note: See TracChangeset for help on using the changeset viewer.