Changeset 3232 for trunk/bp-core.php
- Timestamp:
- 09/06/2010 04:24:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r2978 r3232 30 30 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); 31 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' ); 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );33 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' ); 34 33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' ); … … 38 37 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' ); 39 38 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' ); 39 40 /* Multisite includes built in account activation support. */ 41 if ( bp_core_is_multisite() ) 42 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-activation.php' ); 40 43 41 44 /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */ … … 229 232 } 230 233 231 232 234 return apply_filters( 'bp_core_get_page_names', $pages ); 233 235 } 236 234 237 235 238 /** … … 463 466 } 464 467 465 do_action( 'bp_core_action_ delete_user', $errors );468 do_action( 'bp_core_action_set_spammer_status', $errors ); 466 469 467 470 if ( $errors ) … … 497 500 'search_terms' => false, // Limit to users that match these search terms 498 501 499 'include' => false, // Pass comma separated list of user_ids to limit to only these users500 502 'per_page' => 20, // The number of results to return per page 501 503 'page' => 1, // The page to return if limiting per page … … 506 508 extract( $params, EXTR_SKIP ); 507 509 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 ); 509 511 } 510 512 … … 898 900 } 899 901 900 901 902 /** 902 903 * bp_core_get_random_member() … … 934 935 global $wpdb; 935 936 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 ) ) ); 940 939 } 941 940 … … 1290 1289 add_action( 'bp_init', 'bp_core_setup_message' ); 1291 1290 1291 1292 1292 /** 1293 1293 * bp_core_render_message() … … 1331 1331 function bp_core_time_since( $older_date, $newer_date = false ) { 1332 1332 // array of time period chunks 1333 1334 1333 $chunks = array( 1335 1334 array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ), … … 1451 1450 return $number; 1452 1451 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 ); 1454 1453 } 1455 1454 … … 1498 1497 unset( $site_path[2] ); 1499 1498 1500 if ( !count( $site_path ) ) 1501 $site_path = '/'; 1502 else 1503 $site_path = '/' . implode( '/', $site_path ) . '/'; 1499 $site_path = '/' . implode( '/', $site_path ) . '/'; 1504 1500 } 1505 1501 } … … 1507 1503 return apply_filters( 'bp_core_get_site_path', $site_path ); 1508 1504 } 1505 1509 1506 /** 1510 1507 * bp_core_get_site_options() … … 1623 1620 1624 1621 /** 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 */ 1630 function bp_core_email_from_name_filter() { 1631 return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) ); 1632 } 1633 add_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 */ 1645 function 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 } 1650 add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' ); 1651 1652 /** 1625 1653 * bp_core_delete_account() 1626 1654 * … … 1635 1663 */ 1636 1664 function bp_core_delete_account( $user_id = false ) { 1637 global $bp, $wp db;1665 global $bp, $wp_version; 1638 1666 1639 1667 if ( !$user_id ) … … 1644 1672 return false; 1645 1673 1674 /* Site admins cannot be deleted */ 1675 if ( is_super_admin( bp_core_get_username( $user_id ) ) ) 1676 return false; 1677 1646 1678 /* Specifically handle multi-site environment */ 1647 1679 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 1653 1685 require_once( ABSPATH . '/wp-admin/includes/user.php' ); 1654 1686 1655 1687 return wpmu_delete_user( $user_id ); 1656 }1657 1688 1658 1689 /* 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 } 1663 1695 1664 1696 /** … … 1767 1799 ?> 1768 1800 1769 <!-- Generated in <?php timer_stop(1); ?> seconds. -->1801 <!-- Generated in <?php timer_stop(1); ?> seconds. (<?php echo get_num_queries(); ?> q) --> 1770 1802 1771 1803 <?php … … 1838 1870 $user = get_userdatabylogin( $username ); 1839 1871 1840 if ( ( bp_core_is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status)1872 if ( (int)$user->spam ) 1841 1873 bp_core_redirect( $bp->root_domain ); 1842 1874 else … … 1861 1893 wp_cache_flush(); 1862 1894 } 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' );1895 add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 ); 1896 add_action( 'delete_user', 'bp_core_remove_data', 1 ); 1897 add_action( 'make_spam_user', 'bp_core_remove_data', 1 ); 1866 1898 1867 1899 /** … … 1899 1931 } 1900 1932 add_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 */ 1941 function 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 } 1949 add_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 */ 1961 function 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 } 1974 add_filter( 'allowed_themes', 'bp_core_allow_default_theme' ); 1901 1975 1902 1976 /** … … 1941 2015 add_action( 'admin_notices', 'bp_core_activation_notice' ); 1942 2016 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 */ 2025 function 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 } 2053 add_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 */ 2063 function 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 } 2077 add_filter( 'login_redirect', 'bp_core_login_redirect' ); 2078 2079 1943 2080 /******************************************************************************** 1944 2081 * Custom Actions … … 1964 2101 do_action( 'bp_setup_nav' ); 1965 2102 } 1966 add_action( 'plugins_loaded', 'bp_setup_nav' ); 1967 add_action( 'admin_menu', 'bp_setup_nav' ); 2103 add_action( 'bp_loaded', 'bp_setup_nav', 8 ); 1968 2104 1969 2105 /* Allow core components and dependent plugins to register widgets */
Note: See TracChangeset
for help on using the changeset viewer.