| 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 |
*/ |
| 15 |
function wp_declare_classic_block_necessary(): void { |
| 16 |
/** |
| 17 |
* Filters whether the Classic block should be available in the inserter. |
| 18 |
* |
| 19 |
* Defaults to false. Use this filter to opt in (globally or per post). |
| 20 |
* |
| 21 |
* @param bool $supports_inserter Whether the Classic block is available in the inserter. |
| 22 |
* @param WP_Post|null $post The post being edited, or null if not in the post editor. |
| 23 |
*/ |
| 24 |
if ( ! (bool) apply_filters( 'wp_classic_block_supports_inserter', false, get_post() ) ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
wp_add_inline_script( |
| 29 |
'wp-block-library', |
| 30 |
'window.__needsClassicBlock = true;', |
| 31 |
'before' |
| 32 |
); |
| 33 |
} |
| 34 |
add_action( 'enqueue_block_editor_assets', 'wp_declare_classic_block_necessary' ); |
| 35 |
} |
| 36 |
|