3 * Defines constants and global variables that can be overridden, generally in wp-config.php.
6 * @subpackage Multisite
11 * Defines Multisite upload constants.
13 * Exists for backward compatibility with legacy file-serving through
14 * wp-includes/ms-files.php (wp-content/blogs.php in MU).
18 * @global wpdb $wpdb WordPress database abstraction object.
20 function ms_upload_constants() {
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' );
26 if ( ! get_site_option( 'ms_files_rewriting' ) )
29 // Base uploads dir relative to ABSPATH
30 if ( !defined( 'UPLOADBLOGSDIR' ) )
31 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
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/" );
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/" );
45 * Defines Multisite cookie constants.
49 function ms_cookie_constants( ) {
50 $current_site = get_current_site();
55 if ( !defined( 'COOKIEPATH' ) )
56 define( 'COOKIEPATH', $current_site->path );
61 if ( !defined( 'SITECOOKIEPATH' ) )
62 define( 'SITECOOKIEPATH', $current_site->path );
67 if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
68 if ( ! is_subdomain_install() || trim( parse_url( get_option( 'siteurl' ), PHP_URL_PATH ), '/' ) ) {
69 define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
71 define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
78 if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
79 if ( !empty( $current_site->cookie_domain ) )
80 define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
82 define('COOKIE_DOMAIN', '.' . $current_site->domain);
87 * Defines Multisite file constants.
89 * Exists for backward compatibility with legacy file-serving through
90 * wp-includes/ms-files.php (wp-content/blogs.php in MU).
94 function ms_file_constants() {
96 * Optional support for X-Sendfile header
99 if ( !defined( 'WPMU_SENDFILE' ) )
100 define( 'WPMU_SENDFILE', false );
103 * Optional support for X-Accel-Redirect header
106 if ( !defined( 'WPMU_ACCEL_REDIRECT' ) )
107 define( 'WPMU_ACCEL_REDIRECT', false );
111 * Defines Multisite subdomain constants and handles warnings and notices.
113 * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
115 * On first call, the constants are checked and defined. On second call,
116 * we will have translations loaded and can trigger warnings easily.
120 * @staticvar bool $subdomain_error
121 * @staticvar bool $subdomain_error_warn
123 function ms_subdomain_constants() {
124 static $subdomain_error = null;
125 static $subdomain_error_warn = null;
127 if ( false === $subdomain_error ) {
131 if ( $subdomain_error ) {
132 $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.' );
133 if ( $subdomain_error_warn ) {
134 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 );
136 _deprecated_argument( 'define()', '3.0', $vhost_deprecated );
141 if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
142 $subdomain_error = true;
143 if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) {
144 $subdomain_error_warn = true;
146 } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
147 $subdomain_error = false;
148 define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
149 } elseif ( defined( 'VHOST' ) ) {
150 $subdomain_error = true;
151 define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
153 $subdomain_error = false;
154 define( 'SUBDOMAIN_INSTALL', false );
155 define( 'VHOST', 'no' );