Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r15967 r17194  
    257257function wp_debug_mode() {
    258258    if ( WP_DEBUG ) {
     259        // E_DEPRECATED is a core PHP constant in PHP 5.3. Don't define this yourself.
     260        // The two statements are equivalent, just one is for 5.3+ and for less than 5.3.
    259261        if ( defined( 'E_DEPRECATED' ) )
    260262            error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
     
    309311
    310312/**
     313 * Load the correct database class file.
     314 *
     315 * This function is used to load the database class file either at runtime or by
     316 * wp-admin/setup-config.php. We must globalize $wpdb to ensure that it is
     317 * defined globally by the inline code in wp-db.php.
     318 *
     319 * @since 2.5.0
     320 * @global $wpdb WordPress Database Object
     321 */
     322function require_wp_db() {
     323    global $wpdb;
     324
     325    require_once( ABSPATH . WPINC . '/wp-db.php' );
     326    if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
     327        require_once( WP_CONTENT_DIR . '/db.php' );
     328
     329    if ( isset( $wpdb ) )
     330        return;
     331
     332    $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
     333}
     334
     335/**
    311336 * Sets the database table prefix and the format specifiers for database table columns.
    312337 *
     
    379404
    380405    if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    381         wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
     406        wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
    382407        wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
    383408    }
     
    397422            wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
    398423    } elseif ( ! is_blog_installed() && false === strpos( $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) {
    399         if ( defined( 'WP_SITEURL' ) )
    400             $link = WP_SITEURL . '/wp-admin/install.php';
    401         elseif ( false !== strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) )
    402             $link = preg_replace( '|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
    403         else
    404             $link = preg_replace( '|/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
     424
     425        $link = wp_guess_url() . '/wp-admin/install.php';
     426
    405427        require( ABSPATH . WPINC . '/kses.php' );
    406428        require( ABSPATH . WPINC . '/pluggable.php' );
     
    453475    $active_plugins = (array) get_option( 'active_plugins', array() );
    454476
    455     // Get active network plugins
    456     if ( is_multisite() ) {
    457         $active_sitewide_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
    458         if ( !empty($active_sitewide_plugins) ) {
    459             $active_plugins = array_merge( $active_plugins, array_keys( $active_sitewide_plugins ) );
    460             sort( $active_plugins );
    461         }
    462     }
    463 
    464477    // Check for hacks file if the option is enabled
    465478    if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
     
    471484        return $plugins;
    472485
     486    $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
     487
    473488    foreach ( $active_plugins as $plugin ) {
    474489        if ( ! validate_file( $plugin ) // $plugin must validate as file
    475490            && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
    476491            && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
     492            // not already included as a network plugin
     493            && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
    477494            )
    478495        $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
     
    554571
    555572/**
    556  * Whether the current request is in WordPress admin Panel
     573 * Whether the current request is for a network or blog admin page
    557574 *
    558575 * Does not inform on whether the user is an admin! Use capability checks to
     
    570587
    571588/**
     589 * Whether the current request is for a blog admin screen /wp-admin/
     590 *
     591 * Does not inform on whether the user is a blog admin! Use capability checks to
     592 * tell if the user should be accessing a section or not.
     593 *
     594 * @since 3.1.0
     595 *
     596 * @return bool True if inside WordPress network administration pages.
     597 */
     598function is_blog_admin() {
     599    if ( defined( 'WP_BLOG_ADMIN' ) )
     600        return WP_BLOG_ADMIN;
     601    return false;
     602}
     603
     604/**
     605 * Whether the current request is for a network admin screen /wp-admin/network/
     606 *
     607 * Does not inform on whether the user is a network admin! Use capability checks to
     608 * tell if the user should be accessing a section or not.
     609 *
     610 * @since 3.1.0
     611 *
     612 * @return bool True if inside WordPress network administration pages.
     613 */
     614function is_network_admin() {
     615    if ( defined( 'WP_NETWORK_ADMIN' ) )
     616        return WP_NETWORK_ADMIN;
     617    return false;
     618}
     619
     620/**
     621 * Whether the current request is for a user admin screen /wp-admin/user/
     622 *
     623 * Does not inform on whether the user is an admin! Use capability checks to
     624 * tell if the user should be accessing a section or not.
     625 *
     626 * @since 3.1.0
     627 *
     628 * @return bool True if inside WordPress user administration pages.
     629 */
     630function is_user_admin() {
     631    if ( defined( 'WP_USER_ADMIN' ) )
     632        return WP_USER_ADMIN;
     633    return false;
     634}
     635
     636/**
    572637 * Whether Multisite support is enabled
    573638 *
Note: See TracChangeset for help on using the changeset viewer.