Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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