diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 7b5aeb8948..537425d898 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4078,12 +4078,14 @@ function _wp_json_prepare_data( $data ) { * * @since 3.5.0 * @since 4.7.0 The `$status_code` parameter was added. + * @since 5.6.0 The `$options` parameter was added. * * @param mixed $response Variable (usually an array or object) to encode as JSON, * then print and die. - * @param int $status_code The HTTP status code to output. + * @param int $status_code Optional. The HTTP status code to output. Default null. + * @param int $options Optional. Options to be passed to json_encode(). Default 0. */ -function wp_send_json( $response, $status_code = null ) { +function wp_send_json( $response, $status_code = null, $options = 0 ) { if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { _doing_it_wrong( __FUNCTION__, @@ -4104,7 +4106,7 @@ function wp_send_json( $response, $status_code = null ) { } } - echo wp_json_encode( $response ); + echo wp_json_encode( $response, $options ); if ( wp_doing_ajax() ) { wp_die( @@ -4124,18 +4126,20 @@ function wp_send_json( $response, $status_code = null ) { * * @since 3.5.0 * @since 4.7.0 The `$status_code` parameter was added. + * @since 5.6.0 The `$options` parameter was added. * - * @param mixed $data Data to encode as JSON, then print and die. - * @param int $status_code The HTTP status code to output. + * @param mixed $data Optional. Data to encode as JSON, then print and die. Default null. + * @param int $status_code Optional. The HTTP status code to output. Default null. + * @param int $options Optional. Options to be passed to json_encode(). Default 0. */ -function wp_send_json_success( $data = null, $status_code = null ) { +function wp_send_json_success( $data = null, $status_code = null, $options = 0 ) { $response = array( 'success' => true ); if ( isset( $data ) ) { $response['data'] = $data; } - wp_send_json( $response, $status_code ); + wp_send_json( $response, $status_code, $options ); } /** @@ -4149,11 +4153,13 @@ function wp_send_json_success( $data = null, $status_code = null ) { * @since 3.5.0 * @since 4.1.0 The `$data` parameter is now processed if a WP_Error object is passed in. * @since 4.7.0 The `$status_code` parameter was added. + * @since 5.6.0 The `$options` parameter was added. * - * @param mixed $data Data to encode as JSON, then print and die. - * @param int $status_code The HTTP status code to output. + * @param mixed $data Optional. Data to encode as JSON, then print and die. Default null. + * @param int $status_code Optional. The HTTP status code to output. Default null. + * @param int $options Optional. Options to be passed to json_encode(). Default 0. */ -function wp_send_json_error( $data = null, $status_code = null ) { +function wp_send_json_error( $data = null, $status_code = null, $options = 0 ) { $response = array( 'success' => false ); if ( isset( $data ) ) { @@ -4174,7 +4180,7 @@ function wp_send_json_error( $data = null, $status_code = null ) { } } - wp_send_json( $response, $status_code ); + wp_send_json( $response, $status_code, $options ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 79b19a670f..f79dc901f6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49234'; +$wp_version = '5.6-alpha-49235'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.