WP_Error::__construct()
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.
Method of the class: WP_Error{}
No Hooks.
Return
null
. Ничего (null).
Usage
$WP_Error = new WP_Error(); $WP_Error->__construct( $code, $message, $data );
- $code(string|int)
- Error code.
Default: '' - $message(string)
- Error message.
Default: '' - $data(mixed)
- Error data.
Default: empty string
Changelog
Since 2.1.0 | Introduced. |
WP_Error::__construct() WP Error:: construct code WP 6.4.1
public function __construct( $code = '', $message = '', $data = '' ) { if ( empty( $code ) ) { return; } $this->add( $code, $message, $data ); }