| @@ -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,74 +88,12 @@ | ||
| 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 | - /** | |
| 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 | - * Get widget upsale data. | |
| 146 | - * | |
| 147 | - * Retrieve the widget promotion data. | |
| 148 | - * | |
| 149 | - * @since 3.18.0 | |
| 150 | - * @access protected | |
| 151 | - * | |
| 152 | - * @return array Widget promotion data. | |
| 153 | - */ | |
| 154 | 92 | protected function get_upsale_data() { |
| 155 | 93 | return [ |
| 156 | - 'condition' => ! Utils::has_pro(), | |
| 157 | - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), | |
| 158 | - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), | |
| 159 | 94 | 'description' => esc_html__( 'Create captivating headings that rotate with the Animated Headline Widget.', 'elementor' ), |
| 160 | - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-heading-widget/' ), | |
| 161 | - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), | |
| 95 | + 'upgrade_url' => 'https://go.elementor.com/go-pro-heading-widget/', | |
| 162 | 96 | ]; |
| 163 | 97 | } |
| 164 | 98 | |
| 165 | 99 | /** |
| @@ -173,9 +107,9 @@ | ||
| 173 | 107 | protected function register_controls() { |
| 174 | 108 | $this->start_controls_section( |
| 175 | 109 | 'section_title', |
| 176 | 110 | [ |
| 177 | - 'label' => esc_html__( 'Heading', 'elementor' ), | |
| 111 | + 'label' => esc_html__( 'Title', 'elementor' ), | |
| 178 | 112 | ] |
| 179 | 113 | ); |
| 180 | 114 | |
| 181 | 115 | $this->add_control( |
| @@ -204,8 +138,9 @@ | ||
| 204 | 138 | ], |
| 205 | 139 | 'default' => [ |
| 206 | 140 | 'url' => '', |
| 207 | 141 | ], |
| 142 | + 'separator' => 'before', | |
| 208 | 143 | ] |
| 209 | 144 | ); |
| 210 | 145 | |
| 211 | 146 | $this->add_control( |
| @@ -212,8 +147,9 @@ | ||
| 212 | 147 | 'size', |
| 213 | 148 | [ |
| 214 | 149 | 'label' => esc_html__( 'Size', 'elementor' ), |
| 215 | 150 | 'type' => Controls_Manager::SELECT, |
| 151 | + 'default' => 'default', | |
| 216 | 152 | 'options' => [ |
| 217 | 153 | 'default' => esc_html__( 'Default', 'elementor' ), |
| 218 | 154 | 'small' => esc_html__( 'Small', 'elementor' ), |
| 219 | 155 | 'medium' => esc_html__( 'Medium', 'elementor' ), |
| @@ -220,12 +156,8 @@ | ||
| 220 | 156 | 'large' => esc_html__( 'Large', 'elementor' ), |
| 221 | 157 | 'xl' => esc_html__( 'XL', 'elementor' ), |
| 222 | 158 | 'xxl' => esc_html__( 'XXL', 'elementor' ), |
| 223 | 159 | ], |
| 224 | - 'default' => 'default', | |
| 225 | - 'condition' => [ | |
| 226 | - 'size!' => 'default', // a workaround to hide the control, unless it's in use (not default). | |
| 227 | - ], | |
| 228 | 160 | ] |
| 229 | 161 | ); |
| 230 | 162 | |
| 231 | 163 | $this->add_control( |
| @@ -247,20 +179,8 @@ | ||
| 247 | 179 | 'default' => 'h2', |
| 248 | 180 | ] |
| 249 | 181 | ); |
| 250 | 182 | |
| 251 | - $this->maybe_add_ally_heading_hint(); | |
| 252 | - | |
| 253 | - $this->end_controls_section(); | |
| 254 | - | |
| 255 | - $this->start_controls_section( | |
| 256 | - 'section_title_style', | |
| 257 | - [ | |
| 258 | - 'label' => esc_html__( 'Heading', 'elementor' ), | |
| 259 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 260 | - ] | |
| 261 | - ); | |
| 262 | - | |
| 263 | 183 | $this->add_responsive_control( |
| 264 | 184 | 'align', |
| 265 | 185 | [ |
| 266 | 186 | 'label' => esc_html__( 'Alignment', 'elementor' ), |
| @@ -265,10 +185,10 @@ | ||
| 265 | 185 | [ |
| 266 | 186 | 'label' => esc_html__( 'Alignment', 'elementor' ), |
| 267 | 187 | 'type' => Controls_Manager::CHOOSE, |
| 268 | 188 | 'options' => [ |
| 269 | - 'start' => [ | |
| 270 | - 'title' => esc_html__( 'Start', 'elementor' ), | |
| 189 | + 'left' => [ | |
| 190 | + 'title' => esc_html__( 'Left', 'elementor' ), | |
| 271 | 191 | 'icon' => 'eicon-text-align-left', |
| 272 | 192 | ], |
| 273 | 193 | 'center' => [ |
| 274 | 194 | 'title' => esc_html__( 'Center', 'elementor' ), |
| @@ -273,10 +193,10 @@ | ||
| 273 | 193 | 'center' => [ |
| 274 | 194 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 275 | 195 | 'icon' => 'eicon-text-align-center', |
| 276 | 196 | ], |
| 277 | - 'end' => [ | |
| 278 | - 'title' => esc_html__( 'End', 'elementor' ), | |
| 197 | + 'right' => [ | |
| 198 | + 'title' => esc_html__( 'Right', 'elementor' ), | |
| 279 | 199 | 'icon' => 'eicon-text-align-right', |
| 280 | 200 | ], |
| 281 | 201 | 'justify' => [ |
| 282 | 202 | 'title' => esc_html__( 'Justified', 'elementor' ), |
| @@ -282,21 +202,48 @@ | ||
| 282 | 202 | 'title' => esc_html__( 'Justified', 'elementor' ), |
| 283 | 203 | 'icon' => 'eicon-text-align-justify', |
| 284 | 204 | ], |
| 285 | 205 | ], |
| 286 | - 'classes' => 'elementor-control-start-end', | |
| 287 | - 'selectors_dictionary' => [ | |
| 288 | - 'left' => is_rtl() ? 'end' : 'start', | |
| 289 | - 'right' => is_rtl() ? 'start' : 'end', | |
| 290 | - ], | |
| 291 | 206 | 'default' => '', |
| 292 | 207 | 'selectors' => [ |
| 293 | 208 | '{{WRAPPER}}' => 'text-align: {{VALUE}};', |
| 294 | 209 | ], |
| 295 | - 'separator' => 'after', | |
| 296 | 210 | ] |
| 297 | 211 | ); |
| 298 | 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 | + | |
| 299 | 246 | $this->add_group_control( |
| 300 | 247 | Group_Control_Typography::get_type(), |
| 301 | 248 | [ |
| 302 | 249 | 'name' => 'typography', |
| @@ -345,80 +292,12 @@ | ||
| 345 | 292 | ], |
| 346 | 293 | 'selectors' => [ |
| 347 | 294 | '{{WRAPPER}} .elementor-heading-title' => 'mix-blend-mode: {{VALUE}}', |
| 348 | 295 | ], |
| 296 | + 'separator' => 'none', | |
| 349 | 297 | ] |
| 350 | 298 | ); |
| 351 | 299 | |
| 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 | 300 | $this->end_controls_section(); |
| 422 | 301 | } |
| 423 | 302 | |
| 424 | 303 | /** |
| @@ -439,15 +318,13 @@ | ||
| 439 | 318 | $this->add_render_attribute( 'title', 'class', 'elementor-heading-title' ); |
| 440 | 319 | |
| 441 | 320 | if ( ! empty( $settings['size'] ) ) { |
| 442 | 321 | $this->add_render_attribute( 'title', 'class', 'elementor-size-' . $settings['size'] ); |
| 443 | - } else { | |
| 444 | - $this->add_render_attribute( 'title', 'class', 'elementor-size-default' ); | |
| 445 | 322 | } |
| 446 | 323 | |
| 447 | 324 | $this->add_inline_editing_attributes( 'title' ); |
| 448 | 325 | |
| 449 | - $title = wp_kses_post( $settings['title'] ); | |
| 326 | + $title = $settings['title']; | |
| 450 | 327 | |
| 451 | 328 | if ( ! empty( $settings['link']['url'] ) ) { |
| 452 | 329 | $this->add_link_attributes( 'url', $settings['link'] ); |
| 453 | 330 | |
| @@ -459,86 +336,8 @@ | ||
| 459 | 336 | // PHPCS - the variable $title_html holds safe data. |
| 460 | 337 | echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 461 | 338 | } |
| 462 | 339 | |
| 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 | 340 | /** |
| 542 | 341 | * Render heading widget output in the editor. |
| 543 | 342 | * |
| 544 | 343 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| @@ -548,21 +347,15 @@ | ||
| 548 | 347 | */ |
| 549 | 348 | protected function content_template() { |
| 550 | 349 | ?> |
| 551 | 350 | <# |
| 552 | - let title = elementor.helpers.sanitize( settings.title, { ALLOW_DATA_ATTR: false } ); | |
| 351 | + var title = settings.title; | |
| 553 | 352 | |
| 554 | - if ( '' !== settings.link?.url ) { | |
| 555 | - title = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + title + '</a>'; | |
| 353 | + if ( '' !== settings.link.url ) { | |
| 354 | + title = '<a href="' + _.escape( settings.link.url ) + '">' + title + '</a>'; | |
| 556 | 355 | } |
| 557 | 356 | |
| 558 | - view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title' ] ); | |
| 559 | - | |
| 560 | - if ( '' !== settings.size ) { | |
| 561 | - view.addRenderAttribute( 'title', 'class', [ 'elementor-size-' + settings.size ] ); | |
| 562 | - } else { | |
| 563 | - view.addRenderAttribute( 'title', 'class', [ 'elementor-size-default' ] ); | |
| 564 | - } | |
| 357 | + view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title', 'elementor-size-' + settings.size ] ); | |
| 565 | 358 | |
| 566 | 359 | view.addInlineEditingAttributes( 'title' ); |
| 567 | 360 | |
| 568 | 361 | var headerSizeTag = elementor.helpers.validateHTMLTag( settings.header_size ), |