[WordPress]AWS CloudFrontを有効化するとビジュアルエディタが非表示になる問題を修正する方法

WordPressの表示を高速化しようとして、AWS CloudFrontを有効化するとビジュアルエディタが非表示になるという問題が発生する。

その問題を解決するにはfunction.phpに下記コードを追加するだけでよい

<?php
/**
* Overrides the function user_can_richedit and only checks the
* user preferences instead of doing UA sniffing.
*
* @return bool
*/
function user_can_richedit_custom() {
	global $wp_rich_edit;
 
	if (get_user_option('rich_editing') == 'true' || !is_user_logged_in()) {
		$wp_rich_edit = true;
		return true;
	}
 
	$wp_rich_edit = false;
	return false;
}
 
add_filter('user_can_richedit', 'user_can_richedit_custom');

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です