WordPress Disable Block Editor and Enable Classic Editor
This file contains 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
<?php | |
public 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' ); | |
} | |
// register in hook | |
add_action( 'admin_init', array($this, 'disable_gutenberg') ); |
Comments
Post a Comment