Looks like WP_Screen::is_block_editor()
is what you want. Here’s some rough code to demonstrate:
add_filter( 'default_content', function( $content, $post ) {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$is_block_editor = $screen ? $screen->is_block_editor() : false;
if ( $is_block_editor ) {
// Do your block editor stuff here
} else {
// Do your classic editor stuff here
}
return $content;
}, 10, 2 );
If you only want this to occur for a specific post-type, it would look more like this:
add_filter( 'default_content', function( $content, $post ) {
if ( ! empty( $post->post_type ) && 'your_post_type' === $post->post_type ) {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$is_block_editor = $screen ? $screen->is_block_editor() : false;
if ( $is_block_editor ) {
// Do your block editor stuff here
} else {
// Do your classic editor stuff here
}
}
return $content;
}, 10, 2 );