本文整理汇总了PHP中get_avatar_data函数的典型用法代码示例。如果您正苦于以下问题:PHP get_avatar_data函数的具体用法?PHP get_avatar_data怎么用?PHP get_avatar_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_avatar_data函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_avatar
/**
* Retrieve the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.
*
* @since 2.5.0
* @since 4.2.0 Optional `$args` parameter added.
*
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or comment object.
* @param int $size Optional. Height and width of the avatar image file in pixels. Default 96.
* @param string $default Optional. URL for the default image or a default type. Accepts '404'
* (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'
* (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
* 'mystery', 'mm', or 'mysterman' (The Oyster Man), 'blank' (transparent GIF),
* or 'gravatar_default' (the Gravatar logo). Default is the value of the
* 'avatar_default' option, with a fallback of 'mystery'.
* @param string $alt Optional. Alternative text to use in <img> tag. Default empty.
* @param array $args {
* Optional. Extra arguments to retrieve the avatar.
*
* @type int $height Display height of the avatar in pixels. Defaults to $size.
* @type int $width Display width of the avatar in pixels. Defaults to $size.
* @type bool $force_default Whether to always show the default image, never the Gravatar. Default false.
* @type string $rating What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
* judged in that order. Default is the value of the 'avatar_rating' option.
* @type string $scheme URL scheme to use. See set_url_scheme() for accepted values.
* Default null.
* @type array|string $class Array or string of additional classes to add to the <img> element.
* Default null.
* @type bool $force_display Whether to always show the avatar - ignores the show_avatars option.
* Default false.
* @type string $extra_attr HTML attributes to insert in the IMG element. Is not sanitized. Default empty.
* }
* @return false|string `<img>` tag for the user's avatar. False on failure.
*/
function get_avatar($id_or_email, $size = 96, $default = '', $alt = '', $args = null)
{
$defaults = array('size' => 96, 'height' => null, 'width' => null, 'default' => get_option('avatar_default', 'mystery'), 'force_default' => false, 'rating' => get_option('avatar_rating'), 'scheme' => null, 'alt' => '', 'class' => null, 'force_display' => false, 'extra_attr' => '');
if (empty($args)) {
$args = array();
}
$args['size'] = (int) $size;
$args['default'] = $default;
$args['alt'] = $alt;
$args = wp_parse_args($args, $defaults);
if (empty($args['height'])) {
$args['height'] = $args['size'];
}
if (empty($args['width'])) {
$args['width'] = $args['size'];
}
/**
* Filter whether to retrieve the avatar URL early.
*
* Passing a non-null value will effectively short-circuit get_avatar(), passing
* the value through the {@see 'pre_get_avatar'} filter and returning early.
*
* @since 4.2.0
*
* @param string $avatar HTML for the user's avatar. Default null.
* @param int|object|string $id_or_email A user ID, email address, or comment object.
* @param array $args Arguments passed to get_avatar_url(), after processing.
*/
$avatar = apply_filters('pre_get_avatar', null, $id_or_email, $args);
if (!is_null($avatar)) {
/** This filter is documented in wp-includes/pluggable.php */
return apply_filters('get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args);
}
if (!$args['force_display'] && !get_option('show_avatars')) {
return false;
}
$url2x = get_avatar_url($id_or_email, array_merge($args, array('size' => $args['size'] * 2)));
$args = get_avatar_data($id_or_email, $args);
$url = $args['url'];
if (!$url || is_wp_error($url)) {
return false;
}
$class = array('avatar', 'avatar-' . (int) $args['size'], 'photo');
if (!$args['found_avatar'] || $args['force_default']) {
$class[] = 'avatar-default';
}
if ($args['class']) {
if (is_array($args['class'])) {
$class = array_merge($class, $args['class']);
} else {
$class[] = $args['class'];
}
}
$avatar = sprintf("<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>", esc_attr($args['alt']), esc_url($url), esc_attr("{$url2x} 2x"), esc_attr(join(' ', $class)), (int) $args['height'], (int) $args['width'], $args['extra_attr']);
/**
* Filter the avatar to retrieve.
*
* @since 2.5.0
* @since 4.2.0 The `$args` parameter was added.
*
* @param string $avatar <img> tag for the user's avatar.
* @param int|object|string $id_or_email A user ID, email address, or comment object.
* @param int $size Square avatar width and height in pixels to retrieve.
* @param string $alt Alternative text to use in the avatar image tag.
* Default empty.
* @param array $args Arguments passed to get_avatar_data(), after processing.
//.........这里部分代码省略.........
示例2: get_avatar_url
/**
* Retrieve the avatar URL.
*
* @since 4.2.0
*
* @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or comment object.
* @param array $args {
* Optional. Arguments to return instead of the default arguments.
*
* @type int $size Height and width of the avatar in pixels. Default 96.
* @type string $default URL for the default image or a default type. Accepts '404' (return
* a 404 instead of a default image), 'retro' (8bit), 'monsterid' (monster),
* 'wavatar' (cartoon face), 'indenticon' (the "quilt"), 'mystery', 'mm',
* or 'mysterman' (The Oyster Man), 'blank' (transparent GIF), or
* 'gravatar_default' (the Gravatar logo). Default is the value of the
* 'avatar_default' option, with a fallback of 'mystery'.
* @type bool $force_default Whether to always show the default image, never the Gravatar. Default false.
* @type string $rating What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
* judged in that order. Default is the value of the 'avatar_rating' option.
* @type string $scheme URL scheme to use. See set_url_scheme() for accepted values.
* Default null.
* @type array $processed_args When the function returns, the value will be the processed/sanitized $args
* plus a "found_avatar" guess. Pass as a reference. Default null.
* }
* @return false|string The URL of the avatar we found, or false if we couldn't find an avatar.
*/
function get_avatar_url($id_or_email, $args = null)
{
$args = get_avatar_data($id_or_email, $args);
return $args['url'];
}
示例3: array_walk
break;
case 'libraries':
array_walk($group_data['data'], '_wp_credits_build_object_link');
echo '<p class="wp-credits-list">' . wp_sprintf('%l.', $group_data['data']) . "</p>\n\n";
break;
default:
$compact = 'compact' == $group_data['type'];
$classes = 'wp-people-group ' . ($compact ? 'compact' : '');
echo '<ul class="' . $classes . '" id="wp-people-group-' . $group_slug . '">' . "\n";
foreach ($group_data['data'] as $person_data) {
echo '<li class="wp-person" id="wp-person-' . esc_attr($person_data[2]) . '">' . "\n\t";
echo '<a href="' . esc_url(sprintf($credits['data']['profiles'], $person_data[2])) . '" class="web">';
$size = 'compact' == $group_data['type'] ? 30 : 60;
$data = get_avatar_data($person_data[1] . '@md5.gravatar.com', array('size' => $size));
$size *= 2;
$data2x = get_avatar_data($person_data[1] . '@md5.gravatar.com', array('size' => $size));
echo '<img src="' . esc_url($data['url']) . '" srcset="' . esc_url($data2x['url']) . ' 2x" class="gravatar" alt="" />' . "\n";
echo esc_html($person_data[0]) . "</a>\n\t";
if (!$compact) {
echo '<span class="title">' . translate($person_data[3]) . "</span>\n";
}
echo "</li>\n";
}
echo "</ul>\n";
break;
}
}
?>
<p class="clear"><?php
/* translators: %s: https://make.wordpress.org/ */
printf(__('Want to see your name in lights on this page? <a href="%s">Get involved in WordPress</a>.'), __('https://make.wordpress.org/'));
示例4: show_widget
public function show_widget()
{
$this->include_scripts();
global $rm_form_diary;
if (current_user_can('manage_options')) {
?>
<!----Color Switcher---->
<div class="rm-white-box difl rm-color-switcher rm-rounded-corners rm-shadow-10" id="rm-color-switcher">
<div id="rm-theme-box-toggle" style="cursor: pointer; text-align: right; color: grey" onclick="close_theme_box()">x</div>
<div class="rm-color-switcher-note rm-grey-box dbfl rm-pad-10">Welcome! This sticky panel is only visible to you as site admin. You can style RegistrationMagic's front-end panel on the right side, using the options below.</div>
<div class="rm-color-switch-title dbfl rm-accent-bg rm-pad-10">Magic Panel Styler!</div>
<input type="text" class="dbfl rm-grey-box jscolor" placeholder="Panel Accent Color" id="rm-panel-accent">
<select class="dbfl" id="rm-panel-theme">
<option value="Light"><?php
echo RM_UI_Strings::get('LABEL_LIGHT');
?>
</option>
<option value="Dark"><?php
echo RM_UI_Strings::get('LABEL_DARK');
?>
</option>
</select>
<button class="difl" id="rm-color-switch"><?php
echo RM_UI_Strings::get('LABEL_SWITCH');
?>
</button>
</div>
<?php
}
?>
<div class="rm-magic-popup">
<div class="rm-popup-menu rm-rounded-corners rm-white-box rm-shadow-10 dbfl" id="rm-menu">
<?php
if ($this->user_level === 0x4) {
?>
<div class="rm-popup-item dbfl rm-border" id="rm-account-open">
<?php
$av = get_avatar_data($this->user->ID);
?>
<img class="rm-menu-userimage difl" src="<?php
echo $av['url'];
?>
">
<div class="rm-menu-user-details difl">
<div class="dbfl"><b><?php
echo RM_UI_Strings::get('LABEL_WELCOME');
?>
</b></div>
<div class="dbfl"><?php
echo $this->user->first_name . ' ' . $this->user->last_name;
?>
</div>
</div>
</div>
<?php
}
if ($this->user_level === 0x1) {
?>
<div class="rm-popup-item dbfl" id="rm-login-open"><?php
echo RM_UI_Strings::get('LABEL_LOGIN');
?>
</div>
<?php
if (!isset($rm_form_diary[$this->param->default_form])) {
?>
<div class="rm-popup-item dbfl" id="rm-register-open-big"><?php
echo RM_UI_Strings::get('LABEL_REGISTER');
?>
</div>
<?php
} else {
?>
<a href="#form_<?php
echo $this->param->default_form;
?>
_1" id="rm_fab_register_redirect_link"><div class="rm-popup-item dbfl" id="rm-register-open-big"><?php
echo RM_UI_Strings::get('LABEL_REGISTER');
?>
</div></a>
<?php
}
}
?>
<div class="rm-popup-item dbfl" id="rm-submissions-open"><?php
echo RM_UI_Strings::get('LABEL_MY_SUBS');
?>
</div>
<div class="rm-popup-item dbfl" id="rm-transactions-open"><?php
echo RM_UI_Strings::get('LABEL_PAYMENTS');
?>
</div>
<?php
if ($this->user_level === 0x1 || $this->user_level === 0x4) {
?>
<div class="rm-popup-item dbfl" id="rm-account-open"><?php
echo RM_UI_Strings::get('LABEL_MY_DETAILS');
?>
//.........这里部分代码省略.........
示例5: cjtheme_wp_avatar_url
function cjtheme_wp_avatar_url($user_id_or_email, $args = null)
{
$user_id = cjtheme_user_info($user_id_or_email, 'ID');
$args = get_avatar_data($user_id, $args);
$url = $args['url'];
$url = apply_filters('cjtheme_wp_avatar_url', $user_id, $url);
return $url;
}
示例6: get_preview_user_data
/**
* Get the preview user data.
*
* @param int $user_id The user ID.
* @return array|null
*/
public function get_preview_user_data($user_id)
{
$user = get_user_by('id', intval($user_id));
if (!$user) {
return null;
}
return array('user_id' => $user->ID, 'display_name' => $user->display_name, 'avatar' => get_avatar_data($user->ID, array('size' => 40)));
}
示例7: dln_get_avatar
/**
* @return false|string
*/
function dln_get_avatar()
{
$user = wp_get_current_user();
$avatar = '';
if ($user->ID) {
$facebook_login_id = get_user_meta($user->ID, 'facebook_login_id', true);
if ($facebook_login_id) {
$avatar = "https://graph.facebook.com/{$facebook_login_id}/picture?type=normal";
} else {
$avatar = get_avatar_data($user->user_email);
$avatar = !empty($avatar['url']) ? $avatar['url'] : '';
}
}
return $avatar;
}