Last active
May 8, 2020 14:53
-
-
Save mintplugins/d34a7e16ed3038fbf4dbeb2c48b03234 to your computer and use it in GitHub Desktop.
Simple function to programmatically disable Gutenberg, and use the Classic Editor instead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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