# gutenberg/23.3.1/lib/compat/wordpress-7.1/classic-block.php

Gutenberg, version 23.3.1. 36 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/23.3.1/code/lib/compat/wordpress-7.1/classic-block.php
- Raw: https://pluginprobe.com/plugins/gutenberg/23.3.1/raw/lib/compat/wordpress-7.1/classic-block.php
- Modified: 2026-06-03T03:22:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/23.3.1/code/lib/compat/wordpress-7.1/classic-block.php#L10-L20`.

```php
<?php
/**
 * WordPress 7.1 compatibility: controls whether the Classic block
 * is available in the inserter.
 *
 * @package gutenberg
 */

if ( ! function_exists( 'wp_declare_classic_block_necessary' ) ) {
	/**
	 * Declares a flag that the Classic block is necessary for the current post.
	 *
	 * @since 7.1.0
	 */
	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() ) ) {
			return;
		}

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

```
