一:几句代码就能解决的事情
屏蔽当前古腾堡编辑器,找到当前主题的functions.php文件,添加如下内容:
//禁用古腾堡编辑器
add_filter('use_block_editor_for_post', '__return_false');
//屏蔽古腾堡的样式加载
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
这段代码旨在禁止古腾堡编辑器,使用老版本编辑器,但是它并不会自主判断当前wordpress版本,那么就有了下面的升级版本:
/**
* WordPress禁止使用古腾堡Gutenberg块编辑器继续使用经典编辑器
* 兼容判断当前wordpress版本
* https://www.vanhua.cn/1648.html
*/
// WP版本≥5.0版本时 正式集成Gutenberg古腾堡编辑器
if ( version_compare( get_bloginfo('version'), '5.0', '>=' ) ) {
add_filter('use_block_editor_for_post', '__return_false'); // 切换回之前的编辑器
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); // 禁止前端加载样式文件
}else{
// 4.9.8 < WP < 5.0 插件形式集成Gutenberg古腾堡编辑器
add_filter('gutenberg_can_edit_post_type', '__return_false');
}
// Disable Gutenberg
if (version_compare($GLOBALS['wp_version'], '5.0-beta', '>')) {
// WP > 5 beta
add_filter('use_block_editor_for_post_type', '__return_false', 10);
} else {
// WP < 5 beta
add_filter('gutenberg_can_edit_post_type', '__return_false', 10);
}
二:插件大法
肯定有些童鞋心里在嘀咕,果不其然就是插件嘛,对,就是插件,给大家推荐三款插件(都是免费的): Classic Editor 和 Disable Gutenberg 。还有一款很好用的插件,就是水煮鱼的WPJAM,这款插件功能很强大.
评论