public function widget($args, $instance)
 {
     extract($instance);
     echo $args['before_widget'];
     if (isset($title) && !empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     // Templates
     if (isset($template) && !is_array($template)) {
         $template = $template == 'all' ? array_keys($this->templates) : array($template);
     } elseif (!isset($template)) {
         $template = array_keys($this->templates);
     }
     // Sort
     $sort = $this->widget_field($instance, 'to_display', true);
     //Limit
     $limit = $this->widget_field($instance, 'to_display_count', true);
     // Get Ratings
     $ratings = self::query_ratings($template, $sort, $limit);
     $options = $this->widget_field($instance, 'options', true);
     echo '<ul class="rwp-widget-ratings">';
     foreach ($ratings as $i => $rating) {
         //RWP_Reviewer::pretty_print( $rating );
         $rank_num = '';
         if ($sort != 'latest') {
             $rank_num = '<span class="rwp-ranking-number">' . ($i + 1) . '</span>';
         }
         $has_rank = !empty($rank_num) ? 'rwp-has-ranking' : '';
         echo '<li class="' . $has_rank . '">';
         echo $rank_num;
         echo '<div class="rwp-wdj-content">';
         // Post
         if (in_array('rating_option_post_title', $options)) {
             echo '<span class="rwp-w-post-title">' . get_the_title($rating['rating_post_id']) . '</span>';
         }
         // Post
         echo '<div class="rwp-cell">';
         // Avatar
         $has_avatar = '';
         if (in_array('rating_option_avatar', $options)) {
             $avatar = $rating['rating_user_id'] == 0 && isset($rating['rating_user_email']) && !empty($rating['rating_user_email']) ? $rating['rating_user_email'] : $rating['rating_user_id'];
             echo get_avatar($avatar, 30);
             $has_avatar = 'rwp-has-avatar';
         }
         // Avatar
         echo '<div class="rwp-cell-content ' . $has_avatar . '">';
         // Username
         if (in_array('rating_option_name', $options)) {
             $name = $rating['rating_user_id'] > 0 ? get_user_by('id', $rating['rating_user_id'])->display_name : $rating['rating_user_name'];
             echo '<span class="rwp-w-name">' . $name . '</span>';
         }
         // Username
         // Date
         echo '<span class="rwp-w-date"> ' . date_i18n(get_option('date_format') . ', ' . get_option('time_format'), $rating['rating_date']) . '</span>';
         // Score
         if (in_array('rating_option_score', $options)) {
             $mode = $this->preferences['preferences_rating_mode'];
             $template = isset($rating['rating_template']) ? $this->templates[$rating['rating_template']] : array();
             switch ($mode) {
                 case 'five_stars':
                 case 'full_five_stars':
                     echo RWP_Reviewer::get_stars($rating['rating_score'], $template);
                     break;
                 default:
                     echo '<div class="rwp-criterion">';
                     echo '<div class="rwp-criterion-bar-base">';
                     echo RWP_Reviewer::get_score_bar($rating['rating_score'], $template);
                     echo '</div><!-- /criterion-bar -->';
                     echo '<span class="rwp-criterion-score">' . round(RWP_Reviewer::get_avg($rating['rating_score']), 1) . '</span>';
                     echo '</div><!-- /criterion -->';
                     break;
             }
         }
         // Score
         echo '</div><!-- /cell-content -->';
         echo '</div><!-- /cell -->';
         // Title
         if (in_array('rating_option_title', $options) && !empty($rating['rating_title'])) {
             echo '<span class="rwp-w-title">' . $rating['rating_title'] . '</span>';
         }
         // Title
         // Comment
         if (in_array('rating_option_comment', $options) && !empty($rating['rating_comment'])) {
             $comment = $rating['rating_comment'];
             if (strlen($comment) > $this->comment_limit) {
                 $comment = substr($comment, 0, $this->comment_limit) . '...';
             }
             echo '<p class="rwp-w-comment">' . $comment . '</p>';
         }
         // Comment
         // Show Link
         if (in_array('rating_option_link', $options)) {
             $url = add_query_arg('rwpurid', $rating['rating_id'], get_permalink($rating['rating_post_id']));
             echo '<a href="' . esc_url($url) . '">' . $this->widget_field($instance, 'show', true) . '</a>';
         }
         // link
         echo '</div> <!-- /content -->';
         echo '</li>';
     }
     echo '</ul>';
     echo $args['after_widget'];
 }
Example #2
0
    echo $review_title;
    ?>
</a>

			<div class="rwp-rl-scores-wrap">

			    <div class="rwp-rl-total-score-wrap">			        
			    	<span class="rwp-rl-total-score-label"><?php 
    echo $reviews[$i]['review_score']['label'];
    ?>
</span> 
			        <span class="rwp-rl-total-score" style="color:<?php 
    echo $reviews[$i]['review_color'];
    ?>
"><?php 
    echo $stars == 'yes' ? RWP_Reviewer::get_stars($reviews[$i]['review_score']['overall'], $templates[$reviews[$i]['review_template']]) : $reviews[$i]['review_score']['overall'];
    ?>
</span>
			    </div><!--/total-score-->

			    <?php 
    if (isset($reviews[$i]['review_custom_tabs']) && !empty($reviews[$i]['review_custom_tabs'])) {
        ?>

				    <?php 
        foreach ($reviews[$i]['review_custom_tabs'] as $tab) {
            if (empty($tab['tab_value'])) {
                continue;
            }
            ?>
				    	
 public function widget($args, $instance)
 {
     //$this->pretty_print($instance);
     extract($instance);
     echo $args['before_widget'];
     if (isset($title) && !empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     // Templates
     if (isset($template) && !is_array($template)) {
         $template = $template == 'all' ? array_keys($this->templates) : array($template);
     } elseif (!isset($template)) {
         $template = array_keys($this->templates);
     }
     // Theme
     $theme = $this->widget_field($instance, 'theme', true);
     // Sort
     $sort = $this->widget_field($instance, 'to_display', true);
     //Limit
     $limit = $this->widget_field($instance, 'to_display_count', true);
     // Get Reviews
     $reviews = self::query_reviews($template, $sort, $limit);
     echo '<ul class="rwp-widget-reviews rwp-widget-' . $theme . '">';
     foreach ($reviews as $i => $review) {
         //$this->pretty_print($review);
         $rank_num = '';
         if ($sort != 'latest') {
             $rank_num = '<span class="rwp-ranking-number">' . ($i + 1) . '</span>';
         }
         $has_rank = !empty($rank_num) ? 'rwp-has-ranking' : '';
         $review_title = '';
         $review_title_option = $this->review_field('review_title_options', $review, true);
         switch ($review_title_option) {
             case 'hidden':
                 break;
             case 'post_title':
                 $post_id = $this->review_field('review_post_id', $review, true);
                 $review_title = get_the_title($post_id);
                 break;
             default:
                 $review_title = $this->review_field('review_title', $review, true);
                 break;
         }
         switch ($theme) {
             case 'theme-3':
                 // Has Image
                 $img = $review['review_image'];
                 if ($review['review_use_featured_image'] == 'no') {
                     $has_image = !empty($img) ? true : false;
                 } else {
                     $has_image = has_post_thumbnail($review['review_post_id']);
                     $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($review['review_post_id']), 'full');
                     $img = $thumb[0];
                 }
                 $hi = $has_image ? 'rwp-has-image' : 'rwp-no-image';
                 echo '<li class="' . $hi . ' ' . $has_rank . '" >';
                 echo $rank_num;
                 echo '<a href="' . $review['review_permalink'] . '">';
                 echo $has_image ? '<div class="rwp-w-icon" style="background-image: url(' . $img . ');"></div>' : '';
                 echo '<span class="rwp-title">' . $review_title . '</span>';
                 echo RWP_Reviewer::get_stars($review['review_score']['overall'], $this->templates[$review['review_template']]);
                 echo '</a>';
                 echo '</li>';
                 break;
             case 'theme-2':
                 echo '<li class="' . $has_rank . '">';
                 echo $rank_num;
                 echo '<span class="rwp-overall" style="background-color: ' . $review['review_color'] . ';">' . $review['review_score']['overall'] . '<em>' . $review['review_score']['label'] . '</em></span>';
                 echo '<a href="' . $review['review_permalink'] . '">' . $review_title . '</a>';
                 echo '</li>';
                 break;
             case 'theme-1':
             default:
                 // Has Image
                 $img = $review['review_image'];
                 if ($review['review_use_featured_image'] == 'no') {
                     $has_image = !empty($img) ? true : false;
                 } else {
                     $has_image = has_post_thumbnail($review['review_post_id']);
                     $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($review['review_post_id']), 'full');
                     $img = $thumb[0];
                 }
                 $hi = $has_image ? 'rwp-has-image' : 'rwp-no-image';
                 echo '<li class="' . $hi . ' ' . $has_rank . '" >';
                 echo $rank_num;
                 $bg2 = $has_image ? 'style="background-image: url(' . $img . ');"' : 'style="background-color: ' . $review['review_color'] . ';"';
                 echo '<a href="' . $review['review_permalink'] . '" ' . $bg2 . '>';
                 $bg = $has_image ? 'style="background-color: ' . $review['review_color'] . ';"' : '';
                 echo '<span class="rwp-overall" ' . $bg . '>' . $review['review_score']['overall'] . '<em>' . $review['review_score']['label'] . '</em></span>';
                 echo '<span class="rwp-title">' . $review_title . '</span>';
                 echo '</a>';
                 echo '</li>';
                 break;
         }
     }
     echo '</ul>';
     echo $args['after_widget'];
 }