Esempio n. 1
0
 /**
  * Widget Output.
  * @see WP_Widget::widget()
  */
 public function widget($args, $instance)
 {
     global $wpdb;
     extract($args, EXTR_SKIP);
     $number = (int) $instance['number'];
     if (1 > $number) {
         $number = 5;
     } elseif (20 < $number) {
         $number = 20;
     }
     echo $before_widget;
     if (!empty($instance['title'])) {
         echo $before_title . $instance['title'] . $after_title;
     }
     echo '<ul>';
     $subquery = aoc_roles_subquery();
     $query = "SELECT ID, user_login, display_name FROM {$wpdb->usermeta} INNER JOIN ( {$subquery} ) AS usr " . "ON {$wpdb->usermeta}.user_id = usr.id " . "WHERE {$wpdb->usermeta}.meta_key='akucom_gallery_update' " . "ORDER BY {$wpdb->usermeta}.meta_value DESC " . "LIMIT 0,{$number};";
     $users = $wpdb->get_results($query);
     foreach ($users as $user) {
         echo '<li>';
         if ($instance['avatar']) {
             echo get_avatar($user->ID, $instance['avatar-size']);
         }
         echo '<a href="' . aoc_create_link('gallery', urlencode($user->user_login)) . '">' . $user->display_name . '</a></li>';
     }
     echo '</ul>';
     echo $after_widget;
 }
Esempio n. 2
0
/**
 * Shortcut to create a link to the user profile.
 * To be used in other components without worring about changing the 'user' slug.
 *
 * @uses aoc_create_link()
 * @param $user_name	User login name.
 * @return string	Base link to the user profile page.
 */
function aoc_profile_link($user_name = '')
{
    return aoc_create_link('user', urlencode($user_name));
}
 /**
  * Creates and returns previous and next user links.
  * For paged user profiles.
  *
  * @param object $current	Current user object.
  * @param string $direction	Direction for the link. Is 'prev' or 'next'.
  * @return string			Previous or next user link.
  */
 private function pageNavigator($current, $direction = 'next')
 {
     global $wpdb;
     $roles = $this->getAllowedRoles();
     $ord_by = $this->getOption('order_by');
     $ord_dir = $this->getOption('order_dir');
     $keys = array();
     foreach ($roles as $value) {
         $keys[] = "meta_value LIKE '%{$value}%'";
     }
     // Prepare the order field
     switch ($ord_by) {
         case 'user_registered':
             $by = $current->user_registered;
             break;
         case 'user_login':
             $by = $current->user_login;
             break;
         case 'ID':
             $by = $current->ID;
             break;
         case 'display_name':
         default:
             $by = $current->display_name;
             break;
     }
     // $ord_by contains the ordering field name.
     if ('ASC' == $ord_dir) {
         $op = 'next' == $direction ? '>' : '<';
     } else {
         $op = 'next' == $direction ? '<' : '>';
     }
     $condition = "{$ord_by} {$op} '{$by}'";
     $order_dir = '>' == $op ? 'ASC' : 'DESC';
     // Compose the query
     $query = "SELECT user_login, display_name FROM {$wpdb->usermeta} INNER JOIN {$wpdb->users} " . "ON {$wpdb->usermeta}.user_id = {$wpdb->users}.id " . "WHERE {$condition} AND meta_key='{$wpdb->prefix}capabilities' AND (" . implode(' OR ', $keys) . ") " . "ORDER BY {$ord_by} {$order_dir} " . "LIMIT 0,1;";
     $user = $wpdb->get_row($query);
     if (empty($user)) {
         // If no user, no link.
         $link = '';
     } else {
         // Create the base url for the link to user profile page.
         $plink = aoc_create_link('user', urlencode($user->user_login));
         $link = 'next' == $direction ? '<a href="' . $plink . '">' . $user->display_name . '</a> &raquo;' : '&laquo; <a href="' . $plink . '">' . $user->display_name . '</a>';
     }
     return $link;
 }
 /**
  * Sends the user image and gallery link to the user gallery page.
  *
  * @uses apply_filters() Calls the 'aoc_profile_image' hook on the user picture and link.
  * @param object $user The user object to get the pictures from.
  * @param boolean $thumbnail Set to true if we want to get the thumbnail instead the large image.
  * @return string New header with the user image and gallery link.
  */
 public function getProfilePicture($user, $thumbnail = false)
 {
     $out = $this->getUserImage($user->ID, 'aligncenter', $thumbnail);
     $num = $this->countApprovedImages($user->{$this->ID});
     if (1 < $num) {
         $out .= '<p style="text-align:center;"><strong><a href="' . aoc_create_link('gallery') . urlencode($user->user_login) . '">' . sprintf(__('More user pictures [%d]', $this->PID), $num) . '</a></strong></p>';
     }
     $out = apply_filters('aoc_profile_image', $out);
     return $out;
 }