| @@ -6,12 +6,8 @@ | ||
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 9 | 9 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 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 | 10 | |
| 15 | 11 | /** |
| 16 | 12 | * Elementor heading widget. |
| 17 | 13 | * |
| @@ -18,9 +14,9 @@ | ||
| 18 | 14 | * Elementor widget that displays an eye-catching headlines. |
| 19 | 15 | * |
| 20 | 16 | * @since 1.0.0 |
| 21 | 17 | */ |
| 22 | -class Widget_Heading extends Widget_Base implements Sanitizable { | |
| 18 | +class Widget_Heading extends Widget_Base { | |
| 23 | 19 | |
| 24 | 20 | /** |
| 25 | 21 | * Get widget name. |
| 26 | 22 | * |
| @@ -92,57 +88,9 @@ | ||
| 92 | 88 | public function get_keywords() { |
| 93 | 89 | return [ 'heading', 'title', 'text' ]; |
| 94 | 90 | } |
| 95 | 91 | |
| 96 | - protected function is_dynamic_content(): bool { | |
| 97 | - return false; | |
| 98 | - } | |
| 99 | - | |
| 100 | 92 | /** |
| 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 | - * Remove data attributes from the html. | |
| 120 | - * | |
| 121 | - * @param string $content Heading title. | |
| 122 | - * @return string | |
| 123 | - */ | |
| 124 | - public function sanitize( $content ): string { | |
| 125 | - $allowed_tags = wp_kses_allowed_html( 'post' ); | |
| 126 | - $allowed_tags_for_heading = []; | |
| 127 | - $non_allowed_tags = [ 'img' ]; | |
| 128 | - | |
| 129 | - foreach ( $allowed_tags as $tag => $attributes ) { | |
| 130 | - if ( in_array( $tag, $non_allowed_tags, true ) ) { | |
| 131 | - continue; | |
| 132 | - } | |
| 133 | - | |
| 134 | - $filtered_attributes = array_filter( $attributes, function( $attribute ) { | |
| 135 | - return ! substr( $attribute, 0, 5 ) === 'data-'; | |
| 136 | - }, ARRAY_FILTER_USE_KEY ); | |
| 137 | - | |
| 138 | - $allowed_tags_for_heading[ $tag ] = $filtered_attributes; | |
| 139 | - } | |
| 140 | - | |
| 141 | - return wp_kses( $content, $allowed_tags_for_heading ); | |
| 142 | - } | |
| 143 | - | |
| 144 | - /** | |
| 145 | 93 | * Get widget upsale data. |
| 146 | 94 | * |
| 147 | 95 | * Retrieve the widget promotion data. |
| 148 | 96 | * |
| @@ -247,10 +195,8 @@ | ||
| 247 | 195 | 'default' => 'h2', |
| 248 | 196 | ] |
| 249 | 197 | ); |
| 250 | 198 | |
| 251 | - $this->maybe_add_ally_heading_hint(); | |
| 252 | - | |
| 253 | 199 | $this->end_controls_section(); |
| 254 | 200 | |
| 255 | 201 | $this->start_controls_section( |
| 256 | 202 | 'section_title_style', |
| @@ -265,10 +211,10 @@ | ||
| 265 | 211 | [ |
| 266 | 212 | 'label' => esc_html__( 'Alignment', 'elementor' ), |
| 267 | 213 | 'type' => Controls_Manager::CHOOSE, |
| 268 | 214 | 'options' => [ |
| 269 | - 'start' => [ | |
| 270 | - 'title' => esc_html__( 'Start', 'elementor' ), | |
| 215 | + 'left' => [ | |
| 216 | + 'title' => esc_html__( 'Left', 'elementor' ), | |
| 271 | 217 | 'icon' => 'eicon-text-align-left', |
| 272 | 218 | ], |
| 273 | 219 | 'center' => [ |
| 274 | 220 | 'title' => esc_html__( 'Center', 'elementor' ), |
| @@ -273,10 +219,10 @@ | ||
| 273 | 219 | 'center' => [ |
| 274 | 220 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 275 | 221 | 'icon' => 'eicon-text-align-center', |
| 276 | 222 | ], |
| 277 | - 'end' => [ | |
| 278 | - 'title' => esc_html__( 'End', 'elementor' ), | |
| 223 | + 'right' => [ | |
| 224 | + 'title' => esc_html__( 'Right', 'elementor' ), | |
| 279 | 225 | 'icon' => 'eicon-text-align-right', |
| 280 | 226 | ], |
| 281 | 227 | 'justify' => [ |
| 282 | 228 | 'title' => esc_html__( 'Justified', 'elementor' ), |
| @@ -282,21 +228,29 @@ | ||
| 282 | 228 | 'title' => esc_html__( 'Justified', 'elementor' ), |
| 283 | 229 | 'icon' => 'eicon-text-align-justify', |
| 284 | 230 | ], |
| 285 | 231 | ], |
| 286 | - 'classes' => 'elementor-control-start-end', | |
| 287 | - 'selectors_dictionary' => [ | |
| 288 | - 'left' => is_rtl() ? 'end' : 'start', | |
| 289 | - 'right' => is_rtl() ? 'start' : 'end', | |
| 290 | - ], | |
| 291 | 232 | 'default' => '', |
| 292 | 233 | 'selectors' => [ |
| 293 | 234 | '{{WRAPPER}}' => 'text-align: {{VALUE}};', |
| 294 | 235 | ], |
| 295 | - 'separator' => 'after', | |
| 296 | 236 | ] |
| 297 | 237 | ); |
| 298 | 238 | |
| 239 | + $this->add_control( | |
| 240 | + 'title_color', | |
| 241 | + [ | |
| 242 | + 'label' => esc_html__( 'Text Color', 'elementor' ), | |
| 243 | + 'type' => Controls_Manager::COLOR, | |
| 244 | + 'global' => [ | |
| 245 | + 'default' => Global_Colors::COLOR_PRIMARY, | |
| 246 | + ], | |
| 247 | + 'selectors' => [ | |
| 248 | + '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};', | |
| 249 | + ], | |
| 250 | + ] | |
| 251 | + ); | |
| 252 | + | |
| 299 | 253 | $this->add_group_control( |
| 300 | 254 | Group_Control_Typography::get_type(), |
| 301 | 255 | [ |
| 302 | 256 | 'name' => 'typography', |
| @@ -348,77 +302,8 @@ | ||
| 348 | 302 | ], |
| 349 | 303 | ] |
| 350 | 304 | ); |
| 351 | 305 | |
| 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 | 306 | $this->end_controls_section(); |
| 422 | 307 | } |
| 423 | 308 | |
| 424 | 309 | /** |
| @@ -445,9 +330,9 @@ | ||
| 445 | 330 | } |
| 446 | 331 | |
| 447 | 332 | $this->add_inline_editing_attributes( 'title' ); |
| 448 | 333 | |
| 449 | - $title = wp_kses_post( $settings['title'] ); | |
| 334 | + $title = $settings['title']; | |
| 450 | 335 | |
| 451 | 336 | if ( ! empty( $settings['link']['url'] ) ) { |
| 452 | 337 | $this->add_link_attributes( 'url', $settings['link'] ); |
| 453 | 338 | |
| @@ -459,86 +344,8 @@ | ||
| 459 | 344 | // PHPCS - the variable $title_html holds safe data. |
| 460 | 345 | echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 461 | 346 | } |
| 462 | 347 | |
| 463 | - public function maybe_add_ally_heading_hint() { | |
| 464 | - $notice_id = 'ally_heading_notice'; | |
| 465 | - $plugin_slug = 'pojo-accessibility'; | |
| 466 | - | |
| 467 | - if ( ! Hints::should_display_hint( $notice_id ) ) { | |
| 468 | - return; | |
| 469 | - } | |
| 470 | - | |
| 471 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 472 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 473 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 474 | - | |
| 475 | - if ( $is_active ) { | |
| 476 | - return; | |
| 477 | - } | |
| 478 | - | |
| 479 | - if ( $one_subscription ) { | |
| 480 | - if ( ! $is_installed ) { | |
| 481 | - $notice_content = esc_html__( 'Want to ensure this heading is accessible? Your ONE subscription includes Ally. Install it and scan your page.', 'elementor' ); | |
| 482 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 483 | - $button_url = Hints::get_plugin_install_url( $plugin_slug ); | |
| 484 | - $campaign_data = [ | |
| 485 | - 'name' => 'elementor_ea11y_campaign', | |
| 486 | - 'campaign' => 'acc-scanner-plg-heading-one-install', | |
| 487 | - 'source' => 'editor-heading-widget-one-install', | |
| 488 | - 'medium' => 'editor-one', | |
| 489 | - ]; | |
| 490 | - } elseif ( ! $is_active ) { | |
| 491 | - $notice_content = esc_html__( 'Keep your content accessible. Activate Ally, included in ONE, to scan this page.', 'elementor' ); | |
| 492 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 493 | - $button_url = Hints::get_plugin_activate_url( $plugin_slug ); | |
| 494 | - $campaign_data = [ | |
| 495 | - 'name' => 'elementor_ea11y_campaign', | |
| 496 | - 'campaign' => 'acc-scanner-plg-heading-one-activate', | |
| 497 | - 'source' => 'editor-heading-widget-one-non-activate', | |
| 498 | - 'medium' => 'editor-one', | |
| 499 | - ]; | |
| 500 | - } | |
| 501 | - } else { | |
| 502 | - $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' ); | |
| 503 | - if ( ! $is_installed ) { | |
| 504 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 505 | - $button_url = Hints::get_plugin_install_url( $plugin_slug ); | |
| 506 | - } elseif ( ! $is_active ) { | |
| 507 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 508 | - $button_url = Hints::get_plugin_activate_url( $plugin_slug ); | |
| 509 | - } | |
| 510 | - $campaign_data = [ | |
| 511 | - 'name' => 'elementor_ea11y_campaign', | |
| 512 | - 'campaign' => 'acc-scanner-plg-heading', | |
| 513 | - 'source' => 'editor-heading-widget', | |
| 514 | - 'medium' => 'editor', | |
| 515 | - ]; | |
| 516 | - } | |
| 517 | - | |
| 518 | - $notice_heading = esc_html__( 'Accessible structure matters', 'elementor' ); | |
| 519 | - | |
| 520 | - $this->add_control( | |
| 521 | - $notice_id, | |
| 522 | - [ | |
| 523 | - 'type' => Controls_Manager::RAW_HTML, | |
| 524 | - 'raw' => Hints::get_notice_template( [ | |
| 525 | - 'display' => ! Hints::is_dismissed( $notice_id ), | |
| 526 | - 'heading' => $notice_heading, | |
| 527 | - 'type' => 'info', | |
| 528 | - 'content' => $notice_content, | |
| 529 | - 'icon' => true, | |
| 530 | - 'dismissible' => $notice_id, | |
| 531 | - 'button_text' => $button_text, | |
| 532 | - 'button_event' => $notice_id, | |
| 533 | - 'button_data' => [ | |
| 534 | - 'action_url' => Admin_Notices::add_plg_campaign_data( $button_url, $campaign_data ), | |
| 535 | - ], | |
| 536 | - ], true ), | |
| 537 | - ] | |
| 538 | - ); | |
| 539 | - } | |
| 540 | - | |
| 541 | 348 | /** |
| 542 | 349 | * Render heading widget output in the editor. |
| 543 | 350 | * |
| 544 | 351 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| @@ -548,12 +355,12 @@ | ||
| 548 | 355 | */ |
| 549 | 356 | protected function content_template() { |
| 550 | 357 | ?> |
| 551 | 358 | <# |
| 552 | - let title = elementor.helpers.sanitize( settings.title, { ALLOW_DATA_ATTR: false } ); | |
| 359 | + var title = settings.title; | |
| 553 | 360 | |
| 554 | - if ( '' !== settings.link?.url ) { | |
| 555 | - title = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + title + '</a>'; | |
| 361 | + if ( '' !== settings.link.url ) { | |
| 362 | + title = '<a href="' + _.escape( settings.link.url ) + '">' + title + '</a>'; | |
| 556 | 363 | } |
| 557 | 364 | |
| 558 | 365 | view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title' ] ); |
| 559 | 366 | |