我是靠谱客的博主 靓丽手机,最近开发中收集的这篇文章主要介绍wp= Author Avatars List Wordpress Plugin,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

https://authoravatars.wordpress.com/documentation/


[author-avatars] shortcode

As of version 0.4 the plugin comes with a shortcode which can be used to show lists of avatars on a page or inside a post. It’s simple: just add [authoravatars] into your post and hit save!

[show_avatar] shortcode

As of version 0.5 the plugin comes with a shortcode which can be used to show an avatar of any user using a userid or email address.

Developers Guide

Information for advanced users who want to customise the plugin beyond the scope of adjusting settings in the admin section.

Other plug-in’s that work with Author Avatar list

 



微笑

Shortcode: [authoravatars]

As of version 0.4 the plugin comes with a shortcode which can be used to show lists of avatars on a page or inside a post. It’s simple: just add [authoravatars] into your post and hit save!

Available Parameters

Just as for the widget you can use various parameters to configure the list of users.

roles: Only show users of a certain role

Restrict the list of users by roles to show only users belonging to certain roles. Possible values in a default WordPress setup are: administrator, editor, author, contributor, subscriber. Separate multiple values by a comma.

Example: [authoravatars roles=administrator,editor]

hiddenusers: Remove users from the list

Hide one or multiple users from the list. Both login names and user ids are allowed as values. Separate multiple values by a comma.

Example: [authoravatars hiddenusers=admin]

avatar_size: The size of the avatar images

You can adjust the size of the avatar by specifying the avatar_size parameter.

Example: [authoravatars avatar_size=25]

link_to_authorpage: Disable the link to author pages (deprecated)

This is deprecated since version 0.7. Please use the user_link parameter instead.

By default user avatars are linked to their Author Page. If your theme doesn’t support them or you don’t want to show them e.g. for subscribers, then you can easily disable them by setting this parameter to false.

Example: [authoravatars link_to_authorpage=false]

user_link: Link user avatars to user website, blog or authorpage

As of version 0.7 you can link users not only to their respective Author Page but also their website if available or blog on WordPress MU sites.

Version 0.7.3 adds the option to link users to their respective BuddyPress Members page.

Allowed values: falseauthorpage (default), websiteblog (wpmu only), bp_memberpage (only if budypress installed),bppress_memberpage( (only if bbpress installed)

Example: [authoravatars user_link=website]

show_name: Show user names next to avatars

If you’d like to show the user display names next to the avatars set the show_name parameter to true.

Example: [authoravatars show_name=true]

show_biography: Show user biographies next to avatars

If you’d like to show the user biographies next to the avatars set the show_biography parameter to true.

Example: [authoravatars show_biography=true]

show_postcount: Show the users’ post count next to their name

Set this option to true to show a user’s postcount next to their name (in brackets). If the user name is not displayed (see “show_name” parameter) then the postcount will be shown within the title of the image, i.e. it can be seen on mouse-over.

Example: [authoravatars show_postcount=true]

min_post_count: Set a required minimum number of posts

Since version 0.8 you can only show users which have a specified number of posts. This allows for example to hide all authors which have not written any posts yet.

Example: [authoravatars min_post_count=1]

limit: The maximum number of avatars shown

Example: [authoravatars limit=3]

order: The order in which users are shown

Users are ordered by their display name A-Z by default. You can adjust this by changing this parameter. Possible values are: random, user_id, user_login, display_name, post_count (0.7+), date_registered (0.7+).

Example: [authoravatars order=random]

page_size: Max number per page

With this set paging markup (“< 1 2 3 4 5 >”) will be displayed below the avatars block.
The avatars are reloaded via ajax.
Note: this code is only used in the shortcode in page or post and not in a widget.

Example: [authoravatars page_size=10]

sort_direction: The direction in which users are ordered

As of version 0.7 you can specify the sort direction, ascending or descending.
Valid values are “asc” or “ascending” (default) and “desc” or “descending”.

Example: [authoravatars order=date_registered sort_direction=descending]

You can also use this shorter version:

Example: [authoravatars order=date_registered,desc]

blogs which blogs to show authors from

This is only for multi-site (WPMU) mode.

Before you use this you need to grant a site permission to see other blogs in the site on the network admin control panel
/wp-admin/network/settings.php?page=wpmu_author_avatars

sitewide blogs

Without this parameter we only look at the current blog to List authors from all blogs add “blogs-all”

Example: [authoravatars blogs=all]

or just some blogs

Example: [authoravatars blogs=1,2,5]

Note:  Use with care as on big sites this will tax the server as SQL gets very big and number of images being fetch grows

render_as_list: Change the rendering template to a list. (deprecated)

This is deprecated since version 0.7.3. This option is probably going to be removed once a more advanced template system is in place. You can get the same effect by using userlist template filters as described in the Developers Guide.

Set this parameter to true, if you would like the list of users to be rendered using a html list (<ul>) instead of a bunch of <div>s. The plugin’s default style sheet renders these lists a normal list (avatars underneath each other) instead of all next to each other (float-ed).
Example: [authoravatars render_as_list=true]


微笑


Shortcode: [show_avatar]

As of version 0.5 the plugin comes with a shortcode which can be used to show an avatar of any user using a userid or email address.

This is essentially only a wrapper for the get_avatar() template function.

Basic example: [show_avatar email=mail@address.com]

Available Parameters

email and id

The value specified in the id or email attribute is passed as the first parameter to the get_avatar() function.

Specify the email address of the user whose avatar you would like to display.

Example: [show_avatar email=mail@address.com]

avatar_size: The size of the avatar image

You can adjust the size of the avatar by specifying the avatar_size parameter.

Example: [show_avatar avatar_size=25]

align: The alignment of the avatar image

You can add an align attribute to display the avatar floated left/right or centered.

Possible values: leftrightcenter

Example: [show_avatar align=left]

Styling the show_avatar shortcode

Avatars shown using the show_avatar shortcode are wrapped into a div with the following classname: shortcode-show-avatar.

You can for example add the following bit of CSS code to your stylesheet to give the avatar an almost-white background and a grey border.

.shortcode-show-avatar {
padding: 2px;
background-color: #eee;
border: 1px solid #ccc;
}




Developers Guide

This page provides information for advanced users who want to customise the 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.

Stylesheets

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

HandlePurposeDefault stylesheet location 
author-avatars-shortcodeStyles for shortcodes authoravatars and show_avatar.wp-content/plugins/author-avatars/css/shortcode.cssView CSS
author-avatars-widgetStyles for the userlist widget.wp-content/plugins/author-avatars/css/widget.cssView 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.

TagDefault valueDescription
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->user_link = 'authorpage';
$userlist->min_post_count = 0;
$userlist->show_name = false;
$userlist->show_postcount = false;
$userlist->show_biography = 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. 14-72) but the naming should be pretty much the same as for theauthoravatars shortcode.



最后

以上就是靓丽手机为你收集整理的wp= Author Avatars List Wordpress Plugin的全部内容,希望文章能够帮你解决wp= Author Avatars List Wordpress Plugin所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部