BP_Email_Tokens::token__group_card( BP_Email $bp_email, array $formatted_tokens, array $tokens )
Generate the output for token group.card
Description
Parameters
- $bp_email
-
(Required)
- $formatted_tokens
-
(Required)
- $tokens
-
(Required)
Return
(string) html for the output
Source
File: bp-core/classes/class-bp-email-tokens.php
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | public function token__group_card( $bp_email , $formatted_tokens , $tokens ) { $output = '' ; $group = isset( $tokens [ 'group' ] ) ? $tokens [ 'group' ] : false; if ( empty ( $group ) ) { $group_id = isset( $tokens [ 'group.id' ] ) ? $tokens [ 'group.id' ] : false; if ( empty ( $group_id ) ) { return $output ; } $group = groups_get_group( $group_id ); } if ( empty ( $group ) ) { return $output ; } ob_start(); ?> <div class = "card_wrapper card_group card_group_small" style= "border-radius: 5px; padding: 10px;" > <table cellspacing= "0" cellpadding= "0" border= "0" width= "100%" > <?php if ( bp_is_active( 'groups' , 'cover_image' ) && ! bp_disable_cover_image_uploads() && bp_attachments_is_wp_version_supported() ) { $cover_image = bp_attachments_get_attachment( 'url' , array ( 'object_dir' => 'groups' , 'item_id' => $group_id , ) ); echo "<tr><td colspan='100%'><img src='{$cover_image}'></td></tr>" ; } ?> <tr> <td> <a href= "<?php echo bp_get_group_permalink( $group ); ?>" style= "border: 1px solid <?php echo esc_attr( $settings['body_border_color'] ); ?>; display: block; border-radius: 3px; width: 100px;" > <img alt= "" src="<?php echo bp_core_fetch_avatar( array ( 'item_id' => $group ->id, 'avatar_dir' => 'group-avatars' , 'object' => 'group' , 'type' => 'full' , 'width' => 200, 'height' => 200, 'html' => false ) ); ?> " width=" 100 " height=" 100" style= "margin:0; padding:0; box-sizing: border-box; border-radius: 3px; border:3px solid <?php echo esc_attr( $settings['body_bg'] ); ?>; display:block;" border= "0" /> </a> </td> <td> <h3><?php echo $group ->name; ?></h3> <div class = "spacer" style= "font-size: 7px; line-height: 7px; height: 7px;" > </div> <?php echo ucfirst( $group ->status ) . " " . __( 'Group' , 'buddyboss' ); ?><br> <table cellspacing= "0" cellpadding= "0" border= "0" width= "100%" > <tr> <td align= "left" > <?php if ( bp_is_active( 'activity' ) ) { global $wpdb ; $activity_table = buddypress()->activity->table_name; $sql = array ( 'select' => "SELECT user_id, max( date_recorded ) as date_recorded FROM {$activity_table}" , 'where' => array (), 'groupby' => 'GROUP BY user_id' , 'orderby' => 'ORDER BY date_recorded' , 'order' => 'DESC' , ); $sql [ 'where' ] = array ( 'item_id = ' . absint( $group ->id ), $wpdb ->prepare( "component = %s" , buddypress()->groups->id ), ); $sql [ 'where' ] = 'WHERE ' . implode( ' AND ' , $sql [ 'where' ] ); $sql [ 'limit' ] = 'LIMIT 4' ; $group_user_ids = $wpdb ->get_results( "{$sql[ 'select' ]} {$sql[ 'where' ]} {$sql[ 'groupby' ]} {$sql[ 'orderby' ]} {$sql[ 'order' ]} {$sql[ 'limit' ]}" ); $group_user_ids = wp_list_pluck( $group_user_ids , 'user_id' ); $output = "<span class='bs-group-members'>" ; foreach ( $group_user_ids as $user_id ) { $avatar = bp_core_fetch_avatar( array ( 'item_id' => $user_id , 'avatar_dir' => 'avatars' , 'object' => 'user' , 'type' => 'full' , 'html' => false ) ); if ( ! empty ( $avatar ) ) { $output .= sprintf( "<img src='%s' alt='%s'>" , $avatar , bp_core_get_user_displayname( $user_id ) ); } } $output .= "</span>" ; $output .= "<span class='members'>" . groups_get_total_member_count( $group ->id ) . " " . __( 'Members' , 'buddyboss' ) . "</span>" ; echo $output ; } ?> </td> <td align= "right" > <a class = "button-primary" href= "<?php echo bp_get_group_permalink( $group ); ?>" > <?php $joined_status = 'unknown' ; $recepients = $bp_email ->get_to(); if ( ! empty ( $recepients ) && count ( $recepients ) === 1 ) { // BP_Email_Recipient $recepient = reset( $recepients ); $user = $recepient ->get_user(); if ( ! empty ( $user ) ) { if ( groups_is_user_member( $user ->ID, $group ->id ) ) { $joined_status = 'joined' ; } else { $joined_status = 'not-joined' ; } } } switch ( $joined_status ) { case 'joined' : _e( 'Leave Group' , 'buddyboss' ); break ; case 'not-joined' : _e( 'Join Group' , 'buddyboss' ); break ; default : _e( 'Visit Group' , 'buddyboss' ); break ; } ?> </a> </td> </tr> </table> </td> </tr> </table> <div class = "spacer" style= "font-size: 10px; line-height: 10px; height: 10px;" > </div> </div> <?php $output = str_replace ( array ( "\r" , "\n" ), '' , ob_get_clean() ); return $output ; } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.