WC_Notes_Run_Db_Update::get_current_noticeprivate staticWC 1.0

Get current notice id from the database.

Retrieves the first notice of this type.

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

Хуков нет.

Возвращает

Note|null. Note or null in case no note was found.

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

$result = WC_Notes_Run_Db_Update::get_current_notice();

Код WC_Notes_Run_Db_Update::get_current_notice() WC 10.3.5

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 );
}