admin管理员组文章数量:1023866
for disabling gutenberg editor I use the below code
add_filter('use_block_editor_for_post', '__return_false');
but it just disable gutenberg and Classic editor never come back.
I am just curious is there any way to do that without plugins?
for disabling gutenberg editor I use the below code
add_filter('use_block_editor_for_post', '__return_false');
but it just disable gutenberg and Classic editor never come back.
I am just curious is there any way to do that without plugins?
- 2 Why can't you just use the Classic Editor plugin? It's the officially supported way to continue using the old editor. Any other method, such as the accepted answer, runs the risk of falling out of date. – Jacob Peattie Commented May 5, 2019 at 10:54
1 Answer
Reset to default 2Simply add the following to functions.php file of your current theme.
<?php
/**
* Disable Gutenberg for supported posts.
*/
add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );
/**
* Disable Gutenberg action and filter hooks.
*/
function df_disable_gutenberg_hooks() {
remove_action( 'admin_menu', 'gutenberg_menu' );
remove_action( 'admin_init', 'gutenberg_redirect_demo' );
remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save', 1000 );
remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );
remove_action( 'admin_notices', 'gutenberg_build_files_notice' );
remove_filter( 'body_class', 'gutenberg_add_responsive_body_class' );
remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' ); // old
remove_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );
remove_filter( 'register_post_type_args', 'gutenberg_filter_post_type_labels' );
remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
remove_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts' );
remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state' );
remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
}
add_filter( 'after_setup_theme', 'df_disable_gutenberg_hooks' );
/**
* Disable Gutenberg frontend scripts.
*/
function df_disable_gutenberg_wp_enqueue_scripts() {
wp_dequeue_style( 'wp-block-library' );
}
add_filter( 'wp_enqueue_scripts', 'df_disable_gutenberg_wp_enqueue_scripts', 100 );
?>
Source dfactory
for disabling gutenberg editor I use the below code
add_filter('use_block_editor_for_post', '__return_false');
but it just disable gutenberg and Classic editor never come back.
I am just curious is there any way to do that without plugins?
for disabling gutenberg editor I use the below code
add_filter('use_block_editor_for_post', '__return_false');
but it just disable gutenberg and Classic editor never come back.
I am just curious is there any way to do that without plugins?
- 2 Why can't you just use the Classic Editor plugin? It's the officially supported way to continue using the old editor. Any other method, such as the accepted answer, runs the risk of falling out of date. – Jacob Peattie Commented May 5, 2019 at 10:54
1 Answer
Reset to default 2Simply add the following to functions.php file of your current theme.
<?php
/**
* Disable Gutenberg for supported posts.
*/
add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );
/**
* Disable Gutenberg action and filter hooks.
*/
function df_disable_gutenberg_hooks() {
remove_action( 'admin_menu', 'gutenberg_menu' );
remove_action( 'admin_init', 'gutenberg_redirect_demo' );
remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save', 1000 );
remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );
remove_action( 'admin_notices', 'gutenberg_build_files_notice' );
remove_filter( 'body_class', 'gutenberg_add_responsive_body_class' );
remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' ); // old
remove_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );
remove_filter( 'register_post_type_args', 'gutenberg_filter_post_type_labels' );
remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
remove_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts' );
remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state' );
remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
}
add_filter( 'after_setup_theme', 'df_disable_gutenberg_hooks' );
/**
* Disable Gutenberg frontend scripts.
*/
function df_disable_gutenberg_wp_enqueue_scripts() {
wp_dequeue_style( 'wp-block-library' );
}
add_filter( 'wp_enqueue_scripts', 'df_disable_gutenberg_wp_enqueue_scripts', 100 );
?>
Source dfactory
本文标签: How to Disable Gutenberg amp Return to the Classic WordPress Editor Without any Plugins
版权声明:本文标题:How to Disable Gutenberg & Return to the Classic WordPress Editor Without any Plugins 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745523249a2154412.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论