PluginProbe
Elementor Website Builder – more than just a page builder / 3.21.4
Elementor Website Builder – more than just a page builder v3.21.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
← All changes | includes/widgets/heading.php +23 -217 4.2.23.21.4 View file →
@@ -7,11 +7,8 @@
7 7
8 8 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 9 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10 10 use Elementor\Modules\ContentSanitizer\Interfaces\Sanitizable;
11 -use Elementor\Core\Utils\Hints;
12 -use Elementor\Core\Admin\Admin_Notices;
13 -use Elementor\Modules\Promotions\Controls\Promotion_Control;
14 11
15 12 /**
16 13 * Elementor heading widget.
17 14 *
@@ -92,34 +89,12 @@
92 89 public function get_keywords() {
93 90 return [ 'heading', 'title', 'text' ];
94 91 }
95 92
96 - protected function is_dynamic_content(): bool {
97 - return false;
98 - }
99 -
100 93 /**
101 - * Get style dependencies.
102 - *
103 - * Retrieve the list of style dependencies the widget requires.
104 - *
105 - * @since 3.24.0
106 - * @access public
107 - *
108 - * @return array Widget style dependencies.
109 - */
110 - public function get_style_depends(): array {
111 - return [ 'widget-heading' ];
112 - }
113 -
114 - public function has_widget_inner_wrapper(): bool {
115 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
116 - }
117 -
118 - /**
119 94 * Remove data attributes from the html.
120 95 *
121 - * @param string $content Heading title.
96 + * @param string $content Heading title
122 97 * @return string
123 98 */
124 99 public function sanitize( $content ): string {
125 100 $allowed_tags = wp_kses_allowed_html( 'post' );
@@ -131,9 +106,9 @@
131 106 continue;
132 107 }
133 108
134 109 $filtered_attributes = array_filter( $attributes, function( $attribute ) {
135 - return ! substr( $attribute, 0, 5 ) === 'data-';
110 + return ! str_starts_with( $attribute, 'data-' );
136 111 }, ARRAY_FILTER_USE_KEY );
137 112
138 113 $allowed_tags_for_heading[ $tag ] = $filtered_attributes;
139 114 }
@@ -247,10 +222,8 @@
247 222 'default' => 'h2',
248 223 ]
249 224 );
250 225
251 - $this->maybe_add_ally_heading_hint();
252 -
253 226 $this->end_controls_section();
254 227
255 228 $this->start_controls_section(
256 229 'section_title_style',
@@ -265,10 +238,10 @@
265 238 [
266 239 'label' => esc_html__( 'Alignment', 'elementor' ),
267 240 'type' => Controls_Manager::CHOOSE,
268 241 'options' => [
269 - 'start' => [
270 - 'title' => esc_html__( 'Start', 'elementor' ),
242 + 'left' => [
243 + 'title' => esc_html__( 'Left', 'elementor' ),
271 244 'icon' => 'eicon-text-align-left',
272 245 ],
273 246 'center' => [
274 247 'title' => esc_html__( 'Center', 'elementor' ),
@@ -273,10 +246,10 @@
273 246 'center' => [
274 247 'title' => esc_html__( 'Center', 'elementor' ),
275 248 'icon' => 'eicon-text-align-center',
276 249 ],
277 - 'end' => [
278 - 'title' => esc_html__( 'End', 'elementor' ),
250 + 'right' => [
251 + 'title' => esc_html__( 'Right', 'elementor' ),
279 252 'icon' => 'eicon-text-align-right',
280 253 ],
281 254 'justify' => [
282 255 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -282,21 +255,29 @@
282 255 'title' => esc_html__( 'Justified', 'elementor' ),
283 256 'icon' => 'eicon-text-align-justify',
284 257 ],
285 258 ],
286 - 'classes' => 'elementor-control-start-end',
287 - 'selectors_dictionary' => [
288 - 'left' => is_rtl() ? 'end' : 'start',
289 - 'right' => is_rtl() ? 'start' : 'end',
290 - ],
291 259 'default' => '',
292 260 'selectors' => [
293 261 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
294 262 ],
295 - 'separator' => 'after',
296 263 ]
297 264 );
298 265
266 + $this->add_control(
267 + 'title_color',
268 + [
269 + 'label' => esc_html__( 'Text Color', 'elementor' ),
270 + 'type' => Controls_Manager::COLOR,
271 + 'global' => [
272 + 'default' => Global_Colors::COLOR_PRIMARY,
273 + ],
274 + 'selectors' => [
275 + '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
276 + ],
277 + ]
278 + );
279 +
299 280 $this->add_group_control(
300 281 Group_Control_Typography::get_type(),
301 282 [
302 283 'name' => 'typography',
@@ -348,77 +329,8 @@
348 329 ],
349 330 ]
350 331 );
351 332
352 - $this->add_control(
353 - 'separator',
354 - [
355 - 'type' => Controls_Manager::DIVIDER,
356 - ]
357 - );
358 -
359 - $this->start_controls_tabs( 'title_colors' );
360 -
361 - $this->start_controls_tab(
362 - 'title_colors_normal',
363 - [
364 - 'label' => esc_html__( 'Normal', 'elementor' ),
365 - ]
366 - );
367 -
368 - $this->add_control(
369 - 'title_color',
370 - [
371 - 'label' => esc_html__( 'Text Color', 'elementor' ),
372 - 'type' => Controls_Manager::COLOR,
373 - 'global' => [
374 - 'default' => Global_Colors::COLOR_PRIMARY,
375 - ],
376 - 'selectors' => [
377 - '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
378 - ],
379 - ]
380 - );
381 -
382 - $this->end_controls_tab();
383 -
384 - $this->start_controls_tab(
385 - 'title_colors_hover',
386 - [
387 - 'label' => esc_html__( 'Hover', 'elementor' ),
388 - ]
389 - );
390 -
391 - $this->add_control(
392 - 'title_hover_color',
393 - [
394 - 'label' => esc_html__( 'Link Color', 'elementor' ),
395 - 'type' => Controls_Manager::COLOR,
396 - 'selectors' => [
397 - '{{WRAPPER}} .elementor-heading-title a:hover, {{WRAPPER}} .elementor-heading-title a:focus' => 'color: {{VALUE}};',
398 - ],
399 - ]
400 - );
401 -
402 - $this->add_control(
403 - 'title_hover_color_transition_duration',
404 - [
405 - 'label' => esc_html__( 'Transition Duration', 'elementor' ),
406 - 'type' => Controls_Manager::SLIDER,
407 - 'size_units' => [ 's', 'ms', 'custom' ],
408 - 'default' => [
409 - 'unit' => 's',
410 - ],
411 - 'selectors' => [
412 - '{{WRAPPER}} .elementor-heading-title a' => 'transition-duration: {{SIZE}}{{UNIT}};',
413 - ],
414 - ]
415 - );
416 -
417 - $this->end_controls_tab();
418 -
419 - $this->end_controls_tabs();
420 -
421 333 $this->end_controls_section();
422 334 }
423 335
424 336 /**
@@ -445,9 +357,9 @@
445 357 }
446 358
447 359 $this->add_inline_editing_attributes( 'title' );
448 360
449 - $title = wp_kses_post( $settings['title'] );
361 + $title = $settings['title'];
450 362
451 363 if ( ! empty( $settings['link']['url'] ) ) {
452 364 $this->add_link_attributes( 'url', $settings['link'] );
453 365
@@ -459,114 +371,8 @@
459 371 // PHPCS - the variable $title_html holds safe data.
460 372 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
461 373 }
462 374
463 - public function render_markdown(): string {
464 - $settings = $this->get_settings_for_display();
465 -
466 - if ( '' === $settings['title'] ) {
467 - return '';
468 - }
469 -
470 - $tag = $settings['header_size'] ?? 'h2';
471 - $level_map = [
472 - 'h1' => 1,
473 - 'h2' => 2,
474 - 'h3' => 3,
475 - 'h4' => 4,
476 - 'h5' => 5,
477 - 'h6' => 6,
478 - ];
479 - $level = $level_map[ $tag ] ?? 2;
480 - $title = Utils::html_to_plain_text( $settings['title'] );
481 -
482 - $md = str_repeat( '#', $level ) . ' ' . $title;
483 -
484 - if ( ! empty( $settings['link']['url'] ) ) {
485 - $md = str_repeat( '#', $level ) . ' [' . $title . '](' . esc_url( $settings['link']['url'] ) . ')';
486 - }
487 -
488 - return $md;
489 - }
490 -
491 - public function maybe_add_ally_heading_hint() {
492 - $notice_id = 'ally_heading_notice';
493 - $plugin_slug = 'pojo-accessibility';
494 -
495 - if ( ! Hints::should_display_hint( $notice_id ) ) {
496 - return;
497 - }
498 -
499 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
500 - $is_installed = Hints::is_plugin_installed( $plugin_slug );
501 - $is_active = Hints::is_plugin_active( $plugin_slug );
502 -
503 - if ( $is_active ) {
504 - return;
505 - }
506 -
507 - if ( $one_subscription ) {
508 - if ( ! $is_installed ) {
509 - $notice_content = esc_html__( 'Want to ensure this heading is accessible? Your ONE subscription includes Ally. Install it and scan your page.', 'elementor' );
510 - $button_text = esc_html__( 'Install now', 'elementor' );
511 - $button_url = Hints::get_plugin_install_url( $plugin_slug );
512 - $campaign_data = [
513 - 'name' => 'elementor_ea11y_campaign',
514 - 'campaign' => 'acc-scanner-plg-heading-one-install',
515 - 'source' => 'editor-heading-widget-one-install',
516 - 'medium' => 'editor-one',
517 - ];
518 - } elseif ( ! $is_active ) {
519 - $notice_content = esc_html__( 'Keep your content accessible. Activate Ally, included in ONE, to scan this page.', 'elementor' );
520 - $button_text = esc_html__( 'Activate now', 'elementor' );
521 - $button_url = Hints::get_plugin_activate_url( $plugin_slug );
522 - $campaign_data = [
523 - 'name' => 'elementor_ea11y_campaign',
524 - 'campaign' => 'acc-scanner-plg-heading-one-activate',
525 - 'source' => 'editor-heading-widget-one-non-activate',
526 - 'medium' => 'editor-one',
527 - ];
528 - }
529 - } else {
530 - $notice_content = esc_html__( 'Make sure your page is structured with accessibility in mind. Ally helps detect and fix common issues across your site.', 'elementor' );
531 - if ( ! $is_installed ) {
532 - $button_text = esc_html__( 'Install now', 'elementor' );
533 - $button_url = Hints::get_plugin_install_url( $plugin_slug );
534 - } elseif ( ! $is_active ) {
535 - $button_text = esc_html__( 'Activate now', 'elementor' );
536 - $button_url = Hints::get_plugin_activate_url( $plugin_slug );
537 - }
538 - $campaign_data = [
539 - 'name' => 'elementor_ea11y_campaign',
540 - 'campaign' => 'acc-scanner-plg-heading',
541 - 'source' => 'editor-heading-widget',
542 - 'medium' => 'editor',
543 - ];
544 - }
545 -
546 - $notice_heading = esc_html__( 'Accessible structure matters', 'elementor' );
547 -
548 - $this->add_control(
549 - $notice_id,
550 - [
551 - 'type' => Controls_Manager::RAW_HTML,
552 - 'raw' => Hints::get_notice_template( [
553 - 'display' => ! Hints::is_dismissed( $notice_id ),
554 - 'heading' => $notice_heading,
555 - 'type' => 'info',
556 - 'content' => $notice_content,
557 - 'icon' => true,
558 - 'dismissible' => $notice_id,
559 - 'button_text' => $button_text,
560 - 'button_event' => $notice_id,
561 - 'button_data' => [
562 - 'action_url' => Admin_Notices::add_plg_campaign_data( $button_url, $campaign_data ),
563 - ],
564 - ], true ),
565 - ]
566 - );
567 - }
568 -
569 375 /**
570 376 * Render heading widget output in the editor.
571 377 *
572 378 * Written as a Backbone JavaScript template and used to generate the live preview.
@@ -578,10 +384,10 @@
578 384 ?>
579 385 <#
580 386 let title = elementor.helpers.sanitize( settings.title, { ALLOW_DATA_ATTR: false } );
581 387
582 - if ( '' !== settings.link?.url ) {
583 - title = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + title + '</a>';
388 + if ( '' !== settings.link.url ) {
389 + title = '<a href="' + _.escape( settings.link.url ) + '">' + title + '</a>';
584 390 }
585 391
586 392 view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title' ] );
587 393