WP_Error::__construct()publicWP 2.1.0

Initializes the error.

If $code is empty, the other parameters will be ignored. When $code is not empty, $message will be used even if it is empty. The $data parameter will be used only if it is not empty.

Though the class is constructed with a single error code and message, multiple codes can be added using the add() method.

Метод класса: WP_Error{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$WP_Error = new WP_Error();
$WP_Error->__construct( $code, $message, $data );
$code(строка|int)
Error code.
По умолчанию: ''
$message(строка)
Error message.
По умолчанию: ''
$data(разное)
Error data.
По умолчанию: empty string

Список изменений

С версии 2.1.0 Введена.

Код WP_Error::__construct() WP 6.5.2

public function __construct( $code = '', $message = '', $data = '' ) {
	if ( empty( $code ) ) {
		return;
	}

	$this->add( $code, $message, $data );
}