Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vburlak/ba3458e2733d972ccb4531f782954b51 to your computer and use it in GitHub Desktop.
Save vburlak/ba3458e2733d972ccb4531f782954b51 to your computer and use it in GitHub Desktop.
Block Editor Cleanup for WordPress 5.9 and Classic Editor (mu-plugin)
<?php
/**
* Plugin Name: Block Editor Cleanup
* Plugin URI: https://github.com/WordPress/gutenberg/issues/38299#issuecomment-1025520487
* Version: 1.0.0
* Description: Remove WP 5.9 default block editor styles when using Classic Editor
* Author: joshuafredrickson
* Author URI: https://joshuafredrickson.com
* License: GNU General Public License v2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
add_action('after_setup_theme', function () {
// Remove SVG and global styles
remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles');
// @link https://github.com/WordPress/gutenberg/issues/38299#issuecomment-1049011521
remove_action('wp_body_open', 'wp_global_styles_render_svg_filters');
// Remove wp_footer actions which add global inline styles
remove_action('wp_footer', 'wp_enqueue_global_styles', 1);
// Remove render_block filters which add unnecessary stuff
remove_filter('render_block', 'wp_render_duotone_support');
remove_filter('render_block', 'wp_restore_group_inner_container');
remove_filter('render_block', 'wp_render_layout_support_flag');
});
add_action('wp_enqueue_scripts', function () {
if (is_plugin_active('classic-editor/classic-editor.php')) {
// Dequeue block library styles
wp_dequeue_style('wp-block-library');
}
}, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment