You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

165 line
4.6 KiB

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