Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'atbdp_listings_review_price', function( $html ) {
- // Review
- $average = ATBDP()->review->get_average(get_the_ID());
- $average = (int) $average;
- $average_with_zero = number_format( $average, 1 );
- $reviews_count = ATBDP()->review->db->count(array('post_id' => get_the_ID()));
- $review_text = ( $reviews_count > 1 ) ? 'Reviews' : 'Review';
- // Icons
- $icon_empty_star = '<i class="'. 'far fa-star'.'"></i>';
- $icon_half_star = '<i class="'. 'fas fa-star-half-alt'.'"></i>';
- $icon_full_star = '<i class="'. 'fas fa-star'.'"></i>';
- // Stars
- $star_1 = ( $average >= 0.5 && $average < 1) ? $icon_half_star : $icon_empty_star;
- $star_1 = ( $average >= 1) ? $icon_full_star : $star_1;
- $star_2 = ( $average >= 1.5 && $average < 2) ? $icon_half_star : $icon_empty_star;
- $star_2 = ( $average >= 2) ? $icon_full_star : $star_2;
- $star_3 = ( $average >= 2.5 && $average < 3) ? $icon_half_star : $icon_empty_star;
- $star_3 = ( $average >= 3) ? $icon_full_star : $star_3;
- $star_4 = ( $average >= 3.5 && $average < 4) ? $icon_half_star : $icon_empty_star;
- $star_4 = ( $average >= 4) ? $icon_full_star : $star_4;
- $star_5 = ( $average >= 4.5 && $average < 5 ) ? $icon_half_star : $icon_empty_star;
- $star_5 = ( $average >= 5 ) ? $icon_full_star : $star_5;
- // Price
- $display_price = get_directorist_option('display_price', 1);
- $display_pricing_field = get_directorist_option('display_pricing_field', 1);
- $atbd_listing_pricing = $atbd_listing_pricing = get_post_meta(get_the_ID(), '_atbd_listing_pricing', true);
- $is_disable_price = get_directorist_option('disable_list_price');
- $price = '';
- if ( ! empty( $display_price ) && ! empty( $display_pricing_field ) ) {
- if ( ! empty( $price_range ) && ( 'range' === $atbd_listing_pricing )) {
- $price = atbdp_display_price_range($price_range);
- } else {
- $price = apply_filters('atbdp_listing_card_price', atbdp_display_price($price, $is_disable_price, $currency = null, $symbol = null, $c_position = null, $echo = false));
- }
- }
- ob_start(); ?>
- <div class="atbd_listing_meta">
- <span class="atbdp-ratings-count-icons" style="margin-right: 5px; color: #FF9F21;">
- <?php echo $star_1 . $star_2 . $star_3 . $star_4 . $star_5 ?>
- </span>
- <span class="atbdp-ratings-count-number" style="margin-right: 5px; color: #2b2b2b; font-weight: 700;">
- <?php echo $average_with_zero; ?>
- </span>
- <span class="atbdp-review-count-number">
- <?php echo $reviews_count .' '. __( $review_text, 'directorist' ); ?>
- </span>
- <?php echo $price ?>
- </div>
- <?php return ob_get_clean();
- }, 20, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement