diff --git a/lib/compat/wordpress-6.3/class-wp-classic-to-block-menu-converter.php b/lib/compat/wordpress-6.3/class-gutenberg-classic-to-block-menu-converter.php similarity index 97% rename from lib/compat/wordpress-6.3/class-wp-classic-to-block-menu-converter.php rename to lib/compat/wordpress-6.3/class-gutenberg-classic-to-block-menu-converter.php index 65c8a6d5bcba74..8677f9abaee170 100644 --- a/lib/compat/wordpress-6.3/class-wp-classic-to-block-menu-converter.php +++ b/lib/compat/wordpress-6.3/class-gutenberg-classic-to-block-menu-converter.php @@ -1,6 +1,6 @@ 404 ) ) ); diff --git a/lib/compat/wordpress-6.3/rest-api.php b/lib/compat/wordpress-6.3/rest-api.php index 87b52ed9b8992a..144ad4d50c83f1 100644 --- a/lib/compat/wordpress-6.3/rest-api.php +++ b/lib/compat/wordpress-6.3/rest-api.php @@ -109,3 +109,13 @@ function gutenberg_register_rest_block_patterns() { $block_patterns->register_routes(); } add_action( 'rest_api_init', 'gutenberg_register_rest_block_patterns' ); + + +/** + * Registers the Navigation Fallbacks REST API routes. + */ +function gutenberg_register_rest_navigation_fallbacks() { + $editor_settings = new Gutenberg_REST_Navigation_Fallback_Controller(); + $editor_settings->register_routes(); +} +add_action( 'rest_api_init', 'gutenberg_register_rest_navigation_fallbacks' ); diff --git a/lib/experimental/rest-api.php b/lib/experimental/rest-api.php index 4a8bbea1548a6f..2fc7a7af576f82 100644 --- a/lib/experimental/rest-api.php +++ b/lib/experimental/rest-api.php @@ -29,16 +29,6 @@ function gutenberg_register_block_editor_settings() { add_action( 'rest_api_init', 'gutenberg_register_block_editor_settings' ); -/** - * Registers the Navigation Fallbacks REST API routes. - */ -function gutenberg_register_rest_navigation_fallbacks() { - $editor_settings = new WP_REST_Navigation_Fallback_Controller(); - $editor_settings->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_rest_navigation_fallbacks' ); - - /** * Shim for get_sample_permalink() to add support for auto-draft status. * diff --git a/lib/load.php b/lib/load.php index 0ef72a48ebdbbe..a390263fa119da 100644 --- a/lib/load.php +++ b/lib/load.php @@ -48,7 +48,9 @@ function gutenberg_is_experiment_enabled( $name ) { require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php'; require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-global-styles-controller-6-3.php'; require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-global-styles-revisions-controller-6-3.php'; - require_once __DIR__ . '/compat/wordpress-6.3/class-wp-rest-navigation-fallback-controller.php'; + require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-classic-to-block-menu-converter.php'; + require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-navigation-fallback.php'; + require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-navigation-fallback-controller.php'; require_once __DIR__ . '/compat/wordpress-6.3/rest-api.php'; require_once __DIR__ . '/compat/wordpress-6.3/theme-previews.php'; require_once __DIR__ . '/compat/wordpress-6.3/navigation-block-preloading.php'; diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index f8f53a93e70fd9..d16de821b47125 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -341,7 +341,7 @@ function block_core_navigation_get_fallback_blocks() { // If `core/page-list` is not registered then return empty blocks. $fallback_blocks = $registry->is_registered( 'core/page-list' ) ? $page_list_fallback : array(); - $navigation_post = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $navigation_post = Gutenberg_Navigation_Fallback::get_fallback(); // Use the first non-empty Navigation as fallback if available. if ( $navigation_post ) { @@ -846,7 +846,7 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl */ function block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_items_by_parent_id ) { - _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::parse_blocks_from_menu_items' ); + _deprecated_function( __FUNCTION__, '6.3.0', 'Gutenberg_Navigation_Fallback::parse_blocks_from_menu_items' ); if ( empty( $menu_items ) ) { return array(); @@ -895,7 +895,7 @@ function block_core_navigation_parse_blocks_from_menu_items( $menu_items, $menu_ */ function block_core_navigation_get_classic_menu_fallback() { - _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::get_classic_menu_fallback' ); + _deprecated_function( __FUNCTION__, '6.3.0', 'Gutenberg_Navigation_Fallback::get_classic_menu_fallback' ); $classic_nav_menus = wp_get_nav_menus(); @@ -938,7 +938,7 @@ static function( $a, $b ) { */ function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu ) { - _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::get_classic_menu_fallback_blocks' ); + _deprecated_function( __FUNCTION__, '6.3.0', 'Gutenberg_Navigation_Fallback::get_classic_menu_fallback_blocks' ); // BEGIN: Code that already exists in wp_nav_menu(). $menu_items = wp_get_nav_menu_items( $classic_nav_menu->term_id, array( 'update_post_term_cache' => false ) ); @@ -977,7 +977,7 @@ function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_me */ function block_core_navigation_maybe_use_classic_menu_fallback() { - _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::create_classic_menu_fallback' ); + _deprecated_function( __FUNCTION__, '6.3.0', 'Gutenberg_Navigation_Fallback::create_classic_menu_fallback' ); // See if we have a classic menu. $classic_nav_menu = block_core_navigation_get_classic_menu_fallback(); @@ -1020,7 +1020,7 @@ function block_core_navigation_maybe_use_classic_menu_fallback() { */ function block_core_navigation_get_most_recently_published_navigation() { - _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Navigation_Fallback_Gutenberg::get_most_recently_published_navigation' ); + _deprecated_function( __FUNCTION__, '6.3.0', 'Gutenberg_Navigation_Fallback::get_most_recently_published_navigation' ); // Default to the most recently created menu. $parsed_args = array( diff --git a/phpunit/class-wp-classic-to-block-menu-converter-test.php b/phpunit/class-gutenberg-classic-to-block-menu-converter-test.php similarity index 90% rename from phpunit/class-wp-classic-to-block-menu-converter-test.php rename to phpunit/class-gutenberg-classic-to-block-menu-converter-test.php index 0d7670d8ec867e..5f0a8ceee52a10 100644 --- a/phpunit/class-wp-classic-to-block-menu-converter-test.php +++ b/phpunit/class-gutenberg-classic-to-block-menu-converter-test.php @@ -1,20 +1,20 @@ assertTrue( class_exists( 'WP_Classic_To_Block_Menu_Converter' ) ); + $this->assertTrue( class_exists( 'Gutenberg_Classic_To_Block_Menu_Converter' ) ); } /** @@ -23,7 +23,7 @@ public function test_class_exists() { */ public function test_passing_non_menu_object_to_converter_returns_wp_error( $data ) { - $result = WP_Classic_To_Block_Menu_Converter::convert( $data ); + $result = Gutenberg_Classic_To_Block_Menu_Converter::convert( $data ); $this->assertTrue( is_wp_error( $result ), 'Should be a WP_Error instance' ); @@ -88,7 +88,7 @@ public function test_can_convert_classic_menu_to_blocks() { $classic_nav_menu = wp_get_nav_menu_object( $menu_id ); - $blocks = WP_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); + $blocks = Gutenberg_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); $this->assertNotEmpty( $blocks ); @@ -179,7 +179,7 @@ public function test_does_not_convert_menu_items_with_non_publish_status() { $classic_nav_menu = wp_get_nav_menu_object( $menu_id ); - $blocks = WP_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); + $blocks = Gutenberg_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); $this->assertNotEmpty( $blocks ); @@ -204,7 +204,7 @@ public function test_returns_empty_array_for_menus_with_no_items() { $classic_nav_menu = wp_get_nav_menu_object( $menu_id ); - $blocks = WP_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); + $blocks = Gutenberg_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); $this->assertEmpty( $blocks, 'Result should be empty.' ); diff --git a/phpunit/class-wp-navigation-fallback-gutenberg-test.php b/phpunit/class-gutenberg-navigation-fallback-gutenberg-test.php similarity index 91% rename from phpunit/class-wp-navigation-fallback-gutenberg-test.php rename to phpunit/class-gutenberg-navigation-fallback-gutenberg-test.php index fe32e8a640c078..7b0719950df8b5 100644 --- a/phpunit/class-wp-navigation-fallback-gutenberg-test.php +++ b/phpunit/class-gutenberg-navigation-fallback-gutenberg-test.php @@ -1,14 +1,14 @@ assertTrue( class_exists( 'WP_Navigation_Fallback_Gutenberg' ), 'WP_Navigation_Fallback_Gutenberg class should exist.' ); + $this->assertTrue( class_exists( 'Gutenberg_Navigation_Fallback' ), 'Gutenberg_Navigation_Fallback class should exist.' ); } @@ -37,7 +37,7 @@ public function test_it_exists() { * @covers WP_REST_Navigation_Fallback_Controller::get_fallback */ public function test_should_return_a_default_fallback_navigation_menu_in_absence_of_other_fallbacks() { - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -63,7 +63,7 @@ public function test_should_return_a_default_fallback_navigation_menu_with_no_bl unregister_block_type( 'core/page-list' ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -79,11 +79,11 @@ public function test_should_return_a_default_fallback_navigation_menu_with_no_bl */ public function test_should_handle_consecutive_invocations() { // Invoke the method multiple times to ensure that it doesn't create a new fallback menu on each invocation. - WP_Navigation_Fallback_Gutenberg::get_fallback(); - WP_Navigation_Fallback_Gutenberg::get_fallback(); + Gutenberg_Navigation_Fallback::get_fallback(); + Gutenberg_Navigation_Fallback::get_fallback(); // Assert on the final invocation. - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -115,7 +115,7 @@ public function test_should_return_the_most_recently_created_navigation_menu() { ) ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -147,7 +147,7 @@ public function test_should_return_fallback_navigation_from_existing_classic_men ) ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -201,7 +201,7 @@ public function test_should_prioritise_fallback_to_classic_menu_in_primary_locat $locations['header'] = $another_menu_id; set_theme_mod( 'nav_menu_locations', $locations ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -238,7 +238,7 @@ public function test_should_fallback_to_classic_menu_with_primary_slug() { ) ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -275,7 +275,7 @@ public function test_should_fallback_to_most_recently_created_classic_menu() { ) ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); @@ -306,7 +306,7 @@ public function test_should_not_create_fallback_from_classic_menu_if_a_navigatio ) ); - $data = WP_Navigation_Fallback_Gutenberg::get_fallback(); + $data = Gutenberg_Navigation_Fallback::get_fallback(); $this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' ); diff --git a/phpunit/class-wp-rest-navigation-fallback-controller-test.php b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php similarity index 96% rename from phpunit/class-wp-rest-navigation-fallback-controller-test.php rename to phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php index 1cdedb568a5cd7..14ab8ee0971dd9 100644 --- a/phpunit/class-wp-rest-navigation-fallback-controller-test.php +++ b/phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php @@ -1,6 +1,6 @@