PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.2
Elementor Website Builder – more than just a page builder v4.2.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / controls / base-units.php

base-units.php in Elementor Website Builder – more than just a page builder 4.2.2, at includes/controls/base-units.php

160 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor control base units.
10 *
11 * An abstract class for creating new unit controls in the panel.
12 *
13 * @since 1.0.0
14 * @abstract
15 */
16 abstract class Control_Base_Units extends Control_Base_Multiple {
17
18 /**
19 * Get units control default value.
20 *
21 * Retrieve the default value of the units control. Used to return the default
22 * values while initializing the units control.
23 *
24 * @since 1.0.0
25 * @access public
26 *
27 * @return array Control default value.
28 */
29 public function get_default_value() {
30 return [
31 'unit' => 'px',
32 ];
33 }
34
35 /**
36 * Get units control default settings.
37 *
38 * Retrieve the default settings of the units control. Used to return the default
39 * settings while initializing the units control.
40 *
41 * @since 1.0.0
42 * @access protected
43 *
44 * @return array Control default settings.
45 */
46 protected function get_default_settings() {
47 return [
48 'size_units' => [ 'px' ],
49 'range' => [
50 'px' => [
51 'min' => 0,
52 'max' => 100,
53 'step' => 1,
54 ],
55 'em' => [
56 'min' => 0.1,
57 'max' => 10,
58 'step' => 0.1,
59 ],
60 'rem' => [
61 'min' => 0.1,
62 'max' => 10,
63 'step' => 0.1,
64 ],
65 '%' => [
66 'min' => 0,
67 'max' => 100,
68 'step' => 1,
69 ],
70 'deg' => [
71 'min' => 0,
72 'max' => 360,
73 'step' => 1,
74 ],
75 'grad' => [
76 'min' => 0,
77 'max' => 400,
78 'step' => 1,
79 ],
80 'rad' => [
81 'min' => 0,
82 'max' => 6.2832,
83 'step' => 0.0001,
84 ],
85 'turn' => [
86 'min' => 0,
87 'max' => 1,
88 'step' => 0.01,
89 ],
90 'vh' => [
91 'min' => 0,
92 'max' => 100,
93 'step' => 1,
94 ],
95 'vw' => [
96 'min' => 0,
97 'max' => 100,
98 'step' => 1,
99 ],
100 's' => [
101 'min' => 0,
102 'max' => 3,
103 'step' => 0.1,
104 ],
105 'ms' => [
106 'min' => 0,
107 'max' => 3000,
108 'step' => 100,
109 ],
110 ],
111 ];
112 }
113
114 /**
115 * Print units control settings.
116 *
117 * Used to generate the units control template in the editor.
118 *
119 * @since 1.0.0
120 * @access protected
121 */
122 protected function print_units_template() {
123 ?>
124 <# if ( data.size_units && data.size_units.length > 1 ) { #>
125 <div class="e-units-wrapper">
126 <div class="e-units-switcher">
127 <span></span>
128 <i class="eicon-edit" aria-hidden="true"></i>
129 <i class="eicon-angle-right" aria-hidden="true"></i>
130 <span class="elementor-screen-only"><?php echo esc_html__( 'Switch units', 'elementor' ); ?></span>
131 </div>
132 <div class="e-units-choices">
133 <# _.each( data.size_units, function( unit ) { #>
134 <input id="elementor-choose-{{ data._cid + data.name + unit }}" type="radio" name="elementor-choose-{{ data.name + data._cid }}" data-setting="unit" value="{{ unit }}">
135 <label class="elementor-units-choices-label" for="elementor-choose-{{ data._cid + data.name + unit }}" data-choose="{{{ unit }}}">
136 <# if ( 'custom' === unit ) { #>
137 <i class="eicon-edit" aria-hidden="true"></i>
138 <span class="elementor-screen-only"><?php echo esc_html__( 'Custom unit', 'elementor' ); ?></span>
139 <# } else { #>
140 <span>{{{ unit }}}</span>
141 <# } #>
142 </label>
143 <# } ); #>
144 </div>
145 </div>
146 <# } #>
147 <?php
148 }
149
150 public function get_style_value( $css_property, $control_value, array $control_data ) {
151 $return_value = parent::get_style_value( $css_property, $control_value, $control_data );
152
153 if ( 'UNIT' === $css_property && 'custom' === $return_value ) {
154 $return_value = '__EMPTY__';
155 }
156
157 return $return_value;
158 }
159 }
160