/** * @param $atts * * @return string */ public static function cbratingsystem_top_rated_user($atts) { global $post; if (!is_object($post)) { return ''; } //Example: [cbratingsystem rating_form_id=1] $options = shortcode_atts(array('post_id' => '', 'form_id' => '', 'user_id' => '', 'post_time' => '0', 'limit' => 10, 'posttype' => '0', 'post_filter' => '', 'order' => 'DESC', 'title' => __('Top Rated Users', 'cbratingsystem')), $atts); //var_dump($options); $limit = $options['limit']; if ($options['post_time'] != 0) { $date = CBRatingSystemFunctions::get_calculated_date($options['post_time']); $options['post_date'] = $date; } $data = CBRatingSystemData::get_top_rated_post($options, false, $limit); $cbrp_output = '<ul class="cbrp-top-rated-wpanel" style="">'; if (!empty($data)) { foreach ($data as $newdata) { $cbrp_output .= '<li class="cbrp-top-rated-userlist">'; $author_info = get_userdata((int) $newdata['post_author']); $cbrp_output .= '<div style=""> <a style="" href="' . get_author_posts_url((int) $newdata['post_author']) . ' ">' . $author_info->display_name . ' </a></div> <div style=""> ' . $newdata['post_count'] . ' Posts</div>'; $rating = $newdata['rating'] / 100 * 5; ?> <script> jQuery(document).ready(function ($) { $('#cbrp-top-rated<?php echo $newdata['post_author'] . '_' . $post->ID; ?> ').raty({ half : true, path : '<?php echo CB_RATINGSYSTEM_PLUGIN_DIR_IMG; ?> ', score : <?php echo number_format($rating, 2, '.', ''); ?> , readOnly: true, hintList: ['', '', '', '', ''] }); }); </script> <?php $cbrp_output .= ' <strong>' . number_format($rating, 2, '.', '') . '/5</strong> '; $cbrp_output .= '<div id ="cbrp-top-rated' . $newdata['post_author'] . '_' . $post->ID . '" style=""></div> </li>'; } } else { $cbrp_output .= ' <li class="cbrp-top-rated-userlist">' . __('No Results found', 'cbratingsystem') . ' </li>'; } $cbrp_output .= '</ul>'; return $cbrp_output; }
/** * @param array $args * @param array $instance */ function widget($args, $instance) { global $wpdb; extract($args); $widget_id = $args['widget_id']; // var_dump($widget_id); CBRatingSystem::load_scripts_and_styles(); $posttype = $instance['posttype']; $date = $instance['timelimit']; $limit = $instance['resultlimit']; $form_id = $instance['form_id']; $user_id = $instance['user_id']; $post_id = $instance['post_id']; $post_filter = $instance['post_filter']; $order = $instance['order']; $firstorder = $instance['firstorder']; if ($date != 0) { $date = self::get_calculated_date($date); $whrOptn['post_date'] = $date; } $whrOptn['post_type'] = $posttype; $whrOptn['form_id'] = $form_id; //added from v3.2.20 $whrOptn['user_id'] = $user_id; $whrOptn['form_id'] = $form_id; //added from v3.2.20 $whrOptn['post_id'] = $post_id; $whrOptn['post_filter'] = $post_filter; //added from v3.2.20 $whrOptn['order'] = $order; //added from v3.2.20 $whrOptn['firstorder'] = $firstorder; $data = CBRatingSystemData::get_top_rated_post($whrOptn, false, $limit); $title = empty($options['widget_title']) ? __('Top Rated Posts', 'cbratingsystem') : $instance['widget_title']; $title = apply_filters('widget_title', $instance['title']); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="cbrp-top-rated-wpanel" style=""> <?php if (!empty($data)) { ?> <!-- <td style=""> <?php /*echo 'Name'; */ ?> </td> <td style=""> <?php /*echo 'Post '; */ ?> </td> <td style=""> <?php /*echo 'Rating'; */ ?> </td> --> <?php foreach ($data as $newdata) { ?> <li> <?php $author_info = get_userdata((int) $newdata['post_author']); ?> <div style=""> <a style="" href="<?php echo get_author_posts_url((int) $newdata['post_author']); ?> "><?php echo $author_info->display_name; ?> </a></div> <div style=""> <?php echo $newdata['post_count']; ?> Posts</div> <?php $rating = $newdata['rating'] / 100 * 5; ?> <script> jQuery(document).ready(function ($) { $('#cbrp-top-rated<?php echo $newdata['post_author'] . '_' . $widget_id; ?> ').raty({ half : true, path : '<?php echo CB_RATINGSYSTEM_PLUGIN_DIR_IMG; ?> ', score : <?php echo number_format($rating, 2, '.', ''); ?> , readOnly: true, hintList: ['', '', '', '', ''] }); }); </script> <?php echo "<strong>" . number_format($rating, 2, '.', '') . "/5</strong> "; ?> <div id ="cbrp-top-rated<?php echo $newdata['post_author'] . '_' . $widget_id; ?> " style=""></div> </li> <?php } ?> <?php } else { ?> <li><?php _e('No Results found', 'cbratingsystem'); ?> </li> <?php } ?> </ul> <?php echo $after_widget; }