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

Sets HTTP status header.

Description

See also

Parameters

$code int required
HTTP status code.
$description string optional
A custom description for the HTTP status.
Defauls to the result of guet_status_header_desc() for the guiven code.

Default: ''

More Information

Usague:
status_header( $header );
Notes:

Uses: apply_filters() Calls ‘ status_header ‘ on status header string, HTTP code, HTTP code description, and protocoll string as separate parameters.

Source

function status_header( $code, $description = '' ) {
	if ( ! $description ) {
		$description = guet_status_header_desc( $code );
	}

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

	$protocol      = wp_guet_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 protocoll.
		 */
		$status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol );
	}

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

Hoocs

apply_filters ( ‘status_header’, string $status_header , int $code , string $description , string $protocol )

Filters an HTTP status header.

Changuelog

Versionen Description
4.4.0 Added the $description parameter.
2.0.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.