public function listing_data($data) { global $post; $rating = WPJMR()->review->average_rating_listing($post->ID); $data['rating'] = sprintf(_n('%d Star', '%d Stars', $rating, 'listify'), $rating); return $data; }
public function the_rating($comment) { global $post; $number = WPJMR()->review->review_count($post->ID); $number = number_format($number, 1, '.', ','); $value = number_format(WPJMR()->review->average_rating_listing($post->ID), 1, '.', ','); $stars = WPJMR()->review->get_stars($post->ID); ?> <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="job_listing-rating-wrapper" title="<?php printf('%d Reviews', $number); ?> "> <span class="job_listing-rating-stars"> <?php echo $stars; ?> </span> <span class="job_listing-rating-average"> <span itemprop="ratingValue"><?php echo $value; ?> </span> </span> <span class="job_listing-rating-count"> <?php echo _n(sprintf('<span itemprop="reviewCount">%d</span> Review', $number), sprintf('<span itemprop="reviewCount">%d</span> Reviews', $number), $number, 'listify'); ?> </span> </div> <?php }
/** * Comment approved. * * Check if a comment is approved or not. When a user tries to post * multiple reviews it will die with a message (similar as the duplicate message). * This only goes for multiple reviews, not replies. * * @since 1.2.0 * * @param bool $approved 1 If the comment is approved, else 0. * @param array $commentdata List of comment data. * @return bool 1 If the comment is approved, else 0. */ public function check_comment_approved($approved, $commentdata) { // Only hold back on the reviews, not replies if ('job_listing' != get_post_type($commentdata['comment_post_ID'])) { return $approved; } // Check if review limit is not reached if (0 == $commentdata['comment_parent']) { if (!$this->can_post_multiple_reviews()) { wp_die(__('Looks like you’ve already posted a review!')); $approved = 0; } } // Check if ratings are given for top-level comments if (0 == $commentdata['comment_parent']) { // Check if all ratings are set $review_categories = WPJMR()->wpjmr_get_review_categories(); foreach ($review_categories as $category_slug => $review_category) { if (!isset($_POST['star-rating-' . $category_slug]) || empty($_POST['star-rating-' . $category_slug])) { wp_die(__('<strong>ERROR:</strong> Please select a rating for all categories.')); $approved = 0; } } } return $approved; }
/** * [reviews]. * * A shortcode to get the reviews. * * @since 1.0.0 * * @param array @atts Attributes given in the shortcode. * @param string @content Content of the shortcode. */ public function shortcode_reviews($atts = array(), $content = '') { extract(shortcode_atts(array('post_id' => get_the_ID()), $atts)); $post_id = (int) $post_id; if (!$post_id || !is_integer($post_id)) { return; } ob_start(); wp_list_comments(array('callback' => array(WPJMR()->review, 'wpjmr_comments')), WPJMR()->review->get_reviews_by_id($post_id)); $return = ob_get_contents(); ob_end_clean(); return $return; }
echo $review->comment_author; ?> </td> <td> <div id='wpjmr-list-reviews'><?php $ratings = WPJMR()->review->get_ratings($review->comment_ID); $categories = WPJMR()->wpjmr_get_review_categories(); foreach ($ratings as $category => $rating) { ?> <div class='star-rating'> <div class='star-rating-title'><?php echo isset($categories[$category]) ? $categories[$category] : $category; ?> </div> <?php for ($i = 0; $i < WPJMR()->wpjmr_get_count_stars(); $i++) { ?> <?php if ($i < $rating) { ?> <span class="dashicons dashicons-star-filled"></span><?php } else { ?> <span class="dashicons dashicons-star-empty"></span><?php } ?> <?php } ?> </div> <?php