PluginProbe
Elementor Website Builder – more than just a page builder / 3.18.2
Elementor Website Builder – more than just a page builder v3.18.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 / widgets / heading.php

heading.php in Elementor Website Builder – more than just a page builder 3.18.2, at includes/widgets/heading.php

369 lines 8.6 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 heading widget.
13 *
14 * Elementor widget that displays an eye-catching headlines.
15 *
16 * @since 1.0.0
17 */
18 class Widget_Heading extends Widget_Base {
19
20 /**
21 * Get widget name.
22 *
23 * Retrieve heading widget name.
24 *
25 * @since 1.0.0
26 * @access public
27 *
28 * @return string Widget name.
29 */
30 public function get_name() {
31 return 'heading';
32 }
33
34 /**
35 * Get widget title.
36 *
37 * Retrieve heading widget title.
38 *
39 * @since 1.0.0
40 * @access public
41 *
42 * @return string Widget title.
43 */
44 public function get_title() {
45 return esc_html__( 'Heading', 'elementor' );
46 }
47
48 /**
49 * Get widget icon.
50 *
51 * Retrieve heading widget icon.
52 *
53 * @since 1.0.0
54 * @access public
55 *
56 * @return string Widget icon.
57 */
58 public function get_icon() {
59 return 'eicon-t-letter';
60 }
61
62 /**
63 * Get widget categories.
64 *
65 * Retrieve the list of categories the heading widget belongs to.
66 *
67 * Used to determine where to display the widget in the editor.
68 *
69 * @since 2.0.0
70 * @access public
71 *
72 * @return array Widget categories.
73 */
74 public function get_categories() {
75 return [ 'basic' ];
76 }
77
78 /**
79 * Get widget keywords.
80 *
81 * Retrieve the list of keywords the widget belongs to.
82 *
83 * @since 2.1.0
84 * @access public
85 *
86 * @return array Widget keywords.
87 */
88 public function get_keywords() {
89 return [ 'heading', 'title', 'text' ];
90 }
91
92 protected function get_upsale_data() {
93 return [
94 'description' => esc_html__( 'Create captivating headings that rotate with the Animated Headline Widget.', 'elementor' ),
95 'upgrade_url' => 'https://go.elementor.com/go-pro-heading-widget/',
96 ];
97 }
98
99 /**
100 * Register heading widget controls.
101 *
102 * Adds different input fields to allow the user to change and customize the widget settings.
103 *
104 * @since 3.1.0
105 * @access protected
106 */
107 protected function register_controls() {
108 $this->start_controls_section(
109 'section_title',
110 [
111 'label' => esc_html__( 'Title', 'elementor' ),
112 ]
113 );
114
115 $this->add_control(
116 'title',
117 [
118 'label' => esc_html__( 'Title', 'elementor' ),
119 'type' => Controls_Manager::TEXTAREA,
120 'ai' => [
121 'type' => 'text',
122 ],
123 'dynamic' => [
124 'active' => true,
125 ],
126 'placeholder' => esc_html__( 'Enter your title', 'elementor' ),
127 'default' => esc_html__( 'Add Your Heading Text Here', 'elementor' ),
128 ]
129 );
130
131 $this->add_control(
132 'link',
133 [
134 'label' => esc_html__( 'Link', 'elementor' ),
135 'type' => Controls_Manager::URL,
136 'dynamic' => [
137 'active' => true,
138 ],
139 'default' => [
140 'url' => '',
141 ],
142 'separator' => 'before',
143 ]
144 );
145
146 $this->add_control(
147 'size',
148 [
149 'label' => esc_html__( 'Size', 'elementor' ),
150 'type' => Controls_Manager::SELECT,
151 'default' => 'default',
152 'options' => [
153 'default' => esc_html__( 'Default', 'elementor' ),
154 'small' => esc_html__( 'Small', 'elementor' ),
155 'medium' => esc_html__( 'Medium', 'elementor' ),
156 'large' => esc_html__( 'Large', 'elementor' ),
157 'xl' => esc_html__( 'XL', 'elementor' ),
158 'xxl' => esc_html__( 'XXL', 'elementor' ),
159 ],
160 ]
161 );
162
163 $this->add_control(
164 'header_size',
165 [
166 'label' => esc_html__( 'HTML Tag', 'elementor' ),
167 'type' => Controls_Manager::SELECT,
168 'options' => [
169 'h1' => 'H1',
170 'h2' => 'H2',
171 'h3' => 'H3',
172 'h4' => 'H4',
173 'h5' => 'H5',
174 'h6' => 'H6',
175 'div' => 'div',
176 'span' => 'span',
177 'p' => 'p',
178 ],
179 'default' => 'h2',
180 ]
181 );
182
183 $this->add_responsive_control(
184 'align',
185 [
186 'label' => esc_html__( 'Alignment', 'elementor' ),
187 'type' => Controls_Manager::CHOOSE,
188 'options' => [
189 'left' => [
190 'title' => esc_html__( 'Left', 'elementor' ),
191 'icon' => 'eicon-text-align-left',
192 ],
193 'center' => [
194 'title' => esc_html__( 'Center', 'elementor' ),
195 'icon' => 'eicon-text-align-center',
196 ],
197 'right' => [
198 'title' => esc_html__( 'Right', 'elementor' ),
199 'icon' => 'eicon-text-align-right',
200 ],
201 'justify' => [
202 'title' => esc_html__( 'Justified', 'elementor' ),
203 'icon' => 'eicon-text-align-justify',
204 ],
205 ],
206 'default' => '',
207 'selectors' => [
208 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
209 ],
210 ]
211 );
212
213 $this->add_control(
214 'view',
215 [
216 'label' => esc_html__( 'View', 'elementor' ),
217 'type' => Controls_Manager::HIDDEN,
218 'default' => 'traditional',
219 ]
220 );
221
222 $this->end_controls_section();
223
224 $this->start_controls_section(
225 'section_title_style',
226 [
227 'label' => esc_html__( 'Title', 'elementor' ),
228 'tab' => Controls_Manager::TAB_STYLE,
229 ]
230 );
231
232 $this->add_control(
233 'title_color',
234 [
235 'label' => esc_html__( 'Text Color', 'elementor' ),
236 'type' => Controls_Manager::COLOR,
237 'global' => [
238 'default' => Global_Colors::COLOR_PRIMARY,
239 ],
240 'selectors' => [
241 '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
242 ],
243 ]
244 );
245
246 $this->add_group_control(
247 Group_Control_Typography::get_type(),
248 [
249 'name' => 'typography',
250 'global' => [
251 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
252 ],
253 'selector' => '{{WRAPPER}} .elementor-heading-title',
254 ]
255 );
256
257 $this->add_group_control(
258 Group_Control_Text_Stroke::get_type(),
259 [
260 'name' => 'text_stroke',
261 'selector' => '{{WRAPPER}} .elementor-heading-title',
262 ]
263 );
264
265 $this->add_group_control(
266 Group_Control_Text_Shadow::get_type(),
267 [
268 'name' => 'text_shadow',
269 'selector' => '{{WRAPPER}} .elementor-heading-title',
270 ]
271 );
272
273 $this->add_control(
274 'blend_mode',
275 [
276 'label' => esc_html__( 'Blend Mode', 'elementor' ),
277 'type' => Controls_Manager::SELECT,
278 'options' => [
279 '' => esc_html__( 'Normal', 'elementor' ),
280 'multiply' => esc_html__( 'Multiply', 'elementor' ),
281 'screen' => esc_html__( 'Screen', 'elementor' ),
282 'overlay' => esc_html__( 'Overlay', 'elementor' ),
283 'darken' => esc_html__( 'Darken', 'elementor' ),
284 'lighten' => esc_html__( 'Lighten', 'elementor' ),
285 'color-dodge' => esc_html__( 'Color Dodge', 'elementor' ),
286 'saturation' => esc_html__( 'Saturation', 'elementor' ),
287 'color' => esc_html__( 'Color', 'elementor' ),
288 'difference' => esc_html__( 'Difference', 'elementor' ),
289 'exclusion' => esc_html__( 'Exclusion', 'elementor' ),
290 'hue' => esc_html__( 'Hue', 'elementor' ),
291 'luminosity' => esc_html__( 'Luminosity', 'elementor' ),
292 ],
293 'selectors' => [
294 '{{WRAPPER}} .elementor-heading-title' => 'mix-blend-mode: {{VALUE}}',
295 ],
296 'separator' => 'none',
297 ]
298 );
299
300 $this->end_controls_section();
301 }
302
303 /**
304 * Render heading widget output on the frontend.
305 *
306 * Written in PHP and used to generate the final HTML.
307 *
308 * @since 1.0.0
309 * @access protected
310 */
311 protected function render() {
312 $settings = $this->get_settings_for_display();
313
314 if ( '' === $settings['title'] ) {
315 return;
316 }
317
318 $this->add_render_attribute( 'title', 'class', 'elementor-heading-title' );
319
320 if ( ! empty( $settings['size'] ) ) {
321 $this->add_render_attribute( 'title', 'class', 'elementor-size-' . $settings['size'] );
322 }
323
324 $this->add_inline_editing_attributes( 'title' );
325
326 $title = $settings['title'];
327
328 if ( ! empty( $settings['link']['url'] ) ) {
329 $this->add_link_attributes( 'url', $settings['link'] );
330
331 $title = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'url' ), $title );
332 }
333
334 $title_html = sprintf( '<%1$s %2$s>%3$s</%1$s>', Utils::validate_html_tag( $settings['header_size'] ), $this->get_render_attribute_string( 'title' ), $title );
335
336 // PHPCS - the variable $title_html holds safe data.
337 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
338 }
339
340 /**
341 * Render heading widget output in the editor.
342 *
343 * Written as a Backbone JavaScript template and used to generate the live preview.
344 *
345 * @since 2.9.0
346 * @access protected
347 */
348 protected function content_template() {
349 ?>
350 <#
351 var title = settings.title;
352
353 if ( '' !== settings.link.url ) {
354 title = '<a href="' + _.escape( settings.link.url ) + '">' + title + '</a>';
355 }
356
357 view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title', 'elementor-size-' + settings.size ] );
358
359 view.addInlineEditingAttributes( 'title' );
360
361 var headerSizeTag = elementor.helpers.validateHTMLTag( settings.header_size ),
362 title_html = '<' + headerSizeTag + ' ' + view.getRenderAttributeString( 'title' ) + '>' + title + '</' + headerSizeTag + '>';
363
364 print( title_html );
365 #>
366 <?php
367 }
368 }
369