WPSEO_Utils::format_json_encode()public staticYoast 1.0

Prepares data for outputting as JSON.

{} Это метод класса: WPSEO_Utils{}

Хуки из метода

Возвращает

false|Строку. The prepared JSON string.

Использование

$result = WPSEO_Utils::format_json_encode( $data );
$data(массив) (обязательный)
The data to format.

Код WPSEO_Utils::format_json_encode() Yoast 19.7.1

public static function format_json_encode( $data ) {
	$flags = ( JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );

	if ( self::is_development_mode() ) {
		$flags = ( $flags | JSON_PRETTY_PRINT );

		/**
		 * Filter the Yoast SEO development mode.
		 *
		 * @api array $data Allows filtering of the JSON data for debug purposes.
		 */
		$data = apply_filters( 'wpseo_debug_json_data', $data );
	}

	// phpcs:ignore Yoast.Yoast.AlternativeFunctions.json_encode_wp_json_encodeWithAdditionalParams -- This is the definition of format_json_encode.
	return wp_json_encode( $data, $flags );
}