| @@ -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( |
| @@ -130,9 +108,9 @@ | ||
| 130 | 108 | |
| 131 | 109 | $this->add_control( |
| 132 | 110 | 'alert_title', |
| 133 | 111 | [ |
| 134 | - 'label' => esc_html__( 'Title', 'elementor' ), | |
| 112 | + 'label' => esc_html__( 'Title & Description', 'elementor' ), | |
| 135 | 113 | 'type' => Controls_Manager::TEXT, |
| 136 | 114 | 'placeholder' => esc_html__( 'Enter your title', 'elementor' ), |
| 137 | 115 | 'default' => esc_html__( 'This is an Alert', 'elementor' ), |
| 138 | 116 | 'label_block' => true, |
| @@ -148,8 +126,10 @@ | ||
| 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', | |
| 131 | + 'show_label' => false, | |
| 152 | 132 | 'dynamic' => [ |
| 153 | 133 | 'active' => true, |
| 154 | 134 | ], |
| 155 | 135 | ] |
| @@ -158,13 +138,14 @@ | ||
| 158 | 138 | $this->add_control( |
| 159 | 139 | 'show_dismiss', |
| 160 | 140 | [ |
| 161 | 141 | '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', | |
| 142 | + 'type' => Controls_Manager::SELECT, | |
| 166 | 143 | 'default' => 'show', |
| 144 | + 'options' => [ | |
| 145 | + 'show' => esc_html__( 'Show', 'elementor' ), | |
| 146 | + 'hide' => esc_html__( 'Hide', 'elementor' ), | |
| 147 | + ], | |
| 167 | 148 | ] |
| 168 | 149 | ); |
| 169 | 150 | |
| 170 | 151 | $this->add_control( |
| @@ -201,8 +182,17 @@ | ||
| 201 | 182 | ], |
| 202 | 183 | ] |
| 203 | 184 | ); |
| 204 | 185 | |
| 186 | + $this->add_control( | |
| 187 | + 'view', | |
| 188 | + [ | |
| 189 | + 'label' => esc_html__( 'View', 'elementor' ), | |
| 190 | + 'type' => Controls_Manager::HIDDEN, | |
| 191 | + 'default' => 'traditional', | |
| 192 | + ] | |
| 193 | + ); | |
| 194 | + | |
| 205 | 195 | $this->end_controls_section(); |
| 206 | 196 | |
| 207 | 197 | $this->start_controls_section( |
| 208 | 198 | 'section_type', |
| @@ -225,12 +215,12 @@ | ||
| 225 | 215 | |
| 226 | 216 | $this->add_control( |
| 227 | 217 | 'border_color', |
| 228 | 218 | [ |
| 229 | - 'label' => esc_html__( 'Side Border Color', 'elementor' ), | |
| 219 | + 'label' => esc_html__( 'Border Color', 'elementor' ), | |
| 230 | 220 | 'type' => Controls_Manager::COLOR, |
| 231 | 221 | 'selectors' => [ |
| 232 | - '{{WRAPPER}} .elementor-alert' => 'border-inline-start-color: {{VALUE}};', | |
| 222 | + '{{WRAPPER}} .elementor-alert' => 'border-color: {{VALUE}};', | |
| 233 | 223 | ], |
| 234 | 224 | ] |
| 235 | 225 | ); |
| 236 | 226 | |
| @@ -236,11 +226,11 @@ | ||
| 236 | 226 | |
| 237 | 227 | $this->add_control( |
| 238 | 228 | 'border_left-width', |
| 239 | 229 | [ |
| 240 | - 'label' => esc_html__( 'Side Border Width', 'elementor' ), | |
| 230 | + 'label' => esc_html__( 'Left Border Width', 'elementor' ), | |
| 241 | 231 | 'type' => Controls_Manager::SLIDER, |
| 242 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 232 | + 'size_units' => [ 'px', '%', 'em' ], | |
| 243 | 233 | 'range' => [ |
| 244 | 234 | 'px' => [ |
| 245 | 235 | 'max' => 100, |
| 246 | 236 | ], |
| @@ -248,9 +238,9 @@ | ||
| 248 | 238 | 'max' => 10, |
| 249 | 239 | ], |
| 250 | 240 | ], |
| 251 | 241 | 'selectors' => [ |
| 252 | - '{{WRAPPER}} .elementor-alert' => 'border-inline-start-width: {{SIZE}}{{UNIT}};', | |
| 242 | + '{{WRAPPER}} .elementor-alert' => 'border-left-width: {{SIZE}}{{UNIT}};', | |
| 253 | 243 | ], |
| 254 | 244 | ] |
| 255 | 245 | ); |
| 256 | 246 | |
| @@ -351,19 +341,13 @@ | ||
| 351 | 341 | 'dismiss_icon_size', |
| 352 | 342 | [ |
| 353 | 343 | 'label' => esc_html__( 'Size', 'elementor' ), |
| 354 | 344 | 'type' => Controls_Manager::SLIDER, |
| 355 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 356 | 345 | 'range' => [ |
| 357 | 346 | 'px' => [ |
| 347 | + 'min' => 0, | |
| 358 | 348 | 'max' => 100, |
| 359 | 349 | ], |
| 360 | - 'em' => [ | |
| 361 | - 'max' => 10, | |
| 362 | - ], | |
| 363 | - 'rem' => [ | |
| 364 | - 'max' => 10, | |
| 365 | - ], | |
| 366 | 350 | ], |
| 367 | 351 | 'selectors' => [ |
| 368 | 352 | '{{WRAPPER}}' => '--dismiss-icon-size: {{SIZE}}{{UNIT}};', |
| 369 | 353 | ], |
| @@ -380,9 +364,9 @@ | ||
| 380 | 364 | 'min' => -100, |
| 381 | 365 | 'max' => 100, |
| 382 | 366 | ], |
| 383 | 367 | ], |
| 384 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ], | |
| 368 | + 'size_units' => [ '%', 'px' ], | |
| 385 | 369 | 'selectors' => [ |
| 386 | 370 | '{{WRAPPER}}' => '--dismiss-icon-vertical-position: {{SIZE}}{{UNIT}};', |
| 387 | 371 | ], |
| 388 | 372 | ] |
| @@ -398,9 +382,9 @@ | ||
| 398 | 382 | 'min' => -100, |
| 399 | 383 | 'max' => 100, |
| 400 | 384 | ], |
| 401 | 385 | ], |
| 402 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], | |
| 386 | + 'size_units' => [ '%', 'px' ], | |
| 403 | 387 | 'selectors' => [ |
| 404 | 388 | '{{WRAPPER}}' => '--dismiss-icon-horizontal-position: {{SIZE}}{{UNIT}};', |
| 405 | 389 | ], |
| 406 | 390 | ] |
| @@ -442,13 +426,12 @@ | ||
| 442 | 426 | |
| 443 | 427 | $this->add_control( |
| 444 | 428 | 'dismiss_icon_hover_transition_duration', |
| 445 | 429 | [ |
| 446 | - 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (s)', | |
| 430 | + 'label' => esc_html__( 'Transition Duration', 'elementor' ), | |
| 447 | 431 | 'type' => Controls_Manager::SLIDER, |
| 448 | 432 | 'range' => [ |
| 449 | 433 | 'px' => [ |
| 450 | - 'min' => 0, | |
| 451 | 434 | 'max' => 3, |
| 452 | 435 | 'step' => 0.1, |
| 453 | 436 | ], |
| 454 | 437 | ], |
| @@ -475,45 +458,45 @@ | ||
| 475 | 458 | */ |
| 476 | 459 | protected function render() { |
| 477 | 460 | $settings = $this->get_settings_for_display(); |
| 478 | 461 | |
| 479 | - if ( Utils::is_empty( $settings['alert_title'] ) && Utils::is_empty( $settings['alert_description'] ) ) { | |
| 462 | + if ( Utils::is_empty( $settings['alert_title'] ) ) { | |
| 480 | 463 | return; |
| 481 | 464 | } |
| 482 | 465 | |
| 483 | - $this->add_render_attribute( 'alert_wrapper', 'class', 'elementor-alert' ); | |
| 466 | + if ( ! empty( $settings['alert_type'] ) ) { | |
| 467 | + $this->add_render_attribute( 'wrapper', 'class', 'elementor-alert elementor-alert-' . $settings['alert_type'] ); | |
| 468 | + } | |
| 484 | 469 | |
| 485 | - $this->add_render_attribute( 'alert_wrapper', 'role', 'alert' ); | |
| 470 | + $this->add_render_attribute( 'wrapper', 'role', 'alert' ); | |
| 486 | 471 | |
| 487 | 472 | $this->add_render_attribute( 'alert_title', 'class', 'elementor-alert-title' ); |
| 488 | 473 | |
| 489 | - $this->add_render_attribute( 'alert_description', 'class', 'elementor-alert-description' ); | |
| 490 | - | |
| 491 | 474 | $this->add_inline_editing_attributes( 'alert_title', 'none' ); |
| 492 | - | |
| 493 | - $this->add_inline_editing_attributes( 'alert_description' ); | |
| 494 | 475 | ?> |
| 495 | - <div <?php $this->print_render_attribute_string( 'alert_wrapper' ); ?>> | |
| 476 | + <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>> | |
| 477 | + <span <?php $this->print_render_attribute_string( 'alert_title' ); ?>><?php $this->print_unescaped_setting( 'alert_title' ); ?></span> | |
| 478 | + <?php | |
| 479 | + if ( ! Utils::is_empty( $settings['alert_description'] ) ) : | |
| 480 | + $this->add_render_attribute( 'alert_description', 'class', 'elementor-alert-description' ); | |
| 496 | 481 | |
| 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> | |
| 482 | + $this->add_inline_editing_attributes( 'alert_description' ); | |
| 483 | + ?> | |
| 484 | + <span <?php $this->print_render_attribute_string( 'alert_description' ); ?>><?php $this->print_unescaped_setting( 'alert_description' ); ?></span> | |
| 499 | 485 | <?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 | 486 | <?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> | |
| 487 | + <button type="button" class="elementor-alert-dismiss"> | |
| 488 | + <?php | |
| 489 | + if ( ! empty( $settings['dismiss_icon']['value'] ) ) { | |
| 490 | + Icons_Manager::render_icon( $settings['dismiss_icon'], [ | |
| 491 | + 'aria-hidden' => 'true', | |
| 492 | + ] ); | |
| 493 | + } else { ?> | |
| 494 | + <span aria-hidden="true">×</span> | |
| 495 | + <?php } ?> | |
| 496 | + <span class="elementor-screen-only"><?php echo esc_html__( 'Dismiss alert', 'elementor' ); ?></span> | |
| 497 | + </button> | |
| 514 | 498 | <?php endif; ?> |
| 515 | - | |
| 516 | 499 | </div> |
| 517 | 500 | <?php |
| 518 | 501 | } |
| 519 | 502 | |
| @@ -524,71 +507,36 @@ | ||
| 524 | 507 | * |
| 525 | 508 | * @since 2.9.0 |
| 526 | 509 | * @access protected |
| 527 | 510 | */ |
| 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 | 511 | protected function content_template() { |
| 550 | 512 | ?> |
| 551 | - <# | |
| 552 | - if ( ! settings.alert_title && ! settings.alert_description ) { | |
| 553 | - return; | |
| 554 | - } | |
| 513 | + <# if ( settings.alert_title ) { | |
| 514 | + view.addRenderAttribute( { | |
| 515 | + alert_title: { class: 'elementor-alert-title' }, | |
| 516 | + alert_description: { class: 'elementor-alert-description' } | |
| 517 | + } ); | |
| 555 | 518 | |
| 556 | - view.addRenderAttribute( 'alert_wrapper', 'class', 'elementor-alert' ); | |
| 519 | + view.addInlineEditingAttributes( 'alert_title', 'none' ); | |
| 520 | + view.addInlineEditingAttributes( 'alert_description' ); | |
| 557 | 521 | |
| 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> | |
| 522 | + var iconHTML = elementor.helpers.renderIcon( view, settings.dismiss_icon, { 'aria-hidden': true }, 'i' , 'object' ), | |
| 523 | + migrated = elementor.helpers.isIconMigrated( settings, 'dismiss_icon' ); | |
| 524 | + #> | |
| 525 | + <div class="elementor-alert elementor-alert-{{ settings.alert_type }}" role="alert"> | |
| 526 | + <span {{{ view.getRenderAttributeString( 'alert_title' ) }}}>{{{ settings.alert_title }}}</span> | |
| 527 | + <span {{{ view.getRenderAttributeString( 'alert_description' ) }}}>{{{ settings.alert_description }}}</span> | |
| 528 | + <# if ( 'show' === settings.show_dismiss ) { #> | |
| 529 | + <button type="button" class="elementor-alert-dismiss"> | |
| 530 | + <# if ( iconHTML && iconHTML.rendered && ( ! settings.icon || migrated ) ) { #> | |
| 531 | + {{{ iconHTML.value }}} | |
| 532 | + <# } else { #> | |
| 533 | + <span aria-hidden="true">×</span> | |
| 534 | + <# } #> | |
| 535 | + <span class="elementor-screen-only"><?php echo esc_html__( 'Dismiss alert', 'elementor' ); ?></span> | |
| 536 | + </button> | |
| 587 | 537 | <# } #> |
| 588 | - </button> | |
| 589 | - <# } #> | |
| 590 | - | |
| 591 | - </div> | |
| 538 | + </div> | |
| 539 | + <# } #> | |
| 592 | 540 | <?php |
| 593 | 541 | } |
| 594 | 542 | } |