升級 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 都會自動更新。