[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> ms-settings.php (source)

   1  <?php
   2  /**
   3   * Used to set up and fix common variables and include
   4   * the Multisite procedural and class library.
   5   *
   6   * Allows for some configuration in wp-config.php (see ms-default-constants.php)
   7   *
   8   * @package WordPress
   9   * @subpackage Multisite
  10   * @since 3.0.0
  11   */
  12  
  13  /**
  14   * Objects representing the current network and current site.
  15   *
  16   * These may be populated through a custom `sunrise.php`. If not, then this
  17   * file will attempt to populate them based on the current request.
  18   *
  19   * @global WP_Network $current_site The current network.
  20   * @global object     $current_blog The current site.
  21   * @global string     $domain       Deprecated. The domain of the site found on load.
  22   *                                  Use `get_site()->domain` instead.
  23   * @global string     $path         Deprecated. The path of the site found on load.
  24   *                                  Use `get_site()->path` instead.
  25   * @global int        $site_id      Deprecated. The ID of the network found on load.
  26   *                                  Use `get_current_network_id()` instead.
  27   * @global bool       $public       Deprecated. Whether the site found on load is public.
  28   *                                  Use `get_site()->public` instead.
  29   *
  30   * @since 3.0.0
  31   */
  32  global $current_site, $current_blog, $domain, $path, $site_id, $public;
  33  
  34  /** WP_Network class */
  35  require_once  ABSPATH . WPINC . '/class-wp-network.php';
  36  
  37  /** WP_Site class */
  38  require_once  ABSPATH . WPINC . '/class-wp-site.php';
  39  
  40  /** Multisite loader */
  41  require_once  ABSPATH . WPINC . '/ms-load.php';
  42  
  43  /** Default Multisite constants */
  44  require_once  ABSPATH . WPINC . '/ms-default-constants.php';
  45  
  46  if ( defined( 'SUNRISE' ) ) {
  47      include_once WP_CONTENT_DIR . '/sunrise.php';
  48  }
  49  
  50  /** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */
  51  ms_subdomain_constants();
  52  
  53  // This block will process a request if the current network or current site objects
  54  // have not been populated in the global scope through something like `sunrise.php`.
  55  if ( ! isset( $current_site ) || ! isset( $current_blog ) ) {
  56  
  57      $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) );
  58      if ( str_ends_with( $domain, ':80' ) ) {
  59          $domain               = substr( $domain, 0, -3 );
  60          $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
  61      } elseif ( str_ends_with( $domain, ':443' ) ) {
  62          $domain               = substr( $domain, 0, -4 );
  63          $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
  64      }
  65  
  66      $path = stripslashes( $_SERVER['REQUEST_URI'] );
  67      if ( is_admin() ) {
  68          $path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path );
  69      }
  70      list( $path ) = explode( '?', $path );
  71  
  72      $bootstrap_result = ms_load_current_site_and_network( $domain, $path, is_subdomain_install() );
  73  
  74      if ( true === $bootstrap_result ) {
  75          // `$current_blog` and `$current_site are now populated.
  76      } elseif ( false === $bootstrap_result ) {
  77          ms_not_installed( $domain, $path );
  78      } else {
  79          header( 'Location: ' . $bootstrap_result );
  80          exit;
  81      }
  82      unset( $bootstrap_result );
  83  
  84      $blog_id = $current_blog->blog_id;
  85      $public  = $current_blog->public;
  86  
  87      if ( empty( $current_blog->site_id ) ) {
  88          // This dates to [MU134] and shouldn't be relevant anymore,
  89          // but it could be possible for arguments passed to insert_blog() etc.
  90          $current_blog->site_id = 1;
  91      }
  92  
  93      $site_id = $current_blog->site_id;
  94      wp_load_core_site_options( $site_id );
  95  }
  96  
  97  $wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php.
  98  $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id );
  99  $table_prefix       = $wpdb->get_blog_prefix();
 100  $_wp_switched_stack = array();
 101  $switched           = false;
 102  
 103  // Need to init cache again after blog_id is set.
 104  wp_start_object_cache();
 105  
 106  if ( ! $current_site instanceof WP_Network ) {
 107      $current_site = new WP_Network( $current_site );
 108  }
 109  
 110  if ( ! $current_blog instanceof WP_Site ) {
 111      $current_blog = new WP_Site( $current_blog );
 112  }
 113  
 114  // Define upload directory constants.
 115  ms_upload_constants();
 116  
 117  /**
 118   * Fires after the current site and network have been detected and loaded
 119   * in multisite's bootstrap.
 120   *
 121   * @since 4.6.0
 122   */
 123  do_action( 'ms_loaded' );


Generated : Thu Mar 28 08:20:01 2024 Cross-referenced by PHPXref