function comicpress_display_author_gravatar($is_comic = false) { global $post, $wp_query, $is_IE; if (is_page()) { return; } if (!$is_comic && comicpress_themeinfo('enable_post_author_gravatar') || $is_comic && comicpress_themeinfo('enable_comic_post_author_gravatar')) { $author_get_gravatar = get_avatar(get_the_author_meta('email'), 64, comicpress_random_default_avatar(get_the_author_meta('email'), get_the_author_meta('display_name'))); if (!$is_IE) { $author_get_gravatar = str_replace('photo', 'photo instant nocorner itxtalt', $author_get_gravatar); } $author_gravatar = "<div class=\"post-author-gravatar\">" . $author_get_gravatar . "</div>\r\n"; echo apply_filters('comicpress_display_author_gravatar', $author_gravatar); } }
/** * Better display of avatars in comments * Should only be used in comment sections (may update in future) * Checks for false empty commenter URLs 'http://' w/registered users * Adds the class 'photo' to the image * Adds a call to 'images/trackback.jpg' for trackbacks * Adds a call to 'images/pingback.jpg' for pingbacks * * Filters should only return a string for an image URL for the avatar with class $avatar * They should not get the avatar as this is done after the filter * * @since 0.2 * @filter */ function comicpress_avatar() { global $comment; $url = get_comment_author_url(); $comment_type = get_comment_type(); if ($comment_type != 'pingback' && $comment_type != 'trackback') { echo '<div class="comment-avatar">'; if ($url == true && $url != 'http://') { echo '<a href="' . $url . '" rel="external nofollow" title="' . esc_html(get_comment_author(), 1) . '">'; } $id_or_email = get_comment_author_email(); if (empty($id_or_email)) { $id_or_email = get_comment_author(); } $return_str = str_replace('photo', 'photo instant nocorner itxtalt', get_avatar($id_or_email, 64, comicpress_random_default_avatar($id_or_email), esc_html(get_comment_author(), 1))); echo $return_str; if ($url == true && $url != 'http://') { echo '</a>'; } echo '</div>'; } }
} else { ?> <div <?php post_class(); ?> > <?php if (comicpress_themeinfo('enable_caps')) { ?> <div class="post-head"></div><?php } ?> <div class="post-content"> <div class="userpage-avatar"> <?php echo str_replace('photo', 'photo instant nocorner itxtalt', get_avatar($curauth->user_email, 64, comicpress_random_default_avatar($curauth->user_email), esc_attr($curauth->display_name, 1))); ?> </div> <div class="userpage-info"> <div class="userpage-bio"> <?php if ($curauth->display_name) { $authorname = $curauth->display_name; } elseif ($curauth->user_nickname) { $authorname = $curauth->nickname; } elseif ($curauth->user_nicename) { $authorname = $curauth->user_nicename; } else { $authorname = $curauth->user_login; } ?>
/** * Retrieve the avatar for a user who provided a user ID or email address. * * @since 2.5 * @param int|string|object $id_or_email A user ID, email address, or comment object * @param int $size Size of the avatar image * @param string $default URL to a default image to use if no avatar is available * @param string $alt Alternate text to use in image tag. Defaults to blank * @return string <img> tag for the user's avatar */ function comicpress_get_avatar($id_or_email, $size = '64', $alt = false) { global $comicpress_options; 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 ($comicpress_options['avatar_directory'] != 'none' || empty($default)) { $default = comicpress_random_default_avatar((string) $id_or_email); } if (empty($default)) { $avatar_default = get_option('avatar_default'); if (empty($avatar_default)) { $default = 'mystery'; } else { $default = $avatar_default; } } if ('mystery' == $default) { $default = "http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; } 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 = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo instant nocorner itxtalt' height='{$size}' width='{$size}' />"; } else { $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default instant nocorner itxtalt' height='{$size}' width='{$size}' />"; } return apply_filters('comicpress_get_avatar', $avatar, $id_or_email, $size, $default, $alt); }