| @@ -73,31 +73,9 @@ | ||
| 73 | 73 | public function get_keywords() { |
| 74 | 74 | return [ 'alert', 'notice', 'message' ]; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - protected function is_dynamic_content(): bool { | |
| 78 | - return false; | |
| 79 | - } | |
| 80 | - | |
| 81 | 77 | /** |
| 82 | - * Get style dependencies. | |
| 83 | - * | |
| 84 | - * Retrieve the list of style dependencies the widget requires. | |
| 85 | - * | |
| 86 | - * @since 3.24.0 | |
| 87 | - * @access public | |
| 88 | - * | |
| 89 | - * @return array Widget style dependencies. | |
| 90 | - */ | |
| 91 | - public function get_style_depends(): array { | |
| 92 | - return [ 'widget-alert' ]; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public function has_widget_inner_wrapper(): bool { | |
| 96 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 97 | - } | |
| 98 | - | |
| 99 | - /** | |
| 100 | 78 | * Register alert widget controls. |
| 101 | 79 | * |
| 102 | 80 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 103 | 81 | * |
| @@ -123,9 +101,9 @@ | ||
| 123 | 101 | 'success' => esc_html__( 'Success', 'elementor' ), |
| 124 | 102 | 'warning' => esc_html__( 'Warning', 'elementor' ), |
| 125 | 103 | 'danger' => esc_html__( 'Danger', 'elementor' ), |
| 126 | 104 | ], |
| 127 | - 'prefix_class' => 'elementor-alert-', | |
| 105 | + 'style_transfer' => true, | |
| 128 | 106 | ] |
| 129 | 107 | ); |
| 130 | 108 | |
| 131 | 109 | $this->add_control( |
| @@ -148,8 +126,9 @@ | ||
| 148 | 126 | 'label' => esc_html__( 'Content', 'elementor' ), |
| 149 | 127 | 'type' => Controls_Manager::TEXTAREA, |
| 150 | 128 | 'placeholder' => esc_html__( 'Enter your description', 'elementor' ), |
| 151 | 129 | 'default' => esc_html__( 'I am a description. Click the edit button to change this text.', 'elementor' ), |
| 130 | + 'separator' => 'none', | |
| 152 | 131 | 'dynamic' => [ |
| 153 | 132 | 'active' => true, |
| 154 | 133 | ], |
| 155 | 134 | ] |
| @@ -158,13 +137,14 @@ | ||
| 158 | 137 | $this->add_control( |
| 159 | 138 | 'show_dismiss', |
| 160 | 139 | [ |
| 161 | 140 | 'label' => esc_html__( 'Dismiss Icon', 'elementor' ), |
| 162 | - 'type' => Controls_Manager::SWITCHER, | |
| 163 | - 'label_on' => esc_html__( 'Show', 'elementor' ), | |
| 164 | - 'label_off' => esc_html__( 'Hide', 'elementor' ), | |
| 165 | - 'return_value' => 'show', | |
| 141 | + 'type' => Controls_Manager::SELECT, | |
| 166 | 142 | 'default' => 'show', |
| 143 | + 'options' => [ | |
| 144 | + 'show' => esc_html__( 'Show', 'elementor' ), | |
| 145 | + 'hide' => esc_html__( 'Hide', 'elementor' ), | |
| 146 | + ], | |
| 167 | 147 | ] |
| 168 | 148 | ); |
| 169 | 149 | |
| 170 | 150 | $this->add_control( |
| @@ -225,12 +205,12 @@ | ||
| 225 | 205 | |
| 226 | 206 | $this->add_control( |
| 227 | 207 | 'border_color', |
| 228 | 208 | [ |
| 229 | - 'label' => esc_html__( 'Side Border Color', 'elementor' ), | |
| 209 | + 'label' => esc_html__( 'Border Color', 'elementor' ), | |
| 230 | 210 | 'type' => Controls_Manager::COLOR, |
| 231 | 211 | 'selectors' => [ |
| 232 | - '{{WRAPPER}} .elementor-alert' => 'border-inline-start-color: {{VALUE}};', | |
| 212 | + '{{WRAPPER}} .elementor-alert' => 'border-color: {{VALUE}};', | |
| 233 | 213 | ], |
| 234 | 214 | ] |
| 235 | 215 | ); |
| 236 | 216 | |
| @@ -236,9 +216,9 @@ | ||
| 236 | 216 | |
| 237 | 217 | $this->add_control( |
| 238 | 218 | 'border_left-width', |
| 239 | 219 | [ |
| 240 | - 'label' => esc_html__( 'Side Border Width', 'elementor' ), | |
| 220 | + 'label' => esc_html__( 'Left Border Width', 'elementor' ), | |
| 241 | 221 | 'type' => Controls_Manager::SLIDER, |
| 242 | 222 | 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 243 | 223 | 'range' => [ |
| 244 | 224 | 'px' => [ |
| @@ -248,9 +228,9 @@ | ||
| 248 | 228 | 'max' => 10, |
| 249 | 229 | ], |
| 250 | 230 | ], |
| 251 | 231 | 'selectors' => [ |
| 252 | - '{{WRAPPER}} .elementor-alert' => 'border-inline-start-width: {{SIZE}}{{UNIT}};', | |
| 232 | + '{{WRAPPER}} .elementor-alert' => 'border-left-width: {{SIZE}}{{UNIT}};', | |
| 253 | 233 | ], |
| 254 | 234 | ] |
| 255 | 235 | ); |
| 256 | 236 | |
| @@ -475,45 +455,45 @@ | ||
| 475 | 455 | */ |
| 476 | 456 | protected function render() { |
| 477 | 457 | $settings = $this->get_settings_for_display(); |
| 478 | 458 | |
| 479 | - if ( Utils::is_empty( $settings['alert_title'] ) && Utils::is_empty( $settings['alert_description'] ) ) { | |
| 459 | + if ( Utils::is_empty( $settings['alert_title'] ) ) { | |
| 480 | 460 | return; |
| 481 | 461 | } |
| 482 | 462 | |
| 483 | - $this->add_render_attribute( 'alert_wrapper', 'class', 'elementor-alert' ); | |
| 463 | + if ( ! empty( $settings['alert_type'] ) ) { | |
| 464 | + $this->add_render_attribute( 'wrapper', 'class', 'elementor-alert elementor-alert-' . $settings['alert_type'] ); | |
| 465 | + } | |
| 484 | 466 | |
| 485 | - $this->add_render_attribute( 'alert_wrapper', 'role', 'alert' ); | |
| 467 | + $this->add_render_attribute( 'wrapper', 'role', 'alert' ); | |
| 486 | 468 | |
| 487 | 469 | $this->add_render_attribute( 'alert_title', 'class', 'elementor-alert-title' ); |
| 488 | 470 | |
| 489 | - $this->add_render_attribute( 'alert_description', 'class', 'elementor-alert-description' ); | |
| 490 | - | |
| 491 | 471 | $this->add_inline_editing_attributes( 'alert_title', 'none' ); |
| 492 | - | |
| 493 | - $this->add_inline_editing_attributes( 'alert_description' ); | |
| 494 | 472 | ?> |
| 495 | - <div <?php $this->print_render_attribute_string( 'alert_wrapper' ); ?>> | |
| 473 | + <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>> | |
| 474 | + <span <?php $this->print_render_attribute_string( 'alert_title' ); ?>><?php $this->print_unescaped_setting( 'alert_title' ); ?></span> | |
| 475 | + <?php | |
| 476 | + if ( ! Utils::is_empty( $settings['alert_description'] ) ) : | |
| 477 | + $this->add_render_attribute( 'alert_description', 'class', 'elementor-alert-description' ); | |
| 496 | 478 | |
| 497 | - <?php if ( ! Utils::is_empty( $settings['alert_title'] ) ) : ?> | |
| 498 | - <span <?php $this->print_render_attribute_string( 'alert_title' ); ?>><?php echo wp_kses_post( $settings['alert_title'] ); ?></span> | |
| 479 | + $this->add_inline_editing_attributes( 'alert_description' ); | |
| 480 | + ?> | |
| 481 | + <span <?php $this->print_render_attribute_string( 'alert_description' ); ?>><?php $this->print_unescaped_setting( 'alert_description' ); ?></span> | |
| 499 | 482 | <?php endif; ?> |
| 500 | - | |
| 501 | - <?php if ( ! Utils::is_empty( $settings['alert_description'] ) ) : ?> | |
| 502 | - <span <?php $this->print_render_attribute_string( 'alert_description' ); ?>><?php echo wp_kses_post( $settings['alert_description'] ); ?></span> | |
| 503 | - <?php endif; ?> | |
| 504 | - | |
| 505 | 483 | <?php if ( 'show' === $settings['show_dismiss'] ) : ?> |
| 506 | - <button type="button" class="elementor-alert-dismiss" aria-label="<?php echo esc_attr__( 'Dismiss this alert.', 'elementor' ); ?>"> | |
| 507 | - <?php | |
| 508 | - if ( ! empty( $settings['dismiss_icon']['value'] ) ) { | |
| 509 | - Icons_Manager::render_icon( $settings['dismiss_icon'], [ 'aria-hidden' => 'true' ] ); | |
| 510 | - } else { ?> | |
| 511 | - <span aria-hidden="true">×</span> | |
| 512 | - <?php } ?> | |
| 513 | - </button> | |
| 484 | + <button type="button" class="elementor-alert-dismiss"> | |
| 485 | + <?php | |
| 486 | + if ( ! empty( $settings['dismiss_icon']['value'] ) ) { | |
| 487 | + Icons_Manager::render_icon( $settings['dismiss_icon'], [ | |
| 488 | + 'aria-hidden' => 'true', | |
| 489 | + ] ); | |
| 490 | + } else { ?> | |
| 491 | + <span aria-hidden="true">×</span> | |
| 492 | + <?php } ?> | |
| 493 | + <span class="elementor-screen-only"><?php echo esc_html__( 'Dismiss this alert.', 'elementor' ); ?></span> | |
| 494 | + </button> | |
| 514 | 495 | <?php endif; ?> |
| 515 | - | |
| 516 | 496 | </div> |
| 517 | 497 | <?php |
| 518 | 498 | } |
| 519 | 499 | |
| @@ -524,71 +504,36 @@ | ||
| 524 | 504 | * |
| 525 | 505 | * @since 2.9.0 |
| 526 | 506 | * @access protected |
| 527 | 507 | */ |
| 528 | - public function render_markdown(): string { | |
| 529 | - $settings = $this->get_settings_for_display(); | |
| 530 | - | |
| 531 | - $title = Utils::html_to_plain_text( $settings['alert_title'] ?? '' ); | |
| 532 | - $description = Utils::html_to_plain_text( $settings['alert_description'] ?? '' ); | |
| 533 | - | |
| 534 | - if ( empty( $title ) && empty( $description ) ) { | |
| 535 | - return ''; | |
| 536 | - } | |
| 537 | - | |
| 538 | - if ( ! empty( $title ) && ! empty( $description ) ) { | |
| 539 | - return '> **' . $title . ':** ' . $description; | |
| 540 | - } | |
| 541 | - | |
| 542 | - if ( ! empty( $title ) ) { | |
| 543 | - return '> **' . $title . '**'; | |
| 544 | - } | |
| 545 | - | |
| 546 | - return '> ' . $description; | |
| 547 | - } | |
| 548 | - | |
| 549 | 508 | protected function content_template() { |
| 550 | 509 | ?> |
| 551 | - <# | |
| 552 | - if ( ! settings.alert_title && ! settings.alert_description ) { | |
| 553 | - return; | |
| 554 | - } | |
| 510 | + <# if ( settings.alert_title ) { | |
| 511 | + view.addRenderAttribute( { | |
| 512 | + alert_title: { class: 'elementor-alert-title' }, | |
| 513 | + alert_description: { class: 'elementor-alert-description' } | |
| 514 | + } ); | |
| 555 | 515 | |
| 556 | - view.addRenderAttribute( 'alert_wrapper', 'class', 'elementor-alert' ); | |
| 516 | + view.addInlineEditingAttributes( 'alert_title', 'none' ); | |
| 517 | + view.addInlineEditingAttributes( 'alert_description' ); | |
| 557 | 518 | |
| 558 | - view.addRenderAttribute( 'alert_wrapper', 'role', 'alert' ); | |
| 559 | - | |
| 560 | - view.addRenderAttribute( 'alert_title', 'class', 'elementor-alert-title' ); | |
| 561 | - | |
| 562 | - view.addRenderAttribute( 'alert_description', 'class', 'elementor-alert-description' ); | |
| 563 | - | |
| 564 | - view.addInlineEditingAttributes( 'alert_title', 'none' ); | |
| 565 | - | |
| 566 | - view.addInlineEditingAttributes( 'alert_description' ); | |
| 567 | - | |
| 568 | - var iconHTML = elementor.helpers.renderIcon( view, settings.dismiss_icon, { 'aria-hidden': true }, 'i' , 'object' ), | |
| 569 | - migrated = elementor.helpers.isIconMigrated( settings, 'dismiss_icon' ); | |
| 570 | - #> | |
| 571 | - <div {{{ view.getRenderAttributeString( 'alert_wrapper' ) }}}> | |
| 572 | - | |
| 573 | - <# if ( settings.alert_title ) { #> | |
| 574 | - <span {{{ view.getRenderAttributeString( 'alert_title' ) }}}>{{ settings.alert_title }}</span> | |
| 575 | - <# } #> | |
| 576 | - | |
| 577 | - <# if ( settings.alert_description ) { #> | |
| 578 | - <span {{{ view.getRenderAttributeString( 'alert_description' ) }}}>{{ settings.alert_description }}</span> | |
| 579 | - <# } #> | |
| 580 | - | |
| 581 | - <# if ( 'show' === settings.show_dismiss ) { #> | |
| 582 | - <button type="button" class="elementor-alert-dismiss" aria-label="<?php echo esc_attr__( 'Dismiss this alert.', 'elementor' ); ?>"> | |
| 583 | - <# if ( iconHTML && iconHTML.rendered && ( ! settings.icon || migrated ) ) { #> | |
| 584 | - {{{ iconHTML.value }}} | |
| 585 | - <# } else { #> | |
| 586 | - <span aria-hidden="true">×</span> | |
| 519 | + var iconHTML = elementor.helpers.renderIcon( view, settings.dismiss_icon, { 'aria-hidden': true }, 'i' , 'object' ), | |
| 520 | + migrated = elementor.helpers.isIconMigrated( settings, 'dismiss_icon' ); | |
| 521 | + #> | |
| 522 | + <div class="elementor-alert elementor-alert-{{ settings.alert_type }}" role="alert"> | |
| 523 | + <span {{{ view.getRenderAttributeString( 'alert_title' ) }}}>{{{ settings.alert_title }}}</span> | |
| 524 | + <span {{{ view.getRenderAttributeString( 'alert_description' ) }}}>{{{ settings.alert_description }}}</span> | |
| 525 | + <# if ( 'show' === settings.show_dismiss ) { #> | |
| 526 | + <button type="button" class="elementor-alert-dismiss"> | |
| 527 | + <# if ( iconHTML && iconHTML.rendered && ( ! settings.icon || migrated ) ) { #> | |
| 528 | + {{{ iconHTML.value }}} | |
| 529 | + <# } else { #> | |
| 530 | + <span aria-hidden="true">×</span> | |
| 531 | + <# } #> | |
| 532 | + <span class="elementor-screen-only"><?php echo esc_html__( 'Dismiss this alert.', 'elementor' ); ?></span> | |
| 533 | + </button> | |
| 587 | 534 | <# } #> |
| 588 | - </button> | |
| 589 | - <# } #> | |
| 590 | - | |
| 591 | - </div> | |
| 535 | + </div> | |
| 536 | + <# } #> | |
| 592 | 537 | <?php |
| 593 | 538 | } |
| 594 | 539 | } |