get_avatar(). see #5775
git-svn-id: http://svn.automattic.com/wordpress/trunk@6748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
04a6478e12
commit
36a651ef92
|
@ -235,6 +235,10 @@ function populate_options() {
|
|||
// 2.2
|
||||
add_option('tag_base');
|
||||
|
||||
// 2.5
|
||||
add_option('show_avatars', '1');
|
||||
add_option('avatar_rating', 'G');
|
||||
|
||||
// Delete unused options
|
||||
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
|
||||
foreach ($unusedoptions as $option) :
|
||||
|
|
|
@ -75,6 +75,41 @@ include('admin-header.php');
|
|||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="options">
|
||||
<legend><?php _e('Avatars') ?></legend>
|
||||
<table class="niceblue">
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"><?php _e('Show Avatars?') ?></th>
|
||||
<td>
|
||||
<select name="show_avatars" id="show_avatars">
|
||||
<?php
|
||||
$yesorno = array(0 => __("Don't show Avatars"), 1 => __('Show Avatars'));
|
||||
foreach ( $yesorno as $key => $value) {
|
||||
$selected = (get_option('show_avatars') == $key) ? 'selected="selected"' : '';
|
||||
echo "\n\t<option value='$key' $selected>$value</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"><?php _e('Show Avatars with Rating:') ?></th>
|
||||
<td>
|
||||
<select name="avatar_rating" id="avatar_rating">
|
||||
<?php
|
||||
$ratings = array( 'G' => _c('G|rating'), 'PG' => _c('PG|Rating'), 'R' => _c('R|Rating'), 'X' => _c('X|Rating'));
|
||||
foreach ($ratings as $key => $rating) :
|
||||
$selected = (get_option('avatar_rating') == $key) ? 'selected="selected"' : '';
|
||||
echo "\n\t<option value='$key' $selected>$rating</option>";
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<table class="niceblue">
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th>
|
||||
|
@ -88,7 +123,7 @@ include('admin-header.php');
|
|||
</p>
|
||||
<p class="submit">
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
|
||||
<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts,show_avatars,avatar_rating" />
|
||||
<input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 787 B |
Binary file not shown.
After Width: | Height: | Size: 920 B |
Binary file not shown.
After Width: | Height: | Size: 1015 B |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -1162,6 +1162,62 @@ function wp_set_password( $password, $user_id ) {
|
|||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists( 'get_avatar' ) ) :
|
||||
/**
|
||||
* get_avatar() - Get avatar for a user
|
||||
*
|
||||
* Retrieve the avatar for a user provided a user ID or email address
|
||||
*
|
||||
* @since 2.5
|
||||
* @param int|string $id_or_email A user ID or email address
|
||||
* @param int $size Size of the avatar image
|
||||
* @param string $default URL to a default image to use if no avatar is available
|
||||
* @return string <img> tag for the user's avatar
|
||||
*/
|
||||
function get_avatar( $id_or_email, $size = '96', $default = '' ) {
|
||||
if ( ! get_option('show_avatars') )
|
||||
return false;
|
||||
|
||||
if ( is_numeric($id_or_email) ) {
|
||||
$id = (int) $id_or_email;
|
||||
$user = get_userdata($id);
|
||||
if ( !$user)
|
||||
$email = '';
|
||||
else
|
||||
$email = $user->user_email;
|
||||
} else {
|
||||
$email = $id_or_email;
|
||||
}
|
||||
|
||||
$default_sizes = array(16, 32, 48, 96, 128);
|
||||
if ( empty($default) ) {
|
||||
if ( in_array($size, $default_sizes) )
|
||||
$default = trailingslashit(get_bloginfo('wpurl')) . "wp-includes/images/avatar/unknown-$size.jpg";
|
||||
else
|
||||
$default = trailingslashit(get_bloginfo('wpurl')) . "wp-includes/images/avatar/unknown-96.jpg";
|
||||
}
|
||||
|
||||
if ( !empty($email) ) {
|
||||
$default = urlencode( $default );
|
||||
|
||||
$out = 'http://www.gravatar.com/avatar.php?gravatar_id=';
|
||||
$out .= md5( $email );
|
||||
$out .= "&size={$size}";
|
||||
$out .= "&default={$default}";
|
||||
|
||||
$rating = get_option('avatar_rating');
|
||||
if ( !empty( $rating ) )
|
||||
$out .= "&rating={$rating}";
|
||||
|
||||
$avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />";
|
||||
} else {
|
||||
$avatar = "<img alt='' src='{$default}' />";
|
||||
}
|
||||
|
||||
return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default);
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('wp_setcookie') ) :
|
||||
/**
|
||||
* wp_setcookie() - Sets a cookie for a user who just logged in
|
||||
|
|
|
@ -16,6 +16,6 @@ $wp_version = '2.4-bleeding';
|
|||
*
|
||||
* @global int $wp_db_version
|
||||
*/
|
||||
$wp_db_version = 6736;
|
||||
$wp_db_version = 6748;
|
||||
|
||||
?>
|
Loading…
Reference in New Issue