細水長流

WordPress 6.8移除「撰写文章时不使用可视化编辑器」选项

今天使用 WordPress 6.8 新建测试站点,在「用户」-「个人资料」处找不到了禁用可视化编辑器(Disable the visual editor when writing)选项,以为出 bug 了。找了一下资料,才发现是官方把这个选项移除了。

「WordPress 6.8移除「撰写文章时不使用可视化编辑器」选项:https://uxtt.com/wordpress-6-8-removed-option-to-disable-the-visual-editor-from-user-profile-settings」

官方说明见:Miscellaneous developer changes in WordPress 6.8

Removed option to disable the Visual Editor from user profile settings

The option to disable the visual editor was used to enforce the usage of the text interface in the classic editor. This setting was removed in #34681. The setting is removed conditionally; if you have it enabled, it will remain enabled and editable until it is disabled for a user.

「WordPress 6.8移除「撰写文章时不使用可视化编辑器」选项:https://uxtt.com/wordpress-6-8-removed-option-to-disable-the-visual-editor-from-user-profile-settings」

The text editor will continue to be an option for all users. $user->rich_editing continues to be a valid user profile field, and the visual editor can be disabled by toggling that value to false.

Example code:

update_user_option( $user_id, 'rich_editing', 'false' );

「WordPress 6.8移除「撰写文章时不使用可视化编辑器」选项:https://uxtt.com/wordpress-6-8-removed-option-to-disable-the-visual-editor-from-user-profile-settings」

不过,这个设置是有条件移除的——如果您已启用该设置,它将保持启用状态并可编辑,直到用户禁用为止。

文本编辑器将继续作为所有用户的选项。$user->rich_editing 仍然是有效的用户个人资料字段,并且可以通过将该值切换为 false 来禁用可视化编辑器。

「WordPress 6.8移除「撰写文章时不使用可视化编辑器」选项:https://uxtt.com/wordpress-6-8-removed-option-to-disable-the-visual-editor-from-user-profile-settings」

理论上在主题 functions.php 添加以下代码即可禁用可视化编辑器:

add_action('init', 'disable_rich_editing_for_admin');
function disable_rich_editing_for_admin() {
if (is_admin() && get_current_user_id() == 1) {
update_user_option(1, 'rich_editing', 'false');
}
}

不过实测后台没有选项出来,但是确实已经禁用可视化编辑器,不知道哪里出问题了。

还是直接登录 phpMyAdmin 修改对应用户的 rich_editing 字段,将 true 改成 false 即可:

退出移动版