/** * 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. */ return apply_filters('get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args); }
/** * 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']; }
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/'));
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'); ?> </div> <?php } if ($this->user_level !== 0x1 && !is_user_logged_in()) { ?> <div class="rm-popup-item dbfl" id="rm_log_off" onclick="document.getElementById('rm_floating_btn_nav_form').submit()"><?php echo RM_UI_Strings::get('LABEL_LOG_OFF'); ?> </div> <form method="post" id="rm_floating_btn_nav_form"> <input type="hidden" name="rm_slug" value="rm_front_log_off"> <input type="hidden" name="rm_do_not_redirect" value="true"> </form> <?php } ?> </div> <div class="rm-magic-popup-button rm-accent-bg rm-shadow-10 dbfl" id="rm-popup-button"> <img src="<?php echo $this->widget_helper->get_fab_icon(); ?> "> </div> </div> <div class="rm-floating-page rm-rounded-corners rm-shadow-10 dbfl" id="rm-panel-page"> <div class="rm-floating-page-top rm-border rm-white-box dbfl"><?php echo RM_UI_Strings::get('LABEL_MY_SUBS'); ?> </div> <div class="rm-floating-page-content dbfl"> <!----Login Panel----> <div class="rm-floating-page-login dbfl" id="rm-login-panel"> <?php $this->widget_helper->getLoginForm(); ?> </div> <!--Registration Form--> <div class="dbfl" id="rm-register-panel-big"> <?php if ($this->param->default_form > 0 && !is_user_logged_in()) { echo do_shortcode("[RM_Form force_enable_multiform='true' id='" . $this->param->default_form . "']"); } else { echo "<div class='rm-no-default-from-notification'>" . RM_UI_Strings::get('NO_DEFAULT_FORM') . "</div>"; } ?> </div> <!----Panel page submissions area----> <div class="dbfl" id="rm-submissions-panel"> <?php if ($this->user_level !== 0x1) { $this->widget_helper->getSubmissions(); } else { echo "<div class='rm-no-default-from-notification'>" . RM_UI_Strings::get('MSG_PLEASE_LOGIN_FIRST') . "</div>"; } ?> </div> <!--------User Transaction Panel-------> <div class="dbfl" id="rm-transactions-panel"> <?php if ($this->user_level !== 0x1) { $this->widget_helper->getPayments(); } else { echo "<div class='rm-no-default-from-notification'>" . RM_UI_Strings::get('MSG_PLEASE_LOGIN_FIRST') . "</div>"; } ?> </div> <!----User Account Page----> <div class="dbfl" id="rm-account-panel"> <?php if ($this->user_level !== 0x1) { $this->widget_helper->get_account(); } else { echo "<div class='rm-no-default-from-notification'>" . RM_UI_Strings::get('MSG_PLEASE_LOGIN_FIRST') . "</div>"; } ?> </div> </div> <div class="rm-floating-page-bottom rm-border rm-white-box dbfl"> <button class="rm-rounded-corners rm-button" id="rm-panel-close"><?php echo RM_UI_Strings::get('LABEL_FIELD_ICON_CLOSE'); ?> </button> </div> </div> <?php }
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; }
/** * 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))); }
/** * @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; }