PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-beta5
Elementor Website Builder – more than just a page builder v3.23.0-beta5
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 / widgets / divider.php

divider.php in Elementor Website Builder – more than just a page builder 3.23.0-beta5, at includes/widgets/divider.php

1,124 lines 32.9 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 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10
11 /**
12 * Elementor divider widget.
13 *
14 * Elementor widget that displays a line that divides different elements in the
15 * page.
16 *
17 * @since 1.0.0
18 */
19 class Widget_Divider extends Widget_Base {
20
21 /**
22 * Get widget name.
23 *
24 * Retrieve divider widget name.
25 *
26 * @since 1.0.0
27 * @access public
28 *
29 * @return string Widget name.
30 */
31 public function get_name() {
32 return 'divider';
33 }
34
35 /**
36 * Get widget title.
37 *
38 * Retrieve divider widget title.
39 *
40 * @since 1.0.0
41 * @access public
42 *
43 * @return string Widget title.
44 */
45 public function get_title() {
46 return esc_html__( 'Divider', 'elementor' );
47 }
48
49 /**
50 * Get widget icon.
51 *
52 * Retrieve divider widget icon.
53 *
54 * @since 1.0.0
55 * @access public
56 *
57 * @return string Widget icon.
58 */
59 public function get_icon() {
60 return 'eicon-divider';
61 }
62
63 /**
64 * Get widget categories.
65 *
66 * Retrieve the list of categories the divider widget belongs to.
67 *
68 * Used to determine where to display the widget in the editor.
69 *
70 * @since 2.0.0
71 * @access public
72 *
73 * @return array Widget categories.
74 */
75 public function get_categories() {
76 return [ 'basic' ];
77 }
78
79 /**
80 * Get widget keywords.
81 *
82 * Retrieve the list of keywords the widget belongs to.
83 *
84 * @since 2.1.0
85 * @access public
86 *
87 * @return array Widget keywords.
88 */
89 public function get_keywords() {
90 return [ 'divider', 'hr', 'line', 'border' ];
91 }
92
93 protected function is_dynamic_content(): bool {
94 return false;
95 }
96
97 private static function get_additional_styles() {
98 static $additional_styles = null;
99
100 if ( null !== $additional_styles ) {
101 return $additional_styles;
102 }
103 $additional_styles = [];
104 /**
105 * Additional Styles.
106 *
107 * Filters the styles used by Elementor to add additional divider styles.
108 *
109 * @since 2.7.0
110 *
111 * @param array $additional_styles Additional Elementor divider styles.
112 */
113 $additional_styles = apply_filters( 'elementor/divider/styles/additional_styles', $additional_styles );
114 return $additional_styles;
115 }
116
117 private function get_separator_styles() {
118 return array_merge(
119 self::get_additional_styles(),
120 [
121 'curly' => [
122 'label' => esc_html_x( 'Curly', 'Shapes', 'elementor' ),
123 'shape' => '<path d="M0,21c3.3,0,8.3-0.9,15.7-7.1c6.6-5.4,4.4-9.3,2.4-10.3c-3.4-1.8-7.7,1.3-7.3,8.8C11.2,20,17.1,21,24,21"/>',
124 'preserve_aspect_ratio' => false,
125 'supports_amount' => true,
126 'round' => false,
127 'group' => 'line',
128 ],
129 'curved' => [
130 'label' => esc_html_x( 'Curved', 'Shapes', 'elementor' ),
131 'shape' => '<path d="M0,6c6,0,6,13,12,13S18,6,24,6"/>',
132 'preserve_aspect_ratio' => false,
133 'supports_amount' => true,
134 'round' => false,
135 'group' => 'line',
136 ],
137 'multiple' => [
138 'label' => esc_html_x( 'Multiple', 'Shapes', 'elementor' ),
139 'shape' => '<path d="M24,8v12H0V8H24z M24,4v1H0V4H24z"/>',
140 'preserve_aspect_ratio' => false,
141 'supports_amount' => false,
142 'round' => false,
143 'group' => 'pattern',
144 ],
145 'slashes' => [
146 'label' => esc_html_x( 'Slashes', 'Shapes', 'elementor' ),
147 'shape' => '<g transform="translate(-12.000000, 0)"><path d="M28,0L10,18"/><path d="M18,0L0,18"/><path d="M48,0L30,18"/><path d="M38,0L20,18"/></g>',
148 'preserve_aspect_ratio' => false,
149 'supports_amount' => true,
150 'round' => false,
151 'view_box' => '0 0 20 16',
152 'group' => 'line',
153 ],
154 'squared' => [
155 'label' => esc_html_x( 'Squared', 'Shapes', 'elementor' ),
156 'shape' => '<polyline points="0,6 6,6 6,18 18,18 18,6 24,6 "/>',
157 'preserve_aspect_ratio' => false,
158 'supports_amount' => true,
159 'round' => false,
160 'group' => 'line',
161 ],
162 'wavy' => [
163 'label' => esc_html_x( 'Wavy', 'Shapes', 'elementor' ),
164 'shape' => '<path d="M0,6c6,0,0.9,11.1,6.9,11.1S18,6,24,6"/>',
165 'preserve_aspect_ratio' => false,
166 'supports_amount' => true,
167 'round' => false,
168 'group' => 'line',
169 ],
170 'zigzag' => [
171 'label' => esc_html_x( 'Zigzag', 'Shapes', 'elementor' ),
172 'shape' => '<polyline points="0,18 12,6 24,18 "/>',
173 'preserve_aspect_ratio' => false,
174 'supports_amount' => true,
175 'round' => false,
176 'group' => 'line',
177 ],
178 'arrows' => [
179 'label' => esc_html_x( 'Arrows', 'Shapes', 'elementor' ),
180 'shape' => '<path d="M14.2,4c0.3,0,0.5,0.1,0.7,0.3l7.9,7.2c0.2,0.2,0.3,0.4,0.3,0.7s-0.1,0.5-0.3,0.7l-7.9,7.2c-0.2,0.2-0.4,0.3-0.7,0.3s-0.5-0.1-0.7-0.3s-0.3-0.4-0.3-0.7l0-2.9l-11.5,0c-0.4,0-0.7-0.3-0.7-0.7V9.4C1,9,1.3,8.7,1.7,8.7l11.5,0l0-3.6c0-0.3,0.1-0.5,0.3-0.7S13.9,4,14.2,4z"/>',
181 'preserve_aspect_ratio' => true,
182 'supports_amount' => true,
183 'round' => true,
184 'group' => 'pattern',
185 ],
186 'pluses' => [
187 'label' => esc_html_x( 'Pluses', 'Shapes', 'elementor' ),
188 'shape' => '<path d="M21.4,9.6h-7.1V2.6c0-0.9-0.7-1.6-1.6-1.6h-1.6c-0.9,0-1.6,0.7-1.6,1.6v7.1H2.6C1.7,9.6,1,10.3,1,11.2v1.6c0,0.9,0.7,1.6,1.6,1.6h7.1v7.1c0,0.9,0.7,1.6,1.6,1.6h1.6c0.9,0,1.6-0.7,1.6-1.6v-7.1h7.1c0.9,0,1.6-0.7,1.6-1.6v-1.6C23,10.3,22.3,9.6,21.4,9.6z"/>',
189 'preserve_aspect_ratio' => true,
190 'supports_amount' => true,
191 'round' => false,
192 'group' => 'pattern',
193 ],
194 'rhombus' => [
195 'label' => esc_html_x( 'Rhombus', 'Shapes', 'elementor' ),
196 'shape' => '<path d="M12.7,2.3c-0.4-0.4-1.1-0.4-1.5,0l-8,9.1c-0.3,0.4-0.3,0.9,0,1.2l8,9.1c0.4,0.4,1.1,0.4,1.5,0l8-9.1c0.3-0.4,0.3-0.9,0-1.2L12.7,2.3z"/>',
197 'preserve_aspect_ratio' => false,
198 'supports_amount' => true,
199 'round' => false,
200 'group' => 'pattern',
201 ],
202 'parallelogram' => [
203 'label' => esc_html_x( 'Parallelogram', 'Shapes', 'elementor' ),
204 'shape' => '<polygon points="9.4,2 24,2 14.6,21.6 0,21.6"/>',
205 'preserve_aspect_ratio' => false,
206 'supports_amount' => true,
207 'round' => false,
208 'group' => 'pattern',
209 ],
210 'rectangles' => [
211 'label' => esc_html_x( 'Rectangles', 'Shapes', 'elementor' ),
212 'shape' => '<rect x="15" y="0" width="30" height="30"/>',
213 'preserve_aspect_ratio' => false,
214 'supports_amount' => true,
215 'round' => true,
216 'group' => 'pattern',
217 'view_box' => '0 0 60 30',
218 ],
219 'dots_tribal' => [
220 'label' => esc_html_x( 'Dots', 'Shapes', 'elementor' ),
221 'shape' => '<path d="M3,10.2c2.6,0,2.6,2,2.6,3.2S4.4,16.5,3,16.5s-3-1.4-3-3.2S0.4,10.2,3,10.2z M18.8,10.2c1.7,0,3.2,1.4,3.2,3.2s-1.4,3.2-3.2,3.2c-1.7,0-3.2-1.4-3.2-3.2S17,10.2,18.8,10.2z M34.6,10.2c1.5,0,2.6,1.4,2.6,3.2s-0.5,3.2-1.9,3.2c-1.5,0-3.4-1.4-3.4-3.2S33.1,10.2,34.6,10.2z M50.5,10.2c1.7,0,3.2,1.4,3.2,3.2s-1.4,3.2-3.2,3.2c-1.7,0-3.3-0.9-3.3-2.6S48.7,10.2,50.5,10.2z M66.2,10.2c1.5,0,3.4,1.4,3.4,3.2s-1.9,3.2-3.4,3.2c-1.5,0-2.6-0.4-2.6-2.1S64.8,10.2,66.2,10.2z M82.2,10.2c1.7,0.8,2.6,1.4,2.6,3.2s-0.1,3.2-1.6,3.2c-1.5,0-3.7-1.4-3.7-3.2S80.5,9.4,82.2,10.2zM98.6,10.2c1.5,0,2.6,0.4,2.6,2.1s-1.2,4.2-2.6,4.2c-1.5,0-3.7-0.4-3.7-2.1S97.1,10.2,98.6,10.2z M113.4,10.2c1.2,0,2.2,0.9,2.2,3.2s-0.1,3.2-1.3,3.2s-3.1-1.4-3.1-3.2S112.2,10.2,113.4,10.2z"/>',
222 'preserve_aspect_ratio' => true,
223 'supports_amount' => false,
224 'round' => false,
225 'group' => 'tribal',
226 'view_box' => '0 0 126 26',
227 ],
228 'trees_2_tribal' => [
229 'label' => esc_html_x( 'Fir Tree', 'Shapes', 'elementor' ),
230 'shape' => '<path d="M111.9,18.3v3.4H109v-3.4H111.9z M90.8,18.3v3.4H88v-3.4H90.8z M69.8,18.3v3.4h-2.9v-3.4H69.8z M48.8,18.3v3.4h-2.9v-3.4H48.8z M27.7,18.3v3.4h-2.9v-3.4H27.7z M6.7,18.3v3.4H3.8v-3.4H6.7z M46.4,4l4.3,4.8l-1.8,0l3.5,4.4l-2.2-0.1l3,3.3l-11,0.4l3.6-3.8l-2.9-0.1l3.1-4.2l-1.9,0L46.4,4z M111.4,4l2.4,4.8l-1.8,0l3.5,4.4l-2.5-0.1l3.3,3.3h-11l3.1-3.4l-2.5-0.1l3.1-4.2l-1.9,0L111.4,4z M89.9,4l2.9,4.8l-1.9,0l3.2,4.2l-2.5,0l3.5,3.5l-11-0.4l3-3.1l-2.4,0L88,8.8l-1.9,0L89.9,4z M68.6,4l3,4.4l-1.9,0.1l3.4,4.1l-2.7,0.1l3.8,3.7H63.8l2.9-3.6l-2.9,0.1L67,8.7l-2,0.1L68.6,4z M26.5,4l3,4.4l-1.9,0.1l3.7,4.7l-2.5-0.1l3.3,3.3H21l3.1-3.4l-2.5-0.1l3.2-4.3l-2,0.1L26.5,4z M4.9,4l3.7,4.8l-1.5,0l3.1,4.2L7.6,13l3.4,3.4H0l3-3.3l-2.3,0.1l3.5-4.4l-2.3,0L4.9,4z"/>',
231 'preserve_aspect_ratio' => true,
232 'supports_amount' => false,
233 'round' => false,
234 'group' => 'tribal',
235 'view_box' => '0 0 126 26',
236 ],
237 'rounds_tribal' => [
238 'label' => esc_html_x( 'Half Rounds', 'Shapes', 'elementor' ),
239 'shape' => '<path d="M11.9,15.9L11.9,15.9L0,16c-0.2-3.7,1.5-5.7,4.9-6C10,9.6,12.4,14.2,11.9,15.9zM26.9,15.9L26.9,15.9L15,16c0.5-3.7,2.5-5.7,5.9-6C26,9.6,27.4,14.2,26.9,15.9z M37.1,10c3.4,0.3,5.1,2.3,4.9,6H30.1C29.5,14.4,31.9,9.6,37.1,10z M57,15.9L57,15.9L45,16c0-3.4,1.6-5.4,4.9-5.9C54.8,9.3,57.4,14.2,57,15.9z M71.9,15.9L71.9,15.9L60,16c-0.2-3.7,1.5-5.7,4.9-6C70,9.6,72.4,14.2,71.9,15.9z M82.2,10c3.4,0.3,5,2.3,4.8,6H75.3C74,13,77.1,9.6,82.2,10zM101.9,15.9L101.9,15.9L90,16c-0.2-3.7,1.5-5.7,4.9-6C100,9.6,102.4,14.2,101.9,15.9z M112.1,10.1c2.7,0.5,4.3,2.5,4.9,5.9h-11.9l0,0C104.5,14.4,108,9.3,112.1,10.1z"/>',
240 'preserve_aspect_ratio' => true,
241 'supports_amount' => false,
242 'round' => false,
243 'group' => 'tribal',
244 'view_box' => '0 0 120 26',
245 ],
246 'leaves_tribal' => [
247 'label' => esc_html_x( 'Leaves', 'Shapes', 'elementor' ),
248 'shape' => '<path d="M3,1.5C5,4.9,6,8.8,6,13s-1.7,8.1-5,11.5C0.3,21.1,0,17.2,0,13S1,4.9,3,1.5z M16,1.5c2,3.4,3,7.3,3,11.5s-1,8.1-3,11.5c-2-4.1-3-8.3-3-12.5S14,4.3,16,1.5z M29,1.5c2,4.8,3,9.3,3,13.5s-1,7.4-3,9.5c-2-3.4-3-7.3-3-11.5S27,4.9,29,1.5z M41.1,1.5C43.7,4.9,45,8.8,45,13s-1,8.1-3,11.5c-2-3.4-3-7.3-3-11.5S39.7,4.9,41.1,1.5zM55,1.5c2,2.8,3,6.3,3,10.5s-1.3,8.4-4,12.5c-1.3-3.4-2-7.3-2-11.5S53,4.9,55,1.5z M68,1.5c2,3.4,3,7.3,3,11.5s-0.7,8.1-2,11.5c-2.7-4.8-4-9.3-4-13.5S66,3.6,68,1.5z M82,1.5c1.3,4.8,2,9.3,2,13.5s-1,7.4-3,9.5c-2-3.4-3-7.3-3-11.5S79.3,4.9,82,1.5z M94,1.5c2,3.4,3,7.3,3,11.5s-1.3,8.1-4,11.5c-1.3-1.4-2-4.3-2-8.5S92,6.9,94,1.5z M107,1.5c2,2.1,3,5.3,3,9.5s-0.7,8.7-2,13.5c-2.7-3.4-4-7.3-4-11.5S105,4.9,107,1.5z"/>',
249 'preserve_aspect_ratio' => true,
250 'supports_amount' => false,
251 'round' => false,
252 'group' => 'tribal',
253 'view_box' => '0 0 117 26',
254 ],
255 'stripes_tribal' => [
256 'label' => esc_html_x( 'Stripes', 'Shapes', 'elementor' ),
257 'shape' => '<path d="M54,1.6V26h-9V2.5L54,1.6z M69,1.6v23.3L60,26V1.6H69z M24,1.6v23.5l-9-0.6V1.6H24z M30,0l9,0.7v24.5h-9V0z M9,2.5v22H0V3.7L9,2.5z M75,1.6l9,0.9v22h-9V1.6z M99,2.7v21.7h-9V3.8L99,2.7z M114,3.8v20.7l-9-0.5V3.8L114,3.8z"/>',
258 'preserve_aspect_ratio' => true,
259 'supports_amount' => false,
260 'round' => false,
261 'group' => 'tribal',
262 'view_box' => '0 0 120 26',
263 ],
264 'squares_tribal' => [
265 'label' => esc_html_x( 'Squares', 'Shapes', 'elementor' ),
266 'shape' => '<path d="M46.8,7.8v11.5L36,18.6V7.8H46.8z M82.4,7.8L84,18.6l-12,0.7L70.4,7.8H82.4z M0,7.8l12,0.9v9.9H1.3L0,7.8z M30,7.8v10.8H19L18,7.8H30z M63.7,7.8L66,18.6H54V9.5L63.7,7.8z M89.8,7L102,7.8v10.8H91.2L89.8,7zM108,7.8l12,0.9v8.9l-12,1V7.8z"/>',
267 'preserve_aspect_ratio' => true,
268 'supports_amount' => false,
269 'round' => false,
270 'group' => 'tribal',
271 'view_box' => '0 0 126 26',
272 ],
273 'trees_tribal' => [
274 'label' => esc_html_x( 'Trees', 'Shapes', 'elementor' ),
275 'shape' => '<path d="M6.4,2l4.2,5.7H7.7v2.7l3.8,5.2l-3.8,0v7.8H4.8v-7.8H0l4.8-5.2V7.7H1.1L6.4,2z M25.6,2L31,7.7h-3.7v2.7l4.8,5.2h-4.8v7.8h-2.8v-7.8l-3.8,0l3.8-5.2V7.7h-2.9L25.6,2z M47.5,2l4.2,5.7h-3.3v2.7l3.8,5.2l-3.8,0l0.4,7.8h-2.8v-7.8H41l4.8-5.2V7.7h-3.7L47.5,2z M66.2,2l5.4,5.7h-3.7v2.7l4.8,5.2h-4.8v7.8H65v-7.8l-3.8,0l3.8-5.2V7.7h-2.9L66.2,2zM87.4,2l4.8,5.7h-2.9v3.1l3.8,4.8l-3.8,0v7.8h-2.8v-7.8h-4.8l4.8-4.8V7.7h-3.7L87.4,2z M107.3,2l5.4,5.7h-3.7v2.7l4.8,5.2h-4.8v7.8H106v-7.8l-3.8,0l3.8-5.2V7.7h-2.9L107.3,2z"/>',
276 'preserve_aspect_ratio' => true,
277 'supports_amount' => false,
278 'round' => false,
279 'group' => 'tribal',
280 'view_box' => '0 0 123 26',
281 ],
282 'planes_tribal' => [
283 'label' => esc_html_x( 'Tribal', 'Shapes', 'elementor' ),
284 'shape' => '<path d="M29.6,10.3l2.1,2.2l-3.6,3.3h7v2.9h-7l3.6,3.5l-2.1,1.7l-5.2-5.2h-5.8v-2.9h5.8L29.6,10.3z M70.9,9.6l2.1,1.7l-3.6,3.5h7v2.9h-7l3.6,3.3l-2.1,2.2l-5.2-5.5h-5.8v-2.9h5.8L70.9,9.6z M111.5,9.6l2.1,1.7l-3.6,3.5h7v2.9h-7l3.6,3.3l-2.1,2.2l-5.2-5.5h-5.8v-2.9h5.8L111.5,9.6z M50.2,2.7l2.1,1.7l-3.6,3.5h7v2.9h-7l3.6,3.3l-2.1,2.2L45,10.7h-5.8V7.9H45L50.2,2.7z M11,2l2.1,1.7L9.6,7.2h7V10h-7l3.6,3.3L11,15.5L5.8,10H0V7.2h5.8L11,2z M91.5,2l2.1,2.2l-3.6,3.3h7v2.9h-7l3.6,3.5l-2.1,1.7l-5.2-5.2h-5.8V7.5h5.8L91.5,2z"/>',
285 'preserve_aspect_ratio' => true,
286 'supports_amount' => false,
287 'round' => false,
288 'group' => 'tribal',
289 'view_box' => '0 0 121 26',
290 ],
291 'x_tribal' => [
292 'label' => esc_html_x( 'X', 'Shapes', 'elementor' ),
293 'shape' => '<path d="M10.7,6l2.5,2.6l-4,4.3l4,5.4l-2.5,1.9l-4.5-5.2l-3.9,4.2L0.7,17L4,13.1L0,8.6l2.3-1.3l3.9,3.9L10.7,6z M23.9,6.6l4.2,4.5L32,7.2l2.3,1.3l-4,4.5l3.2,3.9L32,19.1l-3.9-3.3l-4.5,4.3l-2.5-1.9l4.4-5.1l-4.2-3.9L23.9,6.6zM73.5,6L76,8.6l-4,4.3l4,5.4l-2.5,1.9l-4.5-5.2l-3.9,4.2L63.5,17l4.1-4.7L63.5,8l2.3-1.3l4.1,3.6L73.5,6z M94,6l2.5,2.6l-4,4.3l4,5.4L94,20.1l-3.9-5l-3.9,4.2L84,17l3.2-3.9L84,8.6l2.3-1.3l3.2,3.9L94,6z M106.9,6l4.5,5.1l3.9-3.9l2.3,1.3l-4,4.5l3.2,3.9l-1.6,2.1l-3.9-4.2l-4.5,5.2l-2.5-1.9l4-5.4l-4-4.3L106.9,6z M53.1,6l2.5,2.6l-4,4.3l4,4.6l-2.5,1.9l-4.5-4.5l-3.5,4.5L43.1,17l3.2-3.9l-4-4.5l2.3-1.3l3.9,3.9L53.1,6z"/>',
294 'preserve_aspect_ratio' => true,
295 'supports_amount' => false,
296 'round' => false,
297 'group' => 'tribal',
298 'view_box' => '0 0 126 26',
299 ],
300 'zigzag_tribal' => [
301 'label' => esc_html_x( 'Zigzag', 'Shapes', 'elementor' ),
302 'shape' => '<polygon points="0,14.4 0,21 11.5,12.4 21.3,20 30.4,11.1 40.3,20 51,12.4 60.6,20 69.6,11.1 79.3,20 90.1,12.4 99.6,20 109.7,11.1 120,21 120,14.4 109.7,5 99.6,13 90.1,5 79.3,14.5 71,5.7 60.6,12.4 51,5 40.3,14.5 31.1,5 21.3,13 11.5,5 "/>',
303 'preserve_aspect_ratio' => true,
304 'supports_amount' => false,
305 'round' => false,
306 'group' => 'tribal',
307 'view_box' => '0 0 120 26',
308 ],
309 ]
310 );
311 }
312
313 private function filter_styles_by( $array, $key, $value ) {
314 return array_filter( $array, function( $style ) use ( $key, $value ) {
315 return $value === $style[ $key ];
316 } );
317 }
318
319 private function get_options_by_groups( $styles, $group = false ) {
320 $groups = [
321 'line' => [
322 'label' => esc_html__( 'Line', 'elementor' ),
323 'options' => [
324 'solid' => esc_html__( 'Solid', 'elementor' ),
325 'double' => esc_html__( 'Double', 'elementor' ),
326 'dotted' => esc_html__( 'Dotted', 'elementor' ),
327 'dashed' => esc_html__( 'Dashed', 'elementor' ),
328 ],
329 ],
330 ];
331 foreach ( $styles as $key => $style ) {
332 if ( ! isset( $groups[ $style['group'] ] ) ) {
333 $groups[ $style['group'] ] = [
334 'label' => ucwords( str_replace( '_', '', $style['group'] ) ),
335 'options' => [],
336 ];
337 }
338 $groups[ $style['group'] ]['options'][ $key ] = $style['label'];
339 }
340
341 if ( $group && isset( $groups[ $group ] ) ) {
342 return $groups[ $group ];
343 }
344 return $groups;
345 }
346
347 /**
348 * Register divider widget controls.
349 *
350 * Adds different input fields to allow the user to change and customize the widget settings.
351 *
352 * @since 3.1.0
353 * @access protected
354 */
355 protected function register_controls() {
356 $styles = $this->get_separator_styles();
357 $this->start_controls_section(
358 'section_divider',
359 [
360 'label' => esc_html__( 'Divider', 'elementor' ),
361 ]
362 );
363
364 $this->add_control(
365 'style',
366 [
367 'label' => esc_html__( 'Style', 'elementor' ),
368 'type' => Controls_Manager::SELECT,
369 'groups' => array_values( $this->get_options_by_groups( $styles ) ),
370 'render_type' => 'template',
371 'default' => 'solid',
372 'selectors' => [
373 '{{WRAPPER}}' => '--divider-border-style: {{VALUE}}',
374 ],
375 ]
376 );
377
378 $this->add_control(
379 'separator_type',
380 [
381 'type' => Controls_Manager::HIDDEN,
382 'default' => 'pattern',
383 'prefix_class' => 'elementor-widget-divider--separator-type-',
384 'condition' => [
385 'style!' => [
386 '',
387 'solid',
388 'double',
389 'dotted',
390 'dashed',
391 ],
392 ],
393 'render_type' => 'template',
394 ]
395 );
396
397 $this->add_control(
398 'pattern_spacing_flag',
399 [
400 'type' => Controls_Manager::HIDDEN,
401 'default' => 'no-spacing',
402 'prefix_class' => 'elementor-widget-divider--',
403 'condition' => [
404 'style' => array_keys( $this->filter_styles_by( $styles, 'supports_amount', false ) ),
405 ],
406 'render_type' => 'template',
407 ]
408 );
409
410 $this->add_control(
411 'pattern_round_flag',
412 [
413 'type' => Controls_Manager::HIDDEN,
414 'default' => 'bg-round',
415 'prefix_class' => 'elementor-widget-divider--',
416 'condition' => [
417 'style' => array_keys( $this->filter_styles_by( $styles, 'round', true ) ),
418 ],
419 ]
420 );
421
422 $this->add_responsive_control(
423 'width',
424 [
425 'label' => esc_html__( 'Width', 'elementor' ),
426 'type' => Controls_Manager::SLIDER,
427 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
428 'range' => [
429 'px' => [
430 'max' => 1000,
431 ],
432 ],
433 'default' => [
434 'size' => 100,
435 'unit' => '%',
436 ],
437 'tablet_default' => [
438 'unit' => '%',
439 ],
440 'mobile_default' => [
441 'unit' => '%',
442 ],
443 'selectors' => [
444 '{{WRAPPER}} .elementor-divider-separator' => 'width: {{SIZE}}{{UNIT}};',
445 ],
446 ]
447 );
448
449 $this->add_responsive_control(
450 'align',
451 [
452 'label' => esc_html__( 'Alignment', 'elementor' ),
453 'type' => Controls_Manager::CHOOSE,
454 'options' => [
455 'left' => [
456 'title' => esc_html__( 'Left', 'elementor' ),
457 'icon' => 'eicon-text-align-left',
458 ],
459 'center' => [
460 'title' => esc_html__( 'Center', 'elementor' ),
461 'icon' => 'eicon-text-align-center',
462 ],
463 'right' => [
464 'title' => esc_html__( 'Right', 'elementor' ),
465 'icon' => 'eicon-text-align-right',
466 ],
467 ],
468 'selectors' => [
469 '{{WRAPPER}} .elementor-divider' => 'text-align: {{VALUE}}',
470 '{{WRAPPER}} .elementor-divider-separator' => 'margin: 0 auto; margin-{{VALUE}}: 0',
471 ],
472 ]
473 );
474
475 $this->add_control(
476 'look',
477 [
478 'label' => esc_html__( 'Add Element', 'elementor' ),
479 'type' => Controls_Manager::CHOOSE,
480 'default' => 'line',
481 'options' => [
482 'line' => [
483 'title' => esc_html__( 'None', 'elementor' ),
484 'icon' => 'eicon-ban',
485 ],
486 'line_text' => [
487 'title' => esc_html__( 'Text', 'elementor' ),
488 'icon' => 'eicon-t-letter-bold',
489 ],
490 'line_icon' => [
491 'title' => esc_html__( 'Icon', 'elementor' ),
492 'icon' => 'eicon-star',
493 ],
494 ],
495 'separator' => 'before',
496 'prefix_class' => 'elementor-widget-divider--view-',
497 'toggle' => false,
498 'render_type' => 'template',
499 ]
500 );
501
502 $this->add_control(
503 'text',
504 [
505 'label' => esc_html__( 'Text', 'elementor' ),
506 'type' => Controls_Manager::TEXT,
507 'condition' => [
508 'look' => 'line_text',
509 ],
510 'default' => esc_html__( 'Divider', 'elementor' ),
511 'dynamic' => [
512 'active' => true,
513 ],
514 ]
515 );
516
517 $this->add_control(
518 'html_tag',
519 [
520 'label' => esc_html__( 'HTML Tag', 'elementor' ),
521 'type' => Controls_Manager::SELECT,
522 'condition' => [
523 'look' => 'line_text',
524 ],
525 'options' => [
526 'h1' => 'H1',
527 'h2' => 'H2',
528 'h3' => 'H3',
529 'h4' => 'H4',
530 'h5' => 'H5',
531 'h6' => 'H6',
532 'div' => 'div',
533 'span' => 'span',
534 'p' => 'p',
535 ],
536 'default' => 'span',
537 ]
538 );
539
540 $this->add_control(
541 'icon',
542 [
543 'label' => esc_html__( 'Icon', 'elementor' ),
544 'type' => Controls_Manager::ICONS,
545 'default' => [
546 'value' => 'fas fa-star',
547 'library' => 'fa-solid',
548 ],
549 'condition' => [
550 'look' => 'line_icon',
551 ],
552 ]
553 );
554
555 $this->end_controls_section();
556
557 $this->start_controls_section(
558 'section_divider_style',
559 [
560 'label' => esc_html__( 'Divider', 'elementor' ),
561 'tab' => Controls_Manager::TAB_STYLE,
562 'condition' => [
563 'style!' => 'none',
564 ],
565 ]
566 );
567
568 $this->add_control(
569 'color',
570 [
571 'label' => esc_html__( 'Color', 'elementor' ),
572 'type' => Controls_Manager::COLOR,
573 'global' => [
574 'default' => Global_Colors::COLOR_SECONDARY,
575 ],
576 'default' => '#000',
577 'render_type' => 'template',
578 'selectors' => [
579 '{{WRAPPER}}' => '--divider-color: {{VALUE}}',
580 ],
581 ]
582 );
583
584 $this->add_control(
585 'weight',
586 [
587 'label' => esc_html__( 'Weight', 'elementor' ),
588 'type' => Controls_Manager::SLIDER,
589 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
590 'default' => [
591 'size' => 1,
592 ],
593 'range' => [
594 'px' => [
595 'min' => 1,
596 'max' => 10,
597 'step' => 0.1,
598 ],
599 'em' => [
600 'min' => 0.1,
601 'max' => 1,
602 ],
603 'rem' => [
604 'min' => 0.1,
605 'max' => 1,
606 ],
607 ],
608 'render_type' => 'template',
609 'condition' => [
610 'style' => array_keys( $this->get_options_by_groups( $styles, 'line' )['options'] ),
611 ],
612 'selectors' => [
613 '{{WRAPPER}}' => '--divider-border-width: {{SIZE}}{{UNIT}}',
614 ],
615 ]
616 );
617
618 $this->add_control(
619 'pattern_height',
620 [
621 'label' => esc_html__( 'Size', 'elementor' ),
622 'type' => Controls_Manager::SLIDER,
623 'selectors' => [
624 '{{WRAPPER}}' => '--divider-pattern-height: {{SIZE}}{{UNIT}}',
625 ],
626 'default' => [
627 'size' => 20,
628 ],
629 'range' => [
630 'px' => [
631 'step' => 0.1,
632 ],
633 ],
634 'condition' => [
635 'style!' => [
636 '',
637 'solid',
638 'double',
639 'dotted',
640 'dashed',
641 ],
642 ],
643 ]
644 );
645
646 $this->add_control(
647 'pattern_size',
648 [
649 'label' => esc_html__( 'Amount', 'elementor' ),
650 'type' => Controls_Manager::SLIDER,
651 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
652 'selectors' => [
653 '{{WRAPPER}}' => '--divider-pattern-size: {{SIZE}}{{UNIT}}',
654 ],
655 'default' => [
656 'size' => 20,
657 ],
658 'range' => [
659 'px' => [
660 'step' => 0.1,
661 ],
662 '%' => [
663 'step' => 0.01,
664 ],
665 ],
666 'condition' => [
667 'style!' => array_merge( array_keys( $this->filter_styles_by( $styles, 'supports_amount', false ) ), [
668 '',
669 'solid',
670 'double',
671 'dotted',
672 'dashed',
673 ] ),
674 ],
675 ]
676 );
677
678 $this->add_responsive_control(
679 'gap',
680 [
681 'label' => esc_html__( 'Gap', 'elementor' ),
682 'type' => Controls_Manager::SLIDER,
683 'default' => [
684 'size' => 15,
685 ],
686 'range' => [
687 'px' => [
688 'min' => 2,
689 'max' => 50,
690 ],
691 ],
692 'selectors' => [
693 '{{WRAPPER}} .elementor-divider' => 'padding-block-start: {{SIZE}}{{UNIT}}; padding-block-end: {{SIZE}}{{UNIT}};',
694 ],
695 'separator' => 'before',
696 ]
697 );
698
699 $this->end_controls_section();
700
701 $this->start_controls_section(
702 'section_text_style',
703 [
704 'label' => esc_html__( 'Text', 'elementor' ),
705 'tab' => Controls_Manager::TAB_STYLE,
706 'condition' => [
707 'look' => 'line_text',
708 ],
709 ]
710 );
711
712 $this->add_control(
713 'text_color',
714 [
715 'label' => esc_html__( 'Color', 'elementor' ),
716 'type' => Controls_Manager::COLOR,
717 'global' => [
718 'default' => Global_Colors::COLOR_SECONDARY,
719 ],
720 'selectors' => [
721 '{{WRAPPER}} .elementor-divider__text' => 'color: {{VALUE}}',
722 ],
723 ]
724 );
725
726 $this->add_group_control(
727 Group_Control_Typography::get_type(),
728 [
729 'name' => 'typography',
730 'global' => [
731 'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
732 ],
733 'selector' => '{{WRAPPER}} .elementor-divider__text',
734 ]
735 );
736
737 $this->add_group_control(
738 Group_Control_Text_Stroke::get_type(),
739 [
740 'name' => 'text_stroke',
741 'selector' => '{{WRAPPER}} .elementor-divider__text',
742 ]
743 );
744
745 $this->add_control(
746 'text_align',
747 [
748 'label' => esc_html__( 'Position', 'elementor' ),
749 'type' => Controls_Manager::CHOOSE,
750 'options' => [
751 'left' => [
752 'title' => esc_html__( 'Left', 'elementor' ),
753 'icon' => 'eicon-h-align-left',
754 ],
755 'center' => [
756 'title' => esc_html__( 'Center', 'elementor' ),
757 'icon' => 'eicon-h-align-center',
758 ],
759 'right' => [
760 'title' => esc_html__( 'Right', 'elementor' ),
761 'icon' => 'eicon-h-align-right',
762 ],
763 ],
764 'default' => 'center',
765 'prefix_class' => 'elementor-widget-divider--element-align-',
766 ]
767 );
768
769 $this->add_responsive_control(
770 'text_spacing',
771 [
772 'label' => esc_html__( 'Spacing', 'elementor' ),
773 'type' => Controls_Manager::SLIDER,
774 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
775 'range' => [
776 'px' => [
777 'max' => 50,
778 ],
779 '%' => [
780 'max' => 50,
781 ],
782 'em' => [
783 'max' => 5,
784 ],
785 'rem' => [
786 'max' => 5,
787 ],
788 'vw' => [
789 'max' => 50,
790 ],
791 ],
792 'selectors' => [
793 '{{WRAPPER}}' => '--divider-element-spacing: {{SIZE}}{{UNIT}};',
794 ],
795 ]
796 );
797
798 $this->end_controls_section();
799
800 $this->start_controls_section(
801 'section_icon_style',
802 [
803 'label' => esc_html__( 'Icon', 'elementor' ),
804 'tab' => Controls_Manager::TAB_STYLE,
805 'condition' => [
806 'look' => 'line_icon',
807 ],
808 ]
809 );
810
811 $this->add_control(
812 'icon_view',
813 [
814 'label' => esc_html__( 'View', 'elementor' ),
815 'type' => Controls_Manager::SELECT,
816 'options' => [
817 'default' => esc_html__( 'Default', 'elementor' ),
818 'stacked' => esc_html__( 'Stacked', 'elementor' ),
819 'framed' => esc_html__( 'Framed', 'elementor' ),
820 ],
821 'default' => 'default',
822 'prefix_class' => 'elementor-view-',
823 ]
824 );
825
826 $this->add_responsive_control(
827 'icon_size',
828 [
829 'label' => esc_html__( 'Size', 'elementor' ),
830 'type' => Controls_Manager::SLIDER,
831 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
832 'range' => [
833 'px' => [
834 'max' => 100,
835 ],
836 'em' => [
837 'max' => 10,
838 ],
839 'rem' => [
840 'max' => 10,
841 ],
842 ],
843 'selectors' => [
844 '{{WRAPPER}}' => '--divider-icon-size: {{SIZE}}{{UNIT}};',
845 ],
846 ]
847 );
848
849 $this->add_control(
850 'icon_padding',
851 [
852 'label' => esc_html__( 'Padding', 'elementor' ),
853 'type' => Controls_Manager::SLIDER,
854 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
855 'selectors' => [
856 '{{WRAPPER}} .elementor-icon' => 'padding: {{SIZE}}{{UNIT}};',
857 ],
858 'range' => [
859 'px' => [
860 'max' => 50,
861 ],
862 'em' => [
863 'min' => 0,
864 'max' => 5,
865 ],
866 'rem' => [
867 'min' => 0,
868 'max' => 5,
869 ],
870 ],
871 'condition' => [
872 'icon_view!' => 'default',
873 ],
874 ]
875 );
876
877 $this->add_control(
878 'primary_color',
879 [
880 'label' => esc_html__( 'Primary Color', 'elementor' ),
881 'type' => Controls_Manager::COLOR,
882 'default' => '',
883 'selectors' => [
884 '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'background-color: {{VALUE}};',
885 '{{WRAPPER}}.elementor-view-framed .elementor-icon, {{WRAPPER}}.elementor-view-default .elementor-icon' => 'color: {{VALUE}}; border-color: {{VALUE}};',
886 '{{WRAPPER}}.elementor-view-framed .elementor-icon, {{WRAPPER}}.elementor-view-default .elementor-icon svg' => 'fill: {{VALUE}};',
887 ],
888 'global' => [
889 'default' => Global_Colors::COLOR_SECONDARY,
890 ],
891 ]
892 );
893
894 $this->add_control(
895 'secondary_color',
896 [
897 'label' => esc_html__( 'Secondary Color', 'elementor' ),
898 'type' => Controls_Manager::COLOR,
899 'default' => '',
900 'condition' => [
901 'icon_view!' => 'default',
902 ],
903 'selectors' => [
904 '{{WRAPPER}}.elementor-view-framed .elementor-icon' => 'background-color: {{VALUE}};',
905 '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'color: {{VALUE}};',
906 '{{WRAPPER}}.elementor-view-stacked .elementor-icon svg' => 'fill: {{VALUE}};',
907 ],
908 ]
909 );
910
911 $this->add_control(
912 'icon_align',
913 [
914 'label' => esc_html__( 'Position', 'elementor' ),
915 'type' => Controls_Manager::CHOOSE,
916 'options' => [
917 'left' => [
918 'title' => esc_html__( 'Left', 'elementor' ),
919 'icon' => 'eicon-h-align-left',
920 ],
921 'center' => [
922 'title' => esc_html__( 'Center', 'elementor' ),
923 'icon' => 'eicon-h-align-center',
924 ],
925 'right' => [
926 'title' => esc_html__( 'Right', 'elementor' ),
927 'icon' => 'eicon-h-align-right',
928 ],
929 ],
930 'default' => 'center',
931 'prefix_class' => 'elementor-widget-divider--element-align-',
932 'separator' => 'before',
933 ]
934 );
935
936 $this->add_responsive_control(
937 'icon_spacing',
938 [
939 'label' => esc_html__( 'Spacing', 'elementor' ),
940 'type' => Controls_Manager::SLIDER,
941 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
942 'range' => [
943 'px' => [
944 'max' => 50,
945 ],
946 'em' => [
947 'max' => 5,
948 ],
949 'rem' => [
950 'max' => 5,
951 ],
952 ],
953 'selectors' => [
954 '{{WRAPPER}}' => '--divider-element-spacing: {{SIZE}}{{UNIT}}',
955 ],
956 'separator' => 'before',
957 ]
958 );
959
960 $this->add_responsive_control(
961 'rotate',
962 [
963 'label' => esc_html__( 'Rotate', 'elementor' ),
964 'type' => Controls_Manager::SLIDER,
965 'size_units' => [ 'deg', 'grad', 'rad', 'turn', 'custom' ],
966 'default' => [
967 'unit' => 'deg',
968 ],
969 'tablet_default' => [
970 'unit' => 'deg',
971 ],
972 'mobile_default' => [
973 'unit' => 'deg',
974 ],
975 'selectors' => [
976 '{{WRAPPER}} .elementor-icon i, {{WRAPPER}} .elementor-icon svg' => 'transform: rotate({{SIZE}}{{UNIT}})',
977 ],
978 ]
979 );
980
981 $this->add_control(
982 'icon_border_width',
983 [
984 'label' => esc_html__( 'Border Width', 'elementor' ),
985 'type' => Controls_Manager::SLIDER,
986 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
987 'range' => [
988 'px' => [
989 'max' => 20,
990 ],
991 'em' => [
992 'max' => 2,
993 ],
994 ],
995 'selectors' => [
996 '{{WRAPPER}} .elementor-icon' => 'border-width: {{SIZE}}{{UNIT}}',
997 ],
998 'condition' => [
999 'icon_view' => 'framed',
1000 ],
1001 ]
1002 );
1003
1004 $this->add_control(
1005 'border_radius',
1006 [
1007 'label' => esc_html__( 'Border Radius', 'elementor' ),
1008 'type' => Controls_Manager::SLIDER,
1009 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1010 'selectors' => [
1011 '{{WRAPPER}} .elementor-icon' => 'border-radius: {{SIZE}}{{UNIT}}',
1012 ],
1013 'condition' => [
1014 'icon_view!' => 'default',
1015 ],
1016 ]
1017 );
1018
1019 $this->end_controls_section();
1020 }
1021
1022 /**
1023 * Build SVG
1024 *
1025 * Build SVG element markup based on the widgets settings.
1026 *
1027 * @return string - An SVG element.
1028 *
1029 * @since 2.7.0
1030 * @access private
1031 */
1032 private function build_svg() {
1033 $settings = $this->get_settings_for_display();
1034
1035 if ( 'pattern' !== $settings['separator_type'] || empty( $settings['style'] ) ) {
1036 return '';
1037 }
1038
1039 $svg_shapes = $this->get_separator_styles();
1040
1041 $selected_pattern = $svg_shapes[ $settings['style'] ];
1042 $preserve_aspect_ratio = $selected_pattern['preserve_aspect_ratio'] ? 'xMidYMid meet' : 'none';
1043 $view_box = isset( $selected_pattern['view_box'] ) ? $selected_pattern['view_box'] : '0 0 24 24';
1044
1045 $attr = [
1046 'preserveAspectRatio' => $preserve_aspect_ratio,
1047 'overflow' => 'visible',
1048 'height' => '100%',
1049 'viewBox' => $view_box,
1050 ];
1051
1052 if ( 'line' !== $selected_pattern['group'] ) {
1053 $attr['fill'] = 'black';
1054 $attr['stroke'] = 'none';
1055 } else {
1056 $attr['fill'] = 'none';
1057 $attr['stroke'] = 'black';
1058 $attr['stroke-width'] = $settings['weight']['size'];
1059 $attr['stroke-linecap'] = 'square';
1060 $attr['stroke-miterlimit'] = '10';
1061 }
1062
1063 $this->add_render_attribute( 'svg', $attr );
1064
1065 $pattern_attribute_string = $this->get_render_attribute_string( 'svg' );
1066 $shape = $selected_pattern['shape'];
1067
1068 return '<svg xmlns="http://www.w3.org/2000/svg" ' . $pattern_attribute_string . '>' . $shape . '</svg>';
1069 }
1070
1071 public function svg_to_data_uri( $svg ) {
1072 return str_replace(
1073 [ '<', '>', '"', '#' ],
1074 [ '%3C', '%3E', "'", '%23' ],
1075 $svg
1076 );
1077 }
1078
1079 /**
1080 * Render divider widget output on the frontend.
1081 *
1082 * Written in PHP and used to generate the final HTML.
1083 *
1084 * @since 1.0.0
1085 * @access protected
1086 */
1087 protected function render() {
1088 $settings = $this->get_settings_for_display();
1089 $svg_code = $this->build_svg();
1090 $has_icon = 'line_icon' === ( $settings['look'] ) && ! empty( $settings['icon'] );
1091 $has_text = 'line_text' === ( $settings['look'] ) && ! empty( $settings['text'] );
1092
1093 $this->add_render_attribute( 'wrapper', 'class', 'elementor-divider' );
1094
1095 if ( ! empty( $svg_code ) ) {
1096 $this->add_render_attribute( 'wrapper', 'style', '--divider-pattern-url: url("data:image/svg+xml,' . $this->svg_to_data_uri( $svg_code ) . '");' );
1097 }
1098
1099 ?>
1100 <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
1101 <span class="elementor-divider-separator">
1102 <?php if ( $has_icon ) : ?>
1103 <div class="elementor-icon elementor-divider__element">
1104 <?php
1105 Icons_Manager::render_icon( $settings['icon'], [
1106 'aria-hidden' => 'true',
1107 ] );
1108 ?></div>
1109 <?php elseif ( $has_text ) :
1110 $this->add_inline_editing_attributes( 'text' );
1111 $this->add_render_attribute( 'text', [ 'class' => [ 'elementor-divider__text', 'elementor-divider__element' ] ] );
1112 ?>
1113 <<?php Utils::print_validated_html_tag( $settings['html_tag'] ); ?> <?php $this->print_render_attribute_string( 'text' ); ?>>
1114 <?php
1115 // PHPCS - the main text of a widget should not be escaped.
1116 echo $settings['text']; // phpcs:ignore WordPress.Security.EscapeOutput ?>
1117 </<?php Utils::print_validated_html_tag( $settings['html_tag'] ); ?>>
1118 <?php endif; ?>
1119 </span>
1120 </div>
1121 <?php
1122 }
1123 }
1124