PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.0-dev3
Elementor Website Builder – more than just a page builder v3.25.0-dev3
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 / spacer.php

spacer.php in Elementor Website Builder – more than just a page builder 3.25.0-dev3, at includes/widgets/spacer.php

192 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 spacer widget.
10 *
11 * Elementor widget that inserts a space that divides various elements.
12 *
13 * @since 1.0.0
14 */
15 class Widget_Spacer extends Widget_Base {
16
17 /**
18 * Get widget name.
19 *
20 * Retrieve spacer widget name.
21 *
22 * @since 1.0.0
23 * @access public
24 *
25 * @return string Widget name.
26 */
27 public function get_name() {
28 return 'spacer';
29 }
30
31 /**
32 * Get widget title.
33 *
34 * Retrieve spacer widget title.
35 *
36 * @since 1.0.0
37 * @access public
38 *
39 * @return string Widget title.
40 */
41 public function get_title() {
42 return esc_html__( 'Spacer', 'elementor' );
43 }
44
45 /**
46 * Get widget icon.
47 *
48 * Retrieve spacer widget icon.
49 *
50 * @since 1.0.0
51 * @access public
52 *
53 * @return string Widget icon.
54 */
55 public function get_icon() {
56 return 'eicon-spacer';
57 }
58
59 /**
60 * Get widget categories.
61 *
62 * Retrieve the list of categories the spacer widget belongs to.
63 *
64 * Used to determine where to display the widget in the editor.
65 *
66 * @since 1.0.0
67 * @access public
68 *
69 * @return array Widget categories.
70 */
71 public function get_categories() {
72 return [ 'basic' ];
73 }
74
75 /**
76 * Get widget keywords.
77 *
78 * Retrieve the list of keywords the widget belongs to.
79 *
80 * @since 2.1.0
81 * @access public
82 *
83 * @return array Widget keywords.
84 */
85 public function get_keywords() {
86 return [ 'space' ];
87 }
88
89 protected function is_dynamic_content(): bool {
90 return false;
91 }
92
93 /**
94 * Get style dependencies.
95 *
96 * Retrieve the list of style dependencies the widget requires.
97 *
98 * @since 3.24.0
99 * @access public
100 *
101 * @return array Widget style dependencies.
102 */
103 public function get_style_depends(): array {
104 return [ 'widget-spacer' ];
105 }
106
107 /**
108 * Register spacer widget controls.
109 *
110 * Adds different input fields to allow the user to change and customize the widget settings.
111 *
112 * @since 3.1.0
113 * @access protected
114 */
115 protected function register_controls() {
116 $this->start_controls_section(
117 'section_spacer',
118 [
119 'label' => esc_html__( 'Spacer', 'elementor' ),
120 ]
121 );
122
123 $this->add_responsive_control(
124 'space',
125 [
126 'label' => esc_html__( 'Space', 'elementor' ),
127 'type' => Controls_Manager::SLIDER,
128 'default' => [
129 'size' => 50,
130 ],
131 'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
132 'range' => [
133 'px' => [
134 'max' => 600,
135 ],
136 'em' => [
137 'max' => 20,
138 ],
139 ],
140 'render_type' => 'template',
141 'selectors' => [
142 '{{WRAPPER}}' => '--spacer-size: {{SIZE}}{{UNIT}};',
143 ],
144 ]
145 );
146
147 $this->end_controls_section();
148 }
149
150 /**
151 * Render spacer widget output on the frontend.
152 *
153 * Written in PHP and used to generate the final HTML.
154 *
155 * @since 1.0.0
156 * @access protected
157 */
158 protected function render() {
159 $settings = $this->get_settings_for_display();
160
161 if ( empty( $settings['space'] ) || empty( $settings['space']['size'] ) || 0 === $settings['space']['size'] ) {
162 return;
163 }
164 ?>
165 <div class="elementor-spacer">
166 <div class="elementor-spacer-inner"></div>
167 </div>
168 <?php
169 }
170
171 /**
172 * Render spacer widget output in the editor.
173 *
174 * Written as a Backbone JavaScript template and used to generate the live preview.
175 *
176 * @since 2.9.0
177 * @access protected
178 */
179 protected function content_template() {
180 ?>
181 <#
182 if ( '' === settings.space || '' === settings.space.size || 0 === settings.space.size ) {
183 return;
184 }
185 #>
186 <div class="elementor-spacer">
187 <div class="elementor-spacer-inner"></div>
188 </div>
189 <?php
190 }
191 }
192