Skip to content

Instantly share code, notes, and snippets.

@marcwieland95
Created August 23, 2018 17:48
Show Gist options
  • Save marcwieland95/6360d88c1b9875f51a4881442b356735 to your computer and use it in GitHub Desktop.
Save marcwieland95/6360d88c1b9875f51a4881442b356735 to your computer and use it in GitHub Desktop.
Remove Gutenberg on pages
class Admin {
function __construct() {
// Gutenberg
add_action( 'current_screen', array( $this, 'clean_page_gutenberg' ) );
}
/*
Disable Gutenberg on pages
*/
function clean_page_gutenberg() {
$current_screen = get_current_screen();
$current_post_type = $current_screen->post_type;
// Check if post type is page
if( $current_post_type == 'page' ){
$this->gutenberg_removal();
}
}
/*
Gutenberg Removal
*/
private function gutenberg_removal() {
remove_filter( 'replace_editor', 'gutenberg_init' );
remove_action( 'load-post.php', 'gutenberg_intercept_edit_post' );
remove_action( 'load-post-new.php', 'gutenberg_intercept_post_new' );
remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' );
remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
remove_action( 'admin_enqueue_scripts', 'gutenberg_editor_scripts_and_styles' );
remove_filter( 'screen_options_show_screen', '__return_false' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment