From cc980c5bc19e86078a0b4dddc240b599005639b8 Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Mon, 7 Sep 2009 06:38:00 -0700 Subject: [PATCH] renamed gravatars to avatars Signed-off-by: Philip M. Hofer (Frumph) --- functions/gravatars.php | 98 ----------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 functions/gravatars.php diff --git a/functions/gravatars.php b/functions/gravatars.php deleted file mode 100644 index ffdbd7b..0000000 --- a/functions/gravatars.php +++ /dev/null @@ -1,98 +0,0 @@ - tag for the user's avatar -*/ -function comicpress_get_avatar( $id_or_email, $size = '64', $alt = false) { - if ( ! get_option('show_avatars') ) - return false; - - if ( false === $alt) - $safe_alt = ''; - else - $safe_alt = attribute_escape( $alt ); - - if ( !is_numeric($size) ) - $size = '96'; - - $email = ''; - if ( is_numeric($id_or_email) ) { - $id = (int) $id_or_email; - $user = get_userdata($id); - if ( $user ) - $email = $user->user_email; - } elseif ( is_object($id_or_email) ) { - if ( isset($id_or_email->comment_type) && '' != $id_or_email->comment_type && 'comment' != $id_or_email->comment_type ) - return false; // No avatar for pingbacks or trackbacks - - if ( !empty($id_or_email->user_id) ) { - $id = (int) $id_or_email->user_id; - $user = get_userdata($id); - if ( $user) - $email = $user->user_email; - } elseif ( !empty($id_or_email->comment_author_email) ) { - $email = $id_or_email->comment_author_email; - } - } else { - $email = $id_or_email; - } - - if ( empty($default) ) { - $default = comicpress_random_default_avatar((string)$id_or_email); - } - - if ( 'mystery' == $default ) - $default = "http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com') - elseif ( 'blank' == $default ) - $default = includes_url('images/blank.gif'); - elseif ( !empty($email) && 'gravatar_default' == $default ) - $default = ''; - elseif ( 'gravatar_default' == $default ) - $default = "http://www.gravatar.com/avatar/s={$size}"; - elseif ( empty($email) ) - $default = "http://www.gravatar.com/avatar/?d=$default&s={$size}"; - elseif ( strpos($default, 'http://') === 0 ) - $default = add_query_arg( 's', $size, $default ); - - if ( !empty($email) ) { - $out = 'http://www.gravatar.com/avatar/'; - $out .= md5( strtolower( $email ) ); - $out .= '?s='.$size; - $out .= '&d=' . urlencode( $default ); - - $rating = get_option('avatar_rating'); - if ( !empty( $rating ) ) - $out .= "&r={$rating}"; - - $avatar = "{$safe_alt}"; - } else { - $avatar = "{$safe_alt}"; - } - - return apply_filters('comicpress_get_avatar', $avatar, $id_or_email, $size, $default, $alt); -} - -function comicpress_random_default_avatar($id_or_email = '') { - $current_avatar_directory = get_option('comicpress-avatar_directory'); - if (empty($current_avatar_directory)) $current_avatar_directory = 'default'; - - $count = count($results = glob(get_template_directory() . '/images/avatars/'.$current_avatar_directory.'/*')); - $default = ''; - - $checknum = hexdec(substr(md5($id_or_email),0,5)) % $count; - if ($count > 0) { - $default = basename($results[(int)$checknum]); - } else { - return false; - } - return get_bloginfo('stylesheet_directory').'/images/avatars/'.$current_avatar_directory.'/'.$default; -} - -?> \ No newline at end of file