PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.2
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.2
3.3.2 3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 All 157 releases
notificationx / vendor / priyomukul / wp-notice / src / Utils / Storage.php

Storage.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.3.2, at vendor/priyomukul/wp-notice/src/Utils/Storage.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PriyoMukul\WPNotice\Utils;
4
5 use function property_exists;
6
7 #[\AllowDynamicProperties]
8 class Storage extends Base {
9 private $id = 'wpnotice';
10 private $type = 'options';
11 private $version = '1.1.0';
12 private $storage_key = 'notices';
13
14 public function __construct( $args ) {
15 $this->id = ! empty( $args['id'] ) ? $args['id'] : $this->id;
16 $this->type = ! empty( $args['store'] ) ? $args['store'] : $this->type;
17 $this->storage_key = ! empty( $args['storage_key'] ) ? $this->id . '_' . $args['storage_key'] : "{$this->id}_{$this->storage_key}";
18 }
19
20 public function __get( $name ) {
21 return property_exists( $this, $name ) ? $this->$name : null;
22 }
23
24 public function save( $value, $key = '' ) {
25 if ( empty( $key ) ) {
26 $key = $this->storage_key;
27 $value['version'] = $this->version;
28 }
29
30 if ( $this->type === 'options' ) {
31 return update_site_option( $key, $value );
32 }
33
34 return false;
35 }
36
37 public function get( $key = '', $default = false ) {
38 $key = empty( $key ) ? $this->storage_key : $key;
39
40 if ( $this->type === 'options' ) {
41 return get_site_option( $key, $default );
42 }
43
44 return $default;
45 }
46
47 public function save_meta( $id, $value = true ) {
48 return update_user_meta( get_current_user_id(), "{$this->id}_{$id}_notice_dismissed", $value );
49 }
50
51 public function get_meta( $id ) {
52 return boolval( get_user_meta( get_current_user_id(), "{$this->id}_{$id}_notice_dismissed", true ) );
53 }
54
55 public function remove_meta( $id ) {
56 return delete_user_meta( get_current_user_id(), "{$this->id}_{$id}_notice_dismissed" );
57 }
58 }