我有一个问题,即Wordpress编辑器选项卡"视觉"和"文本"不可见。我已经尝试了以下所有方法:
- 禁用所有插件
- 启用二十九个插件
- 安装并激活了TinyMCE高级插件
- 新增
define('CONCATENATE_SCRIPTS', false);
- 从配置文件设置中,我尝试切换"编写时禁用可视化编辑器",每次切换设置时都会保存
以上所有操作都不起作用,编辑器选项卡仍未显示。在当地环境中,一切正常。
问题似乎出在用户代理上,有一篇关于它的文章:https://benjaminhorn.io//code/wordpress-visual-editor-not-visible-because-of-user-agent-sniffing/
基本上下面的过滤器解决了我的问题:
<?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');