Search code examples
phpcsswordpress-gutenberg

How to disable gutemberg css only if classic editor is activated?


I would like to delete the css of gutenberg on wordpress only when the Classic Editor plugin is active.

This is the code I use to turn it off, but I'd like to make it dependent on the plugin

function remove_block_css(){
wp_dequeue_style( 'wp-block-library' );
}
add_action( 'wp_enqueue_scripts', 'remove_block_css', 100 );

Solution

  • You could wrap your add_action call inside a conditional checking for the existence of the Classic Editor class: if ( class_exists( 'Classic_Editor' ) ) {} or you can have a look at: is_plugin_active in the Codex: https://codex.wordpress.org/Function_Reference/is_plugin_active