WP_REST_Server::get_json_encode_options( WP_REST_Request $request )

Gets the encoding options passed to {@see wp_json_encode}.


Parameters

$request

(Required) The current request object.


Return

(int) The JSON encode options.


Source

File: wp-includes/rest-api/class-wp-rest-server.php

	protected function get_json_encode_options( WP_REST_Request $request ) {
		$options = 0;

		if ( $request->has_param( '_pretty' ) ) {
			$options |= JSON_PRETTY_PRINT;
		}

		/**
		 * Filters the JSON encoding options used to send the REST API response.
		 *
		 * @since 6.1.0
		 *
		 * @param int $options             JSON encoding options {@see json_encode()}.
		 * @param WP_REST_Request $request Current request object.
		 */
		return apply_filters( 'rest_json_encode_options', $options, $request );
	}

Changelog

Changelog
Version Description
6.1.0 Introduced.