PluginProbe ʕ •ᴥ•ʔ
Disable Admin Notices – Hide Dashboard Notifications / trunk
Disable Admin Notices – Hide Dashboard Notifications vtrunk
1.4.5 trunk 1.0.0 1.0.2 1.0.3 1.0.5 1.0.6 1.1.1 1.1.3 1.1.4 1.2.0 1.2.2 1.2.3 1.2.4 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4
disable-admin-notices / libs / factory / forms / includes / providers / options-value-provider.class.php
disable-admin-notices / libs / factory / forms / includes / providers Last commit date
index.php 3 years ago meta-value-provider.class.php 1 year ago options-value-provider.class.php 1 year ago value-provider.interface.php 1 year ago
options-value-provider.class.php
98 lines
1 <?php
2 /**
3 * The file contains the class of Factory Option Value Provider.
4 *
5 * @author Alex Kovalev <alex.kovalevv@gmail.com>
6 * @copyright (c) 2018, Webcraftic Ltd
7 *
8 * @package factory-forms
9 * @since 1.0.0
10 */
11 // Exit if accessed directly
12 if( !defined('ABSPATH') ) {
13 exit;
14 }
15
16 if( !class_exists('Wbcr_FactoryForms480_OptionsValueProvider') ) {
17
18 /**
19 * Factory Options Value Provider
20 *
21 * This provide stores form values in the wordpress options.
22 *
23 * @since 1.0.0
24 */
25 class Wbcr_FactoryForms480_OptionsValueProvider implements Wbcr_IFactoryForms480_ValueProvider {
26
27 /**
28 * A prefix that will be added to all option names.
29 *
30 * @since 1.0.0
31 * @var string
32 */
33 public $scope;
34
35 public $plugin;
36
37 /**
38 * Values to save $optionName => $optionValue
39 *
40 * @since 1.0.0
41 * @var mixed[]
42 */
43 private $values = array();
44
45 /**
46 * Creates a new instance of an options value provider.
47 */
48 public function __construct(Wbcr_Factory480_Plugin $plugin)
49 {
50 $this->plugin = $plugin;
51 }
52
53 /**
54 * @since 1.0.0
55 */
56 public function init()
57 {
58 // nothing to do
59 }
60
61 /**
62 * @since 1.0.0
63 */
64 public function saveChanges()
65 {
66 foreach((array)$this->values as $option_name => $option_value) {
67 $this->plugin->updatePopulateOption($option_name, $option_value);
68 }
69 }
70
71 public function getValue($name, $default = null, $multiple = false)
72 {
73 $value = $this->plugin->getPopulateOption($name, $default);
74
75 if( $value === 'true' || $value === true ) {
76 $value = 1;
77 }
78 if( $value === 'false' || $value === false ) {
79 $value = 0;
80 }
81
82 return $value;
83 }
84
85 /**
86 * @param string $name
87 * @param mixed $value
88 */
89 public function setValue($name, $value)
90 {
91 $value = empty($value)
92 ? $value
93 : stripslashes($value);
94
95 $this->values[$name] = $value;
96 }
97 }
98 }