# status_header()

URL: https://chugunov.pro/api-wordpress/functions/status_header/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.0.0.

## Сигнатура

```php
status_header( int $code, string $description = '' )
```

## Описание

См. alsoget_status_header_desc()

## Параметры

- `$code` `int` — обязательный. Код HTTP-статуса.
- `$description` `string` — необязательный, по умолчанию `''`. Пользовательское описание для HTTP-статуса.
  
  По умолчанию — результат get_status_header_desc() для указанного кода.

## Исходный код

Файл: `wp-includes/functions.php:1458`

```php
function status_header( $code, $description = '' ) {
	if ( ! $description ) {
		$description = get_status_header_desc( $code );
	}

	if ( empty( $description ) ) {
		return;
	}

	$protocol      = wp_get_server_protocol();
	$status_header = "$protocol $code $description";
	if ( function_exists( 'apply_filters' ) ) {

		/**
		 * Filters an HTTP status header.
		 *
		 * @since 2.2.0
		 *
		 * @param string $status_header HTTP status header.
		 * @param int    $code          HTTP status code.
		 * @param string $description   Description for the status code.
		 * @param string $protocol      Server protocol.
		 */
		$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
	}

	if ( ! headers_sent() ) {
		header( $status_header, true, $code );
	}
}
```

## История изменений

- 4.4.0 — Added the $description parameter.
- 2.0.0 — Introduced.

## Связанные

Использует: [`wp_get_server_protocol`](https://chugunov.pro/api-wordpress/functions/wp_get_server_protocol/), [`get_status_header_desc`](https://chugunov.pro/api-wordpress/functions/get_status_header_desc/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: `IXR_Server::serve`, `wp_xmlrpc_server::error`, `WP_Sitemaps::render_sitemaps`, [`_jsonp_wp_die_handler`](https://chugunov.pro/api-wordpress/functions/_jsonp_wp_die_handler/), [`_xml_wp_die_handler`](https://chugunov.pro/api-wordpress/functions/_xml_wp_die_handler/), [`_json_wp_die_handler`](https://chugunov.pro/api-wordpress/functions/_json_wp_die_handler/), `WP_Customize_Nav_Menus::ajax_insert_auto_draft_post`, `WP_Customize_Selective_Refresh::handle_render_partials_request`, [`_oembed_rest_pre_serve_request`](https://chugunov.pro/api-wordpress/functions/_oembed_rest_pre_serve_request/), `WP_REST_Server::set_status`, [`wp_redirect`](https://chugunov.pro/api-wordpress/functions/wp_redirect/), `WP::handle_404`, `WP::send_headers`, [`wp_send_json`](https://chugunov.pro/api-wordpress/functions/wp_send_json/), [`_default_wp_die_handler`](https://chugunov.pro/api-wordpress/functions/_default_wp_die_handler/), [`_ajax_wp_die_handler`](https://chugunov.pro/api-wordpress/functions/_ajax_wp_die_handler/), [`send_origin_headers`](https://chugunov.pro/api-wordpress/functions/send_origin_headers/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/status_header/
