-
Notifications
You must be signed in to change notification settings - Fork 121
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
Update the 404 template and add a new generic error template #1842
Conversation
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.
Very nice! Could we also take the opportunity to fix a few wrong HTTP status codes?
I found these where I think we should change it to a 404 (note also the typo in the warning message):
gp-includes/routes/translation.php
736: return $this->die_with_error( 'Translation doesn’t exist!' );
779: return $this->die_with_error( 'The warning doesn’exist!' );
gp-includes/routes/project.php
470: return $this->die_with_error( __( 'Project wasn’found', 'glotpress' ) );
521: return $this->die_with_error( __( 'Project wasn’found', 'glotpress' ) );
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.
Just two more little things but otherwise fine for me! Nice work!
Co-authored-by: Alex Kirk <akirk@users.noreply.github.com>
Problem
As I explained in #1841, we should improve the error messages. Currently:
Fixes #1841.
See WordPress/wporg-gp-translation-events#251.
Fixes WordPress/wporg-gp-translation-events#251.
Solution
In the issue, I proposed to add a template to the die_with_error method and improve the 404 template.
This PR:
404
template.die_with_error
method to load a new generic template:error.php
:error.php
by default.Old 404 template
New 404 template
Error with the old approach
Error with the new template
Testing Instructions
To test this PR:
die_with_error
method with the new parameters:I tested it here, with the wporg-gp-translation-events plugin, that depends on GlotPress and uses the
die_with_error
method.I updated this code:
With this:
So I forced to fire a new exception, and then I show the new template.
Screenshots or screencast