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