-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify template parts in error messages #28398
Identify template parts in error messages #28398
Conversation
Adding the template part slug to the error messages helps developers identify the missing template part.
Co-authored-by: Ari Stathopoulos <[email protected]>
Co-authored-by: Ari Stathopoulos <[email protected]>
Remove the icons that were left after solving the merge conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -65,8 +65,12 @@ function render_block_core_template_part( $attributes ) { | |||
} | |||
} | |||
|
|||
if ( ! $template_part_id || is_null( $content ) ) { | |||
return __( 'Template Part not found.' ); | |||
if ( is_null( $content ) && is_user_logged_in() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this check for a user role and not only logged in users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that too... Maybe current_user_can( edit_themes );
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps leave it as is until #27597
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ That's why I approved the PR 😆
Description
Fixes #28056
This PR adds the template part slug to the error messages when a template part can not be found.
The error message on the front is only visible to logged in users and is now translatable.
How has this been tested?
To confirm the issue in #28056 you first need a full site editing theme where a template part is missing.
You can install TT1 Blocks and rename either the header or footer template part files inside
the block-template-parts folder, and view the site editor and the front.
In the site editor, you should see the message: Template part has been deleted or is unavailable.
On the front, you should see: Template Part Not Found.
If you log out, you should see that the error message is visible to all visitors.
Apply the PR.
View the front while logged out. The error message should not be visible.
Login. The error message should now say: Template part has been deleted or is unavailable: (template part slug)
Open the site editor. The error message should now say: Template part has been deleted or is unavailable: (template part slug)
Screenshots
Types of changes
Enhancement, bug fix.
Checklist: