File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 627627add_action ( 'enqueue_block_editor_assets ' , 'wp_enqueue_block_editor_script_modules ' );
628628add_action ( 'enqueue_block_editor_assets ' , 'wp_enqueue_global_styles_css_custom_properties ' );
629629add_action ( 'enqueue_block_editor_assets ' , '_wp_enqueue_auto_register_blocks ' );
630+ add_action ( 'enqueue_block_editor_assets ' , 'wp_declare_classic_block_necessary ' );
630631add_action ( 'wp_print_scripts ' , 'wp_just_in_time_script_localization ' );
631632add_filter ( 'print_scripts_array ' , 'wp_prototype_before_jquery ' );
632633add_action ( 'customize_controls_print_styles ' , 'wp_resource_hints ' , 1 );
Original file line number Diff line number Diff line change @@ -2647,6 +2647,33 @@ function wp_enqueue_global_styles() {
26472647 wp_add_global_styles_for_blocks ();
26482648}
26492649
2650+ /**
2651+ * Declares a flag that the Classic block is necessary for the current post.
2652+ *
2653+ * @since 7.1.0
2654+ */
2655+ function wp_declare_classic_block_necessary () {
2656+ global $ post ;
2657+
2658+ /**
2659+ * Filters whether the Classic block should be available in the inserter.
2660+ *
2661+ * Defaults to false. Use this filter to opt in (globally or per post).
2662+ *
2663+ * @param bool $supports_inserter Whether the Classic block is available in the inserter.
2664+ * @param WP_Post|null $post The post being edited, or null if not in the post editor.
2665+ */
2666+ if ( ! (bool ) apply_filters ( 'wp_classic_block_supports_inserter ' , false , $ post ) ) {
2667+ return ;
2668+ }
2669+
2670+ wp_add_inline_script (
2671+ 'wp-block-library ' ,
2672+ 'window.__needsClassicBlock = true; ' ,
2673+ 'before '
2674+ );
2675+ }
2676+
26502677/**
26512678 * Checks if the editor scripts and styles for all registered block types
26522679 * should be enqueued on the current screen.
You can’t perform that action at this time.
0 commit comments