Skip to:
Content

BuddyPress.org

Changeset 1844


Ignore:
Timestamp:
09/10/2009 06:34:52 PM (16 years ago)
Author:
apeatling
Message:

Added extra filtering on template loops, applies to #980 props jeffsayre.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r1839 r1844  
    162162    else
    163163        bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
     164       
     165    do_action( 'bp_activity_action_delete_activity', $activity_id );
    164166   
    165167    bp_core_redirect( $_SERVER['HTTP_REFERER'] );
     
    334336    }
    335337
    336     return $content;
     338    return apply_filters( 'bp_activity_add_timesince_placeholder', $content );
    337339}
    338340
     
    341343    $content = bp_activity_add_timesince_placeholder( $content );
    342344
    343     return BP_Activity_Activity::check_exists_by_content( $content );
     345    return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
    344346}
    345347
    346348function bp_activity_get_last_updated() {
    347     return BP_Activity_Activity::get_last_updated();
     349    return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
    348350}
    349351
    350352function bp_activity_get_sitewide_activity( $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) {
    351     return BP_Activity_Activity::get_sitewide_activity( $max_items, $pag_num, $pag_page, $filter );
     353    return apply_filters( 'bp_activity_get_sitewide_activity', BP_Activity_Activity::get_sitewide_activity( $max_items, $pag_num, $pag_page, $filter ), $max_items, $pag_num, $pag_page, $filter );
    352354}
    353355
    354356function bp_activity_get_user_activity( $user_id, $max_items = 30, $pag_num = false, $pag_page = false, $filter = false ) {
    355     return BP_Activity_Activity::get_activity_for_user( $user_id, $max_items, $pag_num, $pag_page, $filter );
     357    return apply_filters( 'bp_activity_get_user_activity', BP_Activity_Activity::get_activity_for_user( $user_id, $max_items, $pag_num, $pag_page, $filter ), $user_id, $max_items, $pag_num, $pag_page, $filter );
    356358}
    357359
    358360function bp_activity_get_friends_activity( $user_id, $max_items = 30, $max_items_per_friend = false, $pag_num = false, $pag_page = false, $filter = false ) {
    359     return BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter );
     361    return apply_filters( 'bp_activity_get_friends_activity', BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter ), $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter );
    360362}
    361363
     
    372374/* Ordering function - don't call this directly */
    373375function bp_activity_order_by_date( $a, $b ) {
    374     return strcasecmp( $b['date_recorded'], $a['date_recorded'] ); 
     376    return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );   
    375377}
    376378
  • trunk/bp-activity/bp-activity-templatetags.php

    r1839 r1844  
    171171   
    172172    $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );       
    173     return $activities_template->has_activities();
     173    return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
    174174}
    175175
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r1771 r1844  
    309309
    310310    $blogs_template = new BP_Blogs_User_Blogs_Template( $user_id, $per_page, $max );
    311     return $blogs_template->has_blogs();
     311    return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), &$blogs_template );
    312312}
    313313
     
    485485
    486486    $posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max );
    487     return $posts_template->has_posts();
     487    return apply_filters( 'bp_has_posts', $posts_template->has_posts(), &$posts_template );
    488488}
    489489
     
    920920   
    921921    $comments_template = new BP_Blogs_Post_Comment_Template( $user_id, $per_page, $max );
    922    
    923     return $comments_template->has_comments();
     922    return apply_filters( 'bp_has_comments', $comments_template->has_comments(), &$comments_template );
    924923}
    925924
  • trunk/bp-forums/bp-forums-templatetags.php

    r1790 r1844  
    138138        return false;
    139139
    140     return $forum_template->has_topics();
     140    return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );
    141141}
    142142
     
    600600        return false;
    601601
    602     return $topic_template->has_posts();
     602    return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template );
    603603}
    604604
  • trunk/bp-friends/bp-friends-templatetags.php

    r1834 r1844  
    172172
    173173    $friends_template = new BP_Friendship_Template( $user_id, $type, $per_page, $max, $filter );
    174     return $friends_template->has_friendships();
     174    return apply_filters( 'bp_has_friendships', $friends_template->has_friendships(), &$friends_template );
    175175}
    176176
     
    345345
    346346function bp_add_friend_button( $potential_friend_id = false ) {
    347     global $bp, $friends_template;
    348    
    349     if ( is_user_logged_in() ) {
    350        
    351         if ( !$potential_friend_id && $friends_template->friendship->friend )
    352             $potential_friend_id = $friends_template->friendship->friend->id;
    353         else if ( !$potential_friend_id && !$friends_template->friendship->friend )
    354             $potential_friend_id = $bp->displayed_user->id;
    355 
    356         if ( $bp->loggedin_user->id == $potential_friend_id )
    357             return false;
    358 
    359         $friend_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
    360 
    361         echo '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
    362         if ( 'pending' == $friend_status ) {
    363             echo '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
    364         } else if ( 'is_friend' == $friend_status ) {
    365             echo '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id, 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
    366         } else {
    367             echo '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id, 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
    368         }
    369         echo '</div>';
    370     }
    371 }
     347    echo bp_get_add_friend_button();
     348}
     349    function bp_get_add_friend_button( $potential_friend_id = false ) {
     350        global $bp, $friends_template;
     351   
     352        $button = false;
     353       
     354        if ( is_user_logged_in() ) {
     355       
     356            if ( !$potential_friend_id && $friends_template->friendship->friend )
     357                $potential_friend_id = $friends_template->friendship->friend->id;
     358            else if ( !$potential_friend_id && !$friends_template->friendship->friend )
     359                $potential_friend_id = $bp->displayed_user->id;
     360
     361            if ( $bp->loggedin_user->id == $potential_friend_id )
     362                return false;
     363
     364            $friend_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
     365
     366            $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
     367            if ( 'pending' == $friend_status ) {
     368                $button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
     369            } else if ( 'is_friend' == $friend_status ) {
     370                $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id, 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
     371            } else {
     372                $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id, 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
     373            }
     374            $button .= '</div>';
     375        }
     376       
     377        return apply_filters( 'bp_get_add_friend_button', $button );
     378    }
    372379
    373380function bp_friends_header_tabs() {
  • trunk/bp-groups/bp-groups-templatetags.php

    r1834 r1844  
    309309   
    310310    $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter );
    311     return $groups_template->has_groups();
     311    return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
    312312}
    313313
     
    13601360
    13611361    $members_template = new BP_Groups_Group_Members_Template( $group_id, $per_page, $max, (int)$exclude_admins_mods, (int)$exclude_banned );
    1362    
    1363     return $members_template->has_members();
     1362    return apply_filters( 'bp_group_has_members', $members_template->has_members(), &$members_template );
    13641363}
    13651364
     
    19281927       
    19291928    $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
    1930 
    1931     return $site_groups_template->has_groups();
     1929    return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
    19321930}
    19331931
     
    22132211
    22142212    $requests_template = new BP_Groups_Membership_Requests_Template( $group_id, $per_page, $max );
    2215     return $requests_template->has_requests();
     2213    return apply_filters( 'bp_group_has_membership_requests', $requests_template->has_requests(), &$requests_template );
    22162214}
    22172215
     
    23592357
    23602358    $invites_template = new BP_Groups_Invite_Template( $user_id, $group_id );
    2361     return $invites_template->has_invites();
     2359    return apply_filters( 'bp_group_has_invites', $invites_template->has_invites(), &$invites_template );
    23622360}
    23632361
  • trunk/bp-messages/bp-messages-templatetags.php

    r1655 r1844  
    141141    }
    142142   
    143     return $messages_template->has_threads();
     143    return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template );
    144144}
    145145
     
    434434
    435435function bp_send_message_button() {
    436     global $bp;
    437    
    438     if ( bp_is_home() || !is_user_logged_in() )
    439         return false;
    440    
    441     $ud = get_userdata( $bp->displayed_user->id );
    442     ?>
    443     <div class="generic-button">
    444         <a class="send-message" title="<?php _e( 'Send Message', 'buddypress' ) ?>" href="<?php echo $bp->loggedin_user->domain . $bp->messages->slug ?>/compose/?r=<?php echo $ud->user_login ?>"><?php _e( 'Send Message', 'buddypress' ) ?></a>
    445     </div>
    446     <?php
    447 }
    448 
    449 function bp_message_loading_image_src() {
     436    echo bp_get_send_message_button();
     437}
     438    function bp_get_send_message_button() {
     439        global $bp;
     440   
     441        if ( bp_is_home() || !is_user_logged_in() )
     442            return false;
     443   
     444        $ud = get_userdata( $bp->displayed_user->id );
     445       
     446        return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
     447    }
     448
     449function bp_message_loading_imAage_src() {
    450450    echo bp_get_message_loading_image_src();
    451451}
  • trunk/bp-wire/bp-wire-templatetags.php

    r1834 r1844  
    120120       
    121121    $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max );     
    122     return $wire_posts_template->has_wire_posts();
     122    return apply_filters( 'bp_has_wire_posts', $wire_posts_template->has_wire_posts(), &$wire_posts_template );
    123123}
    124124
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r1835 r1844  
    5151
    5252        $this->group = $this->groups[$this->current_group];
    53         $this->field_count = count($this->group->fields);
    5453       
    5554        if ( !$fields = wp_cache_get( 'xprofile_fields_' . $this->group->id . '_' . $this->user_id, 'bp' ) ) {
    56             for ( $i = 0; $i < $this->field_count; $i++ ) {
     55            for ( $i = 0; $i < count($this->group->fields); $i++ ) {
    5756                $field = new BP_XProfile_Field( $this->group->fields[$i]->id, $this->user_id );
    5857                $fields[$i] = $field;
     
    6261        }
    6362       
    64         $this->group->fields = $fields;
     63        $this->group->fields = apply_filters( 'xprofile_group_fields', $fields, $this->group->id );
     64        $this->field_count = count( $this->group->fields );
    6565       
    6666        return $this->group;
     
    178178   
    179179    $profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id );
    180    
    181     return $profile_template->has_groups();
     180    return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template );
    182181}
    183182
Note: See TracChangeset for help on using the changeset viewer.