Skip to content

Commit

Permalink
Don't use the custom 'Template Parts' page with WP 6.1 and above (#45158
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Mamaduka authored Oct 21, 2022
1 parent 24ade9d commit 902dd72
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/compat/wordpress-6.1/template-parts-screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down

0 comments on commit 902dd72

Please sign in to comment.