/wp-includes/ms-default-constants.php

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