| @@ -7,11 +7,10 @@ | ||
| 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 | 11 | use Elementor\Modules\Promotions\Controls\Promotion_Control; |
| 12 | +use Elementor\Utils; | |
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * Elementor heading widget. |
| 17 | 16 | * |
| @@ -117,9 +116,9 @@ | ||
| 117 | 116 | |
| 118 | 117 | /** |
| 119 | 118 | * Remove data attributes from the html. |
| 120 | 119 | * |
| 121 | - * @param string $content Heading title. | |
| 120 | + * @param string $content Heading title | |
| 122 | 121 | * @return string |
| 123 | 122 | */ |
| 124 | 123 | public function sanitize( $content ): string { |
| 125 | 124 | $allowed_tags = wp_kses_allowed_html( 'post' ); |
| @@ -141,29 +140,8 @@ | ||
| 141 | 140 | return wp_kses( $content, $allowed_tags_for_heading ); |
| 142 | 141 | } |
| 143 | 142 | |
| 144 | 143 | /** |
| 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 | - protected function get_upsale_data() { | |
| 155 | - 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 | - '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' ), | |
| 162 | - ]; | |
| 163 | - } | |
| 164 | - | |
| 165 | - /** | |
| 166 | 144 | * Register heading widget controls. |
| 167 | 145 | * |
| 168 | 146 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 169 | 147 | * |
| @@ -247,9 +225,17 @@ | ||
| 247 | 225 | 'default' => 'h2', |
| 248 | 226 | ] |
| 249 | 227 | ); |
| 250 | 228 | |
| 251 | - $this->maybe_add_ally_heading_hint(); | |
| 229 | + if ( ! Utils::has_pro() ) { | |
| 230 | + $this->add_control( | |
| 231 | + Utils::ANIMATED_HEADLINE . '_promotion', | |
| 232 | + [ | |
| 233 | + 'label' => esc_html__( 'Animated Headline widget', 'elementor' ), | |
| 234 | + 'type' => Promotion_Control::TYPE, | |
| 235 | + ] | |
| 236 | + ); | |
| 237 | + } | |
| 252 | 238 | |
| 253 | 239 | $this->end_controls_section(); |
| 254 | 240 | |
| 255 | 241 | $this->start_controls_section( |
| @@ -265,10 +251,10 @@ | ||
| 265 | 251 | [ |
| 266 | 252 | 'label' => esc_html__( 'Alignment', 'elementor' ), |
| 267 | 253 | 'type' => Controls_Manager::CHOOSE, |
| 268 | 254 | 'options' => [ |
| 269 | - 'start' => [ | |
| 270 | - 'title' => esc_html__( 'Start', 'elementor' ), | |
| 255 | + 'left' => [ | |
| 256 | + 'title' => esc_html__( 'Left', 'elementor' ), | |
| 271 | 257 | 'icon' => 'eicon-text-align-left', |
| 272 | 258 | ], |
| 273 | 259 | 'center' => [ |
| 274 | 260 | 'title' => esc_html__( 'Center', 'elementor' ), |
| @@ -273,10 +259,10 @@ | ||
| 273 | 259 | 'center' => [ |
| 274 | 260 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 275 | 261 | 'icon' => 'eicon-text-align-center', |
| 276 | 262 | ], |
| 277 | - 'end' => [ | |
| 278 | - 'title' => esc_html__( 'End', 'elementor' ), | |
| 263 | + 'right' => [ | |
| 264 | + 'title' => esc_html__( 'Right', 'elementor' ), | |
| 279 | 265 | 'icon' => 'eicon-text-align-right', |
| 280 | 266 | ], |
| 281 | 267 | 'justify' => [ |
| 282 | 268 | 'title' => esc_html__( 'Justified', 'elementor' ), |
| @@ -282,13 +268,8 @@ | ||
| 282 | 268 | 'title' => esc_html__( 'Justified', 'elementor' ), |
| 283 | 269 | 'icon' => 'eicon-text-align-justify', |
| 284 | 270 | ], |
| 285 | 271 | ], |
| 286 | - 'classes' => 'elementor-control-start-end', | |
| 287 | - 'selectors_dictionary' => [ | |
| 288 | - 'left' => is_rtl() ? 'end' : 'start', | |
| 289 | - 'right' => is_rtl() ? 'start' : 'end', | |
| 290 | - ], | |
| 291 | 272 | 'default' => '', |
| 292 | 273 | 'selectors' => [ |
| 293 | 274 | '{{WRAPPER}}' => 'text-align: {{VALUE}};', |
| 294 | 275 | ], |
| @@ -361,8 +342,11 @@ | ||
| 361 | 342 | $this->start_controls_tab( |
| 362 | 343 | 'title_colors_normal', |
| 363 | 344 | [ |
| 364 | 345 | 'label' => esc_html__( 'Normal', 'elementor' ), |
| 346 | + 'condition' => [ | |
| 347 | + 'link[url]!' => '', | |
| 348 | + ], | |
| 365 | 349 | ] |
| 366 | 350 | ); |
| 367 | 351 | |
| 368 | 352 | $this->add_control( |
| @@ -384,8 +368,11 @@ | ||
| 384 | 368 | $this->start_controls_tab( |
| 385 | 369 | 'title_colors_hover', |
| 386 | 370 | [ |
| 387 | 371 | 'label' => esc_html__( 'Hover', 'elementor' ), |
| 372 | + 'condition' => [ | |
| 373 | + 'link[url]!' => '', | |
| 374 | + ], | |
| 388 | 375 | ] |
| 389 | 376 | ); |
| 390 | 377 | |
| 391 | 378 | $this->add_control( |
| @@ -390,13 +377,16 @@ | ||
| 390 | 377 | |
| 391 | 378 | $this->add_control( |
| 392 | 379 | 'title_hover_color', |
| 393 | 380 | [ |
| 394 | - 'label' => esc_html__( 'Link Color', 'elementor' ), | |
| 381 | + 'label' => esc_html__( 'Text Color', 'elementor' ), | |
| 395 | 382 | 'type' => Controls_Manager::COLOR, |
| 396 | 383 | 'selectors' => [ |
| 397 | - '{{WRAPPER}} .elementor-heading-title a:hover, {{WRAPPER}} .elementor-heading-title a:focus' => 'color: {{VALUE}};', | |
| 384 | + '{{WRAPPER}} .elementor-heading-title:hover' => 'color: {{VALUE}};', | |
| 398 | 385 | ], |
| 386 | + 'condition' => [ | |
| 387 | + 'link[url]!' => '', | |
| 388 | + ], | |
| 399 | 389 | ] |
| 400 | 390 | ); |
| 401 | 391 | |
| 402 | 392 | $this->add_control( |
| @@ -408,9 +398,9 @@ | ||
| 408 | 398 | 'default' => [ |
| 409 | 399 | 'unit' => 's', |
| 410 | 400 | ], |
| 411 | 401 | 'selectors' => [ |
| 412 | - '{{WRAPPER}} .elementor-heading-title a' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 402 | + '{{WRAPPER}} .elementor-heading-title' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 413 | 403 | ], |
| 414 | 404 | ] |
| 415 | 405 | ); |
| 416 | 406 | |
| @@ -459,114 +449,8 @@ | ||
| 459 | 449 | // PHPCS - the variable $title_html holds safe data. |
| 460 | 450 | echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 461 | 451 | } |
| 462 | 452 | |
| 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 | 453 | /** |
| 570 | 454 | * Render heading widget output in the editor. |
| 571 | 455 | * |
| 572 | 456 | * Written as a Backbone JavaScript template and used to generate the live preview. |
| @@ -578,10 +462,10 @@ | ||
| 578 | 462 | ?> |
| 579 | 463 | <# |
| 580 | 464 | let title = elementor.helpers.sanitize( settings.title, { ALLOW_DATA_ATTR: false } ); |
| 581 | 465 | |
| 582 | - if ( '' !== settings.link?.url ) { | |
| 583 | - title = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + title + '</a>'; | |
| 466 | + if ( '' !== settings.link.url ) { | |
| 467 | + title = '<a href="' + elementor.helpers.sanitizeUrl( settings.link.url ) + '">' + title + '</a>'; | |
| 584 | 468 | } |
| 585 | 469 | |
| 586 | 470 | view.addRenderAttribute( 'title', 'class', [ 'elementor-heading-title' ] ); |
| 587 | 471 | |