WC_Notes_Run_Db_Update::get_current_notice
Get current notice id from the database.
Retrieves the first notice of this type.
Method of the class: WC_Notes_Run_Db_Update{}
No Hooks.
Returns
Note|null. Note or null in case no note was found.
Usage
$result = WC_Notes_Run_Db_Update::get_current_notice();
WC_Notes_Run_Db_Update::get_current_notice() WC Notes Run Db Update::get current notice code WC 10.4.3
private static function get_current_notice() {
try {
$data_store = \WC_Data_Store::load( 'admin-note' );
} catch ( Exception $e ) {
return;
}
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
if ( empty( $note_ids ) ) {
return;
}
$current_note_id = array_shift( $note_ids );
// Remove weird duplicates. Leave the first one.
foreach ( $note_ids as $note_id ) {
$note = new Note( $note_id );
$data_store->delete( $note );
}
return new Note( $current_note_id );
}