Крякозябры в твиттер-виджете

Seredniy
На сайте с 17.03.2008
Offline
251
643

Собственно такая ситуация, в виджете WP, который выводит твиты, вот такие крякозябры:

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

function display_twitter_data($id, $twituser, $twitcount, $twitdata = false){

$error = false;
if(!$twitdata):
if (false === ($twitdata = get_transient('mystique_twitter_'.$id))):
require_once(ABSPATH.'wp-includes/class-snoopy.php');
$snoopy = new Snoopy;
$response = @$snoopy->fetch("http://twitter.com/users/show/".$twituser.".json");
if ($response) $userdata = json_decode($snoopy->results, true); else $error = true;
$response = @$snoopy->fetch("http://twitter.com/statuses/user_timeline/".$twituser.".json");
if ($response) $tweets = json_decode($snoopy->results, true); else $error = true;
if(!$error):
// for php < 5 (included JSON returns object)
$userdata = mystique_objectToArray($userdata);
$tweets = mystique_objectToArray($tweets);

$twitdata = array();

$twitdata['user']['profile_image_url'] = $userdata['profile_image_url'];
$twitdata['user']['name'] = $userdata['name'];
$twitdata['user']['screen_name'] = $userdata['screen_name'];
$twitdata['user']['followers_count'] = $userdata['followers_count'];
$i = 0;
foreach($tweets as $tweet):
$twitdata['tweets'][$i]['text'] = $tweet['text'];
$twitdata['tweets'][$i]['created_at'] = $tweet['created_at'];
$twitdata['tweets'][$i]['id'] = $tweet['id'];
$i++;
endforeach;
set_transient('mystique_twitter_'.$id, $twitdata, 60); // keep the data cached 60 seconds
endif;
endif;
endif;

// only show if the twitter data from the database is newer than 6 hours
if(!$error && is_array($twitdata['tweets'])): ?>
<noindex><div class="clear-block">
<div class="avatar"><img src="<?php echo $twitdata['user']['profile_image_url']; ?>" alt="<?php echo $twitdata['user']['name']; ?>" /></div>
<div class="info"><a rel="nofollow" href="http://www.twitter.com/<?php echo $twituser; ?>"><?php echo $twitdata['user']['name']; ?> </a><br /><span class="followers"> <?php printf(__("%s followers","mystique"),$twitdata['user']['followers_count']); ?></span></div>
</div>

<ul>
<?php
$i = 0;
foreach($twitdata['tweets'] as $tweet):
$pattern = '/\@(\w+)/';
$replace = '<a rel="nofollow" href="http://twitter.com/$1">@$1</a>';
$tweet['text'] = preg_replace($pattern, $replace , $tweet['text']);
$tweet['text'] = make_clickable($tweet['text']);

// remove +XXXX
$tweettime = substr_replace($tweet['created_at'],'',strpos($tweet['created_at'],"+"),5);

$link = "http://twitter.com/".$twitdata['user']['screen_name']."/statuses/".$tweet['id'];
echo '<li><span class="entry">' . $tweet['text'] .'<a class="date" href="'.$link.'" rel="nofollow">'.mystique_timeSince(abs(strtotime($tweettime . " GMT")),time()). '</a></span></li>';
$i++;
if ($i == $twitcount) break;
endforeach;
?>
</ul>
</noindex>

<?php else: ?>
<p class="error"><?php _e("Error while retrieving tweets (Twitter down?)","mystique"); ?></p>
<?php endif;
}

function get_twitter_data(){
if($_GET['get_twitter_data'] == 1):
display_twitter_data(wp_specialchars($_GET['widget_id']), wp_specialchars($_GET['twituser']), wp_specialchars($_GET['twitcount']));
die();
endif;
}
add_action('init', 'get_twitter_data');

Ищу помощи, товарищи =)

Seredniy добавил 18.02.2011 в 18:47

хм) Блин, что же делать? Пробовал менять кодировку файла....

Wordpress и другие CMS: правки, настройка, верстка и натяжка шаблонов, разработка сайтов "под ключ" (/ru/forum/1008050)

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