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 / controls / integer.php
disable-admin-notices / libs / factory / forms / controls Last commit date
customs 1 year ago holders 1 year ago checkbox.php 1 year ago color-and-opacity.php 1 year ago color.php 1 year ago datepicker-range.php 1 year ago dropdown-and-colors.php 1 year ago dropdown.php 1 year ago font.php 1 year ago google-font.php 1 year ago gradient.php 1 year ago hidden.php 1 year ago index.php 3 years ago integer.php 1 year ago list.php 1 year ago multiple-textbox.php 1 year ago paddings-editor.php 1 year ago pattern.php 1 year ago radio-colors.php 1 year ago radio.php 1 year ago textarea.php 1 year ago textbox.php 1 year ago url.php 1 year ago wp-editor.php 1 year ago
integer.php
160 lines
1 <?php
2
3 /**
4 * Integer Control
5 * Main options:
6 * name => a name of the control
7 * way => Тип значения 'slider' - слайдер, 'checkbox-slider' - чекбокс активирует слайдер, по умолчанию input
8 * checkbox => Указывается если, 'way' имеет значение 'checkbox-slider'
9 * Пример:
10 * array(
11 * 'on' => __('Show shadow', 'bizpanda'),
12 * 'off' => __('Hide shadow', 'bizpanda'),
13 * )
14 * title => Заголовок контрола
15 * slider-title => Заголовок слайдера( Только если 'way' имеет значение 'checkbox-slider' )
16 * range => Диапазон значений, указывается если 'way' имеет значение 'slider' или 'checkbox-slider'
17 * Пример: array(0,100)
18 * units => Единицы измерения(px,pt,em,%)
19 * isActive => Включение, отключение поля
20 * value => a value to show in the control
21 * default => a default value of the control if the "value" option is not specified
22 *
23 * @author Alex Kovalev <alex.kovalevv@gmail.com>
24 * @copyright (c) 2018, Webcraftic Ltd
25 *
26 * @package factory-forms
27 * @since 1.0.0
28 */
29
30 // Exit if accessed directly
31 if( !defined('ABSPATH') ) {
32 exit;
33 }
34
35 if( !class_exists('Wbcr_FactoryForms480_IntegerControl') ) {
36
37 class Wbcr_FactoryForms480_IntegerControl extends Wbcr_FactoryForms480_Control {
38
39 public $type = 'integer';
40
41 /**
42 * Converting string to integer.
43 *
44 * @since 1.0.0
45 * @return integer
46 */
47 public function html()
48 {
49
50 $name = $this->getNameOnForm();
51 $value = esc_attr($this->getValue());
52 $step = 1;
53 $range = $checkbox = array();
54 $is_active = $this->getOption('isActive', 1);
55 $unit = esc_attr($this->getOption('units'));
56
57 $way = $this->getOption('way');
58
59 if( empty($way) ) {
60 $way = 'text';
61 }
62
63 $has_slider = false;
64
65 if( in_array($way, array('slider', 'checkbox-slider')) ) {
66 $range = $this->getOption('range', array(0, 99));
67 $slider_title = $this->getOption('slider-title');
68 $checkbox = $this->getOption('checkbox');
69 $step = $this->getOption('step', 1);
70 $has_slider = true;
71 }
72
73 $this->addCssClass('factory-way-' . $way);
74
75 if( $has_slider ) {
76 $this->addCssClass('factory-has-slider');
77 }
78 ?>
79
80 <div <?php $this->attrs() ?>>
81 <?php if( $has_slider ) { ?>
82
83 <?php if( 'checkbox-slider' == $way ) { ?>
84
85 <div>
86 <label for="<?php echo esc_attr($name); ?>_checker"><?php echo $is_active
87 ? $checkbox['off']
88 : $checkbox['on']; ?></label><br>
89 <input type="checkbox" id="<?php echo esc_attr($name); ?>_checker" class="factory-checkbox" name="<?php echo esc_attr($name); ?>_checker" <?php echo $is_active
90 ? 'checked'
91 : '' ?>>
92 </div>
93
94 <?php } ?>
95
96 <div
97 data-units="<?php echo esc_attr($unit); ?>"
98 data-range-start="<?php echo esc_attr($range[0]); ?>"
99 data-range-end="<?php echo esc_attr($range[1]); ?>"
100 data-step="<?php echo esc_attr($step) ?>"
101 <?php echo !$is_active
102 ? ' style="display:none;"'
103 : '' ?>
104 class="factory-slider-container factory-slider-container-<?php echo esc_attr($name); ?>">
105 <?php if( !empty($slider_title) ): ?>
106 <label class="factory-title">
107 <?php echo esc_html($this->getOption('slider-title')); ?>
108 </label>
109 <?php endif; ?>
110
111 <div class="factory-slider">
112 <div class="factory-bar"></div>
113 <span class="factory-visible-value">
114 <?php echo esc_html($value); ?><?php echo esc_html($unit); ?>
115 </span>
116 </div>
117 <input type="hidden" name="<?php echo esc_attr($name); ?>" class="factory-result" value="<?php echo esc_attr($value); ?>"/>
118 </div>
119
120 <?php } else { ?>
121
122 <input type="number" id="<?php echo esc_attr($name); ?>" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr($value); ?>" class="factory-input-text"/>
123 <span class="factory-units"><?php echo esc_html($unit); ?></span>
124
125 <?php } ?>
126 </div><!-- .factory-integer -->
127 <?php
128 }
129
130 /**
131 * Форматирует значение без единиц измерения
132 * @param string $values
133 * @param string $unit
134 * @return string
135 */
136 public function valueFormatWithoutUnit($values, $unit)
137 {
138 if( !is_numeric($values) ) {
139 return str_replace($unit, '', $values);
140 } else {
141 return $values;
142 }
143 }
144
145 /**
146 * Форматирует значение c единицами измерения
147 * @param string $values
148 * @param string $unit
149 * @return string
150 */
151 public function valueFormatWithUnit($values, $unit)
152 {
153 if( is_numeric($values) ) {
154 return $values . $unit;
155 } else {
156 return $values;
157 }
158 }
159 }
160 }