NoteTraits
NoteTraits class.
Table of Contents
- add_note() : mixed
- Alias this method for backwards compatibility.
- can_be_added() : bool
- Checks if a note can and should be added.
- delete_if_not_applicable() : mixed
- Delete this note if it is not applicable, unless has been soft-deleted or actioned already.
- has_note_been_actioned() : bool
- Get if the note has been actioned.
- is_applicable() : mixed
- Should this note exist? (Default implementation is generous. Override as needed.)
- note_exists() : mixed
- Check if the note has been previously added.
- possibly_add_note() : mixed
- Add the note if it passes predefined conditions.
- possibly_delete_note() : mixed
- Possibly delete the note, if it exists in the database. Note that this is a hard delete, for where it doesn't make sense to soft delete or action the note.
- possibly_update_note() : mixed
- Update the note if it passes predefined conditions.
- is_wc_admin_active_in_date_range() : bool
- Test if WooCommerce Admin has been active within a pre-defined range.
- possibly_convert_object_to_array() : mixed
- Convert a value to array if it's a stdClass.
- update_note_field_if_changed() : bool
- Update a note field of note1 if it's different from note2 with getter and setter.
- wc_admin_active_for() : bool
- Test how long WooCommerce Admin has been active.
Methods
add_note()
Alias this method for backwards compatibility.
public
static add_note() : mixed
Tags
Return values
mixed —can_be_added()
Checks if a note can and should be added.
public
static can_be_added() : bool
Tags
Return values
bool —delete_if_not_applicable()
Delete this note if it is not applicable, unless has been soft-deleted or actioned already.
public
static delete_if_not_applicable() : mixed
Return values
mixed —has_note_been_actioned()
Get if the note has been actioned.
public
static has_note_been_actioned() : bool
Tags
Return values
bool —is_applicable()
Should this note exist? (Default implementation is generous. Override as needed.)
public
static is_applicable() : mixed
Return values
mixed —note_exists()
Check if the note has been previously added.
public
static note_exists() : mixed
Tags
Return values
mixed —possibly_add_note()
Add the note if it passes predefined conditions.
public
static possibly_add_note() : mixed
Tags
Return values
mixed —possibly_delete_note()
Possibly delete the note, if it exists in the database. Note that this is a hard delete, for where it doesn't make sense to soft delete or action the note.
public
static possibly_delete_note() : mixed
Tags
Return values
mixed —possibly_update_note()
Update the note if it passes predefined conditions.
public
static possibly_update_note() : mixed
Tags
Return values
mixed —is_wc_admin_active_in_date_range()
Test if WooCommerce Admin has been active within a pre-defined range.
private
static is_wc_admin_active_in_date_range(string $range[, int $custom_start = null ]) : bool
Parameters
- $range : string
-
range available in WC_ADMIN_STORE_AGE_RANGES.
- $custom_start : int = null
-
custom start in range.
Return values
bool — Whether or not WooCommerce admin has been active within the range.possibly_convert_object_to_array()
Convert a value to array if it's a stdClass.
private
static possibly_convert_object_to_array(mixed $obj) : mixed
Parameters
- $obj : mixed
-
variable to convert.
Return values
mixed —update_note_field_if_changed()
Update a note field of note1 if it's different from note2 with getter and setter.
private
static update_note_field_if_changed(Note $note1, Note $note2, string $field_name) : bool
Parameters
- $note1 : Note
-
Note to update.
- $note2 : Note
-
Note to compare against.
- $field_name : string
-
Field to update.
Return values
bool — True if the field was updated.wc_admin_active_for()
Test how long WooCommerce Admin has been active.
private
static wc_admin_active_for(int $seconds) : bool
Parameters
- $seconds : int
-
Time in seconds to check.