PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.0-beta1
Elementor Website Builder – more than just a page builder v3.22.0-beta1
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.22.0-beta1, at includes/widgets/spacer.php

178 lines 3.3 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 * Register spacer widget controls.
95 *
96 * Adds different input fields to allow the user to change and customize the widget settings.
97 *
98 * @since 3.1.0
99 * @access protected
100 */
101 protected function register_controls() {
102 $this->start_controls_section(
103 'section_spacer',
104 [
105 'label' => esc_html__( 'Spacer', 'elementor' ),
106 ]
107 );
108
109 $this->add_responsive_control(
110 'space',
111 [
112 'label' => esc_html__( 'Space', 'elementor' ),
113 'type' => Controls_Manager::SLIDER,
114 'default' => [
115 'size' => 50,
116 ],
117 'size_units' => [ 'px', 'em', 'rem', 'vh', 'custom' ],
118 'range' => [
119 'px' => [
120 'max' => 600,
121 ],
122 'em' => [
123 'max' => 20,
124 ],
125 ],
126 'render_type' => 'template',
127 'selectors' => [
128 '{{WRAPPER}}' => '--spacer-size: {{SIZE}}{{UNIT}};',
129 ],
130 ]
131 );
132
133 $this->end_controls_section();
134 }
135
136 /**
137 * Render spacer widget output on the frontend.
138 *
139 * Written in PHP and used to generate the final HTML.
140 *
141 * @since 1.0.0
142 * @access protected
143 */
144 protected function render() {
145 $settings = $this->get_settings_for_display();
146
147 if ( empty( $settings['space'] ) || empty( $settings['space']['size'] ) || 0 === $settings['space']['size'] ) {
148 return;
149 }
150 ?>
151 <div class="elementor-spacer">
152 <div class="elementor-spacer-inner"></div>
153 </div>
154 <?php
155 }
156
157 /**
158 * Render spacer widget output in the editor.
159 *
160 * Written as a Backbone JavaScript template and used to generate the live preview.
161 *
162 * @since 2.9.0
163 * @access protected
164 */
165 protected function content_template() {
166 ?>
167 <#
168 if ( '' === settings.space || '' === settings.space.size || 0 === settings.space.size ) {
169 return;
170 }
171 #>
172 <div class="elementor-spacer">
173 <div class="elementor-spacer-inner"></div>
174 </div>
175 <?php
176 }
177 }
178