Author Avatars List 1.7.1


Hi all

Update: found a small bug which I have fixed in 1.7.1

Lots of changes in version 1.7.0 some of which have been in the dev branch for a while

  • Added Local User select to Single Avatar Shortcode creator
  • Replaced wp_specialchars() with esc_html()
  • Removed support pre 3.0 wordpress installs
  • Added BBPRESS_post_count as shortcode display and sort options
  • Added show_email to shortcode display option
  • Added some translation updates
  • Fixed issue with TniyMCE breaking when using HTTPS
  • And a few other tidy ups
  •  Added SQL filter to only fetch the users for the rolls being requested rather than all users
  • Added caching to the main get_users function which will use an object cache if turned on
  • Started to add support for filters so the template can changed via the calling themes.

I have the ability to pick a local user using a drop and you can now show the users email (don’t use this on public page – you will get spam)

email_selector

Some site that have lots of users were find that some queries were very slow so I have tried to help this a better query (small results set) and and caching if you have it turned on. I plan to do some more work on this.

Filters now available do use

apply_filters('aa_userlist_empty', '<p class="no_users">'. __('No users found.', 'author-avatars'). '</p>');
apply_filters('aa_userlist_group_template', $this->group_template)
apply_filters('aa_userlist_group_wrapper_template', $this->group_wrapper_template)
apply_filters('aa_userlist_template', $this->userlist_template)


apply_filters(‘aa_user_template’, $this->user_template,$user)

and here are the default strings

/**
 * Group wrapper template
 * - {groups} is replaced by the list of groups
 */
 var $group_wrapper_template = '<div class="grouped-author-list">{groups}</div>';

 /**
 * Group template
 * - {name} is replaced by the name of the group
 * - {group} is replaced by the list of users
 */
 var $group_template = '<div class="author-group"><strong>{name}</strong><br/>{group}</div>';

 /**
 * Wrapper template
 * - {users} is replaced by the list of users
 */
 var $userlist_template = '<div class="author-list">{users}</div>';

 /**
 * User template
 * - {class} is replaced by user specific classes
 * - {user} is replaced by the user avatar (and possibly name)
 */
 var $user_template = '<div class="{class}">{user}</div>';


I hope this update goes well I had been holding of releasing it as it kept getting big and have found time to test and release

I have moved the main code repo to https://github.com/pbearne/wp-author-avatars feel free to create a pull requests and submit patches there.

,

10 responses to “Author Avatars List 1.7.1”

  1. Hi,

    This is a very useful plug-in, but the CSS caused all sorts of conflicts for me. I think calling the avatar CSS class ‘avatar’ is just way too generic – any theme will use this for its avatar styling. I had to change this to ‘author-avatar’ in userList.class.php – I think you should too. I had to modify the widget CSS a lot too, but I understand this is an individual thing. But using such a generic name for a custom CSS class is a bad idea.

    • I started to write to you asking for the code changes to be added to https://github.com/pbearne/wp-author-avatars and would still like to see them.

      The problem in changing the class at this point is it will break any other existing css changes.

      I always wrap the block in outer class e.g. shortcode-author-avatars so you could pivot for that.

      the wordpress function does return the image with avatar as part of the class’s

      I feel the best I can is create a filter that you can change the HTML and class via that way you can adjust to need you needs and it will backwards compatible Does that make sense as an approach?

      Paul

      • Hi Paul,

        Thanks for the quick response. I have to admit that I am not an expert on this sort of thing – it’s just that I simply wasn’t able to resolve a conflict with my theme’s own avatar class and yours. If there is some other way to deal with this without changing your class name I am happy to try it, but your suggestion of wrapping it inside another class appears to make sense – I just can’t be sure it will work until I try it, whereas I know my present method actually does work.

  2. Oops, it appears I misread your original comment, as you are already wrapping it. Unfortunately, this does not solve the problem – because my theme (and I suspect many others) use this class for avatar styling, it ‘double styles’, regardless of what it is wrapped in.

  3. this is not easy to fix
    Have word with your theme creator and ask them to either change the class name or make the CSS more selective

    for me to change the plug-in it would be a breaking change at this time

  4. Hi PBearne, after the update to the last version 1.7.0 the avatar images disappeared and I’ve this error all the time on apache error.log:

    [Thu May 16 09:58:54 2013] [error] [client 66.249.75.52] Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”’ at line 8 de la base de datos de WordPress para la consulta \r\n\t\t\t\tSELECT p.post_date\r\n\t\t\t\tFROM wp_posts p\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tp.post_status = ‘publish’\r\n\t\t\t\t\tAND\r\n\t\t\t\t\tp.post_author = 10\r\n\t\t\t\tORDER BY p.post_date\r\n\t\t\t\tDESC LIMIT 1’\r\n\t\t\t\t realizada por require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/motion/single.php’), get_sidebar, locate_template, load_template, require_once(‘/themes/motion/sidebar.php’), dynamic_sidebar, call_user_func_array, MultiWidget->widget_callback, AuthorAvatarsWidget->widget, UserList->output, UserList->get_output, UserList->get_users, UserList->_sort, usort, UserList->_user_cmp_activity, UserList->get_user_last_activity

    But when I execute this sql on mysql console:

    mysql> SELECT p.post_date FROM wp_posts p WHERE p.post_status = ‘publish’ AND p.post_author = 6 ORDER BY p.post_date DESC LIMIT 1
    -> ;
    Empty set (0.00 sec)

    • Thanks for the report

      Can you post the settings you are using in the widget / shortcode so I can recreate

      (this looks like a date sort going wrong) You may want to try changing the sort for now to get the avatars back until I can fix

      Paul

      • Avatar Size 50px
        Show Roles:
        Admin
        Author
        Display options:
        None
        Link users to Author Page
        Sorting order Recent Activity
        Sorting direction Descensing
        Max. number of avatars shown 9

        I tried making several changes in settings but in some cases pictures didn´t appears and in others cases appears. I see the SQL error all the time.

        Can I tell you any more information?