Skip to content

Commit

Permalink
Editor: Fix conditionals in Template Editing Mode.
Browse files Browse the repository at this point in the history
Previously, Site Editor client-side routing started using only the path query argument for loading non-editor views. The router removed the `postType` query 
argument, which caused an error message to be displayed when the template parts list page was reloaded.

This changeset fixes the issue as it was affecting hybrid themes.

Props Mamaduka, isabel_brison, ramonopoly.
Fixes #58889.




git-svn-id: https://develop.svn.wordpress.org/trunk@56302 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
audrasjb committed Jul 25, 2023
1 parent d3ea5c2 commit 9e9ae1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
$submenu['themes.php'][6] = array(
__( 'Template Parts' ),
'edit_theme_options',
'site-editor.php?postType=wp_template_part&path=/wp_template_part/all',
'site-editor.php?path=/wp_template_part/all',
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/wp-admin/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) );
}

$is_template_part_editor = isset( $_GET['postType'] ) && 'wp_template_part' === sanitize_key( $_GET['postType'] );
$is_template_part = isset( $_GET['postType'] ) && 'wp_template_part' === sanitize_key( $_GET['postType'] );
$is_template_part_path = isset( $_GET['path'] ) && 'wp_template_partall' === sanitize_key( $_GET['path'] );
$is_template_part_editor = $is_template_part || $is_template_part_path;

if ( ! wp_is_block_theme() && ! $is_template_part_editor ) {
wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) );
}
Expand Down

0 comments on commit 9e9ae1e

Please sign in to comment.