[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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      /*
  32       * Note, the main site in a post-MU network uses wp-content/uploads.
  33       * This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
  34       */
  35      if ( ! defined( 'UPLOADS' ) ) {
  36          $site_id = get_current_blog_id();
  37  
  38          define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' );
  39  
  40          // Uploads dir relative to ABSPATH.
  41          if ( 'wp-content/blogs.dir' === UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) {
  42              define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' );
  43          }
  44      }
  45  }
  46  
  47  /**
  48   * Defines Multisite cookie constants.
  49   *
  50   * @since 3.0.0
  51   */
  52  function ms_cookie_constants() {
  53      $current_network = get_network();
  54  
  55      /**
  56       * @since 1.2.0
  57       */
  58      if ( ! defined( 'COOKIEPATH' ) ) {
  59          define( 'COOKIEPATH', $current_network->path );
  60      }
  61  
  62      /**
  63       * @since 1.5.0
  64       */
  65      if ( ! defined( 'SITECOOKIEPATH' ) ) {
  66          define( 'SITECOOKIEPATH', $current_network->path );
  67      }
  68  
  69      /**
  70       * @since 2.6.0
  71       */
  72      if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) {
  73          $site_path = parse_url( get_option( 'siteurl' ), PHP_URL_PATH );
  74          if ( ! is_subdomain_install() || is_string( $site_path ) && trim( $site_path, '/' ) ) {
  75              define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
  76          } else {
  77              define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
  78          }
  79      }
  80  
  81      /**
  82       * @since 2.0.0
  83       */
  84      if ( ! defined( 'COOKIE_DOMAIN' ) && is_subdomain_install() ) {
  85          if ( ! empty( $current_network->cookie_domain ) ) {
  86              define( 'COOKIE_DOMAIN', '.' . $current_network->cookie_domain );
  87          } else {
  88              define( 'COOKIE_DOMAIN', '.' . $current_network->domain );
  89          }
  90      }
  91  }
  92  
  93  /**
  94   * Defines Multisite file constants.
  95   *
  96   * Exists for backward compatibility with legacy file-serving through
  97   * wp-includes/ms-files.php (wp-content/blogs.php in MU).
  98   *
  99   * @since 3.0.0
 100   */
 101  function ms_file_constants() {
 102      /**
 103       * Optional support for X-Sendfile header
 104       *
 105       * @since 3.0.0
 106       */
 107      if ( ! defined( 'WPMU_SENDFILE' ) ) {
 108          define( 'WPMU_SENDFILE', false );
 109      }
 110  
 111      /**
 112       * Optional support for X-Accel-Redirect header
 113       *
 114       * @since 3.0.0
 115       */
 116      if ( ! defined( 'WPMU_ACCEL_REDIRECT' ) ) {
 117          define( 'WPMU_ACCEL_REDIRECT', false );
 118      }
 119  }
 120  
 121  /**
 122   * Defines Multisite subdomain constants and handles warnings and notices.
 123   *
 124   * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
 125   *
 126   * On first call, the constants are checked and defined. On second call,
 127   * we will have translations loaded and can trigger warnings easily.
 128   *
 129   * @since 3.0.0
 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  
 149          if ( $subdomain_error_warn ) {
 150              trigger_error(
 151                  sprintf(
 152                      /* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL */
 153                      __( '<strong>Conflicting values for the constants %1$s and %2$s.</strong> The value of %2$s will be assumed to be your subdomain configuration setting.' ),
 154                      '<code>VHOST</code>',
 155                      '<code>SUBDOMAIN_INSTALL</code>'
 156                  ) . ' ' . $vhost_deprecated,
 157                  E_USER_WARNING
 158              );
 159          } else {
 160              _deprecated_argument( 'define()', '3.0.0', $vhost_deprecated );
 161          }
 162  
 163          return;
 164      }
 165  
 166      if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
 167          $subdomain_error = true;
 168          if ( SUBDOMAIN_INSTALL !== ( 'yes' === VHOST ) ) {
 169              $subdomain_error_warn = true;
 170          }
 171      } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
 172          $subdomain_error = false;
 173          define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
 174      } elseif ( defined( 'VHOST' ) ) {
 175          $subdomain_error = true;
 176          define( 'SUBDOMAIN_INSTALL', 'yes' === VHOST );
 177      } else {
 178          $subdomain_error = false;
 179          define( 'SUBDOMAIN_INSTALL', false );
 180          define( 'VHOST', 'no' );
 181      }
 182  }


Generated : Thu Apr 18 08:20:02 2024 Cross-referenced by PHPXref