升级 WordPress4.0 后 Baidu Sitemap Generator 发布文章时报错!,报错内容如下:Warning: Illegal string offset 'lc_is_update_sitemap_when_post' in ****/wp-content/plugins/baidu-sitemap-generator/baidu_sitemap.php on line 406

Warning: Cannot modify header information - headers already sent by (output started at ****t/plugins/baidu-sitemap-generator/baidu_sitemap.php:406) in /****/wp-admin/post.php on line 233

Warning: Cannot modify header information - headers already sent by (output started at /****l/wp-content/plugins/baidu-sitemap-generator/baidu_sitemap.php:406) in ****/wp-includes/pluggable.php on line 1173

看来是 baidu_sitemap.php 文件里的 406 行代码有问题!

1 、用 notepad++软件,打开 baidu-sitemap.php 文件并找到 第 406 行的以下代码:

if($get_baidu_sitemap_options[' lc_is_update_sitemap_when_post '] == 』1′){

wp_clear_scheduled_hook(『do_baidu_sitemap_by_post』);

wp_clear_scheduled_hook(『do_this_auto_daily』);

wp_schedule_single_event(time()+10, 『do_baidu_sitemap_by_post』);

把这段代码注释掉,注释后的代码如下:

//if($get_baidu_sitemap_options[' lc_is_update_sitemap_when_post '] == 』1′){

wp_clear_scheduled_hook(『do_baidu_sitemap_by_post』);

wp_clear_scheduled_hook(『do_this_auto_daily』);

wp_schedule_single_event(time()+10, 『do_baidu_sitemap_by_post』);

//}

修改 bug 的思路:每当发布文章时,sitemap 都会自动更新。