-
Notifications
You must be signed in to change notification settings - Fork 3.2k
63836: add error codes to wp_die in post.php #9639
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
Closed
CallumBW95
wants to merge
3
commits into
WordPress:trunk
from
CallumBW95:63836-wp_die-status-code-addition
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -124,23 +124,23 @@ | |||||
| } | ||||||
|
|
||||||
| if ( ! $post ) { | ||||||
| wp_die( __( 'You attempted to edit an item that does not exist. Perhaps it was deleted?' ) ); | ||||||
| wp_die( __( 'You attempted to edit an item that does not exist. Perhaps it was deleted?' ), 404 ); | ||||||
| } | ||||||
|
|
||||||
| if ( ! $post_type_object ) { | ||||||
| wp_die( __( 'Invalid post type.' ) ); | ||||||
| wp_die( __( 'Invalid post type.' ), 400 ); | ||||||
| } | ||||||
|
|
||||||
| if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ), true ) ) { | ||||||
| wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); | ||||||
| wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ), 403 ); | ||||||
| } | ||||||
|
|
||||||
| if ( ! current_user_can( 'edit_post', $post_id ) ) { | ||||||
| wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); | ||||||
| wp_die( __( 'Sorry, you are not allowed to edit this item.' ), 403 ); | ||||||
| } | ||||||
|
|
||||||
| if ( 'trash' === $post->post_status ) { | ||||||
| wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ) ); | ||||||
| wp_die( __( 'You cannot edit this item because it is in the Trash. Please restore it and try again.' ), 404 ); | ||||||
| } | ||||||
|
|
||||||
| if ( ! empty( $_GET['get-post-lock'] ) ) { | ||||||
|
|
@@ -239,26 +239,26 @@ | |||||
| check_admin_referer( 'trash-post_' . $post_id ); | ||||||
|
|
||||||
| if ( ! $post ) { | ||||||
| wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) ); | ||||||
| wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ), 404 ); | ||||||
CallumBW95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| } | ||||||
|
|
||||||
| if ( ! $post_type_object ) { | ||||||
| wp_die( __( 'Invalid post type.' ) ); | ||||||
| wp_die( __( 'Invalid post type.' ), 400 ); | ||||||
| } | ||||||
|
|
||||||
| if ( ! current_user_can( 'delete_post', $post_id ) ) { | ||||||
| wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); | ||||||
| wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ), 403 ); | ||||||
| } | ||||||
|
|
||||||
| $user_id = wp_check_post_lock( $post_id ); | ||||||
| if ( $user_id ) { | ||||||
| $user = get_userdata( $user_id ); | ||||||
| /* translators: %s: User's display name. */ | ||||||
| wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) ); | ||||||
| wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ), 400 ); | ||||||
|
||||||
| wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ), 400 ); | |
| wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ), 423 ); |
CallumBW95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CallumBW95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CallumBW95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CallumBW95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.