本文整理汇总了PHP中get_wp_user_avatar_src函数的典型用法代码示例。如果您正苦于以下问题:PHP get_wp_user_avatar_src函数的具体用法?PHP get_wp_user_avatar_src怎么用?PHP get_wp_user_avatar_src使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_wp_user_avatar_src函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($wpUser)
{
$this->id = $wpUser->ID;
if (function_exists('get_wp_user_avatar_src')) {
if (strlen(get_wp_user_avatar_src($this->id, 'original')) > 0) {
$this->image = get_wp_user_avatar_src($this->id, 'original');
}
}
if (!strlen($this->image) > 0) {
$this->image = 'http://grafikk.ukm.no/placeholder/person.jpg';
}
$this->company_name = get_the_author_meta('title', $this->id);
$this->login = $wpUser->user_login;
$this->nicename = $wpUser->nicename;
$this->user_email = $wpUser->user_email;
$this->url = $wpUser->url;
$this->registered = $wpUser->registered;
$this->display_name = $wpUser->display_name;
$this->firstname = $wpUser->firstname;
$this->lastname = $wpUser->lastname;
$this->nickname = $wpUser->nickname;
$this->description = $wpUser->description;
$this->facebook_url = get_the_author_meta('facebook', $this->id);
$this->title = get_the_author_meta('Title', $this->id);
$this->link = get_author_posts_url($this->id, $this->nicename);
}
示例2: get_the_category
if ($post_type == "Task") {
$post_cat = get_the_category();
} elseif ($post_type == "News") {
$post_cat = get_the_terms($post->ID, 'news-type');
} elseif ($post_type == "Event") {
$post_cat = get_the_terms($post->ID, 'event-type');
}
$title_context = '';
$context = '';
$icon = '';
$image_url = get_the_post_thumbnail($id, 'thumbnail', array('class' => 'alignright'));
if ($post_type == 'User') {
global $foundstaff;
$foundstaff++;
if (function_exists('get_wp_user_avatar_src')) {
$image_url_src = get_wp_user_avatar_src($post->user_id, 'thumbnail');
$image_url = "<img src=" . $image_url_src . " width='96' height='96' alt='" . $post->title . "' class='img";
$directorystyle = get_option('options_staff_directory_style');
// 0 = squares, 1 = circles
if ($directorystyle == 1) {
$image_url .= ' img-circle';
}
$image_url .= " alignleft' />";
} else {
$image_url = get_avatar($post->user_id, 96);
}
$userurl = get_author_posts_url($post->user_id);
$gis = "options_forum_support";
$forumsupport = get_option($gis);
if (function_exists('bp_activity_screen_index')) {
// if using BuddyPress - link to the members page
示例3: get_wp_user_avatar_src
<h1 class="page-title">About: <?php
echo $curauth->nickname . ' ' . $curauth->last_name;
?>
</h1>
</figcaption>
</figure>
<div class="wrap">
<div class="userinfo">
<?php
if (get_wp_user_avatar_src() !== '') {
?>
<figure>
<img src="/wp-includes/images/blank.gif"
style="background-image:url(<?php
echo get_wp_user_avatar_src();
?>
)">
</figure>
<?php
}
?>
<div class="profile">
<?php
if ($curauth->user_description !== '') {
?>
<h2>Über</h2>
<p><?php
echo $curauth->user_description;
?>
示例4: ht_people_shortcode
function ht_people_shortcode($atts)
{
//get any attributes that may have been passed; override defaults
$opts = shortcode_atts(array('id' => '', 'team' => ''), $atts);
$userid = $opts['id'];
$directorystyle = get_option('options_staff_directory_style');
// 0 = squares, 1 = circles
$showmobile = get_option('options_show_mobile_on_staff_cards');
// 1 = show
$fulldetails = get_option('options_full_detail_staff_cards');
$context = get_user_meta($userid, 'user_job_title', true);
if ($context == '') {
$context = "staff";
}
$icon = "user";
$user_info = get_userdata($userid);
$userurl = site_url() . '/staff/' . $user_info->user_nicename;
$displayname = get_user_meta($userid, 'first_name', true) . " " . get_user_meta($userid, 'last_name', true);
if (function_exists('get_wp_user_avatar_src')) {
$image_url_src = get_wp_user_avatar_src($userid, 'thumbnail');
$avatarhtml = "<img src=" . $image_url_src . " width='66' height='66' alt='" . $user_info->display_name . "' class='img";
if ($directorystyle == 1) {
$avatarhtml .= ' img-circle';
}
$avatarhtml .= " alignleft' />";
} else {
$avatarhtml = get_avatar($post->user_id, 66);
$avatarhtml = str_replace("photo", "photo alignleft", $avatarhtml);
}
$html = '';
$counter = 0;
$tcounter = 0;
if ($fulldetails) {
$html .= "<div class='col-lg-6 col-md-6 col-sm-6'><div class='media well well-sm'><a href='" . site_url() . "/staff/" . $user_info->user_nicename . "/'>" . $avatarhtml . "</a><div class='media-body'><p><a href='" . site_url() . "/staff/" . $user_info->user_nicename . "/'><strong>" . $displayname . "</strong></a><br>";
// display team name(s)
if (get_user_meta($userid, 'user_job_title', true)) {
$html .= get_user_meta($userid, 'user_job_title', true) . "<br>";
}
if (get_user_meta($userid, 'user_telephone', true)) {
$html .= '<i class="dashicons dashicons-phone"></i> <a href="tel:' . str_replace(" ", "", get_user_meta($userid, "user_telephone", true)) . '">' . get_user_meta($userid, 'user_telephone', true) . "</a><br>";
}
if (get_user_meta($userid, 'user_mobile', true) && $showmobile) {
$html .= '<i class="dashicons dashicons-smartphone"></i> <a href="tel:' . str_replace(" ", "", get_user_meta($userid, "user_mobile", true)) . '">' . get_user_meta($userid, 'user_mobile', true) . "</a><br>";
}
$html .= '<a href="mailto:' . $user_info->user_email . '">' . __("Email", "govintranet") . ' ' . $user_info->first_name . '</a></p></div></div></div>';
$counter++;
$tcounter++;
//end full details
} else {
$html .= "<div class='col-lg-6 col-md-6 col-sm-12'><div class='indexcard'><a href='" . site_url() . "/staff/" . $user_info->user_nicename . "/'><div class='media'>" . $avatarhtml . "<div class='media-body'><strong>" . $displayname . "</strong><br>";
if (get_user_meta($userid, 'user_job_title', true)) {
$html .= '<span class="small">' . get_user_meta($userid, 'user_job_title', true) . "</span><br>";
}
if (get_user_meta($userid, 'user_telephone', true)) {
$html .= '<span class="small"><i class="dashicons dashicons-phone"></i> ' . get_user_meta($userid, 'user_telephone', true) . "</span><br>";
}
if (get_user_meta($userid, 'user_mobile', true) && $showmobile) {
$html .= '<span class="small"><i class="dashicons dashicons-smartphone"></i> ' . get_user_meta($userid, 'user_mobile', true) . "</span>";
}
$html .= "</div></div></div></div></a>";
$counter++;
}
return "<div id='peoplenav'>" . $html . "</div>";
}
示例5: wpua_action_show_user_profile
/**
* Add to edit user profile
* @since 1.4
* @param object $user
* @uses int $blog_id
* @uses object $current_user
* @uses bool $show_avatars
* @uses object $wpdb
* @uses object $wp_user_avatar
* @uses bool $wpua_allow_upload
* @uses bool $wpua_edit_avatar
* @uses object $wpua_functions
* @uses string $wpua_upload_size_limit_with_units
* @uses add_query_arg()
* @uses admin_url()
* @uses do_action()
* @uses get_blog_prefix()
* @uses get_user_meta()
* @uses get_wp_user_avatar_src()
* @uses has_wp_user_avatar()
* @uses is_admin()
* @uses wpua_author()
* @uses wpua_get_avatar_original()
* @uses wpua_is_author_or_above()
*/
public static function wpua_action_show_user_profile($user)
{
global $blog_id, $current_user, $show_avatars, $wpdb, $wp_user_avatar, $wpua_allow_upload, $wpua_edit_avatar, $wpua_functions, $wpua_upload_size_limit_with_units;
// Get WPUA attachment ID
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id) . 'user_avatar', true);
// Show remove button if WPUA is set
$hide_remove = !has_wp_user_avatar($user->ID) ? 'wpua-hide' : "";
// Hide image tags if show avatars is off
$hide_images = !has_wp_user_avatar($user->ID) && (bool) $show_avatars == 0 ? 'wpua-no-avatars' : "";
// If avatars are enabled, get original avatar image or show blank
$avatar_medium_src = (bool) $show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original($user->user_email, 'medium') : includes_url() . 'images/blank.gif';
// Check if user has wp_user_avatar, if not show image from above
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
// Check if user has wp_user_avatar, if not show image from above
$avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
$edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php'));
// Chck if admin page
$is_admin = is_admin() ? '_admin' : "";
?>
<?php
do_action('wpua_before_avatar' . $is_admin);
?>
<input type="hidden" name="wp-user-avatar" id="<?php
echo $user == 'add-new-user' ? 'wp-user-avatar' : 'wp-user-avatar-existing';
?>
" value="<?php
echo $wpua;
?>
" />
<?php
if ($wp_user_avatar->wpua_is_author_or_above()) {
// Button to launch Media Uploader
?>
<p id="<?php
echo $user == 'add-new-user' ? 'wpua-add-button' : 'wpua-add-button-existing';
?>
"><button type="button" class="button" id="<?php
echo $user == 'add-new-user' ? 'wpua-add' : 'wpua-add-existing';
?>
" name="<?php
echo $user == 'add-new-user' ? 'wpua-add' : 'wpua-add-existing';
?>
" data-title="<?php
_e('Choose Image');
?>
: <?php
echo $user->display_name;
?>
"><?php
_e('Choose Image');
?>
</button></p>
<?php
} elseif (!$wp_user_avatar->wpua_is_author_or_above()) {
// Upload button
?>
<p id="<?php
echo $user == 'add-new-user' ? 'wpua-upload-button' : 'wpua-upload-button-existing';
?>
">
<input name="wpua-file" id="<?php
echo $user == 'add-new-user' ? 'wpua-file' : 'wpua-file-existing';
?>
" type="file" />
<button type="submit" class="button" id="<?php
echo $user == 'add-new-user' ? 'wpua-upload' : 'wpua-upload-existing';
?>
" name="submit" value="<?php
_e('Upload');
?>
"><?php
_e('Upload');
?>
</button>
</p>
//.........这里部分代码省略.........
示例6: wpua_action_show_user_profile
/**
* Add to edit user profile
* @since 1.4
* @param object/string $user
* @uses bool $show_avatars
* @uses object $wpua_functions
* @uses do_action()
* @uses get_wp_user_avatar_src()
* @uses has_wp_user_avatar()
* @uses is_admin()
* @uses wpua_get_avatar_original()
* @uses array maybe_unserialize()
* @uses get_option()
* @uses bool array_key_exists()
*/
public static function wpua_action_show_user_profile($user)
{
global $blog_id, $current_user, $show_avatars, $wpdb, $wp_user_avatar, $wpua_allow_upload, $wpua_edit_avatar, $wpua_functions, $wpua_upload_size_limit_with_units;
// Get WPUA
$user_id = '';
if (is_object($user)) {
$user_id = $user->ID;
} else {
if (absint($user)) {
$user_id = $user;
}
}
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix(wpua_get_main_blog_id()) . 'user_avatar', true);
if (isset($user->user_email)) {
$default_avatar = $wpua_functions->get_wpua_default_avatar($user->user_email, 'medium');
} else {
$default_avatar = $wpua_functions->get_wpua_default_avatar('', 'medium');
}
// Check if user has wp_user_avatar, if not show image from above
$avatar_medium_src = has_wp_user_avatar($user_id) ? get_wp_user_avatar_src($user_id, 'medium') : $default_avatar;
// Check if user has wp_user_avatar, if not show image from above
$avatar_thumbnail = has_wp_user_avatar($user_id) ? get_wp_user_avatar_src($user_id, 96) : $avatar_medium_src;
// Chck if admin page
$is_admin = is_admin() ? '_admin' : '';
?>
<?php
do_action('wpua_before_avatar' . $is_admin);
?>
<?php
wp_nonce_field('no_action', 'wpua_avatar');
?>
<input type="hidden" name="default_avatar" id="default_avatar" value="<?php
echo $default_avatar;
?>
" />
<input type="hidden" name="wp_user_avatar_url" id="<?php
echo $user == 'add-existing-user' ? 'wp-user-avatar-url-existing' : 'wp-user-avatar-url';
?>
" value="" />
<input type="hidden" name="wp-user-avatar" id="<?php
echo $user == 'add-existing-user' ? 'wp-user-avatar-existing' : 'wp-user-avatar';
?>
" value="<?php
echo $avatar_thumbnail;
?>
" />
<div id="<?php
echo $user == 'add-existing-user' ? 'wpua-add-button-existing' : 'wpua-add-button';
?>
" class="avatar-container">
<?php
// Imagepicker changes starts
?>
<img src="<?php
echo $avatar_thumbnail;
?>
" alt="" id="<?php
echo $user == 'add-existing-user' ? 'wp-user-avatar-img-existing' : 'wp-user-avatar-img';
?>
" class="choose_image" />
<?php
if (has_wp_user_avatar($user_id)) {
?>
<br><input type="button" name="btn_remove" value="<?php
_e('Delete', 'wp-user-avatar-pro');
?>
" id="delete_avatar" class="button-secondary" data-nonce="<?php
echo wp_create_nonce('wpua_avatar_delete');
?>
">
<br><input type="button" name="btn_reset" value="<?php
_e('Reset', 'wp-user-avatar-pro');
?>
" id="reset_avatar" class="button-secondary" style="display:none;">
<?php
}
?>
</div>
<br>
<?php
do_action('wpua_after_avatar' . $is_admin);
?>
<?php
}
示例7: wpdc_the_profile_photo
/**
* GET USER PROFILE IMAGE
***********************************/
function wpdc_the_profile_photo($usuario)
{
if (is_object($usuario) && is_numeric($usuario->ID)) {
$user_id = $usuario->ID;
} elseif (is_numeric($usuario)) {
$user_id = $usuario;
}
$user = get_userdata($user_id);
if (function_exists('get_wp_user_avatar_src') && get_wp_user_avatar_src($user_id, 100, 'medium') != '') {
$user_photo = get_wp_user_avatar_src($user_id, 100, 'medium');
} elseif ($user->userphoto_image_file != '') {
$user_photo = get_bloginfo('url') . '/wp-content/uploads/userphoto/' . $user->userphoto_image_file;
} else {
$user_photo = get_stylesheet_directory_uri() . '/img/default/nophoto.png';
}
echo '<div class="wrap wrap--photo" title="' . wpdc_get_user_name($user_id) . '"><img src="' . $user_photo . '"></div>';
}
示例8: foreach
$q = "select meta_value as ID, user_id, display_name from {$wpdb->users} join {$wpdb->usermeta} on {$wpdb->users}.ID = {$wpdb->usermeta}.user_id where {$wpdb->usermeta}.meta_key='user_line_manager' and {$wpdb->usermeta}.meta_value = " . $user_id;
$poduserreports = $wpdb->get_results($q, ARRAY_A);
if (count($poduserreports) > 0) {
echo "<p><i class='dashicons dashicons-arrow-down-alt2'></i></p>";
echo "<p id='directreports'>";
foreach ($poduserreports as $p) {
$pid = $p['user_id'];
$u = get_userdata($pid);
//print_r($u);
$jobtitle = get_user_meta($pid, 'user_job_title', true);
if ($jobtitle) {
$jobtitle = " - " . $jobtitle;
}
$imgstyle = '';
if (function_exists('get_wp_user_avatar')) {
$imgsrc = get_wp_user_avatar_src($pid, 'thumbnail', 'left');
$imgstyle .= " width='50' height='50'";
if ($directorystyle == 1) {
$imgstyle .= " class='img img-circle'";
} else {
$imgstyle .= " class='img'";
}
echo "<a class='tlink' data-placement='right' data-original-title = '" . $u->user_nicename . "' title='" . $u->display_name . $jobtitle . "' href='" . site_url() . "/staff/" . $u->user_nicename . "'><img src='" . $imgsrc . "' " . $imgstyle . " alt='" . $u->display_name . "'/></a>";
} else {
$imgsrc = get_avatar($user_id, 'thumbnail', '', $u->display_name);
$imgsrc = str_replace('height=\'96\'', 'height="50"', $imgsrc);
$imgsrc = str_replace('width=\'96\'', 'width="50"', $imgsrc);
echo "<a title='" . $u->display_name . "' href='" . site_url() . "/staff/" . $u->user_nicename . "'>" . $imgsrc . "</a>";
}
}
echo "</p>";
示例9: get_site_url
?>
/source/css/editor-style.css" />
<h1 style="text-align: center;font-weight: bold;display: block;font-size: 2em;font:normal 34px myrid, Arial, Helvetica, sans-serif; color: #d03423;">Instructor's Profile</h1>
<ul>
<style>
.thumb-wrapper {
position:relative;
}
</style>
<?php
$hturl = get_site_url() . "/wp-content/uploads/2013/play.png";
?>
<?php
$src_img = get_wp_user_avatar_src($userid);
//echo $userid;
//echo $src_img;
?>
<li class="list_item clearfix" style="color:#999999;">
<div class="content">
<div style="width:140px !important;float:left;padding:5px 20px 5px 5px;">
<?php
/*?><img src="images/img_akash.png" style="margin:0 0 15px 17px;" /><?php */
//echo get_avatar( $userid, '128' );
$youtubeurl = get_user_meta($userid, 'jabber', true);
?>
<?php
if ($youtubeurl) {
?>
示例10: foreach
/*
* QUOTEBOARD
* Author Following
*
* Displays the members the current user is following
*
* This template is called from author.php and is only accessed when
* the URL endpoint is 'following'
*/
$query = "SELECT * FROM wp_qb_followers WHERE follower_id = '{$current_page_user_id}'";
if ($followings = $wpdb->get_results($query)) {
foreach ($followings as $following) {
$following = get_user_by('id', $following->user_id);
$following_url = home_url('/') . 'author/' . $following->user_nicename;
// get user avatar, and specify a fallback
if (!($following_avatar = get_wp_user_avatar_src($following->ID, 80))) {
$following_avatar = DEFAULT_THUMBNAIL;
}
// count stats
$quotecount = count_user_posts_by_type($following->ID, 'quote');
$boardcount = count_user_posts_by_type($following->ID, 'board');
// member background
if ($background_id = get_user_meta($following->ID, 'user_background', true)) {
$upload_directory = wp_upload_dir();
$background_src = $wpdb->get_var("SELECT meta_value FROM {$wpdb->postmeta} WHERE post_id = '" . $background_id . "' AND meta_key = '_wp_attached_file'");
$user_background = $upload_directory['baseurl'] . '/' . $background_src;
} else {
$user_background = DEFAULT_BACKGROUND;
}
// description
if (strlen($following->description = get_user_meta($following->ID, 'description', true)) > 200) {
示例11: foreach
?>
<?php
if ($user_query->results > 100) {
echo 'wrap--masonry__100';
}
?>
">
<?php
$cont = 0;
$limit = 11;
foreach ($user_query->results as $user) {
if ($cont >= $limit) {
continue;
}
$have_photo = false;
if (function_exists('get_wp_user_avatar_src') && get_wp_user_avatar_src($user->ID, 100, 'medium') != '') {
$have_photo = true;
} elseif ($user->userphoto_image_file != '') {
$have_photo = true;
}
if (!$have_photo) {
continue;
}
wpdc_the_profile_photo($user);
$cont++;
}
if (get_option('users_can_asociate')) {
?>
<div class="wrap wrap--photo wrap--photo__upgrade" title="">
<a href="<?php
echo site_url('upgrade');
示例12: sizeof
</select>
</div>
</div>
</div>
<div class="wrap wrap--frame wrap--userlist">
<h4><?php
echo sizeof(get_post_meta(get_the_ID(), 'members_pending', true));
?>
Socios con la cuota pendiente de validar</h4>
<table>
<?php
foreach ($members_pending as $user_id => $time) {
$user = get_userdata($user_id);
$usermeta = get_user_meta($user_id);
if (function_exists('get_wp_user_avatar_src') && get_wp_user_avatar_src($user_id, 100, 'medium') != '') {
$user_photo = get_wp_user_avatar_src($user_id, 100, 'medium');
} elseif ($user->userphoto_image_file != '') {
$user_photo = get_bloginfo('url') . '/wp-content/uploads/userphoto/' . $user->userphoto_image_file;
} else {
$user_photo = get_stylesheet_directory_uri() . '/img/default/nophoto.png';
}
echo '<tr>';
echo '<td class="hideonmobile"><div class="wrap wrap--photo wrap--photo__mini" title="' . get_the_author_meta('first_name', $user_id) . ' ' . get_the_author_meta('last_name', $user_id) . '"><img src="' . $user_photo . '"></div><td>';
echo '<td><a href="' . get_author_posts_url($user_id) . '">' . get_the_author_meta('first_name', $user_id) . ' ' . get_the_author_meta('last_name', $user_id) . '</a></td>';
echo '<td>' . $time . '</td>';
echo '<td><input type="checkbox" class="hidden" id="checkbox-pen-' . $user_id . '" name="members_pendingdown[]" value="' . $user_id . '"><label for="checkbox-pen-' . $user_id . '">';
// the_svg_icon('close', 'icon--corner');
echo '</label></td>';
echo '<td><input type="checkbox" class="hidden" id="checkbox-topay-' . $user_id . '" name="members_validate[]" value="' . $user_id . '"><label for="checkbox-topay-' . $user_id . '">';
// the_svg_icon('check', 'icon--corner icon--corner__second');
echo '</label></td>';
示例13: the_category
</div>
<span class="article-categories">Published in <?php
the_category(', ');
?>
</span><span class="article-top"><a href="#top" class="top" title="Go to the top of the page">↑ Back to top</a></span>
</article><!-- end of article -->
<div class="about about-box">
<h2 class="about-title">About the Author</h2>
<div class="about-author">
<div class="about-author-bio">
<a class="about-author-avatar" href="<?php
echo get_author_posts_url(get_the_author_meta('ID'));
?>
"><img src="<?php
echo get_wp_user_avatar_src(get_the_author_meta('ID'));
?>
" width="80" height="80" alt="<?php
echo the_author_meta('display_name');
?>
"></a>
<p><span class="about-author-name"><a href="<?php
echo get_author_posts_url(get_the_author_meta('ID'));
?>
"><?php
echo the_author_meta('display_name');
?>
</a></span><br><small><?php
echo get_the_author_meta('description');
?>
</small></p>
示例14: wpua_action_show_user_profile
function wpua_action_show_user_profile($user)
{
global $wpdb, $blog_id, $current_user, $show_avatars;
// Get WPUA attachment ID
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id) . 'user_avatar', true);
// Show remove button if WPUA is set
$hide_notice = has_wp_user_avatar($user->ID) ? ' class="hide-me"' : '';
$hide_remove = !has_wp_user_avatar($user->ID) ? ' hide-me' : '';
// If avatars are enabled, get original avatar image or show blank
$avatar_medium_src = $show_avatars == '1' && is_admin() ? wpua_get_avatar_original($user->user_email, 96) : includes_url() . 'images/blank.gif';
// Check if user has wp_user_avatar, if not show image from above
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
// Check if user has wp_user_avatar, if not show image from above
$avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
// Change text on message based on current user
$profile = $current_user->ID == $user->ID ? 'Profile' : 'User';
// Max upload size
if (!function_exists('wp_max_upload_size')) {
require_once ABSPATH . 'wp-admin/includes/template.php';
}
$upload_size_unit = wp_max_upload_size();
$byte_sizes = array('KB', 'MB', 'GB');
for ($u = -1; $upload_size_unit > 1024 && $u < count($byte_sizes) - 1; $u++) {
$upload_size_unit /= 1024;
}
if ($u < 0) {
$upload_size_unit = 0;
$u = 0;
} else {
$upload_size_unit = (int) $upload_size_unit;
}
?>
<?php
if (class_exists('bbPress') && !is_admin()) {
// Add to bbPress profile with same style
?>
<h2 class="entry-title"><?php
_e('WP User Avatar');
?>
</h2>
<fieldset class="bbp-form">
<legend><?php
_e('WP User Avatar');
?>
</legend>
<?php
} else {
// Add to profile with admin style
?>
<h3><?php
_e('WP User Avatar');
?>
</h3>
<table class="form-table">
<tr>
<th><label for="wp_user_avatar"><?php
_e('WP User Avatar');
?>
</label></th>
<td>
<?php
}
?>
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php
echo $wpua;
?>
" />
<?php
if (current_user_can('upload_files')) {
// Button to launch Media uploader
?>
<p><button type="button" class="button" id="add-wp-user-avatar" name="add-wp-user-avatar"><?php
_e('Edit WP User Avatar');
?>
</button></p>
<?php
} elseif (!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) {
// Upload button
?>
<input name="wp-user-avatar-file" id="wp-user-avatar-file" type="file" />
<button type="submit" class="button" id="upload-wp-user-avatar" name="upload-wp-user-avatar" value="<?php
_e('Upload');
?>
"><?php
_e('Upload');
?>
</button>
<?php
if (isset($_GET['errors']) && $_GET['errors'] == 'type') {
?>
<p id="wp-user-avatar-errors"><?php
_e('File format is not allowed.');
?>
</p>
<?php
}
?>
<?php
$postdata = file_get_contents("php://input");
if (!empty($postdata['wp-user-avatar-file'])) {
//.........这里部分代码省略.........
示例15: wpua_shortcode
/**
* Display shortcode
* @since 1.4
* @param array $atts
* @param string $content
* @uses array $_wp_additional_image_sizes
* @uses array $all_sizes
* @uses int $blog_id
* @uses object $post
* @uses object $wpdb
* @uses do_shortcode()
* @uses get_attachment_link()
* @uses get_blog_prefix()
* @uses get_option()
* @uses get_user_by()
* @uses get_query_var()
* @uses get_the_author_meta()
* @uses get_user_meta()
* @uses get_wp_user_avatar_src()
* @uses get_wp_user_avatar()
* @uses image_add_caption()
* @uses is_author()
* @uses shortcode_atts()
* @return string
*/
public function wpua_shortcode($atts, $content = null)
{
global $all_sizes, $blog_id, $post, $wpdb;
// Set shortcode attributes
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
// Find user by ID, login, slug, or e-mail address
if (!empty($user)) {
$user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
$user = empty($user) ? get_user_by('slug', $user) : $user;
$user = empty($user) ? get_user_by('email', $user) : $user;
} else {
// Find author's name if id_or_email is empty
$author_name = get_query_var('author_name');
if (is_author()) {
// On author page, get user by page slug
$user = get_user_by('slug', $author_name);
} else {
// On post, get user by author meta
$user_id = get_the_author_meta('ID');
$user = get_user_by('id', $user_id);
}
}
// Numeric sizes leave as-is
$get_size = $size;
// Check for custom image sizes if there are captions
if (!empty($content)) {
if (in_array($size, $all_sizes)) {
if (in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
$get_size = $size == 'original' ? get_option('large_size_w') : get_option($size . '_size_w');
} else {
$get_size = $_wp_additional_image_sizes[$size]['width'];
}
}
}
// Get user ID
$id_or_email = !empty($user) ? $user->ID : 'unknown@gravatar.com';
// Check if link is set
if (!empty($link)) {
// CSS class is same as link type, except for URL
$link_class = $link;
if ($link == 'file') {
// Get image src
$link = get_wp_user_avatar_src($id_or_email, 'original');
} elseif ($link == 'attachment') {
// Get attachment URL
$link = get_attachment_link(get_the_author_meta($wpdb->get_blog_prefix($blog_id) . 'user_avatar', $id_or_email));
} else {
// URL
$link_class = 'custom';
}
// Open in new window
$target_link = !empty($target) ? ' target="' . $target . '"' : "";
// Wrap the avatar inside the link
$html = '<a href="' . $link . '" class="wp-user-avatar-link wp-user-avatar-' . $link_class . '"' . $target_link . '>' . get_wp_user_avatar($id_or_email, $get_size, $align) . '</a>';
} else {
$html = get_wp_user_avatar($id_or_email, $get_size, $align);
}
// Check if caption is set
if (!empty($content)) {
// Get attachment ID
$wpua = get_user_meta($id_or_email, $wpdb->get_blog_prefix($blog_id) . 'user_avatar', true);
// Clean up caption
$content = trim($content);
$content = preg_replace('/\\r|\\n/', "", $content);
$content = preg_replace('/<\\/p><p>/', "", $content, 1);
$content = preg_replace('/<\\/p><p>$/', "", $content);
$content = str_replace('</p><p>', "<br /><br />", $content);
$avatar = do_shortcode(image_add_caption($html, $wpua, $content, $title = "", $align, $link, $get_size, $alt = ""));
} else {
$avatar = $html;
}
return $avatar;
}