記事を公開すると、search-everythingで「Fatal error: Cannot use object of type WP_Error as array in・・・」とエラーが出る
エラーコード
Fatal error: Cannot use object of type WP_Error as array in /home/★★★/◆◆◆.net/public_html/wp/wp-content/plugins/search-everything/search-everything.php on line 927
その他
WordPress バージョン 4.9.8
Search Everything バージョン 8.1.9
解決策
ググってみたところ、同様のエラーで困っておられる方がいらっしゃいました。
解決策(コード)によると、Wordpress本体のバージョンとプラグインのバージョン内での記述($_POST)関係で不整合が出てエラーを吐いているようでした。
当環境では、エラーが出ましたがページを移動すると、記事自体は公開されている状態でした。
解決方法は下記のリンクからどうぞ
[Wordpress]プラグインsearch-everything。公開時にエラーが出ます。
https://teratail.com/questions/129563
修正後のコードも抜粋しておきます。916行目あたりのfunctionの中身です。
どこを直すかはよくみてくださいね。
function se_post_publish_ping($post_id) {
//should happen only on first publish
$status = false;
if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
$permalink = get_permalink($post_id);
$zemanta_response = se_api(array(
'method' => 'zemanta.post_published_ping',
'current_url' => $permalink,
'post_url' => $permalink,
'post_rid' => '',
'interface' => 'wordpress-se',
'deployment' => 'search-everything',
'format' => 'json'
));
if (!is_wp_error($zemanta_response)) {
$status = json_decode($zemanta_response['body'])->status;
}
}
return $status;
}
add_action('publish_post', 'se_post_publish_ping');