Аватару по умолчанию тянет с Gravatar

I
На сайте с 02.12.2009
Offline
71
1028

В одном блоке на главной странице все отлично, аватару по умолчанию тянет с локального. Вывод вот такой:

<?php if(function_exists('get_avatar')){ ?>

<div style="float: left;border: 0px dotted #cccccc;padding: 1px;margin-right: 5px;"><?=get_avatar($comment->user_id, '60');?></div>

<?php } ?>

А в других местах, если загрузить аватару, тянет с локального. А если не загружать, не показывает по умолчанию, а тянет с Граватара. В sourse получается <img alt="" src="http://0.gravatar.com/avatar/ce5cb7aa3da8e2cdd53b8a230f80334f?s=60&amp;d=60&amp;r=R" class="avatar avatar-60 photo" height="60" width="60">

Не понимаю, почему? В чем ошибка?

Вывод такой:

echo '<div style="float: left;border: 0px dotted #cccccc;padding-top: 1px;margin-right: 20px;">'.get_avatar($post->post_author, '60','60').'</div>';

и такой:

<div style="float:left;margin-right:7px;border-right:5px #ffffff solid;"><?php if(function_exists('get_avatar')){ ?>

<?=get_avatar($post->post_author, '60','60');?>

<?php } ?></div>

LEOnidUKG
На сайте с 25.11.2006
Offline
1722
#1

и ч0?

ищите в файле с функциями, функцию get_avatar и смотрите, что там

✅ Мой Телеграм канал по SEO, оптимизации сайтов и серверов: https://t.me/leonidukgLIVE ✅ Качественное и рабочее размещение SEO статей СНГ и Бурж: https://getmanylinks.ru/
I
На сайте с 02.12.2009
Offline
71
#2

Сейчас посмотрю.

---------- Добавлено 08.11.2012 в 01:01 ----------

Там нет ни слова про аватары

<?php

remove_action( ‘wp_head’, ‘wp_generator’);
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
function getPostImage(){
global $post;
$values = get_post_custom_values("Image");
if(!$values){
$attachments = get_children( array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1) );
if($attachments){
foreach($attachments as $id => $attachment) {
$img = wp_get_attachment_image_src($id, 'full');
$img_url = parse_url($img[0], PHP_URL_PATH);
}

}
}else{
$img_url = '/wp-content/themes/mimbo2.2/images/'.$values[0];
}

if(!$img_url){
return false;
}else{
return $img_url;
}

}


add_action('thesis_hook_after_post','related_posts');
add_filter('wp_list_categories','ccats');
function ccats($list) {
if ( ! is_single() ) return $list;
foreach((get_the_category()) as $category) {
$temp[] = $category->cat_ID;
}
$temp = '/(cat-item-('.join('|',$temp).'))[ |"]/';
$list = preg_replace($temp,' current-cat $1"',$list);
return $list;
}
function reverse_wpautop($s)
{
//remove any new lines already in there
$s = str_replace("\n", "", $s);

//remove all <p>
$s = str_replace("<p>", "", $s);

//replace <br /> with \n
$s = str_replace(array("<br />", "<br>", "<br>"), "\n", $s);

//replace </p> with \n\n
$s = str_replace("</p>", "\n\n", $s);

$s = preg_replace("/(\n\n)$/im", "", $s);

return $s;
}

if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'myimg', 390, 250, true );
}

function trim_excerpt($text) {
return rtrim($text,'[...]');
}
add_filter('get_the_excerpt', 'trim_excerpt');

function dimox_breadcrumbs() {

$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
$delimiter = ' › '; // delimiter between crumbs
$home = 'Главная'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<span class="current">'; // tag before the current crumb
$after = '</span>'; // tag after the current crumb
///////////////////////get comment page
global $wp_query;
$comment_page = intval($wp_query->query_vars['cpage']);
///////////////////////get comment page

global $post;
$homeLink = get_bloginfo('url');
$read_link = '<a href="' . $homeLink . '/read">Журнал</a> ' . $delimiter . ' ';

if (is_home() || is_front_page()) {

if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';

} else {

echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';

if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if(!in_array($cat_obj->term_id, array(25, 43, 86)) && 0)
echo $read_link;
if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
echo $before . '' . single_cat_title('', false) . '' . $after;

} elseif ( is_search() ) {
echo $before . 'Результаты поиска "' . get_search_query() . '"' . $after;

} elseif ( is_day() ) {
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;

} elseif ( is_month() ) {
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;

} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;

} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} else {
if(!in_category(25) && !in_category(43) && !in_category(86) && 0)
echo $read_link;
$cat = get_the_category(); $cat = $cat[0];
$cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
if ($showCurrent == 0) $cats = preg_replace("/^(.+)\s$delimiter\s$/", "$1", $cats);
echo $cats;
if(in_category(43)){
$category_link = get_category_link( 43 );
$post = get_post(get_the_ID());
$author = get_userdata( $post->post_author );
//print_r($author->data->user_id);
//echo $author->display_name.''. ' ' . $delimiter . ' ';
echo '<a href="'.get_author_posts_url($author->data->user_id).'" title="'.$author->display_name.'">'.$author->display_name.'</a>'. ' ' . $delimiter . ' ';
}
if ($showCurrent == 1) echo $before . get_the_title() . $after;
}

} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;



