| @@ -91,26 +91,8 @@ | ||
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * Get style dependencies. | |
| 96 | - * | |
| 97 | - * Retrieve the list of style dependencies the widget requires. | |
| 98 | - * | |
| 99 | - * @since 3.24.0 | |
| 100 | - * @access public | |
| 101 | - * | |
| 102 | - * @return array Widget style dependencies. | |
| 103 | - */ | |
| 104 | - public function get_style_depends(): array { | |
| 105 | - return [ 'widget-counter' ]; | |
| 106 | - } | |
| 107 | - | |
| 108 | - public function has_widget_inner_wrapper(): bool { | |
| 109 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 110 | - } | |
| 111 | - | |
| 112 | - /** | |
| 113 | 95 | * Register counter widget controls. |
| 114 | 96 | * |
| 115 | 97 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 116 | 98 | * |
| @@ -117,8 +99,11 @@ | ||
| 117 | 99 | * @since 3.1.0 |
| 118 | 100 | * @access protected |
| 119 | 101 | */ |
| 120 | 102 | protected function register_controls() { |
| 103 | + $start = is_rtl() ? 'right' : 'left'; | |
| 104 | + $end = ! is_rtl() ? 'right' : 'left'; | |
| 105 | + | |
| 121 | 106 | $this->start_controls_section( |
| 122 | 107 | 'section_counter', |
| 123 | 108 | [ |
| 124 | 109 | 'label' => esc_html__( 'Counter', 'elementor' ), |
| @@ -279,15 +264,16 @@ | ||
| 279 | 264 | 'after' => [ |
| 280 | 265 | 'title' => esc_html__( 'After', 'elementor' ), |
| 281 | 266 | 'icon' => 'eicon-v-align-bottom', |
| 282 | 267 | ], |
| 268 | + | |
| 283 | 269 | 'start' => [ |
| 284 | 270 | 'title' => esc_html__( 'Start', 'elementor' ), |
| 285 | - 'icon' => 'eicon-h-align-left', | |
| 271 | + 'icon' => "eicon-h-align-$start", | |
| 286 | 272 | ], |
| 287 | 273 | 'end' => [ |
| 288 | 274 | 'title' => esc_html__( 'End', 'elementor' ), |
| 289 | - 'icon' => 'eicon-h-align-right', | |
| 275 | + 'icon' => "eicon-h-align-$end", | |
| 290 | 276 | ], |
| 291 | 277 | ], |
| 292 | 278 | 'selectors_dictionary' => [ |
| 293 | 279 | 'before' => 'flex-direction: column;', |
| @@ -297,9 +283,8 @@ | ||
| 297 | 283 | ], |
| 298 | 284 | 'selectors' => [ |
| 299 | 285 | '{{WRAPPER}} .elementor-counter' => '{{VALUE}}', |
| 300 | 286 | ], |
| 301 | - 'classes' => 'elementor-control-start-end', | |
| 302 | 287 | 'condition' => [ |
| 303 | 288 | 'title!' => '', |
| 304 | 289 | ], |
| 305 | 290 | ] |
| @@ -312,9 +297,9 @@ | ||
| 312 | 297 | 'type' => Controls_Manager::CHOOSE, |
| 313 | 298 | 'options' => [ |
| 314 | 299 | 'start' => [ |
| 315 | 300 | 'title' => esc_html__( 'Start', 'elementor' ), |
| 316 | - 'icon' => 'eicon-h-align-left', | |
| 301 | + 'icon' => "eicon-h-align-$start", | |
| 317 | 302 | ], |
| 318 | 303 | 'center' => [ |
| 319 | 304 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 320 | 305 | 'icon' => 'eicon-h-align-center', |
| @@ -320,13 +305,12 @@ | ||
| 320 | 305 | 'icon' => 'eicon-h-align-center', |
| 321 | 306 | ], |
| 322 | 307 | 'end' => [ |
| 323 | 308 | 'title' => esc_html__( 'End', 'elementor' ), |
| 324 | - 'icon' => 'eicon-h-align-right', | |
| 309 | + 'icon' => "eicon-h-align-$end", | |
| 325 | 310 | ], |
| 326 | 311 | ], |
| 327 | 312 | 'separator' => 'before', |
| 328 | - 'classes' => 'elementor-control-start-end', | |
| 329 | 313 | 'selectors' => [ |
| 330 | 314 | '{{WRAPPER}} .elementor-counter-title' => 'justify-content: {{VALUE}};', |
| 331 | 315 | ], |
| 332 | 316 | 'condition' => [ |
| @@ -387,9 +371,9 @@ | ||
| 387 | 371 | 'type' => Controls_Manager::CHOOSE, |
| 388 | 372 | 'options' => [ |
| 389 | 373 | 'start' => [ |
| 390 | 374 | 'title' => esc_html__( 'Start', 'elementor' ), |
| 391 | - 'icon' => 'eicon-h-align-left', | |
| 375 | + 'icon' => "eicon-h-align-$start", | |
| 392 | 376 | ], |
| 393 | 377 | 'center' => [ |
| 394 | 378 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 395 | 379 | 'icon' => 'eicon-h-align-center', |
| @@ -395,9 +379,9 @@ | ||
| 395 | 379 | 'icon' => 'eicon-h-align-center', |
| 396 | 380 | ], |
| 397 | 381 | 'end' => [ |
| 398 | 382 | 'title' => esc_html__( 'End', 'elementor' ), |
| 399 | - 'icon' => 'eicon-h-align-right', | |
| 383 | + 'icon' => "eicon-h-align-$end", | |
| 400 | 384 | ], |
| 401 | 385 | 'stretch' => [ |
| 402 | 386 | 'title' => esc_html__( 'Stretch', 'elementor' ), |
| 403 | 387 | 'icon' => 'eicon-grow', |
| @@ -402,9 +386,8 @@ | ||
| 402 | 386 | 'title' => esc_html__( 'Stretch', 'elementor' ), |
| 403 | 387 | 'icon' => 'eicon-grow', |
| 404 | 388 | ], |
| 405 | 389 | ], |
| 406 | - 'classes' => 'elementor-control-start-end', | |
| 407 | 390 | 'selectors_dictionary' => [ |
| 408 | 391 | 'start' => 'text-align: {{VALUE}}; --counter-prefix-grow: 0; --counter-suffix-grow: 1; --counter-number-grow: 0;', |
| 409 | 392 | 'center' => 'text-align: {{VALUE}}; --counter-prefix-grow: 1; --counter-suffix-grow: 1; --counter-number-grow: 0;', |
| 410 | 393 | 'end' => 'text-align: {{VALUE}}; --counter-prefix-grow: 1; --counter-suffix-grow: 0; --counter-number-grow: 0;', |
| @@ -424,9 +407,9 @@ | ||
| 424 | 407 | 'type' => Controls_Manager::CHOOSE, |
| 425 | 408 | 'options' => [ |
| 426 | 409 | 'start' => [ |
| 427 | 410 | 'title' => esc_html__( 'Start', 'elementor' ), |
| 428 | - 'icon' => 'eicon-text-align-left', | |
| 411 | + 'icon' => "eicon-text-align-$start", | |
| 429 | 412 | ], |
| 430 | 413 | 'center' => [ |
| 431 | 414 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 432 | 415 | 'icon' => 'eicon-text-align-center', |
| @@ -432,12 +415,11 @@ | ||
| 432 | 415 | 'icon' => 'eicon-text-align-center', |
| 433 | 416 | ], |
| 434 | 417 | 'end' => [ |
| 435 | 418 | 'title' => esc_html__( 'End', 'elementor' ), |
| 436 | - 'icon' => 'eicon-text-align-right', | |
| 419 | + 'icon' => "eicon-text-align-$end", | |
| 437 | 420 | ], |
| 438 | 421 | ], |
| 439 | - 'classes' => 'elementor-control-start-end', | |
| 440 | 422 | 'selectors' => [ |
| 441 | 423 | '{{WRAPPER}} .elementor-counter-number' => 'text-align: {{VALUE}};', |
| 442 | 424 | ], |
| 443 | 425 | 'condition' => [ |
| @@ -644,14 +626,14 @@ | ||
| 644 | 626 | const titleTag = elementor.helpers.validateHTMLTag( settings.title_tag ); |
| 645 | 627 | #> |
| 646 | 628 | <div {{{ view.getRenderAttributeString( 'elementor-counter' ) }}}> |
| 647 | 629 | <# if ( settings.title ) { |
| 648 | - #><{{ titleTag }} {{{ view.getRenderAttributeString( 'counter-title' ) }}}>{{{ elementor.helpers.sanitize( settings.title, { ALLOW_DATA_ATTR: false } ) }}}</{{ titleTag }}><# | |
| 630 | + #><{{ titleTag }} {{{ view.getRenderAttributeString( 'counter-title' ) }}}>{{{ settings.title }}}</{{ titleTag }}><# | |
| 649 | 631 | } #> |
| 650 | 632 | <div {{{ view.getRenderAttributeString( 'counter-number' ) }}}> |
| 651 | - <span {{{ view.getRenderAttributeString( 'prefix' ) }}}>{{ settings.prefix }}</span> | |
| 652 | - <span {{{ view.getRenderAttributeString( 'counter' ) }}}>{{ settings.starting_number }}</span> | |
| 653 | - <span {{{ view.getRenderAttributeString( 'suffix' ) }}}>{{ settings.suffix }}</span> | |
| 633 | + <span {{{ view.getRenderAttributeString( 'prefix' ) }}}>{{{ settings.prefix }}}</span> | |
| 634 | + <span {{{ view.getRenderAttributeString( 'counter' ) }}}>{{{ settings.starting_number }}}</span> | |
| 635 | + <span {{{ view.getRenderAttributeString( 'suffix' ) }}}>{{{ settings.suffix }}}</span> | |
| 654 | 636 | </div> |
| 655 | 637 | </div> |
| 656 | 638 | <?php |
| 657 | 639 | } |
| @@ -698,30 +680,16 @@ | ||
| 698 | 680 | ?> |
| 699 | 681 | <div <?php $this->print_render_attribute_string( 'elementor-counter' ); ?>> |
| 700 | 682 | <?php |
| 701 | 683 | if ( $settings['title'] ) : |
| 702 | - ?><<?php Utils::print_validated_html_tag( $title_tag ); ?> <?php $this->print_render_attribute_string( 'counter-title' ); ?>><?php echo wp_kses_post( $this->get_settings_for_display( 'title' ) ); ?></<?php Utils::print_validated_html_tag( $title_tag ); ?>><?php | |
| 684 | + ?><<?php Utils::print_validated_html_tag( $title_tag ); ?> <?php $this->print_render_attribute_string( 'counter-title' ); ?>><?php $this->print_unescaped_setting( 'title' ); ?></<?php Utils::print_validated_html_tag( $title_tag ); ?>><?php | |
| 703 | 685 | endif; |
| 704 | 686 | ?> |
| 705 | 687 | <div <?php $this->print_render_attribute_string( 'counter-number' ); ?>> |
| 706 | - <span <?php $this->print_render_attribute_string( 'prefix' ); ?>><?php echo wp_kses_post( $settings['prefix'] ); ?></span> | |
| 707 | - <span <?php $this->print_render_attribute_string( 'counter' ); ?>><?php echo wp_kses_post( $settings['starting_number'] ); ?></span> | |
| 708 | - <span <?php $this->print_render_attribute_string( 'suffix' ); ?>><?php echo wp_kses_post( $settings['suffix'] ); ?></span> | |
| 688 | + <span <?php $this->print_render_attribute_string( 'prefix' ); ?>><?php $this->print_unescaped_setting( 'prefix' ); ?></span> | |
| 689 | + <span <?php $this->print_render_attribute_string( 'counter' ); ?>><?php $this->print_unescaped_setting( 'starting_number' ); ?></span> | |
| 690 | + <span <?php $this->print_render_attribute_string( 'suffix' ); ?>><?php $this->print_unescaped_setting( 'suffix' ); ?></span> | |
| 709 | 691 | </div> |
| 710 | 692 | </div> |
| 711 | 693 | <?php |
| 712 | - } | |
| 713 | - | |
| 714 | - public function render_markdown(): string { | |
| 715 | - $settings = $this->get_settings_for_display(); | |
| 716 | - $number = $settings['ending_number'] ?? ''; | |
| 717 | - $prefix = $settings['prefix'] ?? ''; | |
| 718 | - $suffix = $settings['suffix'] ?? ''; | |
| 719 | - $title = Utils::html_to_plain_text( $settings['title'] ?? '' ); | |
| 720 | - $value = $prefix . $number . $suffix; | |
| 721 | - if ( empty( $value ) && empty( $title ) ) { | |
| 722 | - return ''; | |
| 723 | - } | |
| 724 | - $parts = array_filter( [ $value, $title ] ); | |
| 725 | - return implode( ' - ', $parts ); | |
| 726 | 694 | } |
| 727 | 695 | } |