Ticket #6721: 6721.patch
File 6721.patch, 6.2 KB (added by , 9 years ago) |
---|
-
src/bp-groups/bp-groups-widgets.php
26 26 /** 27 27 * Working as a group, we get things done better. 28 28 */ 29 function __construct() {29 public function __construct() { 30 30 $widget_ops = array( 31 31 'description' => __( 'A dynamic list of recently active, popular, and newest groups', 'buddypress' ), 32 32 'classname' => 'widget_bp_groups_widget buddypress widget', … … 33 33 ); 34 34 parent::__construct( false, _x( '(BuddyPress) Groups', 'widget name', 'buddypress' ), $widget_ops ); 35 35 36 if ( is_active_widget( false, false, $this->id_base ) && ! is_admin() && !is_network_admin() ) {36 if ( is_active_widget( false, false, $this->id_base ) && ! is_admin() && ! is_network_admin() ) { 37 37 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 38 38 wp_enqueue_script( 'groups_widget_groups_list-js', buddypress()->plugin_url . "bp-groups/js/widget-groups{$min}.js", array( 'jquery' ), bp_get_version() ); 39 39 } … … 40 40 } 41 41 42 42 /** 43 * PHP4 constructor44 *45 * For backward compatibility only46 */47 function bp_groups_widget() {48 $this->_construct();49 }50 51 /**52 43 * Extends our frontend output method. 53 44 * 54 45 * @param array $args Array of arguments for the widget. 55 46 * @param array $instance Widget instance data. 56 47 */ 57 function widget( $args, $instance ) {48 public function widget( $args, $instance ) { 58 49 59 50 /** 60 51 * Filters the user ID to use with the widget instance. … … 67 58 68 59 extract( $args ); 69 60 70 if ( empty( $instance['group_default'] ) ) 61 if ( empty( $instance['group_default'] ) ) { 71 62 $instance['group_default'] = 'popular'; 63 } 72 64 73 if ( empty( $instance['title'] ) ) 65 if ( empty( $instance['title'] ) ) { 74 66 $instance['title'] = __( 'Groups', 'buddypress' ); 75 67 } 68 76 69 /** 77 70 * Filters the title of the Groups widget. 78 71 * … … 96 89 97 90 echo $before_widget; 98 91 99 $title = ! empty( $instance['link_title'] ) ? '<a href="' . bp_get_groups_directory_permalink() . '">' . $title . '</a>' : $title;92 $title = ! empty( $instance['link_title'] ) ? '<a href="' . bp_get_groups_directory_permalink() . '">' . $title . '</a>' : $title; 100 93 101 94 echo $before_title . $title . $after_title; 102 95 … … 132 125 <div class="item-meta"> 133 126 <span class="activity"> 134 127 <?php 135 if ( 'newest' == $instance['group_default'] ) 128 if ( 'newest' == $instance['group_default'] ) { 136 129 printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() ); 137 if ( 'active' == $instance['group_default'] )138 printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); 139 elseif ( 'popular' == $instance['group_default'] )130 } elseif ( 'active' == $instance['group_default'] ) { 131 printf( __( 'active %s', 'buddypress' ), bp_get_group_last_active() ); 132 } elseif ( 'popular' == $instance['group_default'] ) { 140 133 bp_group_member_count(); 134 } 141 135 ?> 142 136 </span> 143 137 </div> … … 168 162 * @param array $old_instance Original instance data. 169 163 * @return array 170 164 */ 171 function update( $new_instance, $old_instance ) {165 public function update( $new_instance, $old_instance ) { 172 166 $instance = $old_instance; 173 167 174 168 $instance['title'] = strip_tags( $new_instance['title'] ); 175 169 $instance['max_groups'] = strip_tags( $new_instance['max_groups'] ); 176 170 $instance['group_default'] = strip_tags( $new_instance['group_default'] ); 177 $instance['link_title'] = (bool) $new_instance['link_title'];171 $instance['link_title'] = (bool) $new_instance['link_title']; 178 172 179 173 return $instance; 180 174 } … … 185 179 * @param array $instance Current instance. 186 180 * @return mixed 187 181 */ 188 function form( $instance ) {182 public function form( $instance ) { 189 183 $defaults = array( 190 184 'title' => __( 'Groups', 'buddypress' ), 191 185 'max_groups' => 5, … … 197 191 $title = strip_tags( $instance['title'] ); 198 192 $max_groups = strip_tags( $instance['max_groups'] ); 199 193 $group_default = strip_tags( $instance['group_default'] ); 200 $link_title = (bool) $instance['link_title'];194 $link_title = (bool) $instance['link_title']; 201 195 ?> 202 196 203 197 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%" /></label></p> … … 209 203 <p> 210 204 <label for="<?php echo $this->get_field_id( 'group_default' ); ?>"><?php _e('Default groups to show:', 'buddypress'); ?></label> 211 205 <select name="<?php echo $this->get_field_name( 'group_default' ); ?>" id="<?php echo $this->get_field_id( 'group_default' ); ?>"> 212 <option value="newest" <?php if ( $group_default == 'newest' ) : ?>selected="selected"<?php endif;?>><?php _e( 'Newest', 'buddypress' ) ?></option>213 <option value="active" <?php if ( $group_default == 'active' ) : ?>selected="selected"<?php endif;?>><?php _e( 'Active', 'buddypress' ) ?></option>214 <option value="popular" <?php if ( $group_default == 'popular' ) : ?>selected="selected"<?php endif;?>><?php _e( 'Popular', 'buddypress' ) ?></option>206 <option value="newest" <?php selected( $group_default, 'newest' );?>><?php _e( 'Newest', 'buddypress' ) ?></option> 207 <option value="active" <?php selected( $group_default, 'active' );?>><?php _e( 'Active', 'buddypress' ) ?></option> 208 <option value="popular" <?php selected( $group_default, 'popular' );?>><?php _e( 'Popular', 'buddypress' ) ?></option> 215 209 </select> 216 210 </p> 217 211 <?php … … 220 214 221 215 function groups_ajax_widget_groups_list() { 222 216 223 check_ajax_referer( 'groups_widget_groups_list');217 check_ajax_referer( 'groups_widget_groups_list' ); 224 218 225 219 switch ( $_POST['filter'] ) { 226 220 case 'newest-groups': … … 275 269 276 270 <?php else: ?> 277 271 278 <?php echo "-1[[SPLIT]]<li>" . __( "No groups matched the current filter.", 'buddypress'); ?>272 <?php echo "-1[[SPLIT]]<li>" . __( "No groups matched the current filter.", 'buddypress' ); ?> 279 273 280 274 <?php endif; 281 275