{groups}'; /** * Group template * - {name} is replaced by the name of the group * - {group} is replaced by the list of users */ var $group_template = '
'; /** * Wrapper template * - {users} is replaced by the list of users */ var $userlist_template = ''; /** * User template * - {class} is replaced by user specific classes * - {user} is replaced by the user avatar (and possibly name) */ var $user_template = ''. __('No users found.', 'author-avatars'). '
'); } elseif (!empty($this->group_by)) { return $this->format_groups($users); } else { return $this->format_users($users); } } /** * Formats a grouped list of users * * @param Array $groups Array of an array of users. The array keys are used to retrieve the group name (see _group_name()) * @uses apply_filters() Calls 'aa_userlist_group_wrapper_template' hook * @uses apply_filters() Calls 'aa_userlist_group_template' hook * @return String the html formatted list of grouped users */ function format_groups ($groups) { $html = ''; foreach ($groups as $id => $group_users) { $tpl_vars = array( '{name}' => $this->_group_name($id), '{group}' => $this->format_users($group_users), ); $html .= str_replace(array_keys($tpl_vars), $tpl_vars, apply_filters('aa_userlist_group_template', $this->group_template)); } return str_replace('{groups}', $html, apply_filters('aa_userlist_group_wrapper_template', $this->group_wrapper_template)); } /** * Formats a list of users * * @param Array $groups An array of users. * @uses apply_filters() Calls 'aa_userlist_template' hook * @return String the html formatted list of users */ function format_users($users) { $html = ''; foreach ($users as $user) { $html .= $this->format_user($user); } return str_replace('{users}', $html, apply_filters('aa_userlist_template', $this->userlist_template)); } /** * Formats the given user as html. * * @param WP_User $user The user to format (object of type WP_User). * @uses apply_filters() Calls 'aa_user_template' hook * @return String html */ function format_user($user) { $tpl_vars = array('{class}' => '', '{user}' => ''); $avatar_size = intval($this->avatar_size); if (!$avatar_size) $avatar_size = false; $name = $user->display_name; $alt = $title = $name; $divcss = array('user'); if ($this->show_name) $divcss[] = 'with-name'; $link = false; $link_type = $this->user_link; // always use 'website' for commentators if ( $user->user_id == -1) { $link_type = 'website'; } switch ($link_type) { case 'authorpage': $link = get_author_posts_url($user->user_id); break; case 'website': $link = $user->user_url; if (empty($link) || $link == 'http://') $link = false; break; case 'blog': if (AA_is_wpmu()) { $blog = get_active_blog_for_user($user->user_id); if (!empty($blog->siteurl)) $link = $blog->siteurl; } break; case 'bp_memberpage': if (function_exists('bp_core_get_user_domain')) { $link = bp_core_get_user_domain($user->user_id); } elseif (function_exists('bp_core_get_userurl')) { // BP versions < 1.1 $link = bp_core_get_userurl($user->user_id); } break; } if ($this->show_postcount) { $postcount = 0; if ($user->user_id == -1) { $postcount = $this->get_comment_count($user->user_email); $title .= ' ('. sprintf(_n("%d comment", "%d comments", $postcount, 'author-avatars'), $postcount) .')'; } else { $postcount = $this->get_user_postcount($user->user_id); $title .= ' ('. sprintf(_n("%d post", "%d posts", $postcount, 'author-avatars'), $postcount) .')'; } $name .= sprintf(' (%d)', $postcount); } $biography = false; if ($this->show_biography && $user->user_id > 0) { $biography = get_the_author_meta('description', $user->user_id); $divcss[] = 'with-biography'; $name = ''. $name .''; if (empty($biography)) $divcss[] = 'biography-missing'; } if ($user->user_id == -1) { // use email for commentators $avatar = get_avatar($user->user_email, $avatar_size); } else { $avatar = get_avatar($user->user_id, $avatar_size); } /* Strip all existing links (a tags) from the get_avatar() code to * remove e.g. the link which is added by the add-local-avatar plugin * @see http://wordpress.org/support/topic/309878 */ if (!empty($link)) { $avatar = preg_replace('@<\s*\/?\s*[aA]\s*.*?>@', '', $avatar); } /* strip alt and title parameter */ $avatar = preg_replace('@alt=["\'][\w]*["\'] ?@', '', $avatar); $avatar = preg_replace('@title=["\'][\w]*["\'] ?@', '', $avatar); /* insert alt and title parameters */ $avatar = preg_replace('@ ?\/>@', ' alt="'.$alt.'" title="'.$title.'" />', $avatar); $html = ''; if ($link) $html .= ''; $html .= ''. $avatar .''; if ($this->show_name) $html .= ''. $name . ''; if ($link) $html .= ''; if ($biography) $html .= '