From 902dd7278f4f978ae719f41b8ca37f9858d55b01 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 21 Oct 2022 12:31:14 +0400 Subject: [PATCH] Don't use the custom 'Template Parts' page with WP 6.1 and above (#45158) --- .../wordpress-6.1/template-parts-screen.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/compat/wordpress-6.1/template-parts-screen.php b/lib/compat/wordpress-6.1/template-parts-screen.php index 93b68436764b3..d9b785100b8d9 100644 --- a/lib/compat/wordpress-6.1/template-parts-screen.php +++ b/lib/compat/wordpress-6.1/template-parts-screen.php @@ -24,6 +24,24 @@ function gutenberg_template_parts_screen_menu() { return; } + global $submenu; + if ( ! isset( $submenu['themes.php'] ) ) { + return; + } + + $needs_custom_page = true; + foreach ( $submenu['themes.php'] as $menu_item ) { + if ( str_contains( $menu_item[2], 'site-editor.php?postType=wp_template_part' ) ) { + $needs_custom_page = false; + break; + } + } + + // Don't use the custom 'Template Parts' page with WP 6.1 and above. + if ( ! $needs_custom_page ) { + return; + } + add_theme_page( __( 'Template Parts', 'gutenberg' ), __( 'Template Parts', 'gutenberg' ),