Automattic\WooCommerce\Admin\Notes
Note::__construct
Note constructor. Loads note data.
Method of the class: Note{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Note = new Note(); $Note->__construct( $data );
- $data(mixed)
- Note data, object, or ID.
Default:''
Note::__construct() Note:: construct code WC 10.6.2
public function __construct( $data = '' ) {
// Set default data here to allow `content_data` to be an object.
$this->data = array(
'name' => '-',
'type' => self::E_WC_ADMIN_NOTE_INFORMATIONAL,
'locale' => 'en_US',
'title' => '-',
'content' => '-',
'content_data' => new \stdClass(),
'status' => self::E_WC_ADMIN_NOTE_UNACTIONED,
'source' => 'woocommerce',
'date_created' => '0000-00-00 00:00:00',
'date_reminder' => null,
'is_snoozable' => false,
'actions' => array(),
'layout' => 'plain',
'image' => '',
'is_deleted' => false,
'is_read' => false,
);
parent::__construct( $data );
if ( $data instanceof Note ) {
$this->set_id( absint( $data->get_id() ) );
} elseif ( is_numeric( $data ) ) {
$this->set_id( $data );
} elseif ( is_object( $data ) && ! empty( $data->note_id ) ) {
$this->set_id( $data->note_id );
unset( $data->icon ); // Icons are deprecated.
$this->set_props( (array) $data );
$this->set_object_read( true );
} else {
$this->set_object_read( true );
}
$this->data_store = Notes::load_data_store();
if ( $this->get_id() > 0 ) {
$this->data_store->read( $this );
}
}