* $Desc * * @version $Id$ * @package wpbase * @author Opal Team <*****@*****.** > * @copyright Copyright (C) 2014 wpopal.com. All Rights Reserved. * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html * * @website http://www.wpopal.com * @support http://www.wpopal.com/support/forum.html */ // Display the widget title if ($title) { echo $before_title . esc_html($title) . $after_title; } $rt_option = PostRatings()->getOptions(); $max_rating = $rt_option['max_rating']; ?> <div class="post-widget widget-rate widget-content"> <?php foreach ($posts as $key => $post) { ?> <?php $rating = (double) get_post_meta($post->ID, 'rating', true); $current_rating = apply_filters('post_ratings_current_rating', sprintf('%.2F / %d', $rating, $max_rating), $rating, $max_rating); ?> <article> <?php if (has_post_thumbnail()) { ?> <a href="<?php
public function form($instance) { $defaults = array('title' => 'Top Rated', 'layout' => 'default', 'number' => '5', 'sort' => 'bayesian_rating', 'order' => 'DESC', 'date_limit' => 0, 'post_type' => 'post'); $instance = wp_parse_args((array) $instance, $defaults); $plugin_options = PostRatings()->getOptions(); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> ">Title:</label> <br> <input id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $instance['title']; ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('layout'); ?> ">Template Style:</label> <br> <select name="<?php echo $this->get_field_name('layout'); ?> " id="<?php echo $this->get_field_id('layout'); ?> "> <?php foreach ($this->selectLayout() as $key => $value) { ?> <option value="<?php echo $value; ?> " <?php selected($instance['layout'], $value); ?> ><?php echo $value; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('post_type'); ?> "><?php _e('Get most rated:', PostRatings::ID); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('post_type'); ?> " name="<?php echo $this->get_field_name('post_type'); ?> "> <?php foreach (get_post_types(array('public' => true)) as $type) { ?> <?php $object = get_post_type_object($type); ?> <option <?php if (!in_array($type, $plugin_options['post_types'])) { ?> disabled="disabled" <?php } ?> value="<?php echo $type; ?> " <?php selected($type, $instance['post_type']); ?> ><?php echo $object->labels->name; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('sort'); ?> "><?php _e('Sort by:', PostRatings::ID); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('sort'); ?> " name="<?php echo $this->get_field_name('sort'); ?> "> <option <?php selected('bayesian_rating', $instance['sort']); ?> value="bayesian_rating"><?php _e('Overall bayesian rating (score)', PostRatings::ID); ?> </option> <option <?php selected('rating', $instance['sort']); ?> value="rating"><?php _e('Average rating', PostRatings::ID); ?> </option> <option <?php selected('votes', $instance['sort']); ?> value="votes"><?php _e('Number of votes', PostRatings::ID); ?> </option> </select> </p> <p> <label for="<?php echo $this->get_field_id('order'); ?> _desc"> <input id="<?php echo $this->get_field_id('order'); ?> _desc" name="<?php echo $this->get_field_name('order'); ?> " type="radio" value="DESC" <?php checked('DESC', $instance['order']); ?> /> <?php _e('Descending', PostRatings::ID); ?> </label> <label for="<?php echo $this->get_field_id('order'); ?> _asc"> <input id="<?php echo $this->get_field_id('order'); ?> _asc" name="<?php echo $this->get_field_name('order'); ?> " type="radio" value="ASC" <?php checked('ASC', $instance['order']); ?> /> <?php _e('Ascending', PostRatings::ID); ?> </label> </p> <p> <label for="<?php echo $this->get_field_id('date_limit'); ?> "><?php _e('Ignore posts older than:', PostRatings::ID); ?> </label> <input id="<?php echo $this->get_field_id('date_limit'); ?> " name="<?php echo $this->get_field_name('date_limit'); ?> " type="text" value="<?php echo $instance['date_limit']; ?> " size="3" /> <?php _e('days', PostRatings::ID); ?> <br /> <small><?php _e('(0 to ignore date)', PostRatings::ID); ?> </small> </p> <p> <label for="<?php echo $this->get_field_id('number'); ?> "><?php _e('Limit:', PostRatings::ID); ?> </label> <input id="<?php echo $this->get_field_id('number'); ?> " name="<?php echo $this->get_field_name('number'); ?> " type="text" value="<?php echo $instance['number']; ?> " size="3" /> </p> <?php }
function training_wpo_vote_count() { $options = PostRatings()->getRating(get_the_ID()); $classRating = "vote-default"; if (isset($options['bayesian_rating']) && $options['bayesian_rating'] > 0) { if (85 < $options['bayesian_rating'] && $options['bayesian_rating'] <= 100) { $classRating = "vote-perfect"; } if (75 < $options['bayesian_rating'] && $options['bayesian_rating'] <= 85) { $classRating = "vote-good"; } if (65 < $options['bayesian_rating'] && $options['bayesian_rating'] <= 75) { $classRating = "vote-average"; } if (55 < $options['bayesian_rating'] && $options['bayesian_rating'] <= 65) { $classRating = "vote-bad"; } if (0 < $options['bayesian_rating'] && $options['bayesian_rating'] <= 55) { $classRating = "vote-poor"; } ?> <?php $result_ratings = number_format((double) $options['bayesian_rating'] / 10, 1, '.', ''); ?> <div class="entry-vote <?php echo esc_attr($classRating); ?> "><span class="entry-vote-inner"><?php echo trim($result_ratings); ?> </span></div> <?php } }