-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathAbstractNote.php
54 lines (45 loc) · 1.13 KB
/
AbstractNote.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Notes;
use Automattic\WooCommerce\Admin\Notes\Notes;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsAwareInterface;
use WC_Data_Store;
defined( 'ABSPATH' ) || exit;
/**
* AbstractNote class.
*
* @since 1.7.0
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Notes
*/
abstract class AbstractNote implements Note, OptionsAwareInterface {
/**
* Remove the note from the datastore.
*
* @since 1.12.5
*/
public function delete() {
if ( class_exists( Notes::class ) ) {
Notes::delete_notes_with_name( $this->get_name() );
}
}
/**
* Get note data store.
*
* @see \Automattic\WooCommerce\Admin\Notes\DataStore for relavent data store.
*
* @return WC_Data_Store
*/
protected function get_data_store(): WC_Data_Store {
return WC_Data_Store::load( 'admin-note' );
}
/**
* Check if the note has already been added.
*
* @return bool
*/
protected function has_been_added(): bool {
$note_ids = $this->get_data_store()->get_notes_with_name( $this->get_name() );
return ! empty( $note_ids );
}
}