[ Root ] [ Search ] [ Index ]

PHP Cross Reference of WordPress MU 2.9.2

Provided by Yoast

title

Body

[close]

/ -> wp-settings.php (source)

   1  <?php
   2  /**
   3   * Used to setup and fix common variables and include
   4   * the WordPress procedural and class library.
   5   *
   6   * You should not have to change this file and allows
   7   * for some configuration in wp-config.php.
   8   *
   9   * @package WordPress
  10   */
  11  
  12  if ( !defined('WP_MEMORY_LIMIT') )
  13      define('WP_MEMORY_LIMIT', '64M');
  14  
  15  if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
  16      @ini_set('memory_limit', WP_MEMORY_LIMIT);
  17  
  18  set_magic_quotes_runtime(0);
  19  @ini_set('magic_quotes_sybase', 0);
  20  
  21  if ( function_exists('date_default_timezone_set') )
  22      date_default_timezone_set('UTC');
  23  
  24  if ( defined( 'VHOST' ) && ( constant( 'VHOST' ) != 'yes' && constant( 'VHOST' ) != 'no' ) )
  25      die( "Warning! VHOST must be 'yes' or 'no' in wp-config.php" );
  26  
  27  /**
  28   * Turn register globals off.
  29   *
  30   * @access private
  31   * @since 2.1.0
  32   * @return null Will return null if register_globals PHP directive was disabled
  33   */
  34  function wp_unregister_GLOBALS() {
  35      if ( !ini_get('register_globals') )
  36          return;
  37  
  38      if ( isset($_REQUEST['GLOBALS']) )
  39          die('GLOBALS overwrite attempt detected');
  40  
  41      // Variables that shouldn't be unset
  42      $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
  43  
  44      $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
  45      foreach ( $input as $k => $v )
  46          if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
  47              $GLOBALS[$k] = NULL;
  48              unset($GLOBALS[$k]);
  49          }
  50  }
  51  
  52  wp_unregister_GLOBALS();
  53  
  54  unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
  55  
  56  /**
  57   * The $blog_id global, which you can change in the config allows you to create a simple
  58   * multiple blog installation using just one WordPress and changing $blog_id around.
  59   *
  60   * @global int $blog_id
  61   * @since 2.0.0
  62   */
  63  if ( ! isset($blog_id) )
  64      $blog_id = 0;
  65  
  66  // Fix for IIS when running with PHP ISAPI
  67  if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
  68  
  69      // IIS Mod-Rewrite
  70      if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
  71          $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
  72      }
  73      // IIS Isapi_Rewrite
  74      else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
  75          $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
  76      }
  77      else
  78      {
  79          // Use ORIG_PATH_INFO if there is no PATH_INFO
  80          if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
  81              $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
  82  
  83          // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
  84          if ( isset($_SERVER['PATH_INFO']) ) {
  85              if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
  86                  $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
  87              else
  88                  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
  89          }
  90  
  91          // Append the query string if it exists and isn't null
  92          if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
  93              $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
  94          }
  95      }
  96  }
  97  
  98  // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
  99  if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
 100      $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
 101  
 102  // Fix for Dreamhost and other PHP as CGI hosts
 103  if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
 104      unset($_SERVER['PATH_INFO']);
 105  
 106  
 107  if ( version_compare( '4.3', phpversion(), '>' ) ) {
 108      die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, phpversion() ) );
 109  }
 110  
 111  if ( !defined('WP_CONTENT_DIR') )
 112      define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
 113  
 114  if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
 115      include(ABSPATH . '.maintenance');
 116      // If the $upgrading timestamp is older than 10 minutes, don't die.
 117      if ( ( time() - $upgrading ) < 600 ) {
 118          if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
 119              require_once( WP_CONTENT_DIR . '/maintenance.php' );
 120              die();
 121          }
 122  
 123          $protocol = $_SERVER["SERVER_PROTOCOL"];
 124          if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
 125              $protocol = 'HTTP/1.0';
 126          header( "$protocol 503 Service Unavailable", true, 503 );
 127          header( 'Content-Type: text/html; charset=utf-8' );
 128          header( 'Retry-After: 600' );
 129  ?>
 130  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 131  <html xmlns="http://www.w3.org/1999/xhtml">
 132  <head>
 133  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 134      <title>Maintenance</title>
 135  
 136  </head>
 137  <body>
 138      <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
 139  </body>
 140  </html>
 141  <?php
 142          die();
 143      }
 144  }
 145  
 146  if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
 147      die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
 148  
 149  /**
 150   * PHP 4 standard microtime start capture.
 151   *
 152   * @access private
 153   * @since 0.71
 154   * @global int $timestart Seconds and Microseconds added together from when function is called.
 155   * @return bool Always returns true.
 156   */
 157  function timer_start() {
 158      global $timestart;
 159      $mtime = explode(' ', microtime() );
 160      $mtime = $mtime[1] + $mtime[0];
 161      $timestart = $mtime;
 162      return true;
 163  }
 164  
 165  /**
 166   * Return and/or display the time from the page start to when function is called.
 167   *
 168   * You can get the results and print them by doing:
 169   * <code>
 170   * $nTimePageTookToExecute = timer_stop();
 171   * echo $nTimePageTookToExecute;
 172   * </code>
 173   *
 174   * Or instead, you can do:
 175   * <code>
 176   * timer_stop(1);
 177   * </code>
 178   * which will do what the above does. If you need the result, you can assign it to a variable, but
 179   * most cases, you only need to echo it.
 180   *
 181   * @since 0.71
 182   * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
 183   * @global int $timeend  Seconds and Microseconds added together from when function is called
 184   *
 185   * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
 186   * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
 187   * @return float The "second.microsecond" finished time calculation
 188   */
 189  function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
 190      global $timestart, $timeend;
 191      $mtime = microtime();
 192      $mtime = explode(' ',$mtime);
 193      $mtime = $mtime[1] + $mtime[0];
 194      $timeend = $mtime;
 195      $timetotal = $timeend-$timestart;
 196      $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
 197      if ( $display )
 198          echo $r;
 199      return $r;
 200  }
 201  timer_start();
 202  
 203  // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
 204  if ( defined('WP_DEBUG') && WP_DEBUG ) {
 205      if ( defined('E_DEPRECATED') )
 206          error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
 207      else
 208          error_reporting(E_ALL);
 209      // Add define('WP_DEBUG_DISPLAY', false); to wp-config.php to use the globally configured setting for display_errors and not force it to On
 210      if ( ! defined('WP_DEBUG_DISPLAY') || WP_DEBUG_DISPLAY )
 211          ini_set('display_errors', 1);
 212      // Add define('WP_DEBUG_LOG', true); to enable php debug logging to WP_CONTENT_DIR/debug.log
 213      if ( defined('WP_DEBUG_LOG') && WP_DEBUG_LOG ) {
 214          ini_set('log_errors', 1);
 215          ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
 216      }
 217  } else {
 218      define('WP_DEBUG', false);
 219      if ( defined('E_RECOVERABLE_ERROR') )
 220          error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
 221      else
 222          error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
 223  }
 224  
 225  // For an advanced caching plugin to use, static because you would only want one
 226  if ( defined('WP_CACHE') && WP_CACHE )
 227      @include WP_CONTENT_DIR . '/advanced-cache.php';
 228  
 229  /**
 230   * Private
 231   */ 
 232  if ( !defined('MEDIA_TRASH') )
 233      define('MEDIA_TRASH', false);
 234  
 235  /**
 236   * Stores the location of the WordPress directory of functions, classes, and core content.
 237   *
 238   * @since 1.0.0
 239   */
 240  define('WPINC', 'wp-includes');
 241  
 242  if ( !defined('WP_LANG_DIR') ) {
 243      /**
 244       * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
 245       * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
 246       *
 247       * @since 2.1.0
 248       */
 249      if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
 250          define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
 251          if (!defined('LANGDIR')) {
 252              // Old static relative path maintained for limited backwards compatibility - won't work in some cases
 253              define('LANGDIR', 'wp-content/languages');
 254          }
 255      } else {
 256          define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
 257          if (!defined('LANGDIR')) {
 258              // Old relative path maintained for backwards compatibility
 259              define('LANGDIR', WPINC . '/languages');
 260          }
 261      }
 262  }
 263  
 264  require (ABSPATH . WPINC . '/compat.php');
 265  require (ABSPATH . WPINC . '/functions.php');
 266  require (ABSPATH . WPINC . '/classes.php');
 267  
 268  require_wp_db();
 269  
 270  if ( !empty($wpdb->error) )
 271      dead_db();
 272  
 273  /**
 274   * Format specifiers for DB columns. Columns not listed here default to %s.
 275   * @since 2.8.0
 276   * @see wpdb:$field_types
 277   * @see wpdb:prepare()
 278   * @see wpdb:insert()
 279   * @see wpdb:update()
 280   */
 281  $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
 282      'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
 283      'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
 284      'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
 285  
 286  $prefix = $wpdb->set_prefix($table_prefix); // set up global tables
 287  
 288  if ( is_wp_error($prefix) )
 289      wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/);
 290  
 291  /**
 292   * Copy an object.
 293   *
 294   * Returns a cloned copy of an object.
 295   *
 296   * @since 2.7.0
 297   *
 298   * @param object $object The object to clone
 299   * @return object The cloned object
 300   */
 301  function wp_clone( $object ) {
 302      static $can_clone;
 303      if ( !isset( $can_clone ) ) {
 304          $can_clone = version_compare( phpversion(), '5.0', '>=' );
 305      }
 306      return $can_clone ? clone( $object ) : $object;
 307  }
 308  
 309  /**
 310   * Whether the current request is in WordPress admin Panel
 311   *
 312   * Does not inform on whether the user is an admin! Use capability checks to
 313   * tell if the user should be accessing a section or not.
 314   *
 315   * @since 1.5.1
 316   *
 317   * @return bool True if inside WordPress administration pages.
 318   */
 319  function is_admin() {
 320      if ( defined('WP_ADMIN') )
 321          return WP_ADMIN;
 322      return false;
 323  }
 324  
 325  /**
 326   * Whether Multisite support is enabled (stub from WP 3.0)
 327   * 
 328   * @since 2.9.1
 329   *
 330   * @return bool True always.
 331   */
 332  function is_multisite() {
 333      return true;
 334  }
 335  
 336  if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) {
 337      require_once (WP_CONTENT_DIR . '/object-cache.php');
 338      $_wp_using_ext_object_cache = true;
 339  } else {
 340      require_once (ABSPATH . WPINC . '/cache.php');
 341      $_wp_using_ext_object_cache = false;
 342  }
 343  
 344  wp_cache_init();
 345  if ( function_exists('wp_cache_add_global_groups') ) {
 346      wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
 347      wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
 348  }
 349  
 350  if( defined( 'SUNRISE' ) )
 351      include_once( WP_CONTENT_DIR . '/sunrise.php' );
 352  
 353  require_once  ( ABSPATH . 'wpmu-settings.php' );
 354  $wpdb->blogid           = $current_blog->blog_id;
 355  $wpdb->siteid           = $current_blog->site_id;
 356  $wpdb->set_prefix($table_prefix); // set up blog tables
 357  $table_prefix = $table_prefix . $blog_id . '_';
 358  
 359  // Fix empty PHP_SELF
 360  $PHP_SELF = $_SERVER['PHP_SELF'];
 361  if ( empty($PHP_SELF) || ( empty($PHP_SELF) && constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) ) 
 362      $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
 363  
 364  wp_cache_init(); // need to init cache again after blog_id is set
 365  if ( function_exists('wp_cache_add_global_groups') ) { // need to add these again. Yes, it's an ugly hack
 366      wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
 367      wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
 368  }
 369  
 370  if( !defined( "UPLOADBLOGSDIR" ) )
 371      define( "UPLOADBLOGSDIR", 'wp-content/blogs.dir' );
 372  
 373  if( !defined( "UPLOADS" ) )
 374      define( "UPLOADS", UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
 375  
 376  if( !defined( "BLOGUPLOADDIR" ) )
 377      define( "BLOGUPLOADDIR", WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
 378  
 379  require (ABSPATH . WPINC . '/plugin.php');
 380  require (ABSPATH . WPINC . '/default-filters.php');
 381  include_once(ABSPATH . WPINC . '/pomo/mo.php');
 382  
 383  /**
 384   * Runs just before PHP shuts down execution.
 385   *
 386   * @access private
 387   * @since 1.2.0
 388   */
 389  function shutdown_action_hook() {
 390      do_action('shutdown');
 391      wp_cache_close();
 392  }
 393  register_shutdown_function('shutdown_action_hook');
 394  
 395  if( defined( "SHORTINIT" ) && constant( "SHORTINIT" ) == true ) // stop most of WP being loaded, we just want the basics
 396      return false;
 397  
 398  require_once (ABSPATH . WPINC . '/l10n.php');
 399  
 400  if ( !is_blog_installed() && !defined('WP_INSTALLING') ) {
 401      die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
 402  }
 403  
 404  require (ABSPATH . WPINC . '/formatting.php');
 405  require (ABSPATH . WPINC . '/capabilities.php');
 406  require (ABSPATH . WPINC . '/query.php');
 407  require (ABSPATH . WPINC . '/theme.php');
 408  require (ABSPATH . WPINC . '/user.php');
 409  require (ABSPATH . WPINC . '/meta.php');
 410  require (ABSPATH . WPINC . '/general-template.php');
 411  require (ABSPATH . WPINC . '/link-template.php');
 412  require (ABSPATH . WPINC . '/author-template.php');
 413  require (ABSPATH . WPINC . '/post.php');
 414  require (ABSPATH . WPINC . '/post-template.php');
 415  require (ABSPATH . WPINC . '/category.php');
 416  require (ABSPATH . WPINC . '/category-template.php');
 417  require (ABSPATH . WPINC . '/comment.php');
 418  require (ABSPATH . WPINC . '/comment-template.php');
 419  require (ABSPATH . WPINC . '/rewrite.php');
 420  require (ABSPATH . WPINC . '/feed.php');
 421  require (ABSPATH . WPINC . '/bookmark.php');
 422  require (ABSPATH . WPINC . '/bookmark-template.php');
 423  require (ABSPATH . WPINC . '/kses.php');
 424  require (ABSPATH . WPINC . '/cron.php');
 425  require (ABSPATH . WPINC . '/version.php');
 426  require (ABSPATH . WPINC . '/deprecated.php');
 427  require (ABSPATH . WPINC . '/script-loader.php');
 428  require (ABSPATH . WPINC . '/taxonomy.php');
 429  require (ABSPATH . WPINC . '/update.php');
 430  require (ABSPATH . WPINC . '/canonical.php');
 431  require (ABSPATH . WPINC . '/shortcodes.php');
 432  require (ABSPATH . WPINC . '/media.php');
 433  require (ABSPATH . WPINC . '/http.php');
 434  require (ABSPATH . WPINC . '/widgets.php');
 435  
 436  if ( !defined('WP_CONTENT_URL') )
 437      define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
 438  
 439  require_once( ABSPATH . WPINC . '/wpmu-functions.php' );
 440  require_once( ABSPATH . WPINC . '/wpmu-default-filters.php' ); // WPmu Filters 
 441  
 442  /**
 443   * Allows for the plugins directory to be moved from the default location.
 444   *
 445   * @since 2.6.0
 446   */
 447  if ( !defined('WP_PLUGIN_DIR') )
 448      define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
 449  
 450  /**
 451   * Allows for the plugins directory to be moved from the default location.
 452   *
 453   * @since 2.6.0
 454   */
 455  if ( !defined('WP_PLUGIN_URL') )
 456      define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
 457  
 458  /**
 459   * Allows for the plugins directory to be moved from the default location.
 460   *
 461   * @since 2.1.0
 462   */
 463  if ( !defined('PLUGINDIR') )
 464      define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH.  For back compat.
 465  
 466  if( !isset($current_site->site_name) )
 467      $current_site->site_name = get_site_option('site_name');
 468  if( $current_site->site_name == false )
 469      $current_site->site_name = ucfirst( $current_site->domain );
 470      
 471  if ( ! defined('WP_INSTALLING') ) {
 472      // Used to guarantee unique hash cookies
 473      if ( !isset($cookiehash) )
 474          $cookiehash = '';
 475  
 476      /**
 477       * Used to guarantee unique hash cookies
 478       * @since 1.5
 479       */
 480      if ( !defined('COOKIEHASH') )
 481          define( 'COOKIEHASH', $cookiehash );
 482  }
 483  
 484  $wpdb->hide_errors();
 485  /**
 486   * Allows for the mu-plugins directory to be moved from the default location.
 487   *
 488   * @since 2.8.0
 489   */
 490  if ( !defined('WPMU_PLUGIN_DIR') )
 491      define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
 492  
 493  /**
 494   * Allows for the mu-plugins directory to be moved from the default location.
 495   *
 496   * @since 2.8.0
 497   */
 498  if ( !defined('WPMU_PLUGIN_URL') )
 499      define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
 500  
 501  /**
 502   * Allows for the mu-plugins directory to be moved from the default location.
 503   *
 504   * @since 2.8.0
 505   */
 506  if ( !defined( 'MUPLUGINDIR' ) )
 507      define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH.  For back compat.
 508  
 509  if ( is_dir( WPMU_PLUGIN_DIR ) ) {
 510      if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
 511          $mu_plugins = array ();
 512          while ( ( $plugin = readdir( $dh ) ) !== false )
 513              if ( substr( $plugin, -4 ) == '.php' )
 514                  $mu_plugins[] = $plugin;
 515          closedir( $dh );
 516          sort( $mu_plugins );
 517          foreach( $mu_plugins as $mu_plugin )
 518              include_once( WPMU_PLUGIN_DIR . '/' . $mu_plugin );
 519      }
 520  }
 521  
 522  $wpmu_sitewide_plugins = (array) maybe_unserialize( get_site_option( 'wpmu_sitewide_plugins' ) );
 523  foreach( $wpmu_sitewide_plugins as $plugin_file => $activation_time ) {
 524      if ( !$plugin_file )
 525          continue;
 526  
 527      if ( !file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
 528          $deleted_sitewide_plugins[] = $plugin_file;
 529      } else {
 530          include_once( WP_PLUGIN_DIR . '/' . $plugin_file );
 531      }
 532  }
 533  
 534  if ( isset( $deleted_sitewide_plugins ) ) {
 535      $active_sitewide_plugins = maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );
 536  
 537      /* Remove any deleted plugins from the wpmu_sitewide_plugins array */
 538      foreach( $deleted_sitewide_plugins as $plugin_file ) {
 539          unset( $wpmu_sitewide_plugins[$plugin_file] );
 540          unset( $active_sitewide_plugins[$plugin_file] );
 541      }
 542  
 543      update_site_option( 'wpmu_sitewide_plugins', $wpmu_sitewide_plugins );
 544      update_site_option( 'active_sitewide_plugins', $wpmu_sitewide_plugins );
 545  }
 546  
 547  do_action( 'muplugins_loaded' );
 548  $wpdb->show_errors();
 549  
 550  if ( '1' == $current_blog->deleted ) {
 551      if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {
 552          require_once( WP_CONTENT_DIR . '/blog-deleted.php' );
 553          die();
 554      } else {
 555          header('HTTP/1.1 410 Gone');
 556          graceful_fail(__('This user has elected to delete their account and the content is no longer available.'));
 557      }
 558  }
 559  
 560  if ( '2' == $current_blog->deleted ) {
 561      if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
 562          require_once( WP_CONTENT_DIR . '/blog-inactive.php' );
 563          die();
 564      } else {
 565          graceful_fail( sprintf( __( 'This blog has not been activated yet. If you are having problems activating your blog, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) );
 566      }
 567  }
 568  
 569  if( $current_blog->archived == '1' || $current_blog->spam == '1' ) {
 570      if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) {
 571          require_once( WP_CONTENT_DIR . '/blog-suspended.php' );
 572          die();
 573      } else {
 574          header('HTTP/1.1 410 Gone');
 575          graceful_fail(__('This blog has been archived or suspended.'));
 576      }
 577  }
 578  
 579  /**
 580   * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
 581   * @since 2.5.0
 582   */
 583  $wp_default_secret_key = 'put your unique phrase here';
 584  
 585  /**
 586   * It is possible to define this in wp-config.php
 587   * @since 2.0.0
 588   */
 589  if ( !defined('USER_COOKIE') )
 590      define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
 591  
 592  /**
 593   * It is possible to define this in wp-config.php
 594   * @since 2.0.0
 595   */
 596  if ( !defined('PASS_COOKIE') )
 597      define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
 598  
 599  /**
 600   * It is possible to define this in wp-config.php
 601   * @since 2.5.0
 602   */
 603  if ( !defined('AUTH_COOKIE') )
 604      define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
 605  
 606  /**
 607   * It is possible to define this in wp-config.php
 608   * @since 2.6.0
 609   */
 610  if ( !defined('SECURE_AUTH_COOKIE') )
 611      define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
 612  
 613  /**
 614   * It is possible to define this in wp-config.php
 615   * @since 2.6.0
 616   */
 617  if ( !defined('LOGGED_IN_COOKIE') )
 618      define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
 619  
 620  /**
 621   * It is possible to define this in wp-config.php
 622   * @since 2.3.0
 623   */
 624  if ( !defined('TEST_COOKIE') )
 625      define('TEST_COOKIE', 'wordpress_test_cookie');
 626  
 627  /**
 628   * It is possible to define this in wp-config.php
 629   * @since 1.2.0
 630   */
 631  if ( !defined('COOKIEPATH') )
 632      define('COOKIEPATH', $current_site->path );
 633  
 634  /**
 635   * It is possible to define this in wp-config.php
 636   * @since 1.5.0
 637   */
 638  if ( !defined('SITECOOKIEPATH') )
 639      define('SITECOOKIEPATH', $current_site->path );
 640  
 641  /**
 642   * It is possible to define this in wp-config.php
 643   * @since 2.6.0
 644   */
 645  if ( !defined('ADMIN_COOKIE_PATH') ) {
 646      if( constant( 'VHOST' ) == 'no' ) {
 647          define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
 648      } else {
 649          define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
 650      }
 651  }
 652  
 653  /**
 654   * It is possible to define this in wp-config.php
 655   * @since 2.6.0
 656   */
 657  if ( !defined('PLUGINS_COOKIE_PATH') )
 658      define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
 659  
 660  /**
 661   * It is possible to define this in wp-config.php
 662   * @since 2.0.0
 663   */
 664  if ( !defined('COOKIE_DOMAIN') )
 665      define('COOKIE_DOMAIN', '.' . $current_site->domain);
 666  
 667  /**
 668   * It is possible to define this in wp-config.php
 669   * @since 2.6.0
 670   */
 671  if ( !defined('FORCE_SSL_ADMIN') )
 672      define('FORCE_SSL_ADMIN', false);
 673  force_ssl_admin(FORCE_SSL_ADMIN);
 674  
 675  /**
 676   * It is possible to define this in wp-config.php
 677   * @since 2.6.0
 678   */
 679  if ( !defined('FORCE_SSL_LOGIN') )
 680      define('FORCE_SSL_LOGIN', false);
 681  force_ssl_login(FORCE_SSL_LOGIN);
 682  
 683  /**
 684   * It is possible to define this in wp-config.php
 685   * @since 2.5.0
 686   */
 687  if ( !defined( 'AUTOSAVE_INTERVAL' ) )
 688      define( 'AUTOSAVE_INTERVAL', 60 );
 689  
 690  /**
 691   * It is possible to define this in wp-config.php
 692   * @since 2.9.0
 693   */
 694  if ( !defined( 'EMPTY_TRASH_DAYS' ) )
 695      define( 'EMPTY_TRASH_DAYS', 30 );
 696  
 697  require (ABSPATH . WPINC . '/vars.php');
 698  
 699  // make taxonomies available to plugins and themes
 700  // @plugin authors: warning: this gets registered again on the init hook
 701  create_initial_taxonomies();
 702  
 703  $current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
 704  if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) {
 705      foreach ( $current_plugins as $plugin ) {
 706          // check the $plugin filename
 707          // Validate plugin filename
 708          if ( validate_file($plugin) // $plugin must validate as file
 709              || '.php' != substr($plugin, -4) // $plugin must end with '.php'
 710              || !file_exists(WP_PLUGIN_DIR . '/' . $plugin)    // $plugin must exist
 711              )
 712              continue;
 713  
 714          include_once(WP_PLUGIN_DIR . '/' . $plugin);
 715      }
 716      unset($plugin);
 717  }
 718  unset($current_plugins);
 719  
 720  require (ABSPATH . WPINC . '/pluggable.php');
 721  
 722  /*
 723   * In most cases the default internal encoding is latin1, which is of no use,
 724   * since we want to use the mb_ functions for utf-8 strings
 725   */
 726  if (function_exists('mb_internal_encoding')) {
 727      if (!@mb_internal_encoding(get_option('blog_charset')))
 728          mb_internal_encoding('UTF-8');
 729  }
 730  
 731  
 732  if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
 733      wp_cache_postload();
 734  
 735  do_action('plugins_loaded');
 736  
 737  $default_constants = array( 'WP_POST_REVISIONS' => true );
 738  foreach ( $default_constants as $c => $v )
 739      @define( $c, $v ); // will fail if the constant is already defined
 740  unset($default_constants, $c, $v);
 741  
 742  // If already slashed, strip.
 743  if ( get_magic_quotes_gpc() ) {
 744      $_GET    = stripslashes_deep($_GET   );
 745      $_POST   = stripslashes_deep($_POST  );
 746      $_COOKIE = stripslashes_deep($_COOKIE);
 747  }
 748  
 749  // Escape with wpdb.
 750  $_GET    = add_magic_quotes($_GET   );
 751  $_POST   = add_magic_quotes($_POST  );
 752  $_COOKIE = add_magic_quotes($_COOKIE);
 753  $_SERVER = add_magic_quotes($_SERVER);
 754  
 755  // Force REQUEST to be GET + POST.  If SERVER, COOKIE, or ENV are needed, use those superglobals directly.
 756  $_REQUEST = array_merge($_GET, $_POST);
 757  
 758  do_action('sanitize_comment_cookies');
 759  
 760  /**
 761   * WordPress Query object
 762   * @global object $wp_the_query
 763   * @since 2.0.0
 764   */
 765  $wp_the_query =& new WP_Query();
 766  
 767  /**
 768   * Holds the reference to @see $wp_the_query
 769   * Use this global for WordPress queries
 770   * @global object $wp_query
 771   * @since 1.5.0
 772   */
 773  $wp_query     =& $wp_the_query;
 774  
 775  /**
 776   * Holds the WordPress Rewrite object for creating pretty URLs
 777   * @global object $wp_rewrite
 778   * @since 1.5.0
 779   */
 780  $wp_rewrite   =& new WP_Rewrite();
 781  
 782  /**
 783   * WordPress Object
 784   * @global object $wp
 785   * @since 2.0.0
 786   */
 787  $wp           =& new WP();
 788  
 789  /**
 790   * WordPress Widget Factory Object
 791   * @global object $wp_widget_factory
 792   * @since 2.8.0
 793   */
 794  $wp_widget_factory =& new WP_Widget_Factory();
 795  
 796  do_action('setup_theme');
 797  
 798  /**
 799   * Web Path to the current active template directory
 800   * @since 1.5.0
 801   */
 802  define('TEMPLATEPATH', get_template_directory());
 803  
 804  /**
 805   * Web Path to the current active template stylesheet directory
 806   * @since 2.1.0
 807   */
 808  define('STYLESHEETPATH', get_stylesheet_directory());
 809  
 810  // Load the default text localization domain.
 811  load_default_textdomain();
 812  
 813  /**
 814   * The locale of the blog
 815   * @since 1.5.0
 816   */
 817  $locale = get_locale();
 818  $locale_file = WP_LANG_DIR . "/$locale.php";
 819  if ( is_readable($locale_file) )
 820      require_once($locale_file);
 821  
 822  // Pull in locale data after loading text domain.
 823  require_once(ABSPATH . WPINC . '/locale.php');
 824  
 825  /**
 826   * WordPress Locale object for loading locale domain date and various strings.
 827   * @global object $wp_locale
 828   * @since 2.1.0
 829   */
 830  $wp_locale =& new WP_Locale();
 831  
 832  // Load functions for active theme.
 833  if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
 834      include(STYLESHEETPATH . '/functions.php');
 835  if ( file_exists(TEMPLATEPATH . '/functions.php') )
 836      include (TEMPLATEPATH . '/functions.php');
 837  
 838  // Load in support for template functions which the theme supports
 839  require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
 840  
 841  $wp->init();  // Sets up current user.
 842  
 843  // Everything is loaded and initialized.
 844  do_action('init');
 845  
 846  ?>


Generated: Mon May 3 12:25:32 2010 Cross-referenced by PHPXref 0.7