Ticket #7312: group-member-friend-widget.patch
File group-member-friend-widget.patch, 17.4 KB (added by , 8 years ago) |
---|
-
bp-friends/bp-friends-widgets.php
46 46 47 47 check_ajax_referer( 'bp_core_widget_friends' ); 48 48 49 switch ( $_POST['filter'] ) { 49 switch ( $_POST['filter'] ) { 50 case 'alphabetical-friends': 51 $type = 'alphabetical'; 52 break; 53 50 54 case 'newest-friends': 51 55 $type = 'newest'; 52 56 break; -
bp-friends/classes/class-bp-core-friends-widget.php
94 94 'max' => absint( $instance['max_friends'] ), 95 95 'populate_extras' => 1, 96 96 ); 97 97 $show_sort = ! empty( $instance['show_sort'] ) ? true : (bool)$instance['show_sort']; 98 $show_meta = ! empty( $instance['show_meta'] ) ? true : (bool)$instance['show_meta']; 99 98 100 // Back up the global. 99 101 $old_members_template = $members_template; 100 102 … … 101 103 ?> 102 104 103 105 <?php if ( bp_has_members( $members_args ) ) : ?> 106 <?php if ( $show_sort ) : ?> 104 107 <div class="item-options" id="friends-list-options"> 105 108 <a href="<?php bp_members_directory_permalink(); ?>" id="newest-friends" <?php if ( $instance['friend_default'] == 'newest' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ); ?></a> 106 109 | <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-friends" <?php if ( $instance['friend_default'] == 'active' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ); ?></a> 107 110 | <a href="<?php bp_members_directory_permalink(); ?>" id="popular-friends" <?php if ( $instance['friend_default'] == 'popular' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ); ?></a> 111 | <a href="<?php bp_members_directory_permalink(); ?>" id="alphabetical-friends" <?php if ( $instance['friend_default'] == 'alphabetical' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Alphabetical', 'buddypress' ); ?></a> 108 112 </div> 113 <?php endif; ?> 109 114 110 115 <ul id="friends-list" class="item-list"> 111 116 <?php while ( bp_members() ) : bp_the_member(); ?> … … 116 121 117 122 <div class="item"> 118 123 <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>" title="<?php bp_member_name(); ?>"><?php bp_member_name(); ?></a></div> 124 <?php if ($show_meta) : ?> 119 125 <div class="item-meta"> 120 126 <?php if ( 'newest' == $instance['friend_default'] ) : ?> 121 127 <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span> … … 125 131 <span class="activity"><?php bp_member_total_friend_count(); ?></span> 126 132 <?php endif; ?> 127 133 </div> 134 <?php endif; ?> 128 135 </div> 129 136 </li> 130 137 … … 162 169 $instance['max_friends'] = absint( $new_instance['max_friends'] ); 163 170 $instance['friend_default'] = sanitize_text_field( $new_instance['friend_default'] ); 164 171 $instance['link_title'] = (bool) $new_instance['link_title']; 165 172 $instance['show_sort'] = (bool) $new_instance['show_sort']; 173 $instance['show_meta'] = (bool) $new_instance['show_meta']; 166 174 return $instance; 167 175 } 168 176 … … 178 186 $defaults = array( 179 187 'max_friends' => 5, 180 188 'friend_default' => 'active', 181 'link_title' => false 189 'link_title' => false, 190 'show_sort' => true, 191 'show_meta' => true 182 192 ); 183 193 $instance = wp_parse_args( (array) $instance, $defaults ); 184 194 … … 185 195 $max_friends = $instance['max_friends']; 186 196 $friend_default = $instance['friend_default']; 187 197 $link_title = (bool) $instance['link_title']; 198 $show_sort = (bool) $instance['show_sort']; 199 $show_meta = (bool) $instance['show_meta']; 188 200 ?> 189 201 190 202 <p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title'); ?>" id="<?php echo $this->get_field_id( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Members directory', 'buddypress' ); ?></label></p> … … 196 208 <select name="<?php echo $this->get_field_name( 'friend_default' ); ?>" id="<?php echo $this->get_field_id( 'friend_default' ); ?>"> 197 209 <option value="newest" <?php selected( $friend_default, 'newest' ); ?>><?php _e( 'Newest', 'buddypress' ); ?></option> 198 210 <option value="active" <?php selected( $friend_default, 'active' );?>><?php _e( 'Active', 'buddypress' ); ?></option> 199 <option value="popular" <?php selected( $friend_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ); ?></option> 211 <option value="popular" <?php selected( $friend_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ); ?></option> 212 <option value="alphabetical" <?php selected( $friend_default, 'alphabetical' ); ?>><?php _e( 'Alphabetical', 'buddypress' ); ?></option> 200 213 </select> 201 214 </p> 215 <p><label for="<?php echo $this->get_field_id('show_sort') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('show_sort') ?>" id="<?php echo $this->get_field_id('show_sort') ?>" value="1" <?php checked( $show_sort ) ?> /> <?php _e( 'Show the sorting of the friends', 'buddypress' ) ?></label></p> 216 <p><label for="<?php echo $this->get_field_id('show_meta') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('show_meta') ?>" id="<?php echo $this->get_field_id('show_meta') ?>" value="1" <?php checked( $show_meta ) ?> /> <?php _e( 'Show the meta information of the friends', 'buddypress' ) ?></label></p> 202 217 203 218 <?php 204 219 } -
bp-groups/bp-groups-widgets.php
34 34 check_ajax_referer( 'groups_widget_groups_list' ); 35 35 36 36 switch ( $_POST['filter'] ) { 37 case 'alphabetical-groups': 38 $type = 'alphabetical'; 39 break; 37 40 case 'newest-groups': 38 41 $type = 'newest'; 39 42 break; -
bp-groups/classes/class-bp-groups-widget.php
110 110 'per_page' => $max_groups, 111 111 'max' => $max_groups, 112 112 ); 113 $show_groupsort = ! empty( $instance['show_groupsort'] ) ? true : (bool)$instance['show_groupsort']; 114 $show_meta = ! empty( $instance['show_meta'] ) ? true : (bool)$instance['show_meta']; 113 115 114 116 // Back up the global. 115 117 $old_groups_template = $groups_template; … … 117 119 ?> 118 120 119 121 <?php if ( bp_has_groups( $group_args ) ) : ?> 122 <?php if ( $show_groupsort ) : ?> 120 123 <div class="item-options" id="groups-list-options"> 121 124 <a href="<?php bp_groups_directory_permalink(); ?>" id="newest-groups"<?php if ( $instance['group_default'] == 'newest' ) : ?> class="selected"<?php endif; ?>><?php _e("Newest", 'buddypress') ?></a> 122 125 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span> … … 123 126 <a href="<?php bp_groups_directory_permalink(); ?>" id="recently-active-groups"<?php if ( $instance['group_default'] == 'active' ) : ?> class="selected"<?php endif; ?>><?php _e("Active", 'buddypress') ?></a> 124 127 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span> 125 128 <a href="<?php bp_groups_directory_permalink(); ?>" id="popular-groups" <?php if ( $instance['group_default'] == 'popular' ) : ?> class="selected"<?php endif; ?>><?php _e("Popular", 'buddypress') ?></a> 129 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span> 130 <a href="<?php bp_groups_directory_permalink(); ?>" id="alphabetical-groups" <?php if ( $instance['group_default'] == 'alphabetical' ) : ?> class="selected"<?php endif; ?>><?php _e("Alphabetical", 'buddypress') ?></a> 126 131 </div> 132 <?php endif; ?> 127 133 128 134 <ul id="groups-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true"> 129 135 <?php while ( bp_groups() ) : bp_the_group(); ?> … … 134 140 135 141 <div class="item"> 136 142 <div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div> 143 <?php if ($show_meta) : ?> 137 144 <div class="item-meta"> 138 145 <span class="activity"> 139 146 <?php … … 147 154 ?> 148 155 </span> 149 156 </div> 157 <?php endif; ?> 150 158 </div> 151 159 </li> 152 160 … … 185 193 $instance['max_groups'] = strip_tags( $new_instance['max_groups'] ); 186 194 $instance['group_default'] = strip_tags( $new_instance['group_default'] ); 187 195 $instance['link_title'] = (bool) $new_instance['link_title']; 188 196 $instance['show_groupsort']= (bool) $new_instance['show_groupsort']; 197 $instance['show_meta'] = (bool) $new_instance['show_meta']; 198 189 199 return $instance; 190 200 } 191 201 … … 202 212 'title' => __( 'Groups', 'buddypress' ), 203 213 'max_groups' => 5, 204 214 'group_default' => 'active', 205 'link_title' => false 215 'link_title' => false, 216 'show_groupsort'=> true, 217 'show_meta' => true 206 218 ); 207 219 $instance = wp_parse_args( (array) $instance, $defaults ); 208 220 … … 210 222 $max_groups = strip_tags( $instance['max_groups'] ); 211 223 $group_default = strip_tags( $instance['group_default'] ); 212 224 $link_title = (bool) $instance['link_title']; 225 $show_groupsort = (bool) $instance['show_groupsort']; 226 $show_meta = (bool) $instance['show_meta']; 213 227 ?> 214 228 215 229 <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> … … 223 237 <select name="<?php echo $this->get_field_name( 'group_default' ); ?>" id="<?php echo $this->get_field_id( 'group_default' ); ?>"> 224 238 <option value="newest" <?php selected( $group_default, 'newest' ); ?>><?php _e( 'Newest', 'buddypress' ) ?></option> 225 239 <option value="active" <?php selected( $group_default, 'active' ); ?>><?php _e( 'Active', 'buddypress' ) ?></option> 226 <option value="popular" <?php selected( $group_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ) ?></option> 240 <option value="popular" <?php selected( $group_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ) ?></option> 241 <option value="alphabetical" <?php selected( $group_default, 'alphabetical' ); ?>><?php _e( 'Alphabetical', 'buddypress' ) ?></option> 227 242 </select> 228 243 </p> 244 <p><label for="<?php echo $this->get_field_id('show_groupsort') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('show_groupsort') ?>" id="<?php echo $this->get_field_id('show_groupsort') ?>" value="1" <?php checked( $show_groupsort ) ?> /> <?php _e( 'Show the sorting of the groups', 'buddypress' ) ?></label></p> 245 <p><label for="<?php echo $this->get_field_id('show_meta') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('show_meta') ?>" id="<?php echo $this->get_field_id('show_meta') ?>" value="1" <?php checked( $show_meta ) ?> /> <?php _e( 'Show the meta information of the group', 'buddypress' ) ?></label></p> 229 246 <?php 230 247 } 231 248 } -
bp-members/bp-members-widgets.php
48 48 // Determine the type of members query to perform. 49 49 switch ( $filter ) { 50 50 51 // Alphabetical activated. 52 case 'alphabetical-members' : 53 $type = 'alphabetical'; 54 break; 55 51 56 // Newest activated. 52 57 case 'newest-members' : 53 58 $type = 'newest'; -
bp-members/classes/class-bp-core-members-widget.php
26 26 27 27 // Setup widget name & description. 28 28 $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ); 29 $description = __( 'A dynamic list of recently a ctive, popular, and newest members', 'buddypress' );29 $description = __( 'A dynamic list of recently alphabetical, active, popular, and newest members', 'buddypress' ); 30 30 31 31 // Call WP_Widget constructor. 32 32 parent::__construct( false, $name, array( … … 99 99 'populate_extras' => true, 100 100 'search_terms' => false, 101 101 ); 102 $show_sort = ! empty( $instance['show_sort'] ) ? true : (bool)$instance['show_sort']; 103 $show_meta = ! empty( $instance['show_meta'] ) ? true : (bool)$instance['show_meta']; 102 104 103 105 // Back up the global. 104 106 $old_members_template = $members_template; … … 106 108 ?> 107 109 108 110 <?php if ( bp_has_members( $members_args ) ) : ?> 109 111 <?php if ( $show_sort ) : ?> 110 112 <div class="item-options" id="members-list-options"> 111 113 <a href="<?php bp_members_directory_permalink(); ?>" id="newest-members" <?php if ( 'newest' === $settings['member_default'] ) : ?>class="selected"<?php endif; ?>><?php esc_html_e( 'Newest', 'buddypress' ); ?></a> 112 114 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span> … … 117 119 <a href="<?php bp_members_directory_permalink(); ?>" id="popular-members" <?php if ( 'popular' === $settings['member_default'] ) : ?>class="selected"<?php endif; ?>><?php esc_html_e( 'Popular', 'buddypress' ); ?></a> 118 120 119 121 <?php endif; ?> 120 122 123 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span> 124 <a href="<?php bp_members_directory_permalink(); ?>" id="alphabetical-members" <?php if ( 'alphabetical' === $settings['member_default'] ) : ?>class="selected"<?php endif; ?>><?php esc_html_e( 'Alphabetical', 'buddypress' ); ?></a> 121 125 </div> 122 126 <?php endif; ?> 127 123 128 <ul id="members-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true"> 124 129 125 130 <?php while ( bp_members() ) : bp_the_member(); ?> … … 131 136 132 137 <div class="item"> 133 138 <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>" title="<?php bp_member_name(); ?>"><?php bp_member_name(); ?></a></div> 139 <?php if ($show_meta) : ?> 134 140 <div class="item-meta"> 135 141 <?php if ( 'newest' == $settings['member_default'] ) : ?> 136 142 <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span> … … 140 146 <span class="activity"><?php bp_member_total_friend_count(); ?></span> 141 147 <?php endif; ?> 142 148 </div> 149 <?php endif; ?> 143 150 </div> 144 151 </li> 145 152 … … 181 188 $instance['max_members'] = strip_tags( $new_instance['max_members'] ); 182 189 $instance['member_default'] = strip_tags( $new_instance['member_default'] ); 183 190 $instance['link_title'] = (bool) $new_instance['link_title']; 191 $instance['show_sort'] = (bool) $new_instance['show_sort']; 192 $instance['show_meta'] = (bool) $new_instance['show_meta']; 184 193 185 194 return $instance; 186 195 } … … 200 209 $title = strip_tags( $settings['title'] ); 201 210 $max_members = strip_tags( $settings['max_members'] ); 202 211 $member_default = strip_tags( $settings['member_default'] ); 203 $link_title = (bool) $settings['link_title']; ?> 212 $link_title = (bool) $settings['link_title']; 213 $show_sort = (bool) $instance['show_sort']; 214 $show_meta = (bool) $instance['show_meta']; ?> 204 215 205 216 <p> 206 217 <label for="<?php echo $this->get_field_id( 'title' ); ?>"> … … 229 240 <option value="newest" <?php if ( 'newest' === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Newest', 'buddypress' ); ?></option> 230 241 <option value="active" <?php if ( 'active' === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></option> 231 242 <option value="popular" <?php if ( 'popular' === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Popular', 'buddypress' ); ?></option> 243 <option value="alphabetical" <?php if ( 'alphabetical' === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Alphabetical', 'buddypress' ); ?></option> 232 244 </select> 233 245 </p> 246 <p><label for="<?php echo $this->get_field_id('show_sort') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('show_sort') ?>" id="<?php echo $this->get_field_id('show_sort') ?>" value="1" <?php checked( $show_sort ) ?> /> <?php _e( 'Show the sorting of the members', 'buddypress' ) ?></label></p> 247 <p><label for="<?php echo $this->get_field_id('show_meta') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('show_meta') ?>" id="<?php echo $this->get_field_id('show_meta') ?>" value="1" <?php checked( $show_meta ) ?> /> <?php _e( 'Show the meta information of the members', 'buddypress' ) ?></label></p> 234 248 235 249 <?php 236 250 } … … 249 263 'title' => __( 'Members', 'buddypress' ), 250 264 'max_members' => 5, 251 265 'member_default' => 'active', 252 'link_title' => false 266 'link_title' => false, 267 'show_sort' => true, 268 'show_meta' => true 253 269 ), 'members_widget_settings' ); 254 270 } 255 271 }