Skip to:
Content

BuddyPress.org

Changeset 3232 for trunk/bp-core.php


Ignore:
Timestamp:
09/06/2010 04:24:57 PM (14 years ago)
Author:
apeatling
Message:

Merging 1.2 branch with trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r2978 r3232  
    3030require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );
    3131require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );
    32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );
    3332require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );
    3433require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );
     
    3837require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
    3938require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );
     39
     40/* Multisite includes built in account activation support. */
     41if ( bp_core_is_multisite() )
     42    require ( BP_PLUGIN_DIR . '/bp-core/bp-core-activation.php' );
    4043
    4144/* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */
     
    229232    }
    230233
    231 
    232234    return apply_filters( 'bp_core_get_page_names', $pages );
    233235}
     236
    234237
    235238/**
     
    463466        }
    464467
    465         do_action( 'bp_core_action_delete_user', $errors );
     468        do_action( 'bp_core_action_set_spammer_status', $errors );
    466469
    467470        if ( $errors )
     
    497500        'search_terms' => false, // Limit to users that match these search terms
    498501
    499         'include' => false, // Pass comma separated list of user_ids to limit to only these users
    500502        'per_page' => 20, // The number of results to return per page
    501503        'page' => 1, // The page to return if limiting per page
     
    506508    extract( $params, EXTR_SKIP );
    507509
    508     return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras ), &$params );
     510    return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $search_terms, $populate_extras ), &$params );
    509511}
    510512
     
    898900}
    899901
    900 
    901902/**
    902903 * bp_core_get_random_member()
     
    934935    global $wpdb;
    935936
    936     if ( empty( $username ) )
    937         return false;
    938 
    939     return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
     937    if ( !empty( $username ) )
     938        return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
    940939}
    941940
     
    12901289add_action( 'bp_init', 'bp_core_setup_message' );
    12911290
     1291
    12921292/**
    12931293 * bp_core_render_message()
     
    13311331function bp_core_time_since( $older_date, $newer_date = false ) {
    13321332    // array of time period chunks
    1333 
    13341333    $chunks = array(
    13351334    array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
     
    14511450        return $number;
    14521451
    1453     return apply_filters( 'bp_core_number_format', number_format( $number, $decimals ), $number, $decimals );
     1452    return apply_filters( 'bp_core_bp_core_number_format', number_format( $number, $decimals ), $number, $decimals );
    14541453}
    14551454
     
    14981497            unset( $site_path[2] );
    14991498
    1500             if ( !count( $site_path ) )
    1501                 $site_path = '/';
    1502             else
    1503                 $site_path = '/' . implode( '/', $site_path ) . '/';
     1499            $site_path = '/' . implode( '/', $site_path ) . '/';
    15041500        }
    15051501    }
     
    15071503    return apply_filters( 'bp_core_get_site_path', $site_path );
    15081504}
     1505
    15091506/**
    15101507 * bp_core_get_site_options()
     
    16231620
    16241621/**
     1622 * bp_core_email_from_name_filter()
     1623 *
     1624 * Sets the "From" name in emails sent to the name of the site and not "WordPress"
     1625 *
     1626 * @package BuddyPress Core
     1627 * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
     1628 * @return The blog name for the root blog
     1629 */
     1630function bp_core_email_from_name_filter() {
     1631    return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
     1632}
     1633add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
     1634
     1635
     1636/**
     1637 * bp_core_email_from_name_filter()
     1638 *
     1639 * Sets the "From" address in emails sent
     1640 *
     1641 * @package BuddyPress Core
     1642 * @global $current_site Object containing current site metadata
     1643 * @return noreply@sitedomain email address
     1644 */
     1645function bp_core_email_from_address_filter() {
     1646    $domain = (array) explode( '/', site_url() );
     1647
     1648    return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] );
     1649}
     1650add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
     1651
     1652/**
    16251653 * bp_core_delete_account()
    16261654 *
     
    16351663 */
    16361664function bp_core_delete_account( $user_id = false ) {
    1637     global $bp, $wpdb;
     1665    global $bp, $wp_version;
    16381666
    16391667    if ( !$user_id )
     
    16441672        return false;
    16451673
     1674    /* Site admins cannot be deleted */
     1675    if ( is_super_admin( bp_core_get_username( $user_id ) ) )
     1676        return false;
     1677
    16461678    /* Specifically handle multi-site environment */
    16471679    if ( bp_core_is_multisite() ) {
    1648         /* Site admins cannot be deleted */
    1649         if ( is_site_admin( bp_core_get_username( $user_id ) ) )
    1650             return false;
    1651 
    1652         require_once( ABSPATH . '/wp-admin/includes/mu.php' );
     1680        if ( $wp_version >= '3.0' )
     1681            require_once( ABSPATH . '/wp-admin/includes/ms.php' );
     1682        else
     1683            require_once( ABSPATH . '/wp-admin/includes/mu.php' );
     1684
    16531685        require_once( ABSPATH . '/wp-admin/includes/user.php' );
    16541686
    16551687        return wpmu_delete_user( $user_id );
    1656     }
    16571688
    16581689    /* Single site user deletion */
    1659     require_once( ABSPATH . '/wp-admin/includes/user.php' );
    1660     return wp_delete_user( $user_id );
    1661 }
    1662 
     1690    } else {
     1691        require_once( ABSPATH . '/wp-admin/includes/user.php' );
     1692        return wp_delete_user( $user_id );
     1693    }
     1694}
    16631695
    16641696/**
     
    17671799    ?>
    17681800
    1769 <!-- Generated in <?php timer_stop(1); ?> seconds. -->
     1801<!-- Generated in <?php timer_stop(1); ?> seconds. (<?php echo get_num_queries(); ?> q) -->
    17701802
    17711803    <?php
     
    18381870    $user = get_userdatabylogin( $username );
    18391871
    1840     if ( ( bp_core_is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status )
     1872    if ( (int)$user->spam )
    18411873        bp_core_redirect( $bp->root_domain );
    18421874    else
     
    18611893    wp_cache_flush();
    18621894}
    1863 add_action( 'wpmu_delete_user', 'bp_core_remove_data' );
    1864 add_action( 'delete_user', 'bp_core_remove_data' );
    1865 add_action( 'make_spam_user', 'bp_core_remove_data' );
     1895add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 );
     1896add_action( 'delete_user', 'bp_core_remove_data', 1 );
     1897add_action( 'make_spam_user', 'bp_core_remove_data', 1 );
    18661898
    18671899/**
     
    18991931}
    19001932add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' );
     1933
     1934/**
     1935 * bp_core_filter_parent_theme()
     1936 *
     1937 * Remove social network parent theme from the theme list.
     1938 *
     1939 * @package BuddyPress Core
     1940 */
     1941function bp_core_filter_parent_theme() {
     1942    global $wp_themes, $pagenow;
     1943
     1944    if ( is_admin() && 'themes.php' == $pagenow )
     1945        $wp_themes = get_themes();
     1946
     1947    unset( $wp_themes['BuddyPress Classic Parent'] );
     1948}
     1949add_filter( 'admin_menu', 'bp_core_filter_parent_theme' );
     1950
     1951/**
     1952 * bp_core_allow_default_theme()
     1953 *
     1954 * On multiblog installations you must first allow themes to be activated and show
     1955 * up on the theme selection screen. This function will let the BuddyPress bundled
     1956 * themes show up on the root blog selection screen and bypass this step. It also
     1957 * means that the themes won't show for selection on other blogs.
     1958 *
     1959 * @package BuddyPress Core
     1960 */
     1961function bp_core_allow_default_theme( $themes ) {
     1962    global $bp, $current_blog;
     1963
     1964    if ( !is_site_admin() )
     1965        return $themes;
     1966
     1967    if ( $current_blog->ID == $bp->root_blog ) {
     1968        $themes['bp-default'] = 1;
     1969        $themes['bp-classic'] = 1;
     1970    }
     1971
     1972    return $themes;
     1973}
     1974add_filter( 'allowed_themes', 'bp_core_allow_default_theme' );
    19011975
    19021976/**
     
    19412015add_action( 'admin_notices', 'bp_core_activation_notice' );
    19422016
     2017
     2018/**
     2019 * bp_core_filter_comments()
     2020 *
     2021 * Filter the blog post comments array and insert BuddyPress URLs for users.
     2022 *
     2023 * @package BuddyPress Core
     2024 */
     2025function bp_core_filter_comments( $comments, $post_id ) {
     2026    global $wpdb;
     2027
     2028    foreach( (array)$comments as $comment ) {
     2029        if ( $comment->user_id )
     2030            $user_ids[] = $comment->user_id;
     2031    }
     2032
     2033    if ( empty( $user_ids ) )
     2034        return $comments;
     2035
     2036    $user_ids = implode( ',', $user_ids );
     2037
     2038    if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) )
     2039        return $comments;
     2040
     2041    foreach( (array)$userdata as $user )
     2042        $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
     2043
     2044    foreach( (array)$comments as $i => $comment ) {
     2045        if ( !empty( $comment->user_id ) ) {
     2046            if ( !empty( $users[$comment->user_id] ) )
     2047                $comments[$i]->comment_author_url = $users[$comment->user_id];
     2048        }
     2049    }
     2050
     2051    return $comments;
     2052}
     2053add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
     2054
     2055
     2056/**
     2057 * bp_core_login_redirect()
     2058 *
     2059 * When a user logs in, always redirect them back to the previous page. NOT the admin area.
     2060 *
     2061 * @package BuddyPress Core
     2062 */
     2063function bp_core_login_redirect( $redirect_to ) {
     2064    global $bp, $current_blog;
     2065
     2066    if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
     2067        return $redirect_to;
     2068
     2069    if ( !empty( $_REQUEST['redirect_to'] ) || strpos( $_REQUEST['redirect_to'], 'wp-admin' ) )
     2070        return $redirect_to;
     2071
     2072    if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) )
     2073        return wp_get_referer();
     2074
     2075    return $bp->root_domain;
     2076}
     2077add_filter( 'login_redirect', 'bp_core_login_redirect' );
     2078
     2079
    19432080/********************************************************************************
    19442081 * Custom Actions
     
    19642101    do_action( 'bp_setup_nav' );
    19652102}
    1966 add_action( 'plugins_loaded', 'bp_setup_nav' );
    1967 add_action( 'admin_menu', 'bp_setup_nav' );
     2103add_action( 'bp_loaded', 'bp_setup_nav', 8 );
    19682104
    19692105/* Allow core components and dependent plugins to register widgets */
Note: See TracChangeset for help on using the changeset viewer.