Disable Gutenberg Editer Wp

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' );

Last updated