[ 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   * Exists for backward compatibility with legacy file-serving through
  14   * wp-includes/ms-files.php (wp-content/blogs.php in MU).
  15   *
  16   * @since 3.0.0
  17   */
  18  function ms_upload_constants() {
  19      // This filter is attached in ms-default-filters.php but that file is not included during SHORTINIT.
  20      add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
  21  
  22      if ( ! get_site_option( 'ms_files_rewriting' ) ) {
  23          return;
  24      }
  25  
  26      // Base uploads dir relative to ABSPATH
  27      if ( ! defined( 'UPLOADBLOGSDIR' ) ) {
  28          define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
  29      }
  30  
  31      // Note, the main site in a post-MU network uses wp-content/uploads.
  32      // This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
  33      if ( ! defined( 'UPLOADS' ) ) {
  34          $site_id = get_current_blog_id();
  35  
  36          define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' );
  37  
  38          // Uploads dir relative to ABSPATH
  39          if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) {
  40              define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' );
  41          }
  42      }
  43  }
  44  
  45  /**
  46   * Defines Multisite cookie constants.
  47   *
  48   * @since 3.0.0
  49   */
  50  function ms_cookie_constants() {
  51      $current_network = get_network();
  52  
  53      /**
  54       * @since 1.2.0
  55       */
  56      if ( ! defined( 'COOKIEPATH' ) ) {
  57          define( 'COOKIEPATH', $current_network->path );
  58      }
  59  
  60      /**
  61       * @since 1.5.0
  62       */
  63      if ( ! defined( 'SITECOOKIEPATH' ) ) {
  64          define( 'SITECOOKIEPATH', $current_network->path );
  65      }
  66  
  67      /**
  68       * @since 2.6.0
  69       */
  70      if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) {
  71          if ( ! is_subdomain_install() || trim( parse_url( get_option( 'siteurl' ), PHP_URL_PATH ), '/' ) ) {
  72              define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
  73          } else {
  74              define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
  75          }
  76      }
  77  
  78      /**
  79       * @since 2.0.0
  80       */
  81      if ( ! defined( 'COOKIE_DOMAIN' ) && is_subdomain_install() ) {
  82          if ( ! empty( $current_network->cookie_domain ) ) {
  83              define( 'COOKIE_DOMAIN', '.' . $current_network->cookie_domain );
  84          } else {
  85              define( 'COOKIE_DOMAIN', '.' . $current_network->domain );
  86          }
  87      }
  88  }
  89  
  90  /**
  91   * Defines Multisite file constants.
  92   *
  93   * Exists for backward compatibility with legacy file-serving through
  94   * wp-includes/ms-files.php (wp-content/blogs.php in MU).
  95   *
  96   * @since 3.0.0
  97   */
  98  function ms_file_constants() {
  99      /**
 100       * Optional support for X-Sendfile header
 101       *
 102       * @since 3.0.0
 103       */
 104      if ( ! defined( 'WPMU_SENDFILE' ) ) {
 105          define( 'WPMU_SENDFILE', false );
 106      }
 107  
 108      /**
 109       * Optional support for X-Accel-Redirect header
 110       *
 111       * @since 3.0.0
 112       */
 113      if ( ! defined( 'WPMU_ACCEL_REDIRECT' ) ) {
 114          define( 'WPMU_ACCEL_REDIRECT', false );
 115      }
 116  }
 117  
 118  /**
 119   * Defines Multisite subdomain constants and handles warnings and notices.
 120   *
 121   * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
 122   *
 123   * On first call, the constants are checked and defined. On second call,
 124   * we will have translations loaded and can trigger warnings easily.
 125   *
 126   * @since 3.0.0
 127   *
 128   * @staticvar bool $subdomain_error
 129   * @staticvar bool $subdomain_error_warn
 130   */
 131  function ms_subdomain_constants() {
 132      static $subdomain_error      = null;
 133      static $subdomain_error_warn = null;
 134  
 135      if ( false === $subdomain_error ) {
 136          return;
 137      }
 138  
 139      if ( $subdomain_error ) {
 140          $vhost_deprecated = sprintf(
 141              /* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL, 3: wp-config.php, 4: is_subdomain_install() */
 142              __( 'The constant %1$s <strong>is deprecated</strong>. Use the boolean constant %2$s in %3$s to enable a subdomain configuration. Use %4$s to check whether a subdomain configuration is enabled.' ),
 143              '<code>VHOST</code>',
 144              '<code>SUBDOMAIN_INSTALL</code>',
 145              '<code>wp-config.php</code>',
 146              '<code>is_subdomain_install()</code>'
 147          );
 148          if ( $subdomain_error_warn ) {
 149              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 );
 150          } else {
 151              _deprecated_argument( 'define()', '3.0.0', $vhost_deprecated );
 152          }
 153          return;
 154      }
 155  
 156      if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
 157          $subdomain_error = true;
 158          if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) {
 159              $subdomain_error_warn = true;
 160          }
 161      } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
 162          $subdomain_error = false;
 163          define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
 164      } elseif ( defined( 'VHOST' ) ) {
 165          $subdomain_error = true;
 166          define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
 167      } else {
 168          $subdomain_error = false;
 169          define( 'SUBDOMAIN_INSTALL', false );
 170          define( 'VHOST', 'no' );
 171      }
 172  }


Generated: Sat Sep 21 01:00:03 2019 Cross-referenced by PHPXref 0.7.1