[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> ms-default-constants.php (source)

   1  <?php
   2  /**
   3   * Defines constants and global variables that can be overridden, generally in wp-config.php.
   4   *
   5   * @package WordPress
   6   * @subpackage Multisite
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Defines Multisite upload constants.
  12   *
  13   * @since 3.0.0
  14   */
  15  function ms_upload_constants(  ) {
  16      global $wpdb;
  17  
  18      /** @since 3.0.0 */
  19      // Base uploads dir relative to ABSPATH
  20      if ( !defined( 'UPLOADBLOGSDIR' ) )
  21          define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
  22  
  23      /** @since 3.0.0 */
  24      if ( !defined( 'UPLOADS' ) ) {
  25          // Uploads dir relative to ABSPATH
  26          define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
  27          if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )
  28              define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
  29      }
  30  }
  31  
  32  /**
  33   * Defines Multisite cookie constants.
  34   *
  35   * @since 3.0.0
  36   */
  37  function ms_cookie_constants(  ) {
  38      global $current_site;
  39  
  40      /**
  41       * @since 1.2.0
  42       */
  43      if ( !defined( 'COOKIEPATH' ) )
  44          define( 'COOKIEPATH', $current_site->path );
  45  
  46      /**
  47       * @since 1.5.0
  48       */
  49      if ( !defined( 'SITECOOKIEPATH' ) )
  50          define( 'SITECOOKIEPATH', $current_site->path );
  51  
  52      /**
  53       * @since 2.6.0
  54       */
  55      if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
  56          if( !is_subdomain_install() ) {
  57              define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
  58          } else {
  59              define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
  60          }
  61      }
  62  
  63      /**
  64       * @since 2.0.0
  65       */
  66      if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
  67          if ( !empty( $current_site->cookie_domain ) )
  68              define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
  69          else
  70              define('COOKIE_DOMAIN', '.' . $current_site->domain);
  71      }
  72  }
  73  
  74  /**
  75   * Defines Multisite file constants.
  76   *
  77   * @since 3.0.0
  78   */
  79  function ms_file_constants(  ) {
  80      /**
  81       * Optional support for X-Sendfile header
  82       * @since 3.0.0
  83       */
  84      if ( !defined( 'WPMU_SENDFILE' ) )
  85          define( 'WPMU_SENDFILE', false );
  86  
  87      /**
  88       * Optional support for X-Accel-Redirect header
  89       * @since 3.0.0
  90       */
  91      if ( !defined( 'WPMU_ACCEL_REDIRECT' ) )
  92          define( 'WPMU_ACCEL_REDIRECT', false );
  93  }
  94  
  95  /**
  96   * Defines Multisite subdomain constants and handles warnings and notices.
  97   *
  98   * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
  99   *
 100   * On first call, the constants are checked and defined. On second call,
 101   * we will have translations loaded and can trigger warnings easily.
 102   *
 103   * @since 3.0.0
 104   */
 105  function ms_subdomain_constants() {
 106      static $error = null;
 107      static $error_warn = false;
 108  
 109      if ( false === $error )
 110          return;
 111  
 112      if ( $error ) {
 113          $vhost_deprecated = __( 'The constant <code>VHOST</code> <strong>is deprecated</strong>. Use the boolean constant <code>SUBDOMAIN_INSTALL</code> in wp-config.php to enable a subdomain configuration. Use is_subdomain_install() to check whether a subdomain configuration is enabled.' );
 114          if ( $error_warn ) {
 115              trigger_error( __( '<strong>Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL.</strong> The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.' ) . ' ' . $vhost_deprecated, E_USER_WARNING );
 116          } else {
 117               _deprecated_argument( 'define()', '3.0', $vhost_deprecated );
 118          }
 119          return;
 120      }
 121  
 122      if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
 123          if ( SUBDOMAIN_INSTALL == ( 'yes' == VHOST ) ) {
 124              $error = true;
 125          } else {
 126              $error = $error_warn = true;
 127          }
 128      } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
 129          define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
 130      } elseif ( defined( 'VHOST' ) ) {
 131          $error = true;
 132          define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
 133      } else {
 134          define( 'SUBDOMAIN_INSTALL', false );
 135          define( 'VHOST', 'no' );
 136      }
 137  }
 138  add_action( 'init', 'ms_subdomain_constants' );


Generated: Fri May 25 03:56:23 2012 Hosted by follow the white rabbit.