function maxsite_str_word($text, $counttext = 10, $sep = ' ') {
$words = split($sep, $text);
if ( count($words) > $counttext )
$text = join($sep, array_slice($words, 0, $counttext));
return $text;
}

function comment_is_small($text, $counttext = 10, $sep = ' ') {
$words = split($sep, $text);
if ( count($words) > $counttext ){
return 0;
}
return 1;
}


function get_category_tags($args) {
global $wpdb;
$tags = $wpdb->get_results
("
SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link, count(p1.ID) as tag_count
FROM
wp_posts as p1
LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID
LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id
LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,

wp_posts as p2
LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID
LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id
LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id
WHERE
t1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND
t2.taxonomy = 'post_tag' AND p2.post_status = 'publish'
AND p1.ID = p2.ID
GROUP BY terms2.term_id
ORDER by tag_count DESC, RAND()
LIMIT 15
");
$count = 0;
foreach ($tags as $tag) {
$tags[$count]->tag_link = get_tag_link($tag->tag_id);
$count++;
}
return $tags;
}
add_filter( 'wp_tag_cloud', 'wpse_50242_unstyled_tag_cloud' );

function wpse_50242_unstyled_tag_cloud( $tags )
{
//return preg_replace(
// "~ style='font-size: (\d+)pt;'~",
// ' class="tag-cloud-size-\1"',
// $tags
// );
return $tags;
}

// this can live in /themes/mytheme/functions.php, or maybe as a dev plugin?
function get_template_name() {
foreach ( debug_backtrace() as $called_file ) {
foreach ( $called_file as $index ) {
if ( !is_array($index[0]) AND strstr($index[0],'/themes/') AND !strstr($index[0],'footer.php') ) {
$template_file = $index[0] ;
}
}
}
$template_contents = file_get_contents($template_file) ;
preg_match_all("(Template Name:(.*)\n)siU",$template_contents,$template_name);
$template_name = trim($template_name[1][0]);
if ( !$template_name ) { $template_name = '(default)' ; }
$template_file = array_pop(explode('/themes/', basename($template_file)));
return $template_file . ' > '. $template_name ;
}

?>
PR
На сайте с 30.12.2007
Offline
93
#3

http://codex.wordpress.org/Function_Reference/get_avatar

Source File
get_avatar() is located in wp-includes/pluggable.php.
I
На сайте с 02.12.2009
Offline
71
#4

Ой, большое спасибо. Ато фанкшн, фанкшн. Пойду смотреть pluggable. Хотя так странно, что в одном месте работает, а в другом нет.

Не понимаю, почему написано else и дефолт и граватар? Парни, подскажите, пожалуйста, кто в коде разбирается, пожалуйста. Нафик не нужен граватар, если не подгружен. Дефолт во всех, всех, всех случаях http://www.site.ru/images/comments-image.gif

}else{

}

if ( empty($default) ) {

$avatar_default = get_option('avatar_default');

if ( empty($avatar_default) )

$default = 'mystery';

else

$default = $avatar_default;

}

if ( !empty($email) )

$email_hash = md5( strtolower( $email ) );

if ( is_ssl() ) {

$host = 'https://secure.gravatar.com';

} else {

if ( !empty($email) )

$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );

else

$host = 'http://0.gravatar.com';

}

if ( 'mystery' == $default )

//$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')

$default = site_url().'/images/comments-image.gif';

elseif ( 'blank' == $default )

$default = includes_url('images/blank.gif');

elseif ( !empty($email) && 'gravatar_default' == $default )

$default = '';

elseif ( 'gravatar_default' == $default )

$default = "$host/avatar/s={$size}";

elseif ( empty($email) )

$default = "$host/avatar/?d=$default&amp;s={$size}";

elseif ( strpos($default, 'http://') === 0 )

$default = add_query_arg( 's', $size, $default );

if ( !empty($email) ) {

$out = "$host/avatar/";

$out .= $email_hash;

$out .= '?s='.$size;

$out .= '&amp;d=' . urlencode( $default );

$rating = get_option('avatar_rating');

if ( !empty( $rating ) )

$out .= "&amp;r={$rating}";

$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";

} else {

$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";

}

return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);

}

endif;

if ( !function_exists( 'wp_text_diff' ) ) :

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий