PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / trunk
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF vtrunk
2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / libs / factory / forms / includes / providers / options-value-provider.class.php
robin-image-optimizer / libs / factory / forms / includes / providers Last commit date
index.php 6 months ago meta-value-provider.class.php 5 months ago options-value-provider.class.php 5 months ago value-provider.interface.php 5 months ago
options-value-provider.class.php
91 lines
1 <?php
2 /**
3 * The file contains the class of Factory Option Value Provider.
4 *
5 * @package factory-forms
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( ! class_exists( 'Wbcr_FactoryForms600_OptionsValueProvider' ) ) {
14
15 /**
16 * Factory Options Value Provider
17 *
18 * This provide stores form values in the WordPress options.
19 *
20 * @since 1.0.0
21 */
22 class Wbcr_FactoryForms600_OptionsValueProvider implements Wbcr_IFactoryForms600_ValueProvider {
23
24 /**
25 * A prefix that will be added to all option names.
26 *
27 * @since 1.0.0
28 * @var string
29 */
30 public $scope;
31
32 public $plugin;
33
34 /**
35 * Values to save $optionName => $optionValue
36 *
37 * @since 1.0.0
38 * @var mixed[]
39 */
40 private $values = [];
41
42 /**
43 * Creates a new instance of an options value provider.
44 */
45 public function __construct( Wbcr_Factory600_Plugin $plugin ) {
46 $this->plugin = $plugin;
47 }
48
49 /**
50 * @since 1.0.0
51 */
52 public function init() {
53 // nothing to do
54 }
55
56 /**
57 * @since 1.0.0
58 */
59 public function saveChanges() {
60 foreach ( (array) $this->values as $option_name => $option_value ) {
61 $this->plugin->updatePopulateOption( $option_name, $option_value );
62 }
63 }
64
65 public function getValue( $name, $default = null, $multiple = false ) {
66 $value = $this->plugin->getPopulateOption( $name, $default );
67
68 if ( $value === 'true' || $value === true ) {
69 $value = 1;
70 }
71 if ( $value === 'false' || $value === false ) {
72 $value = 0;
73 }
74
75 return $value;
76 }
77
78 /**
79 * @param string $name
80 * @param mixed $value
81 */
82 public function setValue( $name, $value ) {
83 $value = empty( $value )
84 ? $value
85 : stripslashes( $value );
86
87 $this->values[ $name ] = $value;
88 }
89 }
90 }
91