PluginProbe
Gutenberg / 23.5.0
Gutenberg v23.5.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / compat / wordpress-7.1 / classic-block.php

classic-block.php in Gutenberg 23.5.0, at lib/compat/wordpress-7.1/classic-block.php

37 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WordPress 7.1 compatibility: controls whether the Classic block
4 * is available in the inserter.
5 *
6 * @package gutenberg
7 */
8
9 if ( ! function_exists( 'wp_declare_classic_block_necessary' ) ) {
10 /**
11 * Declares a flag that the Classic block is necessary for the current post.
12 *
13 * @since 7.1.0
14 * @access private
15 */
16 function wp_declare_classic_block_necessary(): void {
17 /**
18 * Filters whether the Classic block should be available in the inserter.
19 *
20 * Defaults to false. Use this filter to opt in (globally or per post).
21 *
22 * @param bool $supports_inserter Whether the Classic block is available in the inserter.
23 * @param WP_Post|null $post The post being edited, or null if not in the post editor.
24 */
25 if ( ! (bool) apply_filters( 'wp_classic_block_supports_inserter', false, get_post() ) ) {
26 return;
27 }
28
29 wp_add_inline_script(
30 'wp-block-library',
31 'window.__needsClassicBlock = true;',
32 'before'
33 );
34 }
35 add_action( 'enqueue_block_editor_assets', 'wp_declare_classic_block_necessary' );
36 }
37