Changeset 6334
- Timestamp:
- 03/01/2017 02:17:21 AM (8 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/metaboxes.php
r6273 r6334 669 669 670 670 /** 671 * See who engaged with a topic 672 * 673 * @since 2.6.0 bbPress (r6333) 674 */ 675 function 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 /** 671 706 * See who marked a topic as a favorite 672 707 * 673 708 * @since 2.6.0 bbPress (r6197) 709 * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query 674 710 */ 675 711 function bbp_topic_favorites_metabox( $post ) { … … 681 717 ?><p><?php 682 718 719 // Relationships 720 $args = array( 721 'include' => $user_ids 722 ); 723 683 724 // Users were found 684 if ( ! empty( $user_ids ) ) :685 686 foreach ( $user_ids as $user_id ) :687 echo get_avatar( $user_id, 32 );688 end foreach;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; 689 730 690 731 // No users … … 702 743 * 703 744 * @since 2.6.0 bbPress (r6197) 745 * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query 704 746 */ 705 747 function bbp_topic_subscriptions_metabox( $post ) { … … 711 753 ?><p><?php 712 754 755 // Relationships 756 $args = array( 757 'include' => $user_ids 758 ); 759 713 760 // Users were found 714 if ( ! empty( $user_ids ) ) :715 716 foreach ( $user_ids as $user_id ) :717 echo get_avatar( $user_id, 32 );718 end foreach;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; 719 766 720 767 // No users … … 732 779 * 733 780 * @since 2.6.0 bbPress (r6197) 781 * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query 734 782 */ 735 783 function bbp_forum_subscriptions_metabox( $post ) { … … 741 789 ?><p><?php 742 790 791 // Relationships 792 $args = array( 793 'include' => $user_ids 794 ); 795 743 796 // Users were found 744 if ( ! empty( $user_ids ) ) :745 746 foreach ( $user_ids as $user_id ) :747 echo get_avatar( $user_id, 32 );748 end foreach;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; 749 802 750 803 // No users -
trunk/src/includes/admin/topics.php
r6312 r6334 81 81 add_action( 'add_meta_boxes', array( $this, 'author_metabox' ) ); 82 82 add_action( 'add_meta_boxes', array( $this, 'replies_metabox' ) ); 83 add_action( 'add_meta_boxes', array( $this, 'engagements_metabox' ) ); 83 84 add_action( 'add_meta_boxes', array( $this, 'favorites_metabox' ) ); 84 85 add_action( 'add_meta_boxes', array( $this, 'subscriptions_metabox' ) ); … … 408 409 'normal', 409 410 'high' 411 ); 412 } 413 414 /** 415 * Add the engagements meta-box 416 * 417 * Allows viewing of users who have engaged in a topic. 418 * 419 * @since 2.6.0 bbPress (r6333) 420 * 421 * @uses add_meta_box() To add the meta-box 422 */ 423 public function engagements_metabox() { 424 425 // Bail when creating a new topic 426 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) { 427 return; 428 } 429 430 // Bail if no engagements 431 if ( ! bbp_is_engagements_active() ) { 432 return; 433 } 434 435 // Add the meta-box 436 add_meta_box( 437 'bbp_topic_engagements_metabox', 438 __( 'Engagements', 'bbpress' ), 439 'bbp_topic_engagements_metabox', 440 $this->post_type, 441 'side', 442 'low' 410 443 ); 411 444 } -
trunk/src/includes/users/template.php
r6332 r6334 57 57 58 58 /** 59 * Set up the next user and iterate current user index.59 * PHP5 constructor. 60 60 * 61 61 * @since 2.6.0 bbPress (r6330) 62 62 * @access public 63 63 * 64 * @param null|string|array $query Optional. The query variables. 65 */ 66 public function __construct( $query = null ) { 67 if ( ! empty( $query ) ) { 68 parent::__construct( $query ); 69 $this->user_count = count( $this->results ); 70 } 71 } 72 73 /** 74 * Set up the next user and iterate current user index. 75 * 76 * @since 2.6.0 bbPress (r6330) 77 * @access public 78 * 64 79 * @return WP_User Next user. 65 80 */ 66 81 public function next_user() { 67 68 82 $this->current_user++; 69 70 $this->user = $this->users[ $this->current_user ]; 83 $this->user = $this->results[ $this->current_user ]; 71 84 72 85 return $this->user; … … 89 102 // loop has just started 90 103 if ( $this->current_user === -1 ) { 104 91 105 /** 92 106 * Fires once the loop is started. 93 107 * 94 * @since 2.6.0 bbPress 108 * @since 2.6.0 bbPress (r6330) 95 109 * 96 110 * @param WP_Query &$this The WP_Query instance (passed by reference). … … 99 113 } 100 114 101 $this-> user = $this->next_user();115 $this->next_user(); 102 116 } 103 117 … … 120 134 * Fires once the loop has ended. 121 135 * 122 * @since 2. 0.0136 * @since 2.6.0 bbPress (r6330) 123 137 * 124 138 * @param WP_Query &$this The WP_Query instance (passed by reference). … … 145 159 146 160 if ( $this->user_count > 0 ) { 147 $this->user = $this-> users[ 0 ];161 $this->user = $this->results[ 0 ]; 148 162 } 149 163 } … … 190 204 */ 191 205 function bbp_users() { 192 return bbpress()->user_query->have_users(); ;206 return bbpress()->user_query->have_users(); 193 207 } 194 208 … … 238 252 if ( ! empty( $user_id ) && is_numeric( $user_id ) ) { 239 253 $bbp_user_id = $user_id; 254 255 // Currently inside a user loop 256 } elseif ( ! empty( $bbp->user_query->in_the_loop ) && isset( $bbp->user_query->user->ID ) ) { 257 $bbp_user_id = $bbp->user_query->user->ID; 240 258 241 259 // Currently viewing or editing a user
Note: See TracChangeset
for help on using the changeset viewer.