Changeset 12749
- Timestamp:
- 10/11/2020 01:14:24 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gruntfile.js
r12746 r12749 35 35 '!bp-core/admin/css/hello.css', 36 36 '!bp-members/css/blocks/member.css', 37 '!bp-groups/css/blocks/group.css' 37 '!bp-groups/css/blocks/group.css', 38 '!bp-members/css/blocks/members.css', 39 '!bp-groups/css/blocks/groups.css' 38 40 ], 39 41 -
trunk/src/bp-groups/bp-groups-blocks.php
r12580 r12749 202 202 return apply_filters( 'bp_groups_render_group_block_output', $output, $group, $params ); 203 203 } 204 205 /** 206 * Callback function to render the BP Groups Block. 207 * 208 * @since 7.0.0 209 * 210 * @param array $attributes The block attributes. 211 * @return string HTML output. 212 */ 213 function bp_groups_render_groups_block( $attributes = array() ) { 214 $bp = buddypress(); 215 216 $block_args = wp_parse_args( 217 $attributes, 218 array( 219 'itemIDs' => array(), 220 'avatarSize' => 'full', 221 'displayGroupName' => true, 222 'extraInfo' => 'none', 223 'layoutPreference' => 'list', 224 'columns' => '2', 225 ) 226 ); 227 228 $group_ids = wp_parse_id_list( $block_args['itemIDs'] ); 229 if ( ! array_filter( $group_ids ) ) { 230 return ''; 231 } 232 233 $container_classes = sprintf( 'bp-block-groups avatar-%s', $block_args['avatarSize'] ); 234 if ( 'grid' === $block_args['layoutPreference'] ) { 235 $container_classes .= sprintf( ' is-grid columns-%d', (int) $block_args['columns'] ); 236 } 237 238 $query = groups_get_groups( 239 array( 240 'include' => $group_ids, 241 ) 242 ); 243 244 // Initialize the output and the groups. 245 $output = ''; 246 $groups = $query['groups']; 247 248 foreach ( $groups as $group ) { 249 $has_description = false; 250 $group_item_classes = 'group-content'; 251 252 if ( 'list' === $block_args['layoutPreference'] && 'description' === $block_args['extraInfo'] && isset( $group->description ) && $group->description ) { 253 $has_description = true; 254 $group_item_classes = 'group-content has-description'; 255 } 256 257 $output .= sprintf( '<div class="%s">', $group_item_classes ); 258 259 // Get Member link. 260 $group_link = bp_get_group_permalink( $group ); 261 262 // Set the Avatar output. 263 if ( $bp->avatar && $bp->avatar->show_avatars && ! bp_disable_group_avatar_uploads() && 'none' !== $block_args['avatarSize'] ) { 264 $output .= sprintf( 265 '<div class="item-header-avatar"> 266 <a href="%1$s"> 267 <img class="avatar" alt="%2$s" src="%3$s" /> 268 </a> 269 </div>', 270 esc_url( $group_link ), 271 /* translators: %s: the group's name */ 272 sprintf( esc_attr__( 'Profile photo of %s', 'buddypress' ), $group->display_name ), 273 esc_url( 274 bp_core_fetch_avatar( 275 array( 276 'item_id' => $group->id, 277 'object' => 'group', 278 'type' => $block_args['avatarSize'], 279 'html' => false, 280 ) 281 ) 282 ) 283 ); 284 } 285 286 $output .= '<div class="group-description">'; 287 288 if ( $block_args['displayGroupName'] ) { 289 $output .= sprintf( 290 '<strong><a href="%1$s">%2$s</a></strong>', 291 esc_url( $group_link ), 292 esc_html( $group->name ) 293 ); 294 } 295 296 // Add the latest activity the group posted. 297 if ( $has_description && $group->description ) { 298 $output .= sprintf( 299 '<div class="group-description-content">%s</div>', 300 bp_get_group_description( $group ) 301 ); 302 } elseif ( 'active' === $block_args['extraInfo'] ) { 303 $output .= sprintf( 304 '<time datetime="%1$s">%2$s</time>', 305 esc_attr( bp_core_get_iso8601_date( $group->last_activity ) ), 306 /* translators: %s: a human time diff. */ 307 sprintf( esc_html__( 'Active %s', 'buddypress' ), bp_get_group_last_active( $group ) ) 308 ); 309 } elseif ( 'popular' === $block_args['extraInfo'] ) { 310 $total_member_count = $group->total_member_count; 311 312 $output .= sprintf( 313 '<div class="group-meta">%s</div>', 314 /* translators: %d: the number of group members. */ 315 esc_html( sprintf( _n( '%d member', '%d members', $total_member_count, 'buddypress' ), $total_member_count ) ) 316 ); 317 } 318 319 $output .= '</div></div>'; 320 } 321 322 // Set the final output. 323 $output = sprintf( '<div class="%1$s">%2$s</div>', $container_classes, $output ); 324 325 /** 326 * Filter here to edit the output of the groups block. 327 * 328 * @since 7.0.0 329 * 330 * @param string $output The HTML output of the block. 331 * @param array $block_args The block arguments. 332 * @param array $groups The list of BP_Groups_Group objects. 333 */ 334 return apply_filters( 'bp_groups_render_groups_block_output', $output, $block_args, $groups ); 335 } -
trunk/src/bp-groups/classes/class-bp-groups-component.php
r12731 r12749 1011 1011 ), 1012 1012 ), 1013 'bp/groups' => array( 1014 'name' => 'bp/groups', 1015 'editor_script' => 'bp-groups-block', 1016 'editor_script_url' => plugins_url( 'js/blocks/groups.js', dirname( __FILE__ ) ), 1017 'editor_script_deps' => array( 1018 'wp-blocks', 1019 'wp-element', 1020 'wp-components', 1021 'wp-i18n', 1022 'wp-compose', 1023 'wp-data', 1024 'wp-api-fetch', 1025 'wp-url', 1026 'wp-block-editor', 1027 'bp-block-components', 1028 'lodash', 1029 ), 1030 'style' => 'bp-groups-block', 1031 'style_url' => plugins_url( 'css/blocks/groups.css', dirname( __FILE__ ) ), 1032 'attributes' => array( 1033 'itemIDs' => array( 1034 'type' => 'array', 1035 'items' => array( 1036 'type' => 'integer', 1037 ), 1038 ), 1039 'avatarSize' => array( 1040 'type' => 'string', 1041 'default' => 'full', 1042 ), 1043 'displayGroupName' => array( 1044 'type' => 'boolean', 1045 'default' => true, 1046 ), 1047 'extraInfo' => array( 1048 'type' => 'string', 1049 'default' => 'none', 1050 'enum' => array( 'description', 'popular', 'active', 'none' ), 1051 ), 1052 'layoutPreference' => array( 1053 'type' => 'string', 1054 'default' => 'list', 1055 'enum' => array( 'list', 'grid' ), 1056 ), 1057 'columns' => array( 1058 'type' => 'number', 1059 'default' => 2, 1060 ), 1061 ), 1062 'render_callback' => 'bp_groups_render_groups_block', 1063 ), 1013 1064 ) 1014 1065 );
Note: See TracChangeset
for help on using the changeset viewer.