Skip to content

Commit 1cc21ee

Browse files
committed
feat: retain error code from WP Error object in wp_send_json_error
1 parent 8c492e9 commit 1cc21ee

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,6 @@ wp-tests-config.php
107107

108108
# Visual regression test diffs
109109
tests/visual-regression/specs/__snapshots__
110+
111+
# IDE generated folders
112+
.idea/

src/wp-includes/functions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4606,6 +4606,10 @@ function wp_send_json_error( $value = null, $status_code = null, $flags = 0 ) {
46064606
}
46074607

46084608
$response['data'] = $result;
4609+
if( is_null( $status_code ) ) {
4610+
// set the status code as the status of the first error if status code is null
4611+
$status_code = $value->get_error_code();
4612+
}
46094613
} else {
46104614
$response['data'] = $value;
46114615
}

0 commit comments

Comments
 (0)