Skip to content

Commit c55a4a8

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

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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+
// Sets the status code as the status of the first error if the status code is null
4611+
$status_code = $value->get_error_code();
4612+
}
46094613
} else {
46104614
$response['data'] = $value;
46114615
}

0 commit comments

Comments
 (0)