Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:Bforchhammer/Author Avatars Developers Guide

Note: this page is no longer maintained, please refer to this page instead.

This page provides information for advanced users who want to customise the Author Avatars List plugin beyond the scope of adjusting settings in the admin section.

Note that a some things on this page have not been tested properly yet. Feel free to add a comment to the page or send me an email if you find something that's wrong or not working.

Stylesheets

The plugin has two default stylesheets which are used on the frontend.

Handle Purpose Default stylesheet location
author-avatars-shortcode Styles for shortcodes authoravatars and show_avatar. wp-content/plugins/author-avatars/css/shortcode.css
author-avatars-widget Styles for the userlist widget. wp-content/plugins/author-avatars/css/widget.css

You can remove and replace any of the default stylesheets using wordpress functions wp_deregister_style() and wp_register_style().

Filter and Action Hooks

Userlist Templates

You can change the default template html strings using the following filters. Note that all filters are experimental at this point and might change in a later version.

Tag Default value Description
aa_userlist_empty '<p class="no_users">No users found.</p>' Value being displayed if the list of users is empty.
aa_userlist_group_template '<div class="author-group"><strong>{name}</strong><br/>{group}</div>' Group template
  • {name} is replaced by the name of the group
  • {group} is replaced by the list of users
aa_userlist_group_wrapper_template '<div class="grouped-author-list">{groups}</div>' Group wrapper template
  • {groups} is replaced by the list of groups
aa_userlist_template '<div class="author-list">{users}</div>' Wrapper template
  • {users} is replaced by the list of users
aa_user_template '<div class="{class}">{user}</div>' User template
  • {class} is replaced by user specific classes
  • {user} is replaced by the user avatar (and possibly name)


Usage Example:

   // Change user list templates to use an ordered list instead of divs
   
   function custom_aa_userlist_template($default) {
       return '<ol class="author-list">{users}</ol>';
   }
   add_filter('aa_userlist_template', 'custom_aa_userlist_template');
   
   function custom_aa_user_template($default) {
       return '<li class="{class}">{user}</li>';
   }
   add_filter('aa_user_template', 'custom_aa_user_template');

Avatar lists without shortcode or widget

The plugin can be used to programmatically generate lists of users/avatars. This can be useful for example if you're theme does not support widgets but you would like to add avatars to your sidebar anyway.

Generating the list of users/avatars is controlled by the UserList Class.

Example for displaying a list of max. 30 Administrators, Editors and Authors:

   <?php require_once(ABSPATH . PLUGINDIR . '/author-avatars/lib/UserList.class.php' );
       $userlist = new UserList();
       $userlist->hiddenusers = array('admin');
       $userlist->roles = array('Administrator', 'Editor', 'Author');
       $userlist->link_to_authorpage = true;
       $userlist->show_name = false;
       $userlist->avatar_size = 20;
       $userlist->limit = 30;
       $userlist->order = 'display_name';
       $userlist->output();
   ?>

The parameters are only documented inline in the code at the moment (see UserList class fields, l. 17-83) but the naming should be pretty much the same as for the authoravatars shortcode.