| @@ -72,31 +72,9 @@ | ||
| 72 | 72 | public function get_keywords() { |
| 73 | 73 | return [ 'progress', 'bar' ]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - protected function is_dynamic_content(): bool { | |
| 77 | - return false; | |
| 78 | - } | |
| 79 | - | |
| 80 | 76 | /** |
| 81 | - * Get style dependencies. | |
| 82 | - * | |
| 83 | - * Retrieve the list of style dependencies the widget requires. | |
| 84 | - * | |
| 85 | - * @since 3.24.0 | |
| 86 | - * @access public | |
| 87 | - * | |
| 88 | - * @return array Widget style dependencies. | |
| 89 | - */ | |
| 90 | - public function get_style_depends(): array { | |
| 91 | - return [ 'widget-progress' ]; | |
| 92 | - } | |
| 93 | - | |
| 94 | - public function has_widget_inner_wrapper(): bool { | |
| 95 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 96 | - } | |
| 97 | - | |
| 98 | - /** | |
| 99 | 77 | * Register progress widget controls. |
| 100 | 78 | * |
| 101 | 79 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 102 | 80 | * |
| @@ -148,22 +126,8 @@ | ||
| 148 | 126 | ] |
| 149 | 127 | ); |
| 150 | 128 | |
| 151 | 129 | $this->add_control( |
| 152 | - 'title_display', | |
| 153 | - [ | |
| 154 | - 'label' => esc_html__( 'Display Title', 'elementor' ), | |
| 155 | - 'type' => Controls_Manager::SWITCHER, | |
| 156 | - 'label_on' => esc_html__( 'Show', 'elementor' ), | |
| 157 | - 'label_off' => esc_html__( 'Hide', 'elementor' ), | |
| 158 | - 'default' => 'yes', | |
| 159 | - 'condition' => [ | |
| 160 | - 'title!' => '', | |
| 161 | - ], | |
| 162 | - ] | |
| 163 | - ); | |
| 164 | - | |
| 165 | - $this->add_control( | |
| 166 | 130 | 'progress_type', |
| 167 | 131 | [ |
| 168 | 132 | 'label' => esc_html__( 'Type', 'elementor' ), |
| 169 | 133 | 'type' => Controls_Manager::SELECT, |
| @@ -193,9 +157,8 @@ | ||
| 193 | 157 | ], |
| 194 | 158 | 'dynamic' => [ |
| 195 | 159 | 'active' => true, |
| 196 | 160 | ], |
| 197 | - 'separator' => 'before', | |
| 198 | 161 | ] |
| 199 | 162 | ); |
| 200 | 163 | |
| 201 | 164 | $this->add_control( |
| @@ -206,11 +169,8 @@ | ||
| 206 | 169 | 'label_on' => esc_html__( 'Show', 'elementor' ), |
| 207 | 170 | 'label_off' => esc_html__( 'Hide', 'elementor' ), |
| 208 | 171 | 'return_value' => 'show', |
| 209 | 172 | 'default' => 'show', |
| 210 | - 'condition' => [ | |
| 211 | - 'percent!' => '', | |
| 212 | - ], | |
| 213 | 173 | ] |
| 214 | 174 | ); |
| 215 | 175 | |
| 216 | 176 | $this->add_control( |
| @@ -223,9 +183,8 @@ | ||
| 223 | 183 | ], |
| 224 | 184 | 'placeholder' => esc_html__( 'e.g. Web Designer', 'elementor' ), |
| 225 | 185 | 'default' => esc_html__( 'Web Designer', 'elementor' ), |
| 226 | 186 | 'label_block' => true, |
| 227 | - 'separator' => 'before', | |
| 228 | 187 | ] |
| 229 | 188 | ); |
| 230 | 189 | |
| 231 | 190 | $this->end_controls_section(); |
| @@ -238,70 +197,8 @@ | ||
| 238 | 197 | ] |
| 239 | 198 | ); |
| 240 | 199 | |
| 241 | 200 | $this->add_control( |
| 242 | - 'title_heading', | |
| 243 | - [ | |
| 244 | - 'label' => esc_html__( 'Title', 'elementor' ), | |
| 245 | - 'type' => Controls_Manager::HEADING, | |
| 246 | - 'condition' => [ | |
| 247 | - 'title!' => '', | |
| 248 | - ], | |
| 249 | - ] | |
| 250 | - ); | |
| 251 | - | |
| 252 | - $this->add_control( | |
| 253 | - 'title_color', | |
| 254 | - [ | |
| 255 | - 'label' => esc_html__( 'Text Color', 'elementor' ), | |
| 256 | - 'type' => Controls_Manager::COLOR, | |
| 257 | - 'selectors' => [ | |
| 258 | - '{{WRAPPER}} .elementor-title' => 'color: {{VALUE}};', | |
| 259 | - ], | |
| 260 | - 'global' => [ | |
| 261 | - 'default' => Global_Colors::COLOR_PRIMARY, | |
| 262 | - ], | |
| 263 | - 'condition' => [ | |
| 264 | - 'title!' => '', | |
| 265 | - ], | |
| 266 | - ] | |
| 267 | - ); | |
| 268 | - | |
| 269 | - $this->add_group_control( | |
| 270 | - Group_Control_Typography::get_type(), | |
| 271 | - [ | |
| 272 | - 'name' => 'typography', | |
| 273 | - 'selector' => '{{WRAPPER}} .elementor-title', | |
| 274 | - 'global' => [ | |
| 275 | - 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 276 | - ], | |
| 277 | - 'condition' => [ | |
| 278 | - 'title!' => '', | |
| 279 | - ], | |
| 280 | - ] | |
| 281 | - ); | |
| 282 | - | |
| 283 | - $this->add_group_control( | |
| 284 | - Group_Control_Text_Shadow::get_type(), | |
| 285 | - [ | |
| 286 | - 'name' => 'title_shadow', | |
| 287 | - 'selector' => '{{WRAPPER}} .elementor-title', | |
| 288 | - 'condition' => [ | |
| 289 | - 'title!' => '', | |
| 290 | - ], | |
| 291 | - ] | |
| 292 | - ); | |
| 293 | - | |
| 294 | - $this->add_control( | |
| 295 | - 'percentage_heading', | |
| 296 | - [ | |
| 297 | - 'label' => esc_html__( 'Percentage', 'elementor' ), | |
| 298 | - 'type' => Controls_Manager::HEADING, | |
| 299 | - 'separator' => 'before', | |
| 300 | - ] | |
| 301 | - ); | |
| 302 | - | |
| 303 | - $this->add_control( | |
| 304 | 201 | 'bar_color', |
| 305 | 202 | [ |
| 306 | 203 | 'label' => esc_html__( 'Color', 'elementor' ), |
| 307 | 204 | 'type' => Controls_Manager::COLOR, |
| @@ -354,11 +251,8 @@ | ||
| 354 | 251 | [ |
| 355 | 252 | 'label' => esc_html__( 'Inner Text', 'elementor' ), |
| 356 | 253 | 'type' => Controls_Manager::HEADING, |
| 357 | 254 | 'separator' => 'before', |
| 358 | - 'condition' => [ | |
| 359 | - 'inner_text!' => '', | |
| 360 | - ], | |
| 361 | 255 | ] |
| 362 | 256 | ); |
| 363 | 257 | |
| 364 | 258 | $this->add_control( |
| @@ -368,11 +262,8 @@ | ||
| 368 | 262 | 'type' => Controls_Manager::COLOR, |
| 369 | 263 | 'selectors' => [ |
| 370 | 264 | '{{WRAPPER}} .elementor-progress-bar' => 'color: {{VALUE}};', |
| 371 | 265 | ], |
| 372 | - 'condition' => [ | |
| 373 | - 'inner_text!' => '', | |
| 374 | - ], | |
| 375 | 266 | ] |
| 376 | 267 | ); |
| 377 | 268 | |
| 378 | 269 | $this->add_group_control( |
| @@ -382,11 +273,8 @@ | ||
| 382 | 273 | 'selector' => '{{WRAPPER}} .elementor-progress-bar', |
| 383 | 274 | 'exclude' => [ |
| 384 | 275 | 'line_height', |
| 385 | 276 | ], |
| 386 | - 'condition' => [ | |
| 387 | - 'inner_text!' => '', | |
| 388 | - ], | |
| 389 | 277 | ] |
| 390 | 278 | ); |
| 391 | 279 | |
| 392 | 280 | $this->add_group_control( |
| @@ -393,14 +281,54 @@ | ||
| 393 | 281 | Group_Control_Text_Shadow::get_type(), |
| 394 | 282 | [ |
| 395 | 283 | 'name' => 'bar_inner_shadow', |
| 396 | 284 | 'selector' => '{{WRAPPER}} .elementor-progress-bar', |
| 397 | - 'condition' => [ | |
| 398 | - 'inner_text!' => '', | |
| 285 | + ] | |
| 286 | + ); | |
| 287 | + | |
| 288 | + $this->end_controls_section(); | |
| 289 | + | |
| 290 | + $this->start_controls_section( | |
| 291 | + 'section_title', | |
| 292 | + [ | |
| 293 | + 'label' => esc_html__( 'Title Style', 'elementor' ), | |
| 294 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 295 | + ] | |
| 296 | + ); | |
| 297 | + | |
| 298 | + $this->add_control( | |
| 299 | + 'title_color', | |
| 300 | + [ | |
| 301 | + 'label' => esc_html__( 'Text Color', 'elementor' ), | |
| 302 | + 'type' => Controls_Manager::COLOR, | |
| 303 | + 'selectors' => [ | |
| 304 | + '{{WRAPPER}} .elementor-title' => 'color: {{VALUE}};', | |
| 399 | 305 | ], |
| 306 | + 'global' => [ | |
| 307 | + 'default' => Global_Colors::COLOR_PRIMARY, | |
| 308 | + ], | |
| 400 | 309 | ] |
| 401 | 310 | ); |
| 402 | 311 | |
| 312 | + $this->add_group_control( | |
| 313 | + Group_Control_Typography::get_type(), | |
| 314 | + [ | |
| 315 | + 'name' => 'typography', | |
| 316 | + 'selector' => '{{WRAPPER}} .elementor-title', | |
| 317 | + 'global' => [ | |
| 318 | + 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 319 | + ], | |
| 320 | + ] | |
| 321 | + ); | |
| 322 | + | |
| 323 | + $this->add_group_control( | |
| 324 | + Group_Control_Text_Shadow::get_type(), | |
| 325 | + [ | |
| 326 | + 'name' => 'title_shadow', | |
| 327 | + 'selector' => '{{WRAPPER}} .elementor-title', | |
| 328 | + ] | |
| 329 | + ); | |
| 330 | + | |
| 403 | 331 | $this->end_controls_section(); |
| 404 | 332 | } |
| 405 | 333 | |
| 406 | 334 | /** |
| @@ -413,13 +341,8 @@ | ||
| 413 | 341 | * @access protected |
| 414 | 342 | */ |
| 415 | 343 | protected function render() { |
| 416 | 344 | $settings = $this->get_settings_for_display(); |
| 417 | - | |
| 418 | - if ( empty( $settings['title'] ) && empty( $settings['percent']['size'] ) ) { | |
| 419 | - return; | |
| 420 | - } | |
| 421 | - | |
| 422 | 345 | $progressbar_id = 'elementor-progress-bar-' . $this->get_id(); |
| 423 | 346 | |
| 424 | 347 | $progress_percentage = is_numeric( $settings['percent']['size'] ) ? $settings['percent']['size'] : '0'; |
| 425 | 348 | if ( 100 < $progress_percentage ) { |
| @@ -426,28 +349,19 @@ | ||
| 426 | 349 | $progress_percentage = 100; |
| 427 | 350 | } |
| 428 | 351 | |
| 429 | 352 | if ( ! Utils::is_empty( $settings['title'] ) ) { |
| 353 | + $this->add_render_attribute( | |
| 354 | + 'title', | |
| 355 | + [ | |
| 356 | + 'class' => 'elementor-title', | |
| 357 | + 'id' => $progressbar_id, | |
| 358 | + ] | |
| 359 | + ); | |
| 430 | 360 | |
| 431 | - if ( 'yes' === $settings['title_display'] ) { | |
| 361 | + $this->add_inline_editing_attributes( 'title' ); | |
| 432 | 362 | |
| 433 | - $this->add_render_attribute( | |
| 434 | - 'title', | |
| 435 | - [ | |
| 436 | - 'class' => 'elementor-title', | |
| 437 | - 'id' => $progressbar_id, | |
| 438 | - ] | |
| 439 | - ); | |
| 440 | - | |
| 441 | - $this->add_inline_editing_attributes( 'title' ); | |
| 442 | - | |
| 443 | - $this->add_render_attribute( 'wrapper', 'aria-labelledby', $progressbar_id ); | |
| 444 | - | |
| 445 | - } else { | |
| 446 | - | |
| 447 | - $this->add_render_attribute( 'wrapper', 'aria-label', $settings['title'] ); | |
| 448 | - | |
| 449 | - } | |
| 363 | + $this->add_render_attribute( 'wrapper', 'aria-labelledby', $progressbar_id ); | |
| 450 | 364 | } |
| 451 | 365 | |
| 452 | 366 | $this->add_render_attribute( |
| 453 | 367 | 'wrapper', |
| @@ -479,17 +393,17 @@ | ||
| 479 | 393 | $this->add_render_attribute( 'inner_text', 'class', 'elementor-progress-text' ); |
| 480 | 394 | |
| 481 | 395 | $this->add_inline_editing_attributes( 'inner_text' ); |
| 482 | 396 | |
| 483 | - if ( ! Utils::is_empty( $settings['title'] ) && 'yes' === $settings['title_display'] ) { ?> | |
| 397 | + if ( ! Utils::is_empty( $settings['title'] ) ) { ?> | |
| 484 | 398 | <<?php Utils::print_validated_html_tag( $settings['title_tag'] ); ?> <?php $this->print_render_attribute_string( 'title' ); ?>> |
| 485 | - <?php echo wp_kses_post( $settings['title'] ); ?> | |
| 399 | + <?php $this->print_unescaped_setting( 'title' ); ?> | |
| 486 | 400 | </<?php Utils::print_validated_html_tag( $settings['title_tag'] ); ?>> |
| 487 | 401 | <?php } ?> |
| 488 | 402 | |
| 489 | 403 | <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>> |
| 490 | 404 | <div <?php $this->print_render_attribute_string( 'progress-bar' ); ?>> |
| 491 | - <span <?php $this->print_render_attribute_string( 'inner_text' ); ?>><?php echo wp_kses_post( $settings['inner_text'] ); ?></span> | |
| 405 | + <span <?php $this->print_render_attribute_string( 'inner_text' ); ?>><?php $this->print_unescaped_setting( 'inner_text' ); ?></span> | |
| 492 | 406 | <?php if ( 'show' === $settings['display_percentage'] ) { ?> |
| 493 | 407 | <span class="elementor-progress-percentage"><?php echo $progress_percentage; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>%</span> |
| 494 | 408 | <?php } ?> |
| 495 | 409 | </div> |
| @@ -507,12 +421,8 @@ | ||
| 507 | 421 | */ |
| 508 | 422 | protected function content_template() { |
| 509 | 423 | ?> |
| 510 | 424 | <# |
| 511 | - if ( '' === settings.title && '' === settings.percent.size ) { | |
| 512 | - return; | |
| 513 | - } | |
| 514 | - | |
| 515 | 425 | const title_tag = elementor.helpers.validateHTMLTag( settings.title_tag ); |
| 516 | 426 | const progressbar_id = 'elementor-progress-bar-<?php echo esc_attr( $this->get_id() ); ?>'; |
| 517 | 427 | |
| 518 | 428 | let progress_percentage = 0; |
| @@ -520,28 +430,19 @@ | ||
| 520 | 430 | progress_percentage = 100 < settings.percent.size ? 100 : settings.percent.size; |
| 521 | 431 | } |
| 522 | 432 | |
| 523 | 433 | if ( settings.title ) { |
| 434 | + view.addRenderAttribute( | |
| 435 | + 'title', | |
| 436 | + { | |
| 437 | + 'class': 'elementor-title', | |
| 438 | + 'id': progressbar_id, | |
| 439 | + } | |
| 440 | + ); | |
| 524 | 441 | |
| 525 | - if ( 'yes' === settings.title_display ) { | |
| 442 | + view.addInlineEditingAttributes( 'title' ); | |
| 526 | 443 | |
| 527 | - view.addRenderAttribute( | |
| 528 | - 'title', | |
| 529 | - { | |
| 530 | - 'class': 'elementor-title', | |
| 531 | - 'id': progressbar_id, | |
| 532 | - } | |
| 533 | - ); | |
| 534 | - | |
| 535 | - view.addInlineEditingAttributes( 'title' ); | |
| 536 | - | |
| 537 | - view.addRenderAttribute( 'progressWrapper', 'aria-labelledby', progressbar_id ); | |
| 538 | - | |
| 539 | - } else { | |
| 540 | - | |
| 541 | - view.addRenderAttribute( 'progressWrapper', 'aria-label', settings.title ); | |
| 542 | - | |
| 543 | - } | |
| 444 | + view.addRenderAttribute( 'wrapper', 'aria-labelledby', progressbar_id ); | |
| 544 | 445 | } |
| 545 | 446 | |
| 546 | 447 | view.addRenderAttribute( |
| 547 | 448 | 'progressWrapper', |
| @@ -561,14 +462,14 @@ | ||
| 561 | 462 | view.addRenderAttribute( 'inner_text', 'class', 'elementor-progress-text' ); |
| 562 | 463 | |
| 563 | 464 | view.addInlineEditingAttributes( 'inner_text' ); |
| 564 | 465 | #> |
| 565 | - <# if ( settings.title && 'yes' === settings.title_display ) { #> | |
| 566 | - <{{ title_tag }} {{{ view.getRenderAttributeString( 'title' ) }}}>{{ settings.title }}</{{ title_tag }}> | |
| 466 | + <# if ( settings.title ) { #> | |
| 467 | + <{{ title_tag }} {{{ view.getRenderAttributeString( 'title' ) }}}>{{{ settings.title }}}</{{ title_tag }}> | |
| 567 | 468 | <# } #> |
| 568 | 469 | <div {{{ view.getRenderAttributeString( 'progressWrapper' ) }}}> |
| 569 | 470 | <div class="elementor-progress-bar" data-max="{{ progress_percentage }}"> |
| 570 | - <span {{{ view.getRenderAttributeString( 'inner_text' ) }}}>{{ settings.inner_text }}</span> | |
| 471 | + <span {{{ view.getRenderAttributeString( 'inner_text' ) }}}>{{{ settings.inner_text }}}</span> | |
| 571 | 472 | <# if ( 'show' === settings.display_percentage ) { #> |
| 572 | 473 | <span class="elementor-progress-percentage">{{{ progress_percentage }}}%</span> |
| 573 | 474 | <# } #> |
| 574 | 475 | </div> |
| @@ -573,35 +474,6 @@ | ||
| 573 | 474 | <# } #> |
| 574 | 475 | </div> |
| 575 | 476 | </div> |
| 576 | 477 | <?php |
| 577 | - } | |
| 578 | - | |
| 579 | - public function render_markdown(): string { | |
| 580 | - $settings = $this->get_settings_for_display(); | |
| 581 | - $title = Utils::html_to_plain_text( $settings['title'] ?? '' ); | |
| 582 | - $inner_text = Utils::html_to_plain_text( $settings['inner_text'] ?? '' ); | |
| 583 | - $percent = $settings['percent']['size'] ?? ( $settings['percent'] ?? '' ); | |
| 584 | - | |
| 585 | - $parts = []; | |
| 586 | - | |
| 587 | - if ( ! empty( $title ) ) { | |
| 588 | - $parts[] = $title; | |
| 589 | - } | |
| 590 | - | |
| 591 | - if ( ! empty( $inner_text ) ) { | |
| 592 | - $parts[] = $inner_text; | |
| 593 | - } | |
| 594 | - | |
| 595 | - if ( empty( $parts ) && empty( $percent ) ) { | |
| 596 | - return ''; | |
| 597 | - } | |
| 598 | - | |
| 599 | - $label = implode( ' - ', $parts ); | |
| 600 | - | |
| 601 | - if ( ! empty( $percent ) ) { | |
| 602 | - return ! empty( $label ) ? $label . ': ' . $percent . '%' : $percent . '%'; | |
| 603 | - } | |
| 604 | - | |
| 605 | - return $label; | |
| 606 | 478 | } |
| 607 | 479 | } |