PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 2.3.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v2.3.5
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
betterdocs / admin / wp-notice / Utils / Storage.php

Storage.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 2.3.5, at admin/wp-notice/Utils/Storage.php

59 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 BetterDocs\WPNotice\Utils;
4
5 use function property_exists;
6
7 class Storage extends Base {
8 private $app = 'wpnotice';
9 private $type = 'options';
10 private $version = '1.0.0';
11 private $storage_key = 'wpnotice_options';
12
13 public function __construct( $args ){
14 $this->app = ! empty( $args['id'] ) ? $args['id'] : $this->app;
15 $this->type = ! empty( $args['store'] ) ? $args['store'] : $this->type;
16 $this->version = ! empty( $args['version'] ) ? $args['version'] : $this->version;
17 $this->storage_key = ! empty( $args['storage_key'] ) ? $this->app . '_' . $args['storage_key'] : $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->app}_{$id}_notice_dismissed", $value );
49 }
50
51 public function get_meta( $id ){
52 return boolval( get_user_meta( get_current_user_id(), "{$this->app}_{$id}_notice_dismissed", true ) );
53 }
54
55 public function remove_meta( $id ){
56 return delete_user_meta( get_current_user_id(), "{$this->app}_{$id}_notice_dismissed" );
57 }
58
59 }