Skip to content

Instantly share code, notes, and snippets.

@mintplugins
Last active May 8, 2020 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mintplugins/d34a7e16ed3038fbf4dbeb2c48b03234 to your computer and use it in GitHub Desktop.
Save mintplugins/d34a7e16ed3038fbf4dbeb2c48b03234 to your computer and use it in GitHub Desktop.
Simple function to programmatically disable Gutenberg, and use the Classic Editor instead
if ( ! function_exists( 'disable_gutenberg' ) ) {
function disable_gutenberg() {
global $wp_filter;
$callbacks_array = $wp_filter['init']->callbacks;
foreach( $wp_filter as $tag => $priorities ) {
foreach( $priorities->callbacks as $priority => $callback_data ) {
foreach( $callback_data as $callback_function_name => $callback_function_data ) {
if ( strpos( $callback_function_name, 'disable_gutenberg' ) !== false ){
continue;
}
// Gutenberg disabler
if ( strpos( $callback_function_name, 'gutenberg' ) !== false || strpos( $callback_function_name, 'block_editor' ) ){
remove_filter( $tag, $callback_function_name, $priority );
}
}
}
}
$wp_filter['init']->callbacks = $callbacks_array;
add_filter( 'use_block_editor_for_post_type', '__return_false' );
}
}
add_action( 'admin_init', 'disable_gutenberg' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment