user made icons!
Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
|
@ -214,6 +214,11 @@ $options = array (
|
|||
"default" => "silver",
|
||||
"type" => "comicpress-themepack_directory"),
|
||||
|
||||
array(
|
||||
"id" => "comicpress-icon_directory",
|
||||
"default" => "default",
|
||||
"type" => "comicpress-icon_directory"),
|
||||
|
||||
array("type" => "close")
|
||||
);
|
||||
?>
|
|
@ -365,6 +365,33 @@ function comicpress_admin() {
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<?php break;
|
||||
case "comicpress-icon_directory":
|
||||
$current_icon_directory = get_option($value['id']);
|
||||
if (empty($current_icon_directory)) $current_icon_directory = 'default';
|
||||
|
||||
$count = count($results = glob(get_template_directory() . '/images/icons/'.$current_icon_directory.'/*'));
|
||||
$icon_directories = glob(get_template_directory() . '/images/icons/*');
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><strong>Icon (no Gravatar) Directory</strong><br /><br />Choose a directory to get the icons for default gravatars if someone doesnt have one.<br /></th>
|
||||
<td valign="top">
|
||||
<label>
|
||||
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
|
||||
<?php
|
||||
foreach ($icon_directories as $icon_dirs) {
|
||||
if (is_dir($icon_dirs)) {
|
||||
$icon_dir_name = basename($icon_dirs); ?>
|
||||
<option class="level-0" value="<?php echo $icon_dir_name; ?>" <?php if ($current_icon_directory == $icon_dir_name) { ?>selected="selected"<?php } ?>><?php echo $icon_dir_name; ?></option>
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,13 +84,15 @@ if (get_option('upload_path') !== false) {
|
|||
'contact_in_menubar' => 'contact_in_menubar',
|
||||
'disable_dynamic_menubar_links' => 'disable_dynamic_menubar_links',
|
||||
'disable_footer_text' => 'disable_footer_text',
|
||||
'themepack_directory' => 'themepack_directory' ) as $options => $variable_name) {
|
||||
'themepack_directory' => 'themepack_directory',
|
||||
'icon_directory' => 'icon_directory' ) as $options => $variable_name) {
|
||||
$variables_to_extract[$variable_name] = get_option("comicpress-${options}");
|
||||
}
|
||||
|
||||
extract($variables_to_extract);
|
||||
}
|
||||
|
||||
if (empty($icon_directory)) $icon_directory = 'default';
|
||||
if (empty($themepack_directory)) $themepack_directory = 'silver';
|
||||
if (empty($graphicnav_directory)) $graphicnav_directory = 'default';
|
||||
if (empty($moods_directory)) $moods_directory = 'default';
|
||||
|
|
|
@ -16,5 +16,4 @@ function sc_note( $atts, $content = null ) {
|
|||
return '';
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
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 = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' title='{$safe_alt}' />";
|
||||
} else {
|
||||
$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' title='{$safe_alt}' />";
|
||||
}
|
||||
|
||||
return apply_filters('comicpress_get_avatar', $avatar, $id_or_email, $size, $default, $alt);
|
||||
}
|
||||
|
||||
function comicpress_random_default_avatar($id_or_email = '') {
|
||||
$current_icon_directory = get_option('comicpress-icon_directory');
|
||||
if (empty($current_icon_directory)) $current_icon_directory = 'default';
|
||||
|
||||
$count = count($results = glob(get_template_directory() . '/images/icons/'.$current_icon_directory.'/*'));
|
||||
$default = '';
|
||||
|
||||
$checknum = hexdec(substr(md5($id_or_email),0,5)) % $count;
|
||||
var_dump($id_or_email);
|
||||
var_dump($checknum);
|
||||
var_dump($count);
|
||||
if ($count > 0) {
|
||||
$default = basename($results[(int)$checknum]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return get_bloginfo('stylesheet_directory').'/images/icons/'.$current_icon_directory.'/'.$default;
|
||||
}
|
||||
|
||||
function letter_to_number($letter = '') {
|
||||
if (!empty($letter)) {
|
||||
if ($letter == 'a') $number = 1;
|
||||
if ($letter == 'b') $number = 2;
|
||||
if ($letter == 'c') $number = 3;
|
||||
if ($letter == 'd') $number = 4;
|
||||
if ($letter == 'e') $number = 5;
|
||||
if ($letter == 'f') $number = 6;
|
||||
if ($letter == 'g') $number = 7;
|
||||
if ($letter == 'h') $number = 8;
|
||||
if ($letter == 'i') $number = 9;
|
||||
if ($letter == 'j') $number = 10;
|
||||
if ($letter == 'k') $number = 11;
|
||||
if ($letter == 'l') $number = 12;
|
||||
if ($letter == 'm') $number = 13;
|
||||
if ($letter == 'n') $number = 14;
|
||||
if ($letter == 'o') $number = 15;
|
||||
if ($letter == 'p') $number = 16;
|
||||
if ($letter == 'q') $number = 17;
|
||||
if ($letter == 'r') $number = 18;
|
||||
if ($letter == 's') $number = 19;
|
||||
if ($letter == 't') $number = 20;
|
||||
if ($letter == 'u') $number = 21;
|
||||
if ($letter == 'v') $number = 22;
|
||||
if ($letter == 'w') $number = 23;
|
||||
if ($letter == 'x') $number = 24;
|
||||
if ($letter == 'y') $number = 25;
|
||||
if ($letter == 'z') $number = 26;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $number;
|
||||
}
|
||||
|
||||
?>
|
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
|
@ -35,9 +35,10 @@ function comicpress_avatar() {
|
|||
// $avatar = apply_filters('comicpress_avatar', $avatar);
|
||||
if($url == true && $url != 'http://')
|
||||
echo '<a href="' . $url . '" rel="external nofollow" title="' . wp_specialchars(get_comment_author(), 1) . '">';
|
||||
|
||||
$id_or_email = get_comment_author_email();
|
||||
if (empty($id_or_email)) $id_or_email = get_comment_author();
|
||||
if(function_exists('get_avatar') && $comment_type != 'pingback' && $comment_type != 'trackback' ) {
|
||||
echo str_replace("alt='", "alt='".wp_specialchars(get_comment_author(), 1)."' title='".wp_specialchars(get_comment_author(), 1), get_avatar(get_comment_author_email(), 64));
|
||||
echo str_replace("alt='", "alt='".wp_specialchars(get_comment_author(), 1)."' title='".wp_specialchars(get_comment_author(), 1), comicpress_get_avatar($id_or_email, 64));
|
||||
} else {
|
||||
if ($comment_type == 'pingback' || $comment_type == 'trackback') {
|
||||
echo '<img src="'.get_bloginfo('stylesheet_directory').$avatar.'" class="photo trackping" />';
|
||||
|
|