Esempio n. 1
0
    /**
     * Renders the widget on the front end
     *
     * @package BP Group Reviews
     * @since 1.2
     */
    function widget($args, $instance)
    {
        global $bp, $wpdb, $groups_template;
        extract($args);
        $title = esc_attr($instance['title']);
        $number = empty($instance['number']) ? 3 : (int) $instance['number'];
        $sql = apply_filters('bpgr_groups_data_sql', $wpdb->prepare("\n\t\tSELECT m1.group_id, m1.meta_value AS rating, m2.meta_value AS rating_count  \n\t\tFROM {$bp->groups->table_name_groupmeta} m1 \n\t\tLEFT JOIN {$bp->groups->table_name_groupmeta} m2 ON (m1.group_id = m2.group_id) \n\t\tWHERE m1.meta_key = 'bpgr_rating'\n\t\tAND m2.meta_key = 'bpgr_how_many_ratings'\n\t\tORDER BY rating DESC\n\t\tLIMIT 0, %d", $number));
        $ratings = $wpdb->get_results($sql, ARRAY_A);
        echo $before_widget;
        echo $before_title . $title . $after_title;
        echo '<ul class="item-list">';
        foreach ($ratings as $rating) {
            $group = new BP_Groups_Group($rating['group_id']);
            $groups_template->group = $group;
            ?>
			<li>
			 <a href="<?php 
            bp_group_permalink();
            ?>
"><?php 
            bp_group_avatar_mini();
            ?>
</a>
			 <a href="<?php 
            bp_group_permalink();
            ?>
"><?php 
            bp_group_name();
            ?>
</a>
			 <span><?php 
            echo bpgr_get_plugin_rating_html($rating['rating'], $rating['rating_count']);
            ?>
</span>
			 </li>
			<?php 
        }
        echo "</ul>";
        echo $after_widget;
    }
Esempio n. 2
0
function bpgr_directory_rating()
{
    global $groups_template;
    // Don't show if the group has ratings turned off
    if (empty($groups_template->group->ratings_enabled) || 'yes' != $groups_template->group->ratings_enabled) {
        return;
    }
    // Don't show if there are no ratings
    if (empty($groups_template->group->rating) || empty($groups_template->group->rating_count)) {
        return;
    }
    echo bpgr_get_plugin_rating_html($groups_template->group->rating, $groups_template->group->rating_count);
}