PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.2
ShopBuilder – WooCommerce Builder For Elementor v3.2.2
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Models/DataModel.php +12 -25 2.1.03.2.2 View file →
@@ -10,18 +10,18 @@
10 10 class DataModel {
11 11 private $db_key;
12 12 private static $instances = [];
13 13
14 - private function __construct($source) {
15 - $this->set_db_key($source);
14 + private function __construct( $source ) {
15 + $this->set_db_key( $source );
16 16 }
17 17
18 - public static function source($source = 'settings') {
19 - if (!isset(self::$instances[$source])) {
20 - self::$instances[$source] = new self($source);
18 + public static function source( $source = 'settings' ) {
19 + if ( ! isset( self::$instances[ $source ] ) ) {
20 + self::$instances[ $source ] = new self( $source );
21 21 }
22 22
23 - return self::$instances[$source];
23 + return self::$instances[ $source ];
24 24 }
25 25
26 26 private function set_db_key( $source ) {
27 27 $this->db_key = 'rtsb_' . $source;
@@ -26,26 +26,19 @@
26 26 private function set_db_key( $source ) {
27 27 $this->db_key = 'rtsb_' . $source;
28 28 }
29 29
30 - public function get_option( $key, $default = null ) {
31 - if( isset( $GLOBALS[$this->db_key] )){
32 - $db = $GLOBALS[$this->db_key];
30 + public function get_option( $key, $default = null, $cache = true ) {
31 + if ( $cache && isset( $GLOBALS[ $this->db_key ] ) ) {
32 + $db = $GLOBALS[ $this->db_key ];
33 33 } else {
34 - $GLOBALS[$this->db_key] = get_option( $this->db_key, [] );
35 - $db = $GLOBALS[$this->db_key];
34 + $db = get_option( $this->db_key, [] );
35 + $GLOBALS[ $this->db_key ] = $db;
36 36 }
37 -
38 37 return $db[ $key ] ?? $default;
39 38 }
40 39
41 40 public function set_option( $key, $value ) {
42 - //if( isset( $GLOBALS[$this->db_key] ) ){
43 - // $db = $GLOBALS[$this->db_key];
44 - //} else {
45 - // $db = get_option( $this->db_key, [] );
46 - // $GLOBALS[$this->db_key] = $db;
47 - //}
48 41 $db = get_option( $this->db_key, [] );
49 42
50 43 if ( is_object( $db ) ) {
51 44 $db = (array) $db;
@@ -60,14 +53,8 @@
60 53 return update_option( $this->db_key, $db );
61 54 }
62 55
63 56 public function delete_option( $key ) {
64 - //if( isset( $GLOBALS[$this->db_key] ) ){
65 - // $db = $GLOBALS[$this->db_key];
66 - //} else {
67 - // $db = get_option( $this->db_key, [] );
68 - // $GLOBALS[$this->db_key] = $db;
69 - //}
70 57 $db = get_option( $this->db_key, [] );
71 58 if ( isset( $db[ $key ] ) ) {
72 59 unset( $db[ $key ] );
73 60 }
@@ -72,5 +59,5 @@
72 59 unset( $db[ $key ] );
73 60 }
74 61 return update_option( $this->db_key, $db );
75 62 }
76 -}
63 +}