PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.4
Elementor Website Builder – more than just a page builder v3.31.4
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 +25 -56 4.2.43.31.4 View file →
@@ -214,10 +214,10 @@
214 214 [
215 215 'label' => esc_html__( 'Alignment', 'elementor' ),
216 216 'type' => Controls_Manager::CHOOSE,
217 217 'options' => [
218 - 'start' => [
219 - 'title' => esc_html__( 'Start', 'elementor' ),
218 + 'left' => [
219 + 'title' => esc_html__( 'Left', 'elementor' ),
220 220 'icon' => 'eicon-text-align-left',
221 221 ],
222 222 'center' => [
223 223 'title' => esc_html__( 'Center', 'elementor' ),
@@ -222,10 +222,10 @@
222 222 'center' => [
223 223 'title' => esc_html__( 'Center', 'elementor' ),
224 224 'icon' => 'eicon-text-align-center',
225 225 ],
226 - 'end' => [
227 - 'title' => esc_html__( 'End', 'elementor' ),
226 + 'right' => [
227 + 'title' => esc_html__( 'Right', 'elementor' ),
228 228 'icon' => 'eicon-text-align-right',
229 229 ],
230 230 'justify' => [
231 231 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -231,17 +231,8 @@
231 231 'title' => esc_html__( 'Justified', 'elementor' ),
232 232 'icon' => 'eicon-text-align-justify',
233 233 ],
234 234 ],
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 235 'prefix_class' => 'elementor-star-rating%s--align-',
245 236 'selectors' => [
246 237 '{{WRAPPER}}' => 'text-align: {{VALUE}}',
247 238 ],
@@ -411,9 +402,9 @@
411 402 */
412 403 protected function get_rating() {
413 404 $settings = $this->get_settings_for_display();
414 405 $rating_scale = (int) $settings['rating_scale'];
415 - $rating = min( (float) $settings['rating'], $rating_scale );
406 + $rating = (float) $settings['rating'] > $rating_scale ? $rating_scale : $settings['rating'];
416 407
417 408 return [ $rating, $rating_scale ];
418 409 }
419 410
@@ -434,17 +425,17 @@
434 425 $stars_html = '';
435 426
436 427 for ( $stars = 1.0; $stars <= $rating_data[1]; $stars++ ) {
437 428 if ( $stars <= $floored_rating ) {
438 - $stars_html .= '<i class="elementor-star-full" aria-hidden="true">' . $icon . '</i>';
429 + $stars_html .= '<i class="elementor-star-full">' . $icon . '</i>';
439 430 } elseif ( $floored_rating + 1 === $stars && $rating !== $floored_rating ) {
440 - $stars_html .= '<i class="elementor-star-' . ( $rating - $floored_rating ) * 10 . '" aria-hidden="true">' . $icon . '</i>';
431 + $stars_html .= '<i class="elementor-star-' . ( $rating - $floored_rating ) * 10 . '">' . $icon . '</i>';
441 432 } else {
442 - $stars_html .= '<i class="elementor-star-empty" aria-hidden="true">' . $icon . '</i>';
433 + $stars_html .= '<i class="elementor-star-empty">' . $icon . '</i>';
443 434 }
444 435 }
445 436
446 - Utils::print_unescaped_internal_string( $stars_html );
437 + return $stars_html;
447 438 }
448 439
449 440 /**
450 441 * @since 2.3.0
@@ -452,14 +443,9 @@
452 443 */
453 444 protected function render() {
454 445 $settings = $this->get_settings_for_display();
455 446 $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 - );
447 + $textual_rating = $rating_data[0] . '/' . $rating_data[1];
462 448 $icon = '&#xE934;';
463 449
464 450 if ( 'star_fontawesome' === $settings['star_style'] ) {
465 451 if ( 'outline' === $settings['unmarked_star_style'] ) {
@@ -474,48 +460,28 @@
474 460 }
475 461
476 462 $this->add_render_attribute( 'icon_wrapper', [
477 463 'class' => 'elementor-star-rating',
464 + 'title' => $textual_rating,
478 465 'itemtype' => 'http://schema.org/Rating',
479 466 'itemscope' => '',
480 467 'itemprop' => 'reviewRating',
481 468 ] );
469 +
470 + $schema_rating = '<span itemprop="ratingValue" class="elementor-screen-only">' . $textual_rating . '</span>';
471 + $stars_element = '<div ' . $this->get_render_attribute_string( 'icon_wrapper' ) . '>' . $this->render_stars( $icon ) . ' ' . $schema_rating . '</div>';
482 472 ?>
473 +
483 474 <div class="elementor-star-rating__wrapper">
484 475 <?php if ( ! Utils::is_empty( $settings['title'] ) ) : ?>
485 476 <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>
477 + <?php endif;
478 + // PHPCS - $stars_element contains an HTML string that cannot be escaped. ?>
479 + <?php echo $stars_element; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
491 480 </div>
492 481 <?php
493 482 }
494 483
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 484 /**
519 485 * @since 2.9.0
520 486 * @access protected
521 487 */
@@ -529,9 +495,9 @@
529 495 return [ rating, ratingScale ];
530 496 },
531 497 ratingData = getRating(),
532 498 rating = ratingData[0],
533 - textualRating = 'Rated ' + ratingData[0] + ' out of ' + ratingData[1],
499 + textualRating = ratingData[0] + '/' + ratingData[1],
534 500 renderStars = function( icon ) {
535 501 var starsHtml = '',
536 502 flooredRating = Math.floor( rating );
537 503
@@ -536,13 +502,13 @@
536 502 flooredRating = Math.floor( rating );
537 503
538 504 for ( var stars = 1; stars <= ratingData[1]; stars++ ) {
539 505 if ( stars <= flooredRating ) {
540 - starsHtml += '<i class="elementor-star-full" aria-hidden="true">' + icon + '</i>';
506 + starsHtml += '<i class="elementor-star-full">' + icon + '</i>';
541 507 } else if ( flooredRating + 1 === stars && rating !== flooredRating ) {
542 - starsHtml += '<i class="elementor-star-' + ( rating - flooredRating ).toFixed( 1 ) * 10 + '" aria-hidden="true">' + icon + '</i>';
508 + starsHtml += '<i class="elementor-star-' + ( rating - flooredRating ).toFixed( 1 ) * 10 + '">' + icon + '</i>';
543 509 } else {
544 - starsHtml += '<i class="elementor-star-empty" aria-hidden="true">' + icon + '</i>';
510 + starsHtml += '<i class="elementor-star-empty">' + icon + '</i>';
545 511 }
546 512 }
547 513
548 514 return starsHtml;
@@ -562,13 +528,15 @@
562 528 }
563 529
564 530 view.addRenderAttribute( 'iconWrapper', 'class', 'elementor-star-rating' );
565 531 view.addRenderAttribute( 'iconWrapper', 'itemtype', 'http://schema.org/Rating' );
532 + view.addRenderAttribute( 'iconWrapper', 'title', textualRating );
566 533 view.addRenderAttribute( 'iconWrapper', 'itemscope', '' );
567 534 view.addRenderAttribute( 'iconWrapper', 'itemprop', 'reviewRating' );
568 535
569 536 var stars = renderStars( icon );
570 537 #>
538 +
571 539 <div class="elementor-star-rating__wrapper">
572 540 <# if ( ! _.isEmpty( settings.title ) ) { #>
573 541 <div class="elementor-star-rating__title">{{ settings.title }}</div>
574 542 <# } #>
@@ -576,7 +544,8 @@
576 544 {{{ stars }}}
577 545 <span itemprop="ratingValue" class="elementor-screen-only">{{ textualRating }}</span>
578 546 </div>
579 547 </div>
548 +
580 549 <?php
581 550 }
582 551 }