Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_block_editor_script_modules' );
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' );
add_action( 'enqueue_block_editor_assets', '_wp_enqueue_auto_register_blocks' );
add_action( 'enqueue_block_editor_assets', 'wp_declare_classic_block_necessary' );
add_action( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
add_action( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
Expand Down
25 changes: 25 additions & 0 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2646,6 +2646,31 @@ function wp_enqueue_global_styles() {
wp_add_global_styles_for_blocks();
}

/**
* Declares a flag that the Classic block is necessary for the current post.
*
* @since 7.1.0
Comment thread
tyxla marked this conversation as resolved.
*/
function wp_declare_classic_block_necessary(): void {
/**
* Filters whether the Classic block should be available in the inserter.
*
* Defaults to false. Use this filter to opt in (globally or per post).
*
* @param bool $supports_inserter Whether the Classic block is available in the inserter.
* @param WP_Post|null $post The post being edited, or null if not in the post editor.
*/
if ( ! (bool) apply_filters( 'wp_classic_block_supports_inserter', false, get_post() ) ) {
Comment thread
tyxla marked this conversation as resolved.
return;
}

wp_add_inline_script(
'wp-block-library',
'window.__needsClassicBlock = true;',
'before'
);
}

/**
* Checks if the editor scripts and styles for all registered block types
* should be enqueued on the current screen.
Expand Down
Loading