function qb_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; //$avatar = get_avatar( $comment, 48 ); $comment_author_id = get_comment(get_comment_ID())->user_id; $comment_author_url = get_comment_author_url(); if (has_wp_user_avatar($comment_author_id)) { //$avatar = get_wp_user_avatar_src( $comment_author_id, 48 ); $avatar = get_wp_user_avatar($comment_author_id, 48); } else { //$avatar = get_bloginfo( 'template_url' ) . '/images/default/48.png'; // temporary: this is the same for now, for testing; eventually, it should fall back to default image or Facebook image or smt else //$avatar = get_wp_user_avatar_src( $comment_author_id, 48 ); $avatar = get_wp_user_avatar($comment_author_id, 48); } ?> <li <?php get_comment_class(); ?> ><?php if ($comment_author_url) { echo '<a href="' . $comment_author_url . '">' . $avatar . get_comment_author() . '</a>'; } else { echo $avatar . get_comment_author(); } echo '<time class="timeago" datetime="' . get_comment_date('c') . '">' . get_comment_date('F j, Y') . '</time>'; comment_text(); //edit_comment_link( 'Edit', '<span class="edit">', '</span>' ); if ($comment->comment_approved == '0') { echo '<em class="moderate">Your comment is awaiting moderation.</em>'; } /*comment_reply_link( array_merge( $args, array( 'reply_text' => 'Reply', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) );*/ echo '</li>'; }
*/ if ($members) { echo '<main>'; foreach ($members as $member) { // get user info $member_id = $member['board_members_user']['ID']; $member_screen_name = $member['board_members_user']['display_name']; $member_username = $member['board_members_user']['user_nicename']; $member_description = $member['board_members_user']['user_description']; $member_home_url = get_bloginfo('home') . '/author/' . $member_username; // count stats $quotecount = count_user_posts_by_type($member_id, 'quote'); $boardcount = count_user_posts_by_type($member_id, 'board'); //$follower_count = $wpdb->get_var( "SELECT COUNT(*) FROM wp_qb_followers WHERE follower_id = '$member_id'" ); // member thumbnail if (has_wp_user_avatar($member_id)) { $avatar = get_wp_user_avatar_src($member_id, 80); } else { $avatar = DEFAULT_THUMBNAIL; } // member background if ($background_id = get_user_meta($member_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($member_description = get_user_meta($member_id, 'description', true)) > 200) { $member_description = substr($member_description, 0, 200) . '...';
/** * 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> <p id="<?php echo $user == 'add-new-user' ? 'wpua-upload-messages' : 'wpua-upload-messages-existing'; ?> "> <span id="<?php echo $user == 'add-new-user' ? 'wpua-max-upload' : 'wpua-max-upload-existing'; ?> " class="description"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?> </span> <span id="<?php echo $user == 'add-new-user' ? 'wpua-allowed-files' : 'wpua-allowed-files-existing'; ?> " class="description"><?php _e('Allowed Files'); ?> : <?php _e('<code>jpg jpeg png gif</code>'); ?> </span> </p> <?php } ?> <div id="<?php echo $user == 'add-new-user' ? 'wpua-images' : 'wpua-images-existing'; ?> " class="<?php echo $hide_images; ?> "> <p id="<?php echo $user == 'add-new-user' ? 'wpua-preview' : 'wpua-preview-existing'; ?> "> <img src="<?php echo $avatar_medium; ?> " alt="" /> <span class="description"><?php _e('Original Size'); ?> </span> </p> <p id="<?php echo $user == 'add-new-user' ? 'wpua-thumbnail' : 'wpua-thumbnail-existing'; ?> "> <img src="<?php echo $avatar_thumbnail; ?> " alt="" /> <span class="description"><?php _e('Thumbnail'); ?> </span> </p> <p id="<?php echo $user == 'add-new-user' ? 'wpua-remove-button' : 'wpua-remove-button-existing'; ?> " class="<?php echo $hide_remove; ?> "> <button type="button" class="button" id="<?php echo $user == 'add-new-user' ? 'wpua-remove' : 'wpua-remove-existing'; ?> " name="wpua-remove"><?php _e('Remove Image'); ?> </button> <?php if ((bool) $wpua_edit_avatar == 1 && !$wp_user_avatar->wpua_is_author_or_above() && has_wp_user_avatar($current_user->ID) && $wp_user_avatar->wpua_author($wpua, $current_user->ID)) { // Edit button ?> <span id="<?php echo $user == 'add-new-user' ? 'wpua-edit-attachment' : 'wpua-edit-attachment-existing'; ?> "><a href="<?php echo $edit_attachment_link; ?> " class="edit-attachment" target="_blank"><?php _e('Edit Image'); ?> </a></span> <?php } ?> </p> <p id="<?php echo $user == 'add-new-user' ? 'wpua-undo-button' : 'wpua-undo-button-existing'; ?> "><button type="button" class="button" id="<?php echo $user == 'add-new-user' ? 'wpua-undo' : 'wpua-undo-existing'; ?> " name="wpua-undo"><?php _e('Undo'); ?> </button></p> </div> <?php do_action('wpua_after_avatar' . $is_admin); ?> <?php }
/** * 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 }
get_template_part('includes/get-board'); wp_reset_postdata(); } echo '</ul></div></section>'; } /** * Faves */ if ($faves = get_field('quote_fave')) { echo ' <section class="faves box"> <div class="bubble"> <h4>Faves</h4> <ul>'; foreach ($faves as $fave) { if (has_wp_user_avatar($fave['quote_fave_user']['ID'])) { $avatar = get_wp_user_avatar($fave['quote_fave_user']['ID'], 48); } else { $avatar = DEFAULT_THUMBNAIL; } echo ' <li> <a href="' . home_url('/') . 'author/' . $fave['quote_fave_user']['user_nicename'] . '">' . $avatar . $fave['quote_fave_user']['display_name'] . '</a> </li>'; } echo ' </ul> </div> </section>'; } /**
function wpua_action_show_user_profile($user) { global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_edit_avatar, $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' : ""; // If avatars are enabled, get original avatar image or show blank $avatar_medium_src = (bool) $show_avatars == 1 ? 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 ? '“' . __('Update Profile') . '”' : '“' . __('Update User') . '”'; ?> <?php do_action('wpua_before_avatar'); ?> <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 id="wpua-add-button"><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?> </button></p> <?php } elseif (!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) { // Upload button ?> <p id="wpua-upload-button"> <input name="wpua-file" id="wpua-file" type="file" /> <button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?> "><?php _e('Upload'); ?> </button> </p> <p id="wpua-upload-messages"> <span id="wpua-max-upload"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?> </span> <span id="wpua-allowed-files"><?php _e('Allowed Files'); ?> : <?php _e('<code>jpg jpeg png gif</code>'); ?> </span> </p> <?php } elseif ((bool) $wpua_edit_avatar == 1 && !current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) { // Edit button ?> <?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?> <p id="wpua-edit-button"><button type="button" class="button" id="wpua-edit" name="wpua-edit" onclick="window.open('<?php echo $edit_attachment_link; ?> ', '_self');"><?php _e('Edit Image'); ?> </button></p> <?php } ?> <?php /*?> <p id="wpua-preview"> <img src="<?php echo $avatar_medium; ?>" alt="" /> <?php _e('Original Size'); ?> </p> <?php */ ?> <p id="wpua-thumbnail"> <img src="<?php echo $avatar_thumbnail; ?> " alt="" /> <?php _e('Thumbnail'); ?> </p> <p id="wpua-remove-button"><button type="button" class="button<?php echo $hide_remove; ?> " id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?> </button></p> <p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?> </p> <?php do_action('wpua_after_avatar'); ?> <?php }
/** * Replace get_avatar only in get_wp_user_avatar * @since 1.4 * @param string $avatar * @param int|string $id_or_email * @param int|string $size * @param string $default * @param string $alt * @uses string $avatar_default * @uses string $mustache_admin * @uses string $mustache_avatar * @uses string $mustache_medium * @uses string $mustache_original * @uses string $mustache_thumbnail * @uses object $post * @uses int $wpua_avatar_default * @uses bool $wpua_disable_gravatar * @uses object $wpua_functions * @uses apply_filters() * @uses get_wp_user_avatar() * @uses has_wp_user_avatar() * @uses wpua_has_gravatar() * @uses wpua_attachment_is_image() * @uses wpua_get_attachment_image_src() * @uses get_option() * @return string $avatar */ public function wpua_get_avatar_filter($avatar, $id_or_email = "", $size = "", $default = "", $alt = "") { global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions; // User has WPUA $avatar = str_replace('gravatar_default', '', $avatar); if (is_object($id_or_email)) { if (!empty($id_or_email->comment_author_email)) { $avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt); } else { $avatar = get_wp_user_avatar('*****@*****.**', $size, $default, $alt); } } else { if (has_wp_user_avatar($id_or_email)) { $avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt); // User has Gravatar and Gravatar is not disabled } elseif ((bool) $wpua_disable_gravatar != 1 && $wpua_functions->wpua_has_gravatar($id_or_email)) { // find our src if (!empty($avatar)) { $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $avatar, $matches, PREG_SET_ORDER); $wpua_avatar_image_src = !empty($matches) ? $matches[0][1] : ""; $default_image_details = $this->wpua_default_image($size); $wpua_default_avatar_image_src = $default_image_details['src']; $wpua_final_avatar_image_src = str_replace('d=wp_user_avatar', 'd=' . urlencode($wpua_default_avatar_image_src), $wpua_avatar_image_src); } //$avatar = $avatar; $avatar = '<img src="' . $wpua_final_avatar_image_src . '"' . $default_image_details['dimensions'] . ' alt="' . $alt . '" class="avatar avatar-' . $size . ' wp-user-avatar wp-user-avatar-' . $size . ' photo avatar-default" />'; // User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar } elseif ($avatar_default == 'wp_user_avatar') { $default_image_details = $this->wpua_default_image($size); $avatar = '<img src="' . $default_image_details['src'] . '"' . $default_image_details['dimensions'] . ' alt="' . $alt . '" class="avatar avatar-' . $size . ' wp-user-avatar wp-user-avatar-' . $size . ' photo avatar-default" />'; return $avatar; } } /** * Filter get_avatar filter * @since 1.9 * @param string $avatar * @param int|string $id_or_email * @param int|string $size * @param string $default * @param string $alt */ return apply_filters('wpua_get_avatar_filter', $avatar, $id_or_email, $size, $default, $alt); }
get_header(); $curauth = get_query_var('author_name') ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); $author_email = get_the_author_meta('user_email', $curauth->ID); $twitter_profile = get_the_author_meta('twitter_profile', $curauth->ID); $linkedin_profile = get_the_author_meta('linkedin_profile', $curauth->ID); $google_profile = get_the_author_meta('google_profile', $curauth->ID); $user_url = get_the_author_meta('user_url', $curauth->ID); $facebook_profile = get_the_author_meta('facebook_profile', $curauth->ID); $github_profile = get_the_author_meta('github_profile', $curauth->ID); $pinterest_profile = get_the_author_meta('pinterest_profile', $curauth->ID); $tumbler_profile = get_the_author_meta('tumbler_profile', $curauth->ID); $template_location = get_bloginfo('template_directory'); $avatar_address = $template_location . "/images/surfagility.jpg"; $personal_avatar = false; if (function_exists('has_wp_user_avatar')) { if (has_wp_user_avatar($curauth->ID)) { $avatar_address = get_wp_user_avatar_src($curauth->ID, 'large'); $personal_avatar = true; } } ?> <!-- container div starts in header --> <!-- row div starts in header --> <div class="author-page"> <div class="col-lg-5 col-sm-5 cover" > <?php if ($personal_avatar) { ?> <div class="cover-img" style="background-image:url('<?php echo $avatar_address; ?>
/** * Replace get_avatar only in get_wp_user_avatar * @since 1.4 * @param string $avatar * @param int|string $id_or_email * @param int|string $size * @param string $default * @param string $alt * @uses string $avatar_default * @uses string $mustache_admin * @uses string $mustache_avatar * @uses string $mustache_medium * @uses string $mustache_original * @uses string $mustache_thumbnail * @uses object $post * @uses int $wpua_avatar_default * @uses bool $wpua_disable_gravatar * @uses object $wpua_functions * @uses apply_filters() * @uses get_wp_user_avatar() * @uses has_wp_user_avatar() * @uses wpua_has_gravatar() * @uses wpua_attachment_is_image() * @uses wpua_get_attachment_image_src() * @uses get_option() * @return string $avatar */ public function wpua_get_avatar_filter($avatar, $id_or_email = "", $size = "", $default = "", $alt = "") { global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions; // User has WPUA if (is_object($id_or_email)) { if (!empty($id_or_email->comment_author_email)) { $avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt); } else { $avatar = get_wp_user_avatar('*****@*****.**', $size, $default, $alt); } } else { if (has_wp_user_avatar($id_or_email)) { $avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt); // User has Gravatar and Gravatar is not disabled } elseif ((bool) $wpua_disable_gravatar != 1 && $wpua_functions->wpua_has_gravatar($id_or_email)) { $avatar = $avatar; // User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar } elseif ($avatar_default == 'wp_user_avatar') { // Show custom Default Avatar if (!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) { // Get image $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size, $size)); // Image src $default = $wpua_avatar_default_image[0]; // Add dimensions if numeric size $dimensions = ' width="' . $wpua_avatar_default_image[1] . '" height="' . $wpua_avatar_default_image[2] . '"'; } else { // Get mustache image based on numeric size comparison if ($size > get_option('medium_size_w')) { $default = $mustache_original; } elseif ($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')) { $default = $mustache_medium; } elseif ($size <= get_option('thumbnail_size_w') && $size > 96) { $default = $mustache_thumbnail; } elseif ($size <= 96 && $size > 32) { $default = $mustache_avatar; } elseif ($size <= 32) { $default = $mustache_admin; } // Add dimensions if numeric size $dimensions = ' width="' . $size . '" height="' . $size . '"'; } // Construct the img tag $avatar = '<img src="' . $default . '"' . $dimensions . ' alt="' . $alt . '" class="avatar avatar-' . $size . ' wp-user-avatar wp-user-avatar-' . $size . ' photo avatar-default" />'; } } /** * Filter get_avatar filter * @since 1.9 * @param string $avatar * @param int|string $id_or_email * @param int|string $size * @param string $default * @param string $alt */ return apply_filters('wpua_get_avatar_filter', $avatar, $id_or_email, $size, $default, $alt); }
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'])) { ?> <p id="wp-user-avatar-errors"><?php _e('File is too large.'); ?> </p> <?php } ?> <p> <?php _e('Maximum upload file size: ' . esc_html($upload_size_unit) . esc_html($byte_sizes[$u])); ?> <br /> <?php _e('Allowed file formats: JPG, GIF, PNG'); ?> </p> <?php } elseif (!current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) { // Edit button ?> <?php $edit_attachment_link = function_exists('wp_enqueue_media') ? add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')) : add_query_arg(array('attachment_id' => $wpua, 'action' => 'edit'), admin_url('media.php')); ?> <p><button type="button" class="button" id="edit-wp-user-avatar" name="edit-wp-user-avatar" onclick="window.open('<?php echo $edit_attachment_link; ?> ', '_self');"><?php _e('Edit WP User Avatar'); ?> </button></p> <?php } ?> <p id="wp-user-avatar-preview"> <img src="<?php echo $avatar_medium; ?> " alt="" /> <?php _e('Original'); ?> </p> <p id="wp-user-avatar-thumbnail"> <img src="<?php echo $avatar_thumbnail; ?> " alt="" /> <?php _e('Thumbnail'); ?> </p> <p><button type="button" class="button<?php echo $hide_remove; ?> " id="remove-wp-user-avatar" name="remove-wp-user-avatar"><?php _e('Remove'); ?> </button></p> <p id="wp-user-avatar-message"><?php _e('Press "Update ' . $profile . '" to save your changes.'); ?> </p> <?php if (class_exists('bbPress') && !is_admin()) { // Add to bbPress profile with same style ?> </fieldset> <?php } else { // Add to profile with admin style ?> </td> </tr> </table> <?php } ?> <?php echo wpua_js($user->display_name, $avatar_medium_src); // Add JS ?> <?php }