Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/01/2017 02:17:21 AM (7 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Integrate the user_query into favorites, subscriptions, and engagements.

  • Add to admin metabox avatar loops
  • Fix a few bugs in BBP_User_Query, and include a custom constructor to set the loop counter

See #3068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/metaboxes.php

    r6273 r6334  
    669669
    670670/**
     671 * See who engaged with a topic
     672 *
     673 * @since 2.6.0 bbPress (r6333)
     674 */
     675function bbp_topic_engagements_metabox( $post ) {
     676
     677    // Get user IDs
     678    $user_ids = bbp_get_topic_engagements( $post->ID );
     679
     680    // Output
     681    ?><p><?php
     682
     683        // Relationships
     684        $args = array(
     685            'include' => $user_ids
     686        );
     687
     688        // Users were found
     689        if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) :
     690
     691            while ( bbp_users() ) : bbp_the_user();
     692                echo get_avatar( bbp_get_user_id(), 32 );
     693            endwhile;
     694
     695        // No users
     696        else :
     697            esc_html_e( 'No users have engaged to this topic.', 'bbpress' );
     698        endif;
     699
     700    ?></p><?php
     701
     702    do_action( 'bbp_topic_engagements_metabox', $post );
     703}
     704
     705/**
    671706 * See who marked a topic as a favorite
    672707 *
    673708 * @since 2.6.0 bbPress (r6197)
     709 * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query
    674710 */
    675711function bbp_topic_favorites_metabox( $post ) {
     
    681717    ?><p><?php
    682718
     719        // Relationships
     720        $args = array(
     721            'include' => $user_ids
     722        );
     723
    683724        // Users were found
    684         if ( ! empty( $user_ids ) ) :
    685 
    686             foreach ( $user_ids as $user_id ) :
    687                 echo get_avatar( $user_id, 32 );
    688             endforeach;
     725        if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) :
     726
     727            while ( bbp_users() ) : bbp_the_user();
     728                echo get_avatar( bbp_get_user_id(), 32 );
     729            endwhile;
    689730
    690731        // No users
     
    702743 *
    703744 * @since 2.6.0 bbPress (r6197)
     745 * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query
    704746 */
    705747function bbp_topic_subscriptions_metabox( $post ) {
     
    711753    ?><p><?php
    712754
     755        // Relationships
     756        $args = array(
     757            'include' => $user_ids
     758        );
     759
    713760        // Users were found
    714         if ( ! empty( $user_ids ) ) :
    715 
    716             foreach ( $user_ids as $user_id ) :
    717                 echo get_avatar( $user_id, 32 );
    718             endforeach;
     761        if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) :
     762
     763            while ( bbp_users() ) : bbp_the_user();
     764                echo get_avatar( bbp_get_user_id(), 32 );
     765            endwhile;
    719766
    720767        // No users
     
    732779 *
    733780 * @since 2.6.0 bbPress (r6197)
     781 * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query
    734782 */
    735783function bbp_forum_subscriptions_metabox( $post ) {
     
    741789    ?><p><?php
    742790
     791        // Relationships
     792        $args = array(
     793            'include' => $user_ids
     794        );
     795
    743796        // Users were found
    744         if ( ! empty( $user_ids ) ) :
    745 
    746             foreach ( $user_ids as $user_id ) :
    747                 echo get_avatar( $user_id, 32 );
    748             endforeach;
     797        if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) :
     798
     799            while ( bbp_users() ) : bbp_the_user();
     800                echo get_avatar( bbp_get_user_id(), 32 );
     801            endwhile;
    749802
    750803        // No users
Note: See TracChangeset for help on using the changeset viewer.