Plugin Directory

Changeset 360780


Ignore:
Timestamp:
03/16/2011 03:23:56 PM (15 years ago)
Author:
bforchhammer
Message:

Added sorting by most recent post (latest activity)

Location:
author-avatars/trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • author-avatars/trunk/lib/AuthorAvatarsForm.class.php

    r256994 r360780  
    328328            'random' => __('Random', 'author-avatars'),
    329329            'user_id' => __('User Id', 'author-avatars'),
    330         );
    331         if (AA_is_bp()) {
    332             $order_options['recent_activity'] = __('Recent Activity', 'author-avatars');
    333         }
     330            'recent_activity' => __('Recent Activity', 'author-avatars'),
     331        );
    334332       
    335333        $attributes = array(
  • author-avatars/trunk/lib/UserList.class.php

    r343338 r360780  
    731731     * Returns the time of last activity for a given user.
    732732     *
    733      * This requires that BuddyPress is installed.
    734      * If it's not available the function returns an empty string.
     733     * If BuddyPress is available this function uses the `last_activity` meta
     734     * data value maintained by BuddyPress. Otherwise it returns the date of
     735     * the latest post or page published by the given user.
    735736     *
    736737     * @param int $user_id
     
    741742            return gmdate( 'Y-m-d H:i:s', (int)get_usermeta( $user_id, 'last_activity' ) );
    742743        }
    743         return "";
     744        else {
     745            global $wpdb;
     746            $query = 'SELECT `post_date` FROM `wp_posts` WHERE `post_status` = "publish" AND `post_author` = ' . $user_id . ' ORDER BY `post_date` DESC LIMIT 1';
     747            return $wpdb->get_var($query);
     748        }
    744749    }
    745750   
Note: See TracChangeset for help on using the changeset viewer.