And try/catch if cannot unregister the note

This commit is contained in:
Narek Zakarian 2025-08-18 15:35:29 +04:00
parent 1179a17ae3
commit 3d7654b2ea
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -9,6 +9,8 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Settings\WcInboxNotes;
use Automattic\WooCommerce\Admin\Notes\Note;
use Automattic\WooCommerce\Admin\Notes\Notes;
use Automattic\WooCommerce\Admin\Notes\NotesUnavailableException;
use Exception;
use WpOop\WordPress\Plugin\PluginInterface;
/**
@ -30,7 +32,11 @@ class InboxNoteRegistrar {
public function register(): void {
foreach ( $this->inbox_notes as $inbox_note ) {
if ( ! $inbox_note->is_enabled() ) {
$this->unregister( $inbox_note->name() );
try {
$this->unregister( $inbox_note->name() );
} catch ( Exception $exeption ) {
continue;
}
continue;
}
@ -62,6 +68,9 @@ class InboxNoteRegistrar {
}
}
/**
* @throws NotesUnavailableException If unable to unregister the note.
*/
public function unregister( string $inbox_note_name ): void {
$data_store = Notes::load_data_store();
$existing_note_ids = $data_store->get_notes_with_name( $inbox_note_name );