PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 2.0.4
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v2.0.4
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / abstracts / class-evf-session.php
everest-forms / includes / abstracts Last commit date
legacy 6 years ago class-evf-background-process.php 7 years ago class-evf-deprecated-hooks.php 6 years ago class-evf-form-fields.php 2 years ago class-evf-integration.php 5 years ago class-evf-log-handler.php 6 years ago class-evf-session.php 8 years ago class-evf-settings-api.php 4 years ago
class-evf-session.php
123 lines
1 <?php
2 /**
3 * Handle data for the current customers session
4 *
5 * @version 1.0.0
6 * @package EverestForms\Abstracts
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Session class.
13 */
14 abstract class EVF_Session {
15
16 /**
17 * Customer ID.
18 *
19 * @var int $_customer_id Customer ID.
20 */
21 protected $_customer_id;
22
23 /**
24 * Session Data.
25 *
26 * @var array $_data Data array.
27 */
28 protected $_data = array();
29
30 /**
31 * Dirty when the session needs saving.
32 *
33 * @var bool $_dirty When something changes
34 */
35 protected $_dirty = false;
36
37 /**
38 * Init hooks and session data. Extended by child classes.
39 */
40 public function init() {}
41
42 /**
43 * Cleanup session data. Extended by child classes.
44 */
45 public function cleanup_sessions() {}
46
47 /**
48 * Magic get method.
49 *
50 * @param mixed $key Key to get.
51 * @return mixed
52 */
53 public function __get( $key ) {
54 return $this->get( $key );
55 }
56
57 /**
58 * Magic set method.
59 *
60 * @param mixed $key Key to set.
61 * @param mixed $value Value to set.
62 */
63 public function __set( $key, $value ) {
64 $this->set( $key, $value );
65 }
66
67 /**
68 * Magic isset method.
69 *
70 * @param mixed $key Key to check.
71 * @return bool
72 */
73 public function __isset( $key ) {
74 return isset( $this->_data[ sanitize_title( $key ) ] );
75 }
76
77 /**
78 * Magic unset method.
79 *
80 * @param mixed $key Key to unset.
81 */
82 public function __unset( $key ) {
83 if ( isset( $this->_data[ $key ] ) ) {
84 unset( $this->_data[ $key ] );
85 $this->_dirty = true;
86 }
87 }
88
89 /**
90 * Get a session variable.
91 *
92 * @param string $key Key to get.
93 * @param mixed $default used if the session variable isn't set.
94 * @return array|string value of session variable
95 */
96 public function get( $key, $default = null ) {
97 $key = sanitize_key( $key );
98 return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
99 }
100
101 /**
102 * Set a session variable.
103 *
104 * @param string $key Key to set.
105 * @param mixed $value Value to set.
106 */
107 public function set( $key, $value ) {
108 if ( $value !== $this->get( $key ) ) {
109 $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
110 $this->_dirty = true;
111 }
112 }
113
114 /**
115 * Get customer ID.
116 *
117 * @return int
118 */
119 public function get_customer_id() {
120 return $this->_customer_id;
121 }
122 }
123