diff --git a/lib/compat/wordpress-7.0/rest-api.php b/lib/compat/wordpress-7.0/rest-api.php index 75301fdac94d7d..ff5a757f1907f8 100644 --- a/lib/compat/wordpress-7.0/rest-api.php +++ b/lib/compat/wordpress-7.0/rest-api.php @@ -65,3 +65,71 @@ function gutenberg_parse_pattern_blocks_in_block_templates( $query_result, $quer } add_filter( 'get_block_templates', 'gutenberg_parse_pattern_blocks_in_block_templates', 10, 3 ); + +/** + * Registers the 'overlay' template part area when the experiment is enabled. + * + * @param array $areas Array of template part area definitions. + * @return array Modified array of template part area definitions. + */ +function gutenberg_register_overlay_template_part_area( $areas ) { + if ( ! gutenberg_is_experiment_enabled( 'gutenberg-customizable-navigation-overlays' ) ) { + return $areas; + } + + $areas[] = array( + 'area' => 'overlay', + 'label' => __( 'Overlay', 'gutenberg' ), + 'description' => __( 'Custom overlay area for navigation overlays.', 'gutenberg' ), + 'icon' => 'overlay', + 'area_tag' => 'div', + ); + + return $areas; +} +add_filter( 'default_wp_template_part_areas', 'gutenberg_register_overlay_template_part_area' ); + +/** + * Registers the 'overlay' pattern category when the experiment is enabled. + */ +function gutenberg_register_overlay_pattern_category() { + if ( ! gutenberg_is_experiment_enabled( 'gutenberg-customizable-navigation-overlays' ) ) { + return; + } + + register_block_pattern_category( + 'overlay', + array( 'label' => __( 'Overlay', 'gutenberg' ) ) + ); +} +add_action( 'init', 'gutenberg_register_overlay_pattern_category' ); + +/** + * Registers the default overlay pattern when the experiment is enabled. + */ +function gutenberg_register_overlay_pattern() { + if ( ! gutenberg_is_experiment_enabled( 'gutenberg-customizable-navigation-overlays' ) ) { + return; + } + + register_block_pattern( + 'gutenberg/overlay-default', + array( + 'title' => __( 'Overlay', 'gutenberg' ), + 'categories' => array( 'overlay' ), + 'blockTypes' => array( 'core/template-part/overlay' ), + 'content' => ' +