WP_REST_Server::get_json_encode_options()
Gets the encoding options passed to wp_json_encode().
Метод класса: WP_REST_Server{}
Хуки из метода
Возвращает
int
. The JSON encode options.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_json_encode_options( $request );
- $request(\WP_REST_Request) (обязательный)
- The current request object.
Список изменений
С версии 6.1.0 | Введена. |
Код WP_REST_Server::get_json_encode_options() WP REST Server::get json encode options WP 6.5.2
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 ); }