Skip to:
Content

BuddyPress.org

Changeset 5684


Ignore:
Timestamp:
02/09/2012 10:10:47 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Activity component. See #3989.

Location:
trunk/bp-activity
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-actions.php

    r5664 r5684  
    115115 * @param int $activity_id Activity id to be deleted. Defaults to 0.
    116116 *
    117  * @global object $bp BuddyPress global settings
    118117 * @uses bp_is_activity_component()
    119118 * @uses bp_is_current_action()
     
    130129 */
    131130function bp_activity_action_delete_activity( $activity_id = 0 ) {
    132     global $bp;
    133131
    134132    // Not viewing activity or action is not delete
     
    347345 * @since 1.2.0
    348346 *
    349  * @global object $bp BuddyPress global settings
    350347 * @uses is_user_logged_in()
    351348 * @uses bp_is_activity_component()
     
    361358 */
    362359function bp_activity_action_mark_favorite() {
    363     global $bp;
    364360
    365361    if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
     
    383379 * @since 1.2.0
    384380 *
    385  * @global object $bp BuddyPress global settings
    386381 * @uses is_user_logged_in()
    387382 * @uses bp_is_activity_component()
     
    397392 */
    398393function bp_activity_action_remove_favorite() {
    399     global $bp;
    400394
    401395    if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'unfavorite' ) )
     
    447441 * @since 1.0.0
    448442 *
    449  * @global object $bp BuddyPress global settings
    450443 * @global object $wp_query
    451444 * @uses bp_is_user_activity()
     
    456449 */
    457450function bp_activity_action_personal_feed() {
    458     global $bp, $wp_query;
     451    global $wp_query;
    459452
    460453    if ( !bp_is_user_activity() || !bp_is_current_action( 'feed' ) )
     
    474467 * @since 1.0.0
    475468 *
    476  * @global object $bp BuddyPress global settings
    477469 * @global object $wp_query
    478470 * @uses bp_is_active()
     
    486478 */
    487479function bp_activity_action_friends_feed() {
    488     global $bp, $wp_query;
     480    global $wp_query;
    489481
    490482    if ( !bp_is_active( 'friends' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
     
    504496 * @since 1.2.0
    505497 *
    506  * @global object $bp BuddyPress global settings
    507498 * @global object $wp_query
    508499 * @uses bp_is_active()
     
    516507 */
    517508function bp_activity_action_my_groups_feed() {
    518     global $bp, $wp_query;
     509    global $wp_query;
    519510
    520511    if ( !bp_is_active( 'groups' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_groups_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
     
    534525 * @since 1.2.0
    535526 *
    536  * @global object $bp BuddyPress global settings
    537527 * @global object $wp_query
    538528 * @uses bp_is_user_activity()
     
    544534 */
    545535function bp_activity_action_mentions_feed() {
    546     global $bp, $wp_query;
     536    global $wp_query;
    547537
    548538    if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
     
    562552 * @since 1.2.0
    563553 *
    564  * @global object $bp BuddyPress global settings
    565554 * @global object $wp_query
    566555 * @uses bp_is_user_activity()
     
    572561 */
    573562function bp_activity_action_favorites_feed() {
    574     global $bp, $wp_query;
     563    global $wp_query;
    575564
    576565    if ( !bp_is_user_activity() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) )
     
    584573}
    585574add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
    586 
    587575
    588576/**
     
    610598    $bp->activity->akismet = new BP_Akismet();
    611599}
     600
    612601?>
  • trunk/bp-activity/bp-activity-admin.php

    r5623 r5684  
    2424 * Registers the Activity component admin screen
    2525 *
    26  * @global object $bp Global BuddyPress settings object
    2726 * @since 1.6
    2827 */
    2928function bp_activity_add_admin_menu() {
    30     global $bp;
    3129
    3230    if ( ! bp_current_user_can( 'bp_moderate' ) )
     
    906904     * Constructor
    907905     *
    908      * @global $bp BuddyPress global settings
    909906     * @since 1.6
    910907     */
    911908    public function __construct() {
    912         global $bp;
    913909
    914910        // Define singular and plural labels, as well as whether we support AJAX.
  • trunk/bp-activity/bp-activity-akismet.php

    r5624 r5684  
    481481     */
    482482    public function buddypress_ua( $user_agent ) {
    483         return 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
     483        $user_agent = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
     484        return $user_agent;
    484485    }
    485486
  • trunk/bp-activity/bp-activity-cache.php

    r5505 r5684  
    11<?php
     2
    23/**
    34 * Functions related to the BuddyPress Activity component and the WP Cache
     
    56 * @since 1.6
    67 */
     8
     9// Exit if accessed directly
     10if ( !defined( 'ABSPATH' ) ) exit;
    711
    812/**
  • trunk/bp-activity/bp-activity-classes.php

    r5573 r5684  
    374374     * Append activity comments to their associated activity items
    375375     *
    376      * @global object $bp Global BuddyPress settings object
    377376     * @global wpdb $wpdb WordPress database object
    378377     * @param array $activities
     
    382381     */
    383382    function append_comments( $activities, $spam = 'ham_only' ) {
    384         global $bp, $wpdb;
     383        global $wpdb;
    385384
    386385        $activity_comments = array();
     
    498497
    499498    function get_sitewide_items_for_feed( $limit = 35 ) {
    500         global $wpdb, $bp;
    501 
    502         $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
     499        global $bp;
     500
     501        $activities    = bp_activity_get_sitewide( array( 'max' => $limit ) );
     502        $activity_feed = array();
    503503
    504504        for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
    505                 $title = explode( '<span', $activities[$i]['content'] );
    506 
    507                 $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
    508                 $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
     505                $title                            = explode( '<span', $activities[$i]['content'] );
     506                $activity_feed[$i]['title']       = trim( strip_tags( $title[0] ) );
     507                $activity_feed[$i]['link']        = $activities[$i]['primary_link'];
    509508                $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
    510                 $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
     509                $activity_feed[$i]['pubdate']     = $activities[$i]['date_recorded'];
    511510        }
    512511
     
    539538
    540539    function get_filter_sql( $filter_array ) {
    541         global $wpdb;
     540
     541        $filter_sql = array();
    542542
    543543        if ( !empty( $filter_array['user_id'] ) ) {
     
    571571        }
    572572
    573         if ( empty($filter_sql) )
     573        if ( empty( $filter_sql ) )
    574574            return false;
    575575
  • trunk/bp-activity/bp-activity-functions.php

    r5612 r5684  
    240240 * @param int $user_id
    241241 *
    242  * @global object $bp BuddyPress global settings
    243242 * @uses bp_get_user_meta()
    244243 * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook
     
    247246 */
    248247function bp_activity_get_user_favorites( $user_id = 0 ) {
    249     global $bp;
    250248
    251249    // Fallback to logged in user if no user_id is passed
     
    267265 * @param int $user_id
    268266 *
    269  * @global object $bp BuddyPress global settings
    270267 * @uses is_user_logged_in()
    271268 * @uses bp_get_user_meta()
     
    279276 */
    280277function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
    281     global $bp;
    282278
    283279    // Favorite activity stream items are for logged in users only
     
    326322 * @param int $user_id
    327323 *
    328  * @global object $bp BuddyPress global settings
    329324 * @uses is_user_logged_in()
    330325 * @uses bp_get_user_meta()
     
    337332 */
    338333function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
    339     global $bp;
    340334
    341335    // Favorite activity stream items are for logged in users only
     
    421415 * @param int $user_id
    422416 *
    423  * @global object $bp BuddyPress global settings
    424417 * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity}
    425418 *
     
    427420 */
    428421function bp_activity_total_favorites_for_user( $user_id = 0 ) {
    429     global $bp;
    430422
    431423    // Fallback on displayed user, and then logged in user
     
    879871 * @param array $args See docs for $defaults for details
    880872 *
    881  * @global object $bp BuddyPress global settings
    882873 * @uses wp_parse_args()
    883874 * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity}
     
    889880 */
    890881function bp_activity_add( $args = '' ) {
    891     global $bp;
    892882
    893883    $defaults = array(
     
    10381028    extract( $params, EXTR_SKIP );
    10391029
    1040     if ( empty($content) || empty($user_id) || empty($activity_id) )
    1041         return false;
    1042 
    1043     if ( empty($parent_id) )
     1030    if ( empty( $content ) || empty( $user_id ) || empty( $activity_id ) )
     1031        return false;
     1032
     1033    if ( empty( $parent_id ) )
    10441034        $parent_id = $activity_id;
    10451035
     
    10501040    // Insert the activity comment
    10511041    $comment_id = bp_activity_add( array(
    1052         'id' => $id,
    1053         'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
    1054         'content' => apply_filters( 'bp_activity_comment_content', $content ),
    1055         'component' => $bp->activity->id,
    1056         'type' => 'activity_comment',
    1057         'user_id' => $user_id,
    1058         'item_id' => $activity_id,
     1042        'id'                => $id,
     1043        'action'            => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
     1044        'content'           => apply_filters( 'bp_activity_comment_content', $content ),
     1045        'component'         => $bp->activity->id,
     1046        'type'              => 'activity_comment',
     1047        'user_id'           => $user_id,
     1048        'item_id'           => $activity_id,
    10591049        'secondary_item_id' => $parent_id,
    1060         'hide_sitewide' => $is_hidden
     1050        'hide_sitewide'     => $is_hidden
    10611051    ) );
    10621052
     
    11201110 * @param array $args See docs for $defaults for details
    11211111 *
    1122  * @global object $bp BuddyPress global settings
    11231112 * @uses wp_parse_args()
    11241113 * @uses bp_activity_adjust_mention_count()
     
    11341123 */
    11351124function bp_activity_delete( $args = '' ) {
    1136     global $bp;
    11371125
    11381126    // Pass one or more the of following variables to delete by those variables
     
    11691157    $latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true );
    11701158    if ( !empty( $latest_update ) ) {
    1171         if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
     1159        if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) ) {
    11721160            bp_delete_user_meta( $user_id, 'bp_latest_update' );
     1161        }
    11731162    }
    11741163
     
    11911180     * @param array $args See docs for $defaults for details
    11921181     *
    1193      * @global object $bp BuddyPress global settings
    11941182     * @uses wp_parse_args()
    11951183     * @uses bp_activity_delete()
     
    11981186     */
    11991187    function bp_activity_delete_by_item_id( $args = '' ) {
    1200         global $bp;
    1201 
    1202         $defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false );
     1188
     1189        $defaults = array(
     1190            'item_id'           => false,
     1191            'component'         => false,
     1192            'type'              => false,
     1193            'user_id'           => false,
     1194            'secondary_item_id' => false
     1195        );
    12031196        $r = wp_parse_args( $args, $defaults );
    12041197        extract( $r, EXTR_SKIP );
     
    13371330 * @param object $activity_obj (optional) The activity object
    13381331 *
    1339  * @global object $bp BuddyPress global settings
    13401332 * @uses bp_get_root_domain()
    13411333 * @uses bp_get_activity_root_slug()
     
    13451337 */
    13461338function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
    1347     global $bp;
    1348 
    1349     if ( !$activity_obj )
     1339
     1340    if ( empty( $activity_obj ) )
    13501341        $activity_obj = new BP_Activity_Activity( $activity_id );
    13511342
     
    13541345    }
    13551346
    1356     if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type )
     1347    if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type ) {
    13571348        $link = $activity_obj->primary_link;
    1358     else {
    1359         if ( 'activity_comment' == $activity_obj->type )
     1349    } else {
     1350        if ( 'activity_comment' == $activity_obj->type ) {
    13601351            $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/';
    1361         else
     1352        } else {
    13621353            $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/';
     1354        }
    13631355    }
    13641356
     
    13951387 */
    13961388function bp_activity_thumbnail_content_images( $content, $link = false ) {
    1397     global $post;
    13981389
    13991390    preg_match_all( '/<img[^>]*>/Ui', $content, $matches );
     
    14061397        // Get the width and height
    14071398        preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
    1408         preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
     1399        preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i',  $matches[0][0], $width );
    14091400
    14101401        if ( !empty( $src ) ) {
    1411             $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
     1402            $src    = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
    14121403            $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
    1413             $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
     1404            $width  = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
    14141405
    14151406            if ( empty( $width ) || empty( $height ) ) {
    1416                 $width = 100;
     1407                $width  = 100;
    14171408                $height = 100;
    14181409            }
    14191410
    1420             $ratio = (int)$width / (int)$height;
     1411            $ratio      = (int)$width / (int)$height;
    14211412            $new_height = (int)$height >= 100 ? 100 : $height;
    1422             $new_width = $new_height * $ratio;
     1413            $new_width  = $new_height * $ratio;
    14231414
    14241415            $image = '<img src="' . esc_attr( $src ) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />';
     
    14381429 * Convenience function to control whether the current user is allowed to mark activity items as spam
    14391430 *
    1440  * @global object $bp BuddyPress global settings
    14411431 * @return bool True if user is allowed to mark activity items as spam
    14421432 * @since 1.6
     
    14441434 */
    14451435function bp_activity_user_can_mark_spam() {
    1446     global $bp;
    14471436    return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) );
    14481437}
  • trunk/bp-activity/bp-activity-notifications.php

    r5595 r5684  
    1919 * @param int $receiver_user_id The unique user_id of the user who is receiving the update
    2020 *
    21  * @global object $bp BuddyPress global settings
    2221 * @uses bp_core_add_notification()
    2322 * @uses bp_get_user_meta()
     
    4039 */
    4140function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
    42     global $bp;
    4341   
    4442    // Don't leave multiple notifications for the same activity item
     
    120118 * @param array $params {@link bp_activity_new_comment()}
    121119 *
    122  * @global object $bp BuddyPress global settings
    123120 * @uses bp_get_user_meta()
    124121 * @uses bp_core_get_user_displayname()
     
    142139 */
    143140function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
    144     global $bp;
     141
     142    // Set some default parameters
     143    $activity_id = 0;
     144    $parent_id   = 0;
    145145
    146146    extract( $params );
  • trunk/bp-activity/bp-activity-template.php

    r5639 r5684  
    210210
    211211    function the_activity() {
    212         global $activity;
    213212
    214213        $this->in_the_loop = true;
    215         $this->activity = $this->next_activity();
     214        $this->activity    = $this->next_activity();
    216215
    217216        if ( is_array( $this->activity ) )
     
    441440     * @since 1.2.0
    442441     *
    443      * @global object $bp BuddyPress global settings
    444442     * @global object $activities_template {@link BP_Activity_Template}
    445443     * @uses bp_core_number_format()
     
    448446     */
    449447    function bp_get_activity_pagination_count() {
    450         global $bp, $activities_template;
     448        global $activities_template;
    451449
    452450        $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
     
    566564 */
    567565function bp_activities_title() {
    568     global $bp_activity_title;
    569 
    570566    echo bp_get_activities_title();
    571567}
     
    595591 */
    596592function bp_activities_no_activity() {
    597     global $bp_activity_no_activity;
    598 
    599593    echo bp_get_activities_no_activity();
    600594}
     
    970964     * @param array $args optional
    971965     *
    972      * @global object $bp BuddyPress global settings
    973966     * @global object $activities_template {@link BP_Activity_Template}
    974967     * @uses wp_parse_args()
     
    982975     */
    983976    function bp_get_activity_secondary_avatar( $args = '' ) {
    984         global $bp, $activities_template;
     977        global $activities_template;
    985978
    986979        $defaults = array(
     
    11591152     * @todo properly deprecate this function
    11601153     *
    1161      * @global object $activities_template {@link BP_Activity_Template}
    11621154     * @uses bp_get_activity_action()
    11631155     * @uses bp_get_activity_content_body()
     
    11671159     */
    11681160    function bp_get_activity_content() {
    1169         global $activities_template;
    1170 
    11711161        /**
    11721162         * If you want to filter activity update content, please use
     
    11881178 *
    11891179 * @global object $activities_template {@link BP_Activity_Template}
    1190  * @global object $bp BuddyPress global settings
    11911180 * @uses bp_core_time_since()
    11921181 * @uses apply_filters_ref_array() To call the 'bp_activity_time_since' hook
     
    12001189 */
    12011190function bp_insert_activity_meta( $content ) {
    1202     global $activities_template, $bp;
     1191    global $activities_template;
    12031192
    12041193    // Strip any legacy time since placeholders from BP 1.0-1.1
     
    12251214 *
    12261215 * @global object $activities_template {@link BP_Activity_Template}
    1227  * @global object $bp BuddyPress global settings
    12281216 * @uses apply_filters() To call the 'bp_activity_user_can_delete' hook
    12291217 *
     
    12311219 */
    12321220function bp_activity_user_can_delete( $activity = false ) {
    1233     global $activities_template, $bp;
     1221    global $activities_template;
    12341222
    12351223    if ( !$activity )
     
    12471235        $can_delete = true;
    12481236
    1249     if ( $bp->is_item_admin && $bp->is_single_item )
     1237    if ( bp_is_item_admin() && bp_is_single_item() )
    12501238        $can_delete = true;
    12511239
     
    12731261     * @param array $args Optional
    12741262     *
    1275      * @global object $bp BuddyPress global settings
    12761263     * @global object $activities_template {@link BP_Activity_Template}
    12771264     * @uses wp_parse_args()
     
    12811268     */
    12821269    function bp_get_activity_parent_content( $args = '' ) {
    1283         global $bp, $activities_template;
     1270        global $activities_template;
    12841271
    12851272        $defaults = array(
     
    13281315     * @since 1.2.0
    13291316     *
    1330      * @global object $bp BuddyPress global settings
    13311317     * @global object $activities_template {@link BP_Activity_Template}
    13321318     * @uses apply_filters() To call the 'bp_get_activity_is_favorite' hook
     
    13351321     */
    13361322    function bp_get_activity_is_favorite() {
    1337         global $bp, $activities_template;
     1323        global $activities_template;
    13381324
    13391325        return apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array)$activities_template->my_favs ) );
     
    13661352     *
    13671353     * @global object $activities_template {@link BP_Activity_Template}
    1368      * @global object $bp BuddyPress global settings
    13691354     * @uses bp_activity_recurse_comments()
    13701355     */
    13711356    function bp_activity_get_comments( $args = '' ) {
    1372         global $activities_template, $bp;
     1357        global $activities_template;
    13731358
    13741359        if ( !isset( $activities_template->activity->children ) || !$activities_template->activity->children )
     
    13911376         *
    13921377         * @global object $activities_template {@link BP_Activity_Template}
    1393          * @global object $bp BuddyPress global settings
    13941378         * @uses locate_template()
    13951379         */
    13961380        function bp_activity_recurse_comments( $comment ) {
    1397             global $activities_template, $bp, $counter;
    1398 
    1399             if ( !$comment )
     1381            global $activities_template;
     1382
     1383            if ( empty( $comment ) )
    14001384                return false;
    14011385
     
    16141598     * @since 1.5.0
    16151599     *
    1616      * @global object $bp BuddyPress global settings
    16171600     * @uses wp_nonce_url()
    16181601     * @uses bp_get_root_domain()
     
    16241607     */
    16251608    function bp_get_activity_comment_delete_link() {
    1626         global $bp;
    1627 
    16281609        $link = wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/delete/' . bp_get_activity_comment_id() . '?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' );
    16291610
     
    16881669     *
    16891670     * @global object $activities_template {@link BP_Activity_Template}
    1690      * @global object $bp BuddyPress global settings
    16911671     * @uses bp_activity_recurse_comment_count()
    16921672     * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
     
    16951675     */
    16961676    function bp_activity_get_comment_count( $args = '' ) {
    1697         global $activities_template, $bp;
     1677        global $activities_template;
    16981678
    16991679        if ( !isset( $activities_template->activity->children ) || !$activities_template->activity->children )
     
    17181698         * @param object $comment Activity comments object
    17191699         *
    1720          * @global object $activities_template {@link BP_Activity_Template}
    1721          * @global object $bp BuddyPress global settings
    17221700         * @uses bp_activity_recurse_comment_count()
    17231701         * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
     
    17261704         */
    17271705        function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
    1728             global $activities_template, $bp;
    1729 
    1730             if ( !$comment->children )
     1706
     1707            if ( empty( $comment->children ) )
    17311708                return $count;
    17321709
    1733             foreach ( (array)$comment->children as $comment ) {
     1710            foreach ( (array) $comment->children as $comment ) {
    17341711                $count++;
    17351712                $count = bp_activity_recurse_comment_count( $comment, $count );
     
    18091786     * @since 1.2.0
    18101787     *
    1811      * @global object $bp BuddyPress global settings
    18121788     * @uses home_url()
    18131789     * @uses bp_get_activity_root_slug()
     
    18171793     */
    18181794    function bp_get_activity_comment_form_action() {
    1819         global $bp;
    1820 
    18211795        return apply_filters( 'bp_get_activity_comment_form_action', home_url( bp_get_activity_root_slug() . '/reply/' ) );
    18221796    }
     
    18651839     * @since 1.2.0
    18661840     *
    1867      * @global object $bp BuddyPress global settings
    18681841     * @uses bp_activity_get_permalink()
    18691842     * @uses apply_filters() To call the 'bp_get_activity_thread_permalink' hook
     
    18721845     */
    18731846    function bp_get_activity_thread_permalink() {
    1874         global $bp, $activities_template;
     1847        global $activities_template;
    18751848
    18761849        $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
     
    18951868     * @since 1.2.0
    18961869     *
    1897      * @global object $bp BuddyPress global settings
    18981870     * @global object $activities_template {@link BP_Activity_Template}
    18991871     * @uses wp_nonce_url()
     
    19051877     */
    19061878    function bp_get_activity_favorite_link() {
    1907         global $bp, $activities_template;
     1879        global $activities_template;
    19081880        return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) );
    19091881    }
     
    19251897     * @since 1.2.0
    19261898     *
    1927      * @global object $bp BuddyPress global settings
    19281899     * @global object $activities_template {@link BP_Activity_Template}
    19291900     * @uses wp_nonce_url()
     
    19351906     */
    19361907    function bp_get_activity_unfavorite_link() {
    1937         global $bp, $activities_template;
     1908        global $activities_template;
    19381909        return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) );
    19391910    }
     
    20021973     *
    20031974     * @global object $activities_template {@link BP_Activity_Template}
    2004      * @global object $bp BuddyPress global settings
    20051975     * @uses bp_get_root_domain()
    20061976     * @uses bp_get_activity_root_slug()
     
    20151985     */
    20161986    function bp_get_activity_delete_link() {
    2017         global $activities_template, $bp;
     1987        global $activities_template;
    20181988
    20191989        $url   = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id;
     
    20502020     * @param int $user_id Defaults to 0
    20512021     *
    2052      * @global object $bp BuddyPress global settings
    20532022     * @uses bp_is_user_inactive()
    20542023     * @uses bp_core_is_user_deleted()
     
    20632032     */
    20642033    function bp_get_activity_latest_update( $user_id = 0 ) {
    2065         global $bp;
    2066 
    2067         if ( !$user_id )
     2034
     2035        if ( empty( $user_id ) )
    20682036            $user_id = bp_displayed_user_id();
    20692037
     
    21002068     * @param array $args Defaults to false
    21012069     *
    2102      * @global object $activities_template {@link BP_Activity_Template}
    2103      * @global object $bp BuddyPress global settings
    21042070     * @uses wp_parse_args()
    21052071     * @uses BP_Activity_Activity::get_recorded_components() {@link BP_Activity_Activity}
     
    21132079     */
    21142080    function bp_get_activity_filter_links( $args = false ) {
    2115         global $activities_template, $bp;
    21162081
    21172082        $defaults = array(
     
    21222087        extract( $r, EXTR_SKIP );
    21232088
     2089        // Define local variable
     2090        $component_links = array();
     2091
    21242092        // Fetch the names of components that have activity recorded in the DB
    21252093        $components = BP_Activity_Activity::get_recorded_components();
    21262094
    2127         if ( !$components )
     2095        if ( empty( $components ) )
    21282096            return false;
    21292097
    21302098        foreach ( (array) $components as $component ) {
    2131             /* Skip the activity comment filter */
     2099
     2100            // Skip the activity comment filter
    21322101            if ( 'activity' == $component )
    21332102                continue;
     
    21602129            $link = add_query_arg( 'afilter', $component );
    21612130            $link = remove_query_arg( 'acpage' , $link );
    2162 
    21632131            $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
    21642132
    2165             // Make sure all core internal component names are translatable
    2166             $translatable_components = array( __( 'xprofile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'sites', 'buddypress' ) );
    2167 
    2168             $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
     2133            $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( $component ) . '</a>' . $after;
    21692134        }
    21702135
     
    21832148 *
    21842149 * @global object $activities_template {@link BP_Activity_Template}
    2185  * @global object $bp BuddyPress global settings
    21862150 * @uses bp_get_activity_action_name()
    21872151 * @uses apply_filters() To call the 'bp_activity_can_comment' hook
     
    21902154 */
    21912155function bp_activity_can_comment() {
    2192     global $activities_template, $bp;
     2156    global $activities_template;
    21932157
    21942158    $can_comment = true;
     
    22842248     * @since 1.2.0
    22852249     *
    2286      * @todo remove unnecessary $bp global
    2287      *
    22882250     * @param int $user_id Defaults to 0
    2289      *
    22902251     * @uses bp_get_user_meta()
    22912252     * @uses apply_filters() To call the 'bp_get_total_mention_count_for_user' hook
    2292      *
    22932253     * @return int The total mention count for a specified user
    22942254     */
    22952255    function bp_get_total_mention_count_for_user( $user_id = 0 ) {
    2296         global $bp;
    2297 
    22982256        return apply_filters( 'bp_get_total_mention_count_for_user', bp_get_user_meta( $user_id, 'bp_new_mention_count', true ) );
    22992257    }
     
    25072465     */
    25082466    function bp_get_member_activity_feed_link() {
    2509         global $bp;
    25102467
    25112468        if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) )
     
    25152472        elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) )
    25162473            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
    2517         elseif ( 'favorites' == $bp->current_action )
     2474        elseif ( 'favorites' == bp_current_action() )
    25182475            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    2519         elseif ( 'mentions' == $bp->current_action )
     2476        elseif ( 'mentions' == bp_current_action() )
    25202477            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    25212478        else
Note: See TracChangeset for help on using the changeset viewer.