PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.1.0
Kirki – Freeform Page Builder, Website Builder & Customizer v6.1.0
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / customizer / packages / utils / src / Setting / Site_Option.php
kirki / customizer / packages / utils / src / Setting Last commit date
Site_Option.php 5 months ago User_Meta.php 5 months ago
Site_Option.php
76 lines
1 <?php
2 /**
3 * WordPress Customize Setting classes
4 *
5 * @package Kirki
6 * @subpackage Modules
7 * @since 3.0.0
8 */
9
10 namespace Kirki\Util\Setting;
11
12 /**
13 * Handles saving and sanitizing of user-meta.
14 *
15 * @since 3.0.0
16 * @see WP_Customize_Setting
17 */
18 class Site_Option extends \WP_Customize_Setting {
19
20 /**
21 * Type of customize settings.
22 *
23 * @access public
24 * @since 3.0.0
25 * @var string
26 */
27 public $type = 'site_option';
28
29 /**
30 * Get the root value for a setting, especially for multidimensional ones.
31 *
32 * @access protected
33 * @since 3.0.0
34 * @param mixed $default Value to return if root does not exist.
35 * @return mixed
36 */
37 protected function get_root_value( $default = null ) {
38 return get_site_option( $this->id_data['base'], $default );
39 }
40
41 /**
42 * Set the root value for a setting, especially for multidimensional ones.
43 *
44 * @access protected
45 * @since 3.0.0
46 * @param mixed $value Value to set as root of multidimensional setting.
47 * @return bool Whether the multidimensional root was updated successfully.
48 */
49 protected function set_root_value( $value ) {
50 return update_site_option( $this->id_data['base'], $value );
51 }
52
53 /**
54 * Save the value of the setting, using the related API.
55 *
56 * @access protected
57 * @since 3.0.0
58 * @param mixed $value The value to update.
59 * @return bool The result of saving the value.
60 */
61 protected function update( $value ) {
62 return $this->set_root_value( $value );
63 }
64
65 /**
66 * Fetch the value of the setting.
67 *
68 * @access protected
69 * @since 3.0.0
70 * @return mixed The value.
71 */
72 public function value() {
73 return $this->get_root_value( $this->default );
74 }
75 }
76