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

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

362 lines 8.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 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 /**
93 * Register heading widget controls.
94 *
95 * Adds different input fields to allow the user to change and customize the widget settings.
96 *
97 * @since 3.1.0
98 * @access protected
99 */
100 protected function register_controls() {
101 $this->start_controls_section(
102 'section_title',
103 [
104 'label' => esc_html__( 'Title', 'elementor' ),
105 ]
106 );
107
108 $this->add_control(
109 'title',
110 [
111 'label' => esc_html__( 'Title', 'elementor' ),
112 'type' => Controls_Manager::TEXTAREA,
113 'ai' => [
114 'type' => 'text',
115 ],
116 'dynamic' => [
117 'active' => true,
118 ],
119 'placeholder' => esc_html__( 'Enter your title', 'elementor' ),
120 'default' => esc_html__( 'Add Your Heading Text Here', 'elementor' ),
121 ]
122 );
123
124 $this->add_control(
125 'link',
126 [
127 'label' => esc_html__( 'Link', 'elementor' ),
128 'type' => Controls_Manager::URL,
129 'dynamic' => [
130 'active' => true,
131 ],
132 'default' => [
133 'url' => '',
134 ],
135 'separator' => 'before',
136 ]
137 );
138
139 $this->add_control(
140 'size',
141 [
142 'label' => esc_html__( 'Size', 'elementor' ),
143 'type' => Controls_Manager::SELECT,
144 'default' => 'default',
145 'options' => [
146 'default' => esc_html__( 'Default', 'elementor' ),
147 'small' => esc_html__( 'Small', 'elementor' ),
148 'medium' => esc_html__( 'Medium', 'elementor' ),
149 'large' => esc_html__( 'Large', 'elementor' ),
150 'xl' => esc_html__( 'XL', 'elementor' ),
151 'xxl' => esc_html__( 'XXL', 'elementor' ),
152 ],
153 ]
154 );
155
156 $this->add_control(
157 'header_size',
158 [
159 'label' => esc_html__( 'HTML Tag', 'elementor' ),
160 'type' => Controls_Manager::SELECT,
161 'options' => [
162 'h1' => 'H1',
163 'h2' => 'H2',
164 'h3' => 'H3',
165 'h4' => 'H4',
166 'h5' => 'H5',
167 'h6' => 'H6',
168 'div' => 'div',
169 'span' => 'span',
170 'p' => 'p',
171 ],
172 'default' => 'h2',
173 ]
174 );
175
176 $this->add_responsive_control(
177 'align',
178 [
179 'label' => esc_html__( 'Alignment', 'elementor' ),
180 'type' => Controls_Manager::CHOOSE,
181 'options' => [
182 'left' => [
183 'title' => esc_html__( 'Left', 'elementor' ),
184 'icon' => 'eicon-text-align-left',
185 ],
186 'center' => [
187 'title' => esc_html__( 'Center', 'elementor' ),
188 'icon' => 'eicon-text-align-center',
189 ],
190 'right' => [
191 'title' => esc_html__( 'Right', 'elementor' ),
192 'icon' => 'eicon-text-align-right',
193 ],
194 'justify' => [
195 'title' => esc_html__( 'Justified', 'elementor' ),
196 'icon' => 'eicon-text-align-justify',
197 ],
198 ],
199 'default' => '',
200 'selectors' => [
201 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
202 ],
203 ]
204 );
205
206 $this->add_control(
207 'view',
208 [
209 'label' => esc_html__( 'View', 'elementor' ),
210 'type' => Controls_Manager::HIDDEN,
211 'default' => 'traditional',
212 ]
213 );
214
215 $this->end_controls_section();
216
217 $this->start_controls_section(
218 'section_title_style',
219 [
220 'label' => esc_html__( 'Title', 'elementor' ),
221 'tab' => Controls_Manager::TAB_STYLE,
222 ]
223 );
224
225 $this->add_control(
226 'title_color',
227 [
228 'label' => esc_html__( 'Text Color', 'elementor' ),
229 'type' => Controls_Manager::COLOR,
230 'global' => [
231 'default' => Global_Colors::COLOR_PRIMARY,
232 ],
233 'selectors' => [
234 '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
235 ],
236 ]
237 );
238
239 $this->add_group_control(
240 Group_Control_Typography::get_type(),
241 [
242 'name' => 'typography',
243 'global' => [
244 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
245 ],
246 'selector' => '{{WRAPPER}} .elementor-heading-title',
247 ]
248 );
249
250 $this->add_group_control(
251 Group_Control_Text_Stroke::get_type(),
252 [
253 'name' => 'text_stroke',
254 'selector' => '{{WRAPPER}} .elementor-heading-title',
255 ]
256 );
257
258 $this->add_group_control(
259 Group_Control_Text_Shadow::get_type(),
260 [
261 'name' => 'text_shadow',
262 'selector' => '{{WRAPPER}} .elementor-heading-title',
263 ]
264 );
265
266 $this->add_control(
267 'blend_mode',
268 [
269 'label' => esc_html__( 'Blend Mode', 'elementor' ),
270 'type' => Controls_Manager::SELECT,
271 'options' => [
272 '' => esc_html__( 'Normal', 'elementor' ),
273 'multiply' => esc_html__( 'Multiply', 'elementor' ),
274 'screen' => esc_html__( 'Screen', 'elementor' ),
275 'overlay' => esc_html__( 'Overlay', 'elementor' ),
276 'darken' => esc_html__( 'Darken', 'elementor' ),
277 'lighten' => esc_html__( 'Lighten', 'elementor' ),
278 'color-dodge' => esc_html__( 'Color Dodge', 'elementor' ),
279 'saturation' => esc_html__( 'Saturation', 'elementor' ),
280 'color' => esc_html__( 'Color', 'elementor' ),
281 'difference' => esc_html__( 'Difference', 'elementor' ),
282 'exclusion' => esc_html__( 'Exclusion', 'elementor' ),
283 'hue' => esc_html__( 'Hue', 'elementor' ),
284 'luminosity' => esc_html__( 'Luminosity', 'elementor' ),
285 ],
286 'selectors' => [
287 '{{WRAPPER}} .elementor-heading-title' => 'mix-blend-mode: {{VALUE}}',
288 ],
289 'separator' => 'none',
290 ]
291 );
292
293 $this->end_controls_section();
294 }
295
296 /**
297 * Render heading widget output on the frontend.
298 *
299 * Written in PHP and used to generate the final HTML.
300 *
301 * @since 1.0.0
302 * @access protected
303 */
304 protected function render() {
305 $settings = $this->get_settings_for_display();
306
307 if ( '' === $settings['title'] ) {
308 return;
309 }
310
311 $this->add_render_attribute( 'title', 'class', 'elementor-heading-title' );
312
313 if ( ! empty( $settings['size'] ) ) {
314 $this->add_render_attribute( 'title', 'class', 'elementor-size-' . $settings['size'] );
315 }
316
317 $this->add_inline_editing_attributes( 'title' );
318
319 $title = $settings['title'];
320
321 if ( ! empty( $settings['link']['url'] ) ) {
322 $this->add_link_attributes( 'url', $settings['link'] );
323
324 $title = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'url' ), $title );
325 }
326
327 $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 );
328
329 // PHPCS - the variable $title_html holds safe data.
330 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
331 }
332
333 /**
334 * Render heading widget output in the editor.
335 *
336 * Written as a Backbone JavaScript template and used to generate the live preview.
337 *
338 * @since 2.9.0
339 * @access protected
340 */
341 protected function content_template() {
342 ?>
343 <#
344 var title = settings.title;
345
346 if ( '' !== settings.link.url ) {
347 title = '<a href="' + settings.link.url + '">' + title + '</a>';
348 }
349
350 view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title', 'elementor-size-' + settings.size ] );
351
352 view.addInlineEditingAttributes( 'title' );
353
354 var headerSizeTag = elementor.helpers.validateHTMLTag( settings.header_size ),
355 title_html = '<' + headerSizeTag + ' ' + view.getRenderAttributeString( 'title' ) + '>' + title + '</' + headerSizeTag + '>';
356
357 print( title_html );
358 #>
359 <?php
360 }
361 }
362