PluginProbe
Elementor Website Builder – more than just a page builder / 3.24.8
Elementor Website Builder – more than just a page builder v3.24.8
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | includes/widgets/star-rating.php +29 -62 4.2.0-dev23.24.8 View file →
@@ -102,12 +102,8 @@
102 102 public function show_in_panel(): bool {
103 103 return false;
104 104 }
105 105
106 - public function has_widget_inner_wrapper(): bool {
107 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
108 - }
109 -
110 106 /**
111 107 * Register star rating widget controls.
112 108 *
113 109 * Adds different input fields to allow the user to change and customize the widget settings.
@@ -214,10 +210,10 @@
214 210 [
215 211 'label' => esc_html__( 'Alignment', 'elementor' ),
216 212 'type' => Controls_Manager::CHOOSE,
217 213 'options' => [
218 - 'start' => [
219 - 'title' => esc_html__( 'Start', 'elementor' ),
214 + 'left' => [
215 + 'title' => esc_html__( 'Left', 'elementor' ),
220 216 'icon' => 'eicon-text-align-left',
221 217 ],
222 218 'center' => [
223 219 'title' => esc_html__( 'Center', 'elementor' ),
@@ -222,10 +218,10 @@
222 218 'center' => [
223 219 'title' => esc_html__( 'Center', 'elementor' ),
224 220 'icon' => 'eicon-text-align-center',
225 221 ],
226 - 'end' => [
227 - 'title' => esc_html__( 'End', 'elementor' ),
222 + 'right' => [
223 + 'title' => esc_html__( 'Right', 'elementor' ),
228 224 'icon' => 'eicon-text-align-right',
229 225 ],
230 226 'justify' => [
231 227 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -231,17 +227,8 @@
231 227 'title' => esc_html__( 'Justified', 'elementor' ),
232 228 'icon' => 'eicon-text-align-justify',
233 229 ],
234 230 ],
235 - 'classes' => 'elementor-control-start-end',
236 - 'classes_dictionary' => [
237 - 'left' => is_rtl() ? 'end' : 'start',
238 - 'right' => is_rtl() ? 'start' : 'end',
239 - ],
240 - 'selectors_dictionary' => [
241 - 'left' => is_rtl() ? 'end' : 'start',
242 - 'right' => is_rtl() ? 'start' : 'end',
243 - ],
244 231 'prefix_class' => 'elementor-star-rating%s--align-',
245 232 'selectors' => [
246 233 '{{WRAPPER}}' => 'text-align: {{VALUE}}',
247 234 ],
@@ -313,9 +300,10 @@
313 300 'max' => 5,
314 301 ],
315 302 ],
316 303 'selectors' => [
317 - '{{WRAPPER}}:not(.elementor-star-rating--align-justify) .elementor-star-rating__title' => 'margin-inline-end: {{SIZE}}{{UNIT}}',
304 + 'body:not(.rtl) {{WRAPPER}}:not(.elementor-star-rating--align-justify) .elementor-star-rating__title' => 'margin-right: {{SIZE}}{{UNIT}}',
305 + 'body.rtl {{WRAPPER}}:not(.elementor-star-rating--align-justify) .elementor-star-rating__title' => 'margin-left: {{SIZE}}{{UNIT}}',
318 306 ],
319 307 ]
320 308 );
321 309
@@ -373,9 +361,10 @@
373 361 'max' => 5,
374 362 ],
375 363 ],
376 364 'selectors' => [
377 - '{{WRAPPER}} .elementor-star-rating i:not(:last-of-type)' => 'margin-inline-end: {{SIZE}}{{UNIT}}',
365 + 'body:not(.rtl) {{WRAPPER}} .elementor-star-rating i:not(:last-of-type)' => 'margin-right: {{SIZE}}{{UNIT}}',
366 + 'body.rtl {{WRAPPER}} .elementor-star-rating i:not(:last-of-type)' => 'margin-left: {{SIZE}}{{UNIT}}',
378 367 ],
379 368 ]
380 369 );
381 370
@@ -411,9 +400,9 @@
411 400 */
412 401 protected function get_rating() {
413 402 $settings = $this->get_settings_for_display();
414 403 $rating_scale = (int) $settings['rating_scale'];
415 - $rating = min( (float) $settings['rating'], $rating_scale );
404 + $rating = (float) $settings['rating'] > $rating_scale ? $rating_scale : $settings['rating'];
416 405
417 406 return [ $rating, $rating_scale ];
418 407 }
419 408
@@ -434,17 +423,17 @@
434 423 $stars_html = '';
435 424
436 425 for ( $stars = 1.0; $stars <= $rating_data[1]; $stars++ ) {
437 426 if ( $stars <= $floored_rating ) {
438 - $stars_html .= '<i class="elementor-star-full" aria-hidden="true">' . $icon . '</i>';
427 + $stars_html .= '<i class="elementor-star-full">' . $icon . '</i>';
439 428 } elseif ( $floored_rating + 1 === $stars && $rating !== $floored_rating ) {
440 - $stars_html .= '<i class="elementor-star-' . ( $rating - $floored_rating ) * 10 . '" aria-hidden="true">' . $icon . '</i>';
429 + $stars_html .= '<i class="elementor-star-' . ( $rating - $floored_rating ) * 10 . '">' . $icon . '</i>';
441 430 } else {
442 - $stars_html .= '<i class="elementor-star-empty" aria-hidden="true">' . $icon . '</i>';
431 + $stars_html .= '<i class="elementor-star-empty">' . $icon . '</i>';
443 432 }
444 433 }
445 434
446 - Utils::print_unescaped_internal_string( $stars_html );
435 + return $stars_html;
447 436 }
448 437
449 438 /**
450 439 * @since 2.3.0
@@ -452,14 +441,9 @@
452 441 */
453 442 protected function render() {
454 443 $settings = $this->get_settings_for_display();
455 444 $rating_data = $this->get_rating();
456 - $textual_rating = sprintf(
457 - /* translators: 1: Rating value. 2: Rating scale. */
458 - esc_html__( 'Rated %1$s out of %2$s', 'elementor' ),
459 - $rating_data[0],
460 - $rating_data[1]
461 - );
445 + $textual_rating = $rating_data[0] . '/' . $rating_data[1];
462 446 $icon = '&#xE934;';
463 447
464 448 if ( 'star_fontawesome' === $settings['star_style'] ) {
465 449 if ( 'outline' === $settings['unmarked_star_style'] ) {
@@ -474,48 +458,28 @@
474 458 }
475 459
476 460 $this->add_render_attribute( 'icon_wrapper', [
477 461 'class' => 'elementor-star-rating',
462 + 'title' => $textual_rating,
478 463 'itemtype' => 'http://schema.org/Rating',
479 464 'itemscope' => '',
480 465 'itemprop' => 'reviewRating',
481 466 ] );
467 +
468 + $schema_rating = '<span itemprop="ratingValue" class="elementor-screen-only">' . $textual_rating . '</span>';
469 + $stars_element = '<div ' . $this->get_render_attribute_string( 'icon_wrapper' ) . '>' . $this->render_stars( $icon ) . ' ' . $schema_rating . '</div>';
482 470 ?>
471 +
483 472 <div class="elementor-star-rating__wrapper">
484 473 <?php if ( ! Utils::is_empty( $settings['title'] ) ) : ?>
485 474 <div class="elementor-star-rating__title"><?php echo esc_html( $settings['title'] ); ?></div>
486 - <?php endif; ?>
487 - <div <?php $this->print_render_attribute_string( 'icon_wrapper' ); ?>>
488 - <?php $this->render_stars( $icon ); ?>
489 - <span itemprop="ratingValue" class="elementor-screen-only"><?php echo esc_html( $textual_rating ); ?></span>
490 - </div>
475 + <?php endif;
476 + // PHPCS - $stars_element contains an HTML string that cannot be escaped. ?>
477 + <?php echo $stars_element; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
491 478 </div>
492 479 <?php
493 480 }
494 481
495 - public function render_markdown(): string {
496 - $settings = $this->get_settings_for_display();
497 - $title = Utils::html_to_plain_text( $settings['title'] ?? '' );
498 - $rating = floatval( $settings['rating'] ?? 0 );
499 - $scale = intval( $settings['rating_scale'] ?? 5 );
500 -
501 - if ( empty( $rating ) ) {
502 - return '';
503 - }
504 -
505 - $full_stars = intval( floor( $rating ) );
506 - $empty_stars = $scale - $full_stars;
507 - $stars = str_repeat( '★', $full_stars ) . str_repeat( '☆', max( 0, $empty_stars ) );
508 -
509 - $md = $stars . ' ' . $rating . '/' . $scale;
510 -
511 - if ( ! empty( $title ) ) {
512 - $md .= "\n\n" . $title;
513 - }
514 -
515 - return $md;
516 - }
517 -
518 482 /**
519 483 * @since 2.9.0
520 484 * @access protected
521 485 */
@@ -529,9 +493,9 @@
529 493 return [ rating, ratingScale ];
530 494 },
531 495 ratingData = getRating(),
532 496 rating = ratingData[0],
533 - textualRating = 'Rated ' + ratingData[0] + ' out of ' + ratingData[1],
497 + textualRating = ratingData[0] + '/' + ratingData[1],
534 498 renderStars = function( icon ) {
535 499 var starsHtml = '',
536 500 flooredRating = Math.floor( rating );
537 501
@@ -536,13 +500,13 @@
536 500 flooredRating = Math.floor( rating );
537 501
538 502 for ( var stars = 1; stars <= ratingData[1]; stars++ ) {
539 503 if ( stars <= flooredRating ) {
540 - starsHtml += '<i class="elementor-star-full" aria-hidden="true">' + icon + '</i>';
504 + starsHtml += '<i class="elementor-star-full">' + icon + '</i>';
541 505 } else if ( flooredRating + 1 === stars && rating !== flooredRating ) {
542 - starsHtml += '<i class="elementor-star-' + ( rating - flooredRating ).toFixed( 1 ) * 10 + '" aria-hidden="true">' + icon + '</i>';
506 + starsHtml += '<i class="elementor-star-' + ( rating - flooredRating ).toFixed( 1 ) * 10 + '">' + icon + '</i>';
543 507 } else {
544 - starsHtml += '<i class="elementor-star-empty" aria-hidden="true">' + icon + '</i>';
508 + starsHtml += '<i class="elementor-star-empty">' + icon + '</i>';
545 509 }
546 510 }
547 511
548 512 return starsHtml;
@@ -562,13 +526,15 @@
562 526 }
563 527
564 528 view.addRenderAttribute( 'iconWrapper', 'class', 'elementor-star-rating' );
565 529 view.addRenderAttribute( 'iconWrapper', 'itemtype', 'http://schema.org/Rating' );
530 + view.addRenderAttribute( 'iconWrapper', 'title', textualRating );
566 531 view.addRenderAttribute( 'iconWrapper', 'itemscope', '' );
567 532 view.addRenderAttribute( 'iconWrapper', 'itemprop', 'reviewRating' );
568 533
569 534 var stars = renderStars( icon );
570 535 #>
536 +
571 537 <div class="elementor-star-rating__wrapper">
572 538 <# if ( ! _.isEmpty( settings.title ) ) { #>
573 539 <div class="elementor-star-rating__title">{{ settings.title }}</div>
574 540 <# } #>
@@ -576,7 +542,8 @@
576 542 {{{ stars }}}
577 543 <span itemprop="ratingValue" class="elementor-screen-only">{{ textualRating }}</span>
578 544 </div>
579 545 </div>
546 +
580 547 <?php
581 548 }
582 549 }