Add support for `WP_Error` objects passed to `wp_send_json_error()`. The error object gets output as an array of error codes and messages, rather than as an empty object.

Fixes #28978
Props paulschreiber

Built from https://develop.svn.wordpress.org/trunk@30506


git-svn-id: http://core.svn.wordpress.org/trunk@30495 1a063a9b-81f0-0310-95a4-ce76da25c4cd