PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.4
Elementor Website Builder – more than just a page builder v3.6.4
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.6.4, at includes/widgets/heading.php

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