<?php
/*
Plugin Name: Kill Incoming Links
Version:     2.0
Plugin URI:  http://yskin.net/projects/kill-incoming-links/
Description: 移除 WordPress 后台 <a href="/wp-admin/index.php">Dashboard</a> (控制板)中的 Incoming Links (外部链接)部分,以解决中国大陆地区服务器因无法访问 <a title="Technorati" href="http://www.technorati.com/">Technorati</a> 而导致 Dashboard 页面超时的问题。
Author:      Yskin
Author URI:  http://yskin.net/

Changelog
=============================================================================
2006-11-13    First Release
2006-11-16  modify option on activation and resume it on deactivation

License
=============================================================================
Copyright (C) 2006 yskin (email: yskins@gmail.com)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

if ( !defined('MAGPIE_CACHE_AGE') ) {
    
define('MAGPIE_CACHE_AGE'60*60*24); // 设置cache寿命为1小时
}

// Thanks to Feed Control (http://www.silpstream.com/blog/)
register_activation_hook(__FILE__'kill_incominglinks_activate');
register_deactivation_hook(__FILE__,'kill_incominglinks_deactivate');

function 
kill_incominglinks_activate() {
    
$url 'http://feeds.technorati.com/cosmos/rss/?url='trailingslashit(get_option('home')) .'&partner=wordpress';
    
$cache_option 'rss_' md5($url);
    
$cache_timestamp $cache_option '_ts';

    
// 将cache内容设置为字符串'123',因为cache中不再包含items对象,所以整个div不显示;将cache时间设置为2009年1月1日0点,使cache不超时。
    // 使用update_option()函数,如果该项不存在将自动添加。
    
update_option($cache_option'123');
    
update_option($cache_timestamp1230739200);
}

function 
kill_incominglinks_deactivate() {
    
$url 'http://feeds.technorati.com/cosmos/rss/?url='trailingslashit(get_option('home')) .'&partner=wordpress';
    
$cache_timestamp 'rss_' md5($url) . '_ts';

    
// 将cache时间设置回2006年11月1日0点,下一次访问Dashboard,cache将开始更新
    
update_option($cache_timestamp1162310400);
}

/*
// 貌似div是自动不显示的,所以下面的代码就不需要了。
// Thanks to Kill Preview (http://redalt.com/wiki/Kill+Preview+Plugin)
if (strstr($_SERVER['REQUEST_URI'], 'wp-admin/index.php')) {
    ob_start('kill_incominglinks');
}

//移除Incoming Links的div
function kill_incominglinks($content) {
    $content = preg_replace("/<div[^>]*?id=\"incominglinks\".*?<\/div>/mis", '', $content);
    return $content;
}
*/
?>