1 | <?php |
||
44 | class CMB2_Option { |
||
45 | |||
46 | /** |
||
47 | * Options array |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $options = array(); |
||
52 | |||
53 | /** |
||
54 | * Current option key |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $key = ''; |
||
59 | |||
60 | /** |
||
61 | * Initiate option object |
||
62 | * |
||
63 | * @param string $option_key Option key where data will be saved. |
||
64 | * Leave empty for temporary data store. |
||
65 | * @since 2.0.0 |
||
66 | */ |
||
67 | 6 | public function __construct( $option_key = '' ) { |
|
70 | |||
71 | /** |
||
72 | * Delete the option from the db |
||
73 | * |
||
74 | * @since 2.0.0 |
||
75 | * @return bool Delete success or failure |
||
76 | */ |
||
77 | public function delete_option() { |
||
82 | |||
83 | /** |
||
84 | * Removes an option from an option array |
||
85 | * |
||
86 | * @since 1.0.1 |
||
87 | * @param string $field_id Option array field key |
||
88 | * @return array Modified options |
||
89 | */ |
||
90 | 1 | public function remove( $field_id, $resave = false ) { |
|
104 | |||
105 | /** |
||
106 | * Retrieves an option from an option array |
||
107 | * |
||
108 | * @since 1.0.1 |
||
109 | * @param string $field_id Option array field key |
||
110 | * @param mixed $default Fallback value for the option |
||
111 | * @return array Requested field or default |
||
112 | */ |
||
113 | 7 | public function get( $field_id, $default = false ) { |
|
124 | |||
125 | /** |
||
126 | * Updates Option data |
||
127 | * |
||
128 | * @since 1.0.1 |
||
129 | * @param string $field_id Option array field key |
||
130 | * @param mixed $value Value to update data with |
||
131 | * @param bool $resave Whether to re-save the data |
||
132 | * @param bool $single Whether data should not be an array |
||
133 | * @return boolean Return status of update |
||
134 | */ |
||
135 | 9 | public function update( $field_id, $value = '', $resave = false, $single = true ) { |
|
154 | |||
155 | /** |
||
156 | * Saves the option array |
||
157 | * Needs to be run after finished using remove/update_option |
||
158 | * |
||
159 | * @uses apply_filters() Calls 'cmb2_override_option_save_{$this->key}' hook |
||
160 | * to allow overwriting the option value to be stored. |
||
161 | * |
||
162 | * @since 1.0.1 |
||
163 | * @param array $options Optional options to override |
||
164 | * @return bool Success/Failure |
||
165 | */ |
||
166 | 9 | public function set( $options = array() ) { |
|
184 | |||
185 | /** |
||
186 | * Retrieve option value based on name of option. |
||
187 | * |
||
188 | * @uses apply_filters() Calls 'cmb2_override_option_get_{$this->key}' hook to allow |
||
189 | * overwriting the option value to be retrieved. |
||
190 | * |
||
191 | * @since 1.0.1 |
||
192 | * @param mixed $default Optional. Default value to return if the option does not exist. |
||
193 | * @return mixed Value set for the option. |
||
194 | */ |
||
195 | 13 | public function get_options( $default = null ) { |
|
210 | |||
211 | } |
||
212 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.