Skip to:
Content

BuddyPress.org

Changeset 2077 for trunk/bp-core.php


Ignore:
Timestamp:
11/02/2009 07:54:21 PM (17 years ago)
Author:
apeatling
Message:

Merging 1.1 branch changes and syncing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r2059 r2077  
    44define( 'BP_CORE_DB_VERSION', '1800' );
    55
    6 /*** 
    7  * Define the path and url of the BuddyPress plugins directory. 
    8  * It is important to use plugins_url() core function to obtain 
    9  * the correct scheme used (http or https). 
     6/***
     7 * Define the path and url of the BuddyPress plugins directory.
     8 * It is important to use plugins_url() core function to obtain
     9 * the correct scheme used (http or https).
    1010 */
    1111define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
    … …  
    6666if ( !defined( 'BP_HOME_BLOG_SLUG' ) )
    6767        define( 'BP_HOME_BLOG_SLUG', 'blog' );
    68        
     68
     69/* Register BuddyPress themes contained within the theme folder */
     70if ( function_exists( 'register_theme_folder' ) )
     71        register_theme_folder( 'buddypress/bp-themes' );
     72
    6973/* Register BuddyPress themes contained within the theme folder */
    7074if ( function_exists( 'register_theme_folder' ) )
    … …  
    9498        global $displayed_user_id;
    9599        global $action_variables;
    96        
     100
    97101        $current_user = wp_get_current_user();
    98102
    99         /* The domain for the root of the site where the main blog resides */   
     103        /* The domain for the root of the site where the main blog resides */
    100104        $bp->root_domain = bp_core_get_root_domain();
    101        
     105
    102106        /* The user ID of the user who is currently logged in. */
    103107        $bp->loggedin_user->id = $current_user->ID;
    … …  
    105109        /* The domain for the user currently logged in. eg: http://domain.com/members/andy */
    106110        $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID);
    107        
     111
    108112        /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
    109113        $bp->displayed_user->id = $displayed_user_id;
    110        
     114
    111115        /* The domain for the user currently being displayed */
    112116        $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id);
    113        
     117
    114118        /* The component being used eg: http://domain.com/members/andy/ [profile] */
    115119        $bp->current_component = $current_component; // type: string
    116        
     120
    117121        /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */
    118122        $bp->current_action = $current_action; // type: string
    119        
     123
    120124        /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */
    121125        $bp->action_variables = $action_variables; // type: array
    122        
     126
    123127        /* Only used where a component has a sub item, e.g. groups: http://domain.com/members/andy/groups/ [my-group] / home - manipulated in the actual component not in catch uri code.*/
    124128        $bp->current_item = ''; // type: string
    … …  
    135139        /* Sets up the array container for the component navigation rendered by bp_get_nav() */
    136140        $bp->bp_nav = array();
    137        
     141
    138142        /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
    139143        $bp->bp_options_nav = array();
    140        
     144
    141145        /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */
    142146        $bp->bp_options_title = '';
    143        
     147
    144148        /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */
    145149        $bp->bp_options_avatar = '';
    146        
     150
    147151        /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
    148152        $bp->active_components = array();
    149        
     153
    150154        /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
    151155        $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', get_site_option( 'user-avatar-default' ) );
    152156        $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
    153157        $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
    154        
     158
    155159        /* Fetch the full name for the logged in and current user */
    156160        $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
    … …  
    162166           'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
    163167        $bp->is_item_admin = bp_is_home();
    164        
     168
    165169        /* Used to determine if the logged in user is a moderator for the current content. */
    166170        $bp->is_item_mod = false;
    … …  
    170174        if ( !$bp->current_component )
    171175                $bp->current_component = $bp->default_component;
    172        
     176
    173177        do_action( 'bp_core_setup_globals' );
    174178}
    … …  
    183187 *
    184188 * For example: http://example.org/search or http://example.org/members
    185  * 
     189 *
    186190 * @package BuddyPress Core
    187191 * @uses bp_core_add_root_component() Adds a slug to the root components global variable.
    … …  
    202206 *
    203207 * Installs the core DB tables for BuddyPress.
    204  * 
     208 *
    205209 * @package BuddyPress Core
    206210 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    211215function bp_core_install() {
    212216        global $wpdb, $bp;
    213        
     217
    214218        if ( !empty($wpdb->charset) )
    215219                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    216        
     220
    217221        $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} (
    218222                                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    … …  
    235239        require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    236240        dbDelta( $sql );
    237        
     241
    238242        /* Add names of root components to the banned blog list to avoid conflicts */
    239243        bp_core_add_illegal_names();
    240        
     244
    241245        update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
    242246}
    … …  
    246250 *
    247251 * Checks to make sure the database tables are set up for the core component.
    248  * 
     252 *
    249253 * @package BuddyPress Core
    250254 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    260264        if ( !is_site_admin() )
    261265                return false;
    262        
     266
    263267        require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
    264268
    … …  
    273277 *
    274278 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    275  * 
     279 *
    276280 * @package BuddyPress Core
    277281 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    281285 */
    282286function bp_core_add_admin_menu() {
    283         global $wpdb, $bp, $menu;
    284        
    285287        if ( !is_site_admin() )
    286288                return false;
    287                
     289
    288290        /* Add the administration tab under the "Site Admin" tab for site administrators */
    289291        bp_core_add_admin_menu_page( array(
    … …  
    294296                'position' => 2
    295297        ) );
    296        
     298
    297299        add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
    298300        add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
    … …  
    305307 * Checks to see if a component's URL should be in the root, not under a member page:
    306308 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
    307  * 
     309 *
    308310 * @package BuddyPress Core
    309311 * @return true if root component, else false.
    … …  
    319321 *
    320322 * Sets up the profile navigation item if the Xprofile component is not installed.
    321  * 
     323 *
    322324 * @package BuddyPress Core
    323325 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    329331function bp_core_setup_nav() {
    330332        global $bp;
    331        
    332         /*** 
     333
     334        /***
    333335         * If the extended profiles component is disabled, we need to revert to using the
    334336         * built in WordPress profile information
    … …  
    340342
    341343                /* Add 'Profile' to the main navigation */
    342                 bp_core_new_nav_item( array( 
     344                bp_core_new_nav_item( array(
    343345                        'name' => __('Profile', 'buddypress'),
    344346                        'slug' => $bp->core->profile->slug,
    … …  
    349351
    350352                $profile_link = $bp->loggedin_user->domain . '/profile/';
    351                
     353
    352354                /* Add the subnav items to the profile */
    353355                bp_core_new_subnav_item( array(
    … …  
    358360                        'screen_function' => 'bp_core_catch_profile_uri'
    359361                ) );
    360                
     362
    361363
    362364                if ( 'profile' == $bp->current_component ) {
    … …  
    365367                        } else {
    366368                                $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    367                                 $bp->bp_options_title = $bp->displayed_user->fullname; 
     369                                $bp->bp_options_title = $bp->displayed_user->fullname;
    368370                        }
    369371                }
    370         }       
     372        }
    371373}
    372374add_action( 'plugins_loaded', 'bp_core_setup_nav' );
    … …  
    397399 * Listens to the $bp component and action variables to determine if the user is viewing the members
    398400 * directory page. If they are, it will set up the directory and load the members directory template.
    399  * 
     401 *
    400402 * @package BuddyPress Core
    401403 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    421423 * this action will fire and mark or unmark the user and their blogs as spam.
    422424 * Must be a site admin for this function to run.
    423  * 
     425 *
    424426 * @package BuddyPress Core
    425427 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    427429function bp_core_action_set_spammer_status() {
    428430        global $bp;
    429        
     431
    430432        if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
    431433                return false;
    432                        
     434
    433435        if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
    434436                /* Check the nonce */
    … …  
    437439                /* Get the functions file */
    438440                require( ABSPATH . 'wp-admin/includes/mu.php' );
    439                
     441
    440442                if ( 'mark-spammer' == $bp->current_action )
    441443                        $is_spam = 1;
    … …  
    445447                /* Get the blogs for the user */
    446448                $blogs = get_blogs_of_user( $bp->displayed_user->id, true );
    447        
     449
    448450                foreach ( (array) $blogs as $key => $details ) {
    449451                        /* Do not mark the main or current root blog as spam */
    450                         if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 
    451                                 continue; 
    452                
     452                        if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id )
     453                                continue;
     454
    453455                        /* Update the blog status */
    454456                        update_blog_status( $details->userblog_id, 'spam', $is_spam );
    455                
     457
    456458                        /* Fire the standard WPMU hook */
    457459                        do_action( 'make_spam_blog', $details->userblog_id );
    458460                }
    459        
     461
    460462                /* Finally, mark this user as a spammer */
    461463                update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 );
    462                
     464
    463465                if ( $is_spam )
    464466                        bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
    465467                else
    466468                        bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
    467                        
     469
    468470                do_action( 'bp_core_action_set_spammer_status' );
    469                
     471
    470472                bp_core_redirect( wp_get_referer() );
    471473        }
    … …  
    477479 *
    478480 * Allows a site admin to delete a user from the adminbar menu.
    479  * 
     481 *
    480482 * @package BuddyPress Core
    481483 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    483485function bp_core_action_delete_user() {
    484486        global $bp;
    485        
     487
    486488        if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
    487489                return false;
    488                        
     490
    489491        if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
    490492                /* Check the nonce */
    … …  
    492494
    493495                $errors = false;
    494                
     496
    495497                if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
    496498                        bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) );
    … …  
    499501                        $errors = true;
    500502                }
    501                
     503
    502504                do_action( 'bp_core_action_set_spammer_status', $errors );
    503                
     505
    504506                if ( $errors )
    505507                        bp_core_redirect( $bp->displayed_user->domain );
    … …  
    525527 * Returns the domain for the passed user:
    526528 * e.g. http://domain.com/members/andy/
    527  * 
     529 *
    528530 * @package BuddyPress Core
    529531 * @global $current_user WordPress global variable containing current logged in user information
    … …  
    533535function bp_core_get_user_domain( $user_id ) {
    534536        global $bp;
    535        
     537
    536538        if ( !$user_id ) return;
    537        
     539
    538540        $ud = get_userdata($user_id);
    539        
     541
    540542        if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    541543                $username = $ud->user_login;
    542544        else
    543545                $username = $ud->user_nicename;
    544        
     546
    545547        /* If we are using a members slug, include it. */
    546548        if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
    547549                return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' );
    548550        else
    549                 return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );           
     551                return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );
    550552}
    551553
    … …  
    555557 * Returns the domain for the root blog.
    556558 * eg: http://domain.com/ OR https://domain.com
    557  * 
     559 *
    558560 * @package BuddyPress Core
    559561 * @uses get_blog_option() WordPress function to fetch blog meta.
    … …  
    562564function bp_core_get_root_domain() {
    563565        global $current_blog;
    564        
     566
    565567        if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
    566568                $domain = get_blog_option( $current_blog->blog_id, 'siteurl' );
    … …  
    576578 * Returns the user id for the user that is currently being displayed.
    577579 * eg: http://andy.domain.com/ or http://domain.com/andy/
    578  * 
     580 *
    579581 * @package BuddyPress Core
    580582 * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
    … …  
    590592 *
    591593 * Adds a navigation item to the main navigation array used in BuddyPress themes.
    592  * 
     594 *
    593595 * @package BuddyPress Core
    594596 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    614616        if ( empty($name) || empty($slug) )
    615617                return false;
    616                        
     618
    617619        /* If this is for site admins only and the user is not one, don't create the subnav item */
    618620        if ( $site_admin_only && !is_site_admin() )
    619621                return false;
    620        
     622
    621623        if ( empty( $item_css_id ) )
    622624                $item_css_id = $slug;
    … …  
    637639        if ( !$show_for_displayed_user && !bp_is_home() )
    638640                return false;
    639                
     641
    640642        /***
    641643         * If we are not viewing a user, and this is a root component, don't attach the
    … …  
    660662 *
    661663 * Modify the default subnav item to load when a top level nav item is clicked.
    662  * 
     664 *
    663665 * @package BuddyPress Core
    664666 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    666668function bp_core_new_nav_default( $args = '' ) {
    667669        global $bp;
    668        
     670
    669671        $defaults = array(
    670672                'parent_slug' => false, // Slug of the parent
    … …  
    692694 * We can only sort nav items by their position integer at a later point in time, once all
    693695 * plugins have registered their navigation items.
    694  * 
     696 *
    695697 * @package BuddyPress Core
    696698 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    698700function bp_core_sort_nav_items() {
    699701        global $bp;
    700        
     702
    701703        if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
    702704                return false;
    703        
     705
    704706        foreach ( $bp->bp_nav as $slug => $nav_item ) {
    705707                if ( empty( $temp[$nav_item['position']]) )
    … …  
    710712                                $nav_item['position']++;
    711713                        } while ( !empty( $temp[$nav_item['position']] ) );
    712                        
     714
    713715                        $temp[$nav_item['position']] = $nav_item;
    714716                }
    715717        }
    716        
     718
    717719        ksort( $temp );
    718         $bp->bp_nav = &$temp; 
     720        $bp->bp_nav = &$temp;
    719721}
    720722add_action( 'wp_head', 'bp_core_sort_nav_items' );
    … …  
    724726 *
    725727 * Removes a navigation item from the main navigation array.
    726  * 
     728 *
    727729 * @package BuddyPress Core
    728730 * @param $slug The slug of the sub navigation item.
    … …  
    738740 *
    739741 * Adds a navigation item to the sub navigation array used in BuddyPress themes.
    740  * 
     742 *
    741743 * @package BuddyPress Core
    742744 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    756758                'screen_function' => false // The name of the function to run when clicked
    757759        );
    758        
     760
    759761        $r = wp_parse_args( $args, $defaults );
    760762        extract( $r, EXTR_SKIP );
    … …  
    763765        if ( empty($name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) )
    764766                return false;
    765        
     767
    766768        /* If this is for site admins only and the user is not one, don't create the subnav item */
    767769        if ( $site_admin_only && !is_site_admin() )
    768770                return false;
    769        
     771
    770772        if ( empty( $item_css_id ) )
    771773                $item_css_id = $slug;
    772        
     774
    773775        $bp->bp_options_nav[$parent_slug][$slug] = array(
    774776                'name' => $name,
    … …  
    779781                'user_has_access' => $user_has_access
    780782        );
    781                
     783
    782784        if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
    783785                if ( !is_object( $screen_function[0] ) )
    … …  
    793795        if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
    794796                return false;
    795        
     797
    796798        foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) {
    797799                if ( !is_array( $subnav_items ) )
    798800                        continue;
    799                
     801
    800802                foreach ( $subnav_items as $subnav_item ) {
    801803                        if ( empty( $temp[$subnav_item['position']]) )
    … …  
    806808                                        $subnav_item['position']++;
    807809                                } while ( !empty( $temp[$subnav_item['position']] ) );
    808                        
     810
    809811                                $temp[$subnav_item['position']] = $subnav_item;
    810812                        }
    … …  
    821823 *
    822824 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
    823  * 
     825 *
    824826 * @package BuddyPress Core
    825827 * @param $parent_id The id of the parent navigation item.
    … …  
    828830function bp_core_remove_subnav_item( $parent_id, $slug ) {
    829831        global $bp;
    830        
     832
    831833        unset( $bp->bp_options_nav[$parent_id][$slug] );
    832834}
    … …  
    836838 *
    837839 * Clear the subnav items for a specific nav item.
    838  * 
     840 *
    839841 * @package BuddyPress Core
    840842 * @param $parent_id The id of the parent navigation item.
    … …  
    856858 * Loads:
    857859 *   wp-content/member-themes/[activated_theme]/profile/edit-profile.php
    858  * 
     860 *
    859861 * @package BuddyPress Core
    860862 * @param $username str Username to check.
    … …  
    883885 *           http://community.domain.com/members/andy/friends
    884886 *           http://domain.com/wpmu/members/andy/friends
    885  * 
     887 *
    886888 * @package BuddyPress Core
    887889 * @param $slug str The slug of the component
    … …  
    898900 *
    899901 * Returns the user_id for a user based on their username.
    900  * 
     902 *
    901903 * @package BuddyPress Core
    902904 * @param $username str Username to check.
    … …  
    907909function bp_core_get_random_member() {
    908910        global $bp, $wpdb;
    909        
     911
    910912        if ( isset( $_GET['random-member'] ) ) {
    911913                $user = BP_Core_User::get_random_users(1);
    912                
     914
    913915                $ud = get_userdata( $user['users'][0]->user_id );
    914                
    915                 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );             
     916
     917                bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );
    916918        }
    917919}
    … …  
    922924 *
    923925 * Returns the user_id for a user based on their username.
    924  * 
     926 *
    925927 * @package BuddyPress Core
    926928 * @param $username str Username to check.
    … …  
    931933function bp_core_get_userid( $username ) {
    932934        global $wpdb;
    933        
     935
    934936        if ( !empty( $username ) )
    935                 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 
     937                return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
    936938}
    937939
    … …  
    940942 *
    941943 * Returns the username for a user based on their user id.
    942  * 
     944 *
    943945 * @package BuddyPress Core
    944946 * @param $uid int User ID to check.
    … …  
    950952function bp_core_get_username( $uid ) {
    951953        global $userdata;
    952        
     954
    953955        if ( $uid == $userdata->ID )
    954956                $username =  __( 'You', 'buddypress' );
    955        
     957
    956958        if ( !$ud = get_userdata($uid) )
    957959                return false;
    958                
    959         $username = $ud->user_login;   
     960
     961        $username = $ud->user_login;
    960962
    961963        return apply_filters( 'bp_core_get_username', $username );
    … …  
    966968 *
    967969 * Returns the URL with no HTML markup for a user based on their user id.
    968  * 
     970 *
    969971 * @package BuddyPress Core
    970972 * @param $uid int User ID to check.
    … …  
    976978function bp_core_get_userurl( $uid ) {
    977979        global $bp;
    978        
     980
    979981        if ( !is_numeric($uid) )
    980982                return false;
    … …  
    987989 *
    988990 * Returns the email address for the user based on user ID
    989  * 
     991 *
    990992 * @package BuddyPress Core
    991993 * @param $uid int User ID to check.
    … …  
    10051007 * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
    10061008 * Optional parameters will return just the name, or just the URL, or disable "You" text when
    1007  * user matches the logged in user. 
     1009 * user matches the logged in user.
    10081010 *
    10091011 * [NOTES: This function needs to be cleaned up or split into separate functions]
    1010  * 
     1012 *
    10111013 * @package BuddyPress Core
    10121014 * @param $uid int User ID to check.
    … …  
    10231025function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) {
    10241026        global $userdata;
    1025        
     1027
    10261028        $ud = get_userdata($user_id);
    1027        
     1029
    10281030        if ( !$ud )
    10291031                return false;
    10301032
    1031         if ( function_exists('bp_fetch_user_fullname') ) { 
     1033        if ( function_exists('bp_fetch_user_fullname') ) {
    10321034                $display_name = bp_core_get_user_displayname( $user_id );
    1033                
     1035
    10341036                if ( $with_s )
    10351037                        $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
    1036                        
     1038
    10371039        } else {
    10381040                $display_name = $ud->display_name;
    10391041        }
    1040        
     1042
    10411043        if ( $no_anchor )
    10421044                return $display_name;
    … …  
    10441046        if ( !$url = bp_core_get_userurl($user_id) )
    10451047                return false;
    1046                
     1048
    10471049        if ( $just_link )
    10481050                return $url;
    10491051
    1050         return '<a href="' . $url . '">' . $display_name . '</a>';     
     1052        return '<a href="' . $url . '">' . $display_name . '</a>';
    10511053}
    10521054
    … …  
    10571059 * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
    10581060 * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
    1059  * 
     1061 *
    10601062 * @package BuddyPress Core
    10611063 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    10681070function bp_core_get_user_displayname( $user_id ) {
    10691071        global $bp;
    1070        
     1072
    10711073        if ( !$user_id )
    10721074                return false;
    1073                
     1075
    10741076        if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
    10751077                if ( function_exists('xprofile_install') ) {
    … …  
    10881090                } else {
    10891091                        $ud = get_userdata($user_id);
    1090                        
     1092
    10911093                        if ( !empty( $ud->display_name ) )
    10921094                                $fullname = $ud->display_name;
    … …  
    10941096                                $fullname = $ud->user_nicename;
    10951097                }
    1096                
     1098
    10971099                wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' );
    10981100        }
    1099        
     1101
    11001102        return apply_filters( 'bp_core_get_user_displayname', $fullname );
    11011103}
    … …  
    11091111 *
    11101112 * Returns the user link for the user based on user email address
    1111  * 
     1113 *
    11121114 * @package BuddyPress Core
    11131115 * @param $email str The email address for the user.
    … …  
    11251127 *
    11261128 * Returns the user link for the user based on user's username
    1127  * 
     1129 *
    11281130 * @package BuddyPress Core
    11291131 * @param $username str The username for the user.
    … …  
    11331135function bp_core_get_userlink_by_username( $username ) {
    11341136        global $wpdb;
    1135        
    1136         $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ); 
     1137
     1138        $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) );
    11371139        return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
    11381140}
    … …  
    11491151function bp_core_is_user_spammer( $user_id ) {
    11501152        global $wpdb;
    1151        
    1152         return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 
     1153
     1154        return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
    11531155}
    11541156
    … …  
    11641166function bp_core_is_user_deleted( $user_id ) {
    11651167        global $wpdb;
    1166        
    1167         return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );   
     1168
     1169        return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
    11681170}
    11691171
    … …  
    11741176        if ( !$time )
    11751177                return false;
    1176                
     1178
    11771179        $date = date( "F j, Y ", $time );
    1178        
     1180
    11791181        if ( !$just_date ) {
    11801182                $date .= __('at', 'buddypress') . date( ' g:iA', $time );
    11811183        }
    1182        
     1184
    11831185        return $date;
    11841186}
    … …  
    11891191 *
    11901192 * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
    1191  * 
     1193 *
    11921194 * @package BuddyPress Core
    11931195 */
    11941196function bp_core_add_message( $message, $type = false ) {
    11951197        global $bp;
    1196        
     1198
    11971199        if ( !$type )
    11981200                $type = 'success';
    1199        
     1201
    12001202        /* Send the values to the cookie for page reload display */
    12011203        @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
    12021204        @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
    1203        
     1205
    12041206        /***
    12051207         * Send the values to the $bp global so we can still output messages
    … …  
    12181220 * After the message is displayed, it removes the message vars from the cookie so that the message
    12191221 * is not shown to the user multiple times.
    1220  * 
     1222 *
    12211223 * @package BuddyPress Core
    12221224 * @global $bp_message The message text
    … …  
    12291231        if ( empty( $bp->template_message ) )
    12301232                $bp->template_message = $_COOKIE['bp-message'];
    1231        
     1233
    12321234        if ( empty( $bp->template_message_type ) )
    12331235                $bp->template_message_type = $_COOKIE['bp-message-type'];
    12341236
    12351237        add_action( 'template_notices', 'bp_core_render_message' );
    1236        
     1238
    12371239        @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
    12381240        @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
    … …  
    12451247 * Renders a feedback message (either error or success message) to the theme template.
    12461248 * The hook action 'template_notices' is used to call this function, it is not called directly.
    1247  * 
     1249 *
    12481250 * @package BuddyPress Core
    12491251 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    12511253function bp_core_render_message() {
    12521254        global $bp;
    1253        
     1255
    12541256        if ( $bp->template_message ) {
    12551257                $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';
    … …  
    12601262        <?php
    12611263                do_action( 'bp_core_render_message' );
    1262         }       
     1264        }
    12631265}
    12641266
    … …  
    12671269 *
    12681270 * Based on function created by Dunstan Orchard - http://1976design.com
    1269  * 
     1271 *
    12701272 * This function will return an English representation of the time elapsed
    12711273 * since a given date.
    … …  
    12731275 * eg: 4 days
    12741276 * eg: 4 weeks and 6 days
    1275  * 
     1277 *
    12761278 * @package BuddyPress Core
    12771279 * @param $older_date int Unix timestamp of date you want to calculate the time since for
    … …  
    12911293        array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    12921294        );
    1293        
     1295
    12941296        $older_date = strtotime( gmdate( 'Y-m-d H:i:s', $older_date ) );
    12951297
    … …  
    12971299        /* $newer_date will have a value if we want to work out time elapsed between two known dates */
    12981300        $newer_date = ( !$newer_date ) ? ( strtotime( gmdate( 'Y-m-d H:i:s' ) ) + ( 60*60*0 ) ) : $newer_date;
    1299        
     1301
    13001302        /* Difference in seconds */
    13011303        $since = $newer_date - $older_date;
    1302        
     1304
    13031305        if ( 0 > $since )
    13041306                return __( '[Use GMT Timezone]', 'buddypress' );
    … …  
    13271329                $seconds2 = $chunks[$i + 1][0];
    13281330                $name2 = $chunks[$i + 1][1];
    1329                
     1331
    13301332                //if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output;
    1331        
     1333
    13321334                if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
    13331335                        /* Add to output var */
    … …  
    13491351 * show the length of time since the user was last active.
    13501352 * This function will update that time as a usermeta setting for the user every 5 minutes.
    1351  * 
     1353 *
    13521354 * @package BuddyPress Core
    13531355 * @global $userdata WordPress user data for the current logged in user.
    … …  
    13561358function bp_core_record_activity() {
    13571359        global $bp;
    1358        
     1360
    13591361        if ( !is_user_logged_in() )
    13601362                return false;
    1361        
     1363
    13621364        $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
    1363        
     1365
    13641366        if ( '' == $activity || time() >= strtotime( '+5 minutes', $activity ) )
    13651367                update_usermeta( $bp->loggedin_user->id, 'last_activity', time() );
    … …  
    13721374 *
    13731375 * Formats last activity based on time since date given.
    1374  * 
     1376 *
    13751377 * @package BuddyPress Core
    13761378 * @param last_activity_date The date of last activity.
    … …  
    13841386        } else {
    13851387                if ( strstr( $last_activity_date, '-' ) ) {
    1386                         $last_active = bp_core_time_since( strtotime( $last_activity_date ) ); 
     1388                        $last_active = bp_core_time_since( strtotime( $last_activity_date ) );
    13871389                } else {
    1388                         $last_active = bp_core_time_since( $last_activity_date ); 
     1390                        $last_active = bp_core_time_since( $last_activity_date );
    13891391                }
    1390                
     1392
    13911393                $last_active = sprintf( $string, $last_active );
    13921394        }
    1393        
     1395
    13941396        return $last_active;
    13951397}
    … …  
    14001402 *
    14011403 * Fetch every post that is authored by the given user for the current blog.
    1402  * 
     1404 *
    14031405 * @package BuddyPress Core
    14041406 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    14081410function bp_core_get_all_posts_for_user( $user_id = null ) {
    14091411        global $bp, $wpdb;
    1410        
     1412
    14111413        if ( !$user_id )
    14121414                $user_id = $bp->displayed_user->id;
    1413        
     1415
    14141416        return $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) );
    14151417}
    … …  
    14201422 *
    14211423 * Get the path of of the current site.
    1422  * 
     1424 *
    14231425 * @package BuddyPress Core
    14241426 * @global $comment WordPress comment global for the current comment.
    … …  
    14271429function bp_core_get_site_path() {
    14281430        global $current_site;
    1429        
     1431
    14301432        return $current_site->path;
    14311433}
    … …  
    14351437 *
    14361438 * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
    1437  * 
     1439 *
    14381440 * @package BuddyPress Core
    14391441 * @global $bp_no_status_set Makes sure that there are no conflicts with status_header() called in bp_core_do_catch_uri()
    … …  
    14431445function bp_core_redirect( $location, $status = 302 ) {
    14441446        global $bp_no_status_set;
    1445        
    1446         // Make sure we don't call status_header() in bp_core_do_catch_uri() 
     1447
     1448        // Make sure we don't call status_header() in bp_core_do_catch_uri()
    14471449    // as this conflicts with wp_redirect()
    14481450        $bp_no_status_set = true;
    1449        
     1451
    14501452        wp_redirect( $location, $status );
    14511453        die;
    … …  
    14561458 *
    14571459 * Returns the referrer URL without the http(s)://
    1458  * 
     1460 *
    14591461 * @package BuddyPress Core
    14601462 * @return The referrer URL
    … …  
    14731475 *
    14741476 * For example, it would stop someone creating a blog with the slug "groups".
    1475  * 
     1477 *
    14761478 * @package BuddyPress Core
    14771479 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    14791481function bp_core_add_illegal_names() {
    14801482        global $bp;
    1481        
     1483
    14821484        $current = maybe_unserialize( get_site_option( 'illegal_names' ) );
    14831485        $bp_illegal_names = $bp->root_components;
    1484        
     1486
    14851487        if ( is_array( $current ) ) {
    14861488                foreach( $bp_illegal_names as $bp_illegal_name ) {
    … …  
    15011503 *
    15021504 * Sets the "From" name in emails sent to the name of the site and not "WordPress"
    1503  * 
     1505 *
    15041506 * @package BuddyPress Core
    15051507 * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
    … …  
    15161518 *
    15171519 * Sets the "From" address in emails sent
    1518  * 
     1520 *
    15191521 * @package BuddyPress Core
    15201522 * @global $current_site Object containing current site metadata
    … …  
    15321534 *
    15331535 * Allows a user to completely remove their account from the system
    1534  * 
     1536 *
    15351537 * @package BuddyPress Core
    15361538 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    15641566 *
    15651567 * A javascript free implementation of the search functions in BuddyPress
    1566  * 
     1568 *
    15671569 * @package BuddyPress Core
    15681570 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    … …  
    15751577                $search_terms = $_POST['search-terms'];
    15761578                $search_which = $_POST['search-which'];
    1577                
     1579
    15781580                if ( !$slug || empty( $slug ) ) {
    15791581                        switch ( $search_which ) {
    … …  
    15961598                        }
    15971599                }
    1598                
     1600
    15991601                $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms );
    1600                
     1602
    16011603                bp_core_redirect( $search_url );
    16021604        }
    … …  
    16071609/**
    16081610 * bp_core_ucfirst()
    1609  * 
     1611 *
    16101612 * Localization safe ucfirst() support.
    1611  * 
     1613 *
    16121614 * @package BuddyPress Core
    16131615 */
    … …  
    16151617        if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
    16161618            $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
    1617             return $fc.mb_substr( $str, 1 );   
     1619            return $fc.mb_substr( $str, 1 );
    16181620        } else {
    16191621                return ucfirst( $str );
    … …  
    16241626/**
    16251627 * bp_core_strip_username_spaces()
    1626  * 
     1628 *
    16271629 * Strips spaces from usernames that are created using add_user() and wp_insert_user()
    1628  * 
     1630 *
    16291631 * @package BuddyPress Core
    16301632 */
    … …  
    16371639/**
    16381640 * bp_core_clear_cache()
    1639  * REQUIRES WP-SUPER-CACHE 
    1640  * 
     1641 * REQUIRES WP-SUPER-CACHE
     1642 *
    16411643 * When wp-super-cache is installed this function will clear cached pages
    16421644 * so that success/error messages are not cached, or time sensitive content.
    1643  * 
     1645 *
    16441646 * @package BuddyPress Core
    16451647 */
    16461648function bp_core_clear_cache() {
    16471649        global $cache_path, $cache_filename;
    1648        
     1650
    16491651        if ( function_exists( 'prune_super_cache' ) ) {
    16501652                do_action( 'bp_core_clear_cache' );
    1651                
    1652                 return prune_super_cache( $cache_path, true );         
     1653
     1654                return prune_super_cache( $cache_path, true );
    16531655        }
    16541656}
    … …  
    16561658/**
    16571659 * bp_core_print_generation_time()
    1658  * 
     1660 *
    16591661 * Prints the generation time in the footer of the site.
    1660  * 
     1662 *
    16611663 * @package BuddyPress Core
    16621664 */
    … …  
    16711673/**
    16721674 * bp_core_add_admin_menu_page()
    1673  * 
     1675 *
    16741676 * A better version of add_admin_menu_page() that allows positioning of menus.
    1675  * 
     1677 *
    16761678 * @package BuddyPress Core
    16771679 */
    … …  
    16911693        $r = wp_parse_args( $args, $defaults );
    16921694        extract( $r, EXTR_SKIP );
    1693        
     1695
    16941696        $file = plugin_basename( $file );
    16951697
    … …  
    17081710                $position++;
    17091711        } while ( !empty( $menu[$position] ) );
    1710        
     1712
    17111713        $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
    17121714
    … …  
    17211723 * When a user logs in, check if they have been marked as a spammer. If then simply
    17221724 * redirect them to the home page and stop them from logging in.
    1723  * 
     1725 *
    17241726 * @package BuddyPress Core
    17251727 * @param $username The username of the user
    … …  
    17281730function bp_core_boot_spammer( $auth_obj, $username ) {
    17291731        global $bp;
    1730        
     1732
    17311733        $user = get_userdatabylogin( $username );
    17321734
    … …  
    17401742 *
    17411743 * Deletes usermeta for the user when the user is deleted.
    1742  * 
     1744 *
    17431745 * @package BuddyPress Core
    17441746 * @param $user_id The user id for the user to delete usermeta for
    … …  
    17581760/**
    17591761 * bp_load_buddypress_textdomain()
    1760  * 
     1762 *
    17611763 * Load the buddypress translation file for current language
    1762  * 
     1764 *
    17631765 * @package BuddyPress Core
    17641766 */
    … …  
    17661768        $locale = apply_filters( 'buddypress_locale', get_locale() );
    17671769        $mofile = BP_PLUGIN_DIR . "/bp-languages/buddypress-$locale.mo";
    1768        
     1770
    17691771        if ( file_exists( $mofile ) )
    17701772                load_textdomain( 'buddypress', $mofile );
    … …  
    17811783/**
    17821784 * bp_core_update_message()
    1783  * 
     1785 *
    17841786 * Add an extra update message to the update plugin notification.
    1785  * 
     1787 *
    17861788 * @package BuddyPress Core
    17871789 */
    … …  
    17931795/**
    17941796 * bp_core_clear_user_object_cache()
    1795  * 
     1797 *
    17961798 * Clears all cached objects for a user, or a user is part of.
    1797  * 
     1799 *
    17981800 * @package BuddyPress Core
    17991801 */
Note: See TracChangeset for help on using the changeset viewer.