2012/05/17

[WP-Plugin] 修正Get-Your-Plurk動詞背景

這個bug存在很久了

作者好像也好久沒更新,隨手就來de下bug

其實這bug只是因為這定頁面沒符合w3c的關係

導致若將語系改為繁體中文才會出現

更改後的get-plurk.php如下
';
}
function get_plurk_feeds($username = '', $count = 10, $showtime = true, $timediff = true, $lang = 'zh_tw', $showusername = true)
{
global $plurk_config;
$result =  '
    '; $isBroken = false; // judge if feed exists or not. if($username == '') $result .= '
  • Get the Plurk ATOM Feed Error. No Username.
  • '; else { include_once(ABSPATH . WPINC . '/rss.php'); $feeds = fetch_rss('http://www.plurk.com/user/' . $username . '.xml')); if (empty($feeds->items)) $isBroken = true; //we got some problem to fetch the feed. else { $i = 1; foreach ( $feeds->items as $feed ) { $result .= '
  • ';
    // make patterns and generate links
    $locale = explode ("|",file_get_contents( WP_PLUGIN_DIR . '/get-your-plurk/lang.'. $lang . '.cfg'));
    for($j = 0; $j'.$locale[$j].'' : $replacements[$j] = '';
    }
    $tmp_result = preg_replace($patterns, $replacements , $feed['atom_content'], 1);
    ($showusername) ? $result .= ''. $feed['author_name'] . '' . $tmp_result : $result .= $tmp_result;
    // generate date time start
    if($timediff && $showtime)
    {
    $time = (time() - strtotime($feed['published']));
    if($time < 600) // 10 mins $time = substr($time / 60, 0, 1) . ' minutes ago'; else if($time < 3600) // < 60 mins $time = substr($time / 60, 0, 2) . ' minutes ago'; else if($time < 36000) // < 10 hours $time = substr($time / 3600, 0, 3) . ' hours ago'; else if($time < 86400) // < 1 day $time = substr($time / 3600, 0, 4) . ' hours ago'; else if($time < 864000) // < 10 days $time = substr($time / 86400, 0, 1) . ' days ago'; else if($time < 2592000) // < 30 days $time = substr($time / 864000, 0, 2) . ' days ago'; else $time = "very long ago."; $result .= ' ' . $time . '
  • ' . "\n"; } else if($showtime) { $time = strftime("%Y/%m/%d %H:%M", strtotime($feed['published'])); $result .= ' ' . $time . ' ' . "\n"; } else $result .= ' ' . "\n"; if($i == $count) break; $i++; } } $result .= '
'; ($isBroken) ? $result = file_get_contents($plurk_config['cache']) : @file_put_contents($plurk_config['cache'], $result); return $result; } } function widget_get_plurks($args) { global $plurk_config; extract($args); $plurk_options = get_option('widget_get_plurks'); $refresh = true; if(file_exists($plurk_config['cache'])) $refresh = (time() > filemtime($plurk_config['cache']) + $plurk_options['plurk-cache']); echo $before_widget . $before_title . $plurk_options['plurk-title'] . $after_title; ($refresh || $plurk_options['plurk-cache'] == 0) ? $result = get_plurk_feeds($plurk_options['plurk-username'], $plurk_options['plurk-counts'], $plurk_options['plurk-publish-time'], $plurk_options['plurk-timediff'], $plurk_options['plurk-lang'], $plurk_options['plurk-show-username']) : $result = file_get_contents($plurk_config['cache']); echo $result; echo '
Visit ' . $plurk_options['plurk-username'] . "'s Plurk"; if($plurk_config['debug']) { if ($refresh) echo ' - with fresh feeds!'; else echo ' - next refresh: '. (filemtime($plurk_config['cache']) + $plurk_options['plurk-cache'] - time()).'s'; } echo "
"; if(!file_exists($plurk_config['cache'])) echo 'OOPS! Create ' . $plurk_config['cache'] . ' and make it wriatble first, see readme file.'; echo $after_widget; } function widget_get_plurks_control() { $plurk_options = $new_plurk_options = get_option('widget_get_plurks'); if(isset($_POST['plurk-submit']) ) { $new_plurk_options['plurk-title'] = $_POST['plurk-title']; $new_plurk_options['plurk-username'] = $_POST['plurk-username']; $new_plurk_options['plurk-counts'] = $_POST['plurk-counts']; $new_plurk_options['plurk-show-username'] = $_POST['plurk-show-username']; $new_plurk_options['plurk-publish-time'] = $_POST['plurk-publish-time']; $new_plurk_options['plurk-timediff'] = $_POST['plurk-timediff']; $new_plurk_options['plurk-lang'] = $_POST['plurk-lang']; $new_plurk_options['plurk-cache'] = $_POST['plurk-cache']; } if ( $plurk_options != $new_plurk_options ) { $plurk_options = $new_plurk_options; get_plurk_feeds($plurk_options['plurk-username'], $plurk_options['plurk-counts'], $plurk_options['plurk-publish-time'], $plurk_options['plurk-timediff'], $plurk_options['plurk-lang'], $plurk_options['plurk-show-username']); update_option('widget_get_plurks', $plurk_options); } if(!isset($plurk_options['plurk-cache'])) $plurk_options['plurk-cache'] = 60 ; ($plurk_options['plurk-publish-time']) ? $time_is_checked = 'checked="checked"' : $time_is_checked = ''; ($plurk_options['plurk-timediff'] && $plurk_options['plurk-publish-time']) ? $timediff_is_checked = 'checked="checked"' : $timediff_is_checked = ''; ($plurk_options['plurk-show-username']) ? $show_username_is_checked = 'checked="checked"' : $show_username_is_checked = ''; ($plurk_options['plurk-lang'] == 'zh_tw') ? $lang_is_selected = 'selected="selected"' : $lang_is_selected = ''; ?>

/>

/>

/>

set 0 to ignore cache



或可以在這裡下載

改完後記得去模組重新設定一下應該就可以正常顯示了

另外 正在 在plurk上顏色其實是不同的

可以修改一下style.css:

	.gyp-says {background: #E2560B; border-bottom: 1px solid #E2560B; border-right: 1px solid  #E2560B;}
	.gyp-is {background: #E57C43; border-bottom: 1px solid #E57C43; border-right: 1px solid  #E57C43;}

沒有留言:

張貼留言