author | ymh <ymh.work@gmail.com> |
Tue, 15 Dec 2020 13:49:49 +0100 | |
changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 19 | 3d72ae0968f4 |
permissions | -rw-r--r-- |
0 | 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 |
||
9 | 22 |
if ( ! get_site_option( 'ms_files_rewriting' ) ) { |
0 | 23 |
return; |
9 | 24 |
} |
0 | 25 |
|
16 | 26 |
// Base uploads dir relative to ABSPATH. |
9 | 27 |
if ( ! defined( 'UPLOADBLOGSDIR' ) ) { |
0 | 28 |
define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); |
9 | 29 |
} |
0 | 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' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
$site_id = get_current_blog_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' ); |
0 | 37 |
|
16 | 38 |
// Uploads dir relative to ABSPATH. |
39 |
if ( 'wp-content/blogs.dir' === UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' ); |
9 | 41 |
} |
0 | 42 |
} |
43 |
} |
|
44 |
||
45 |
/** |
|
46 |
* Defines Multisite cookie constants. |
|
47 |
* |
|
48 |
* @since 3.0.0 |
|
49 |
*/ |
|
9 | 50 |
function ms_cookie_constants() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
$current_network = get_network(); |
0 | 52 |
|
53 |
/** |
|
54 |
* @since 1.2.0 |
|
55 |
*/ |
|
9 | 56 |
if ( ! defined( 'COOKIEPATH' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
define( 'COOKIEPATH', $current_network->path ); |
9 | 58 |
} |
0 | 59 |
|
60 |
/** |
|
61 |
* @since 1.5.0 |
|
62 |
*/ |
|
9 | 63 |
if ( ! defined( 'SITECOOKIEPATH' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
define( 'SITECOOKIEPATH', $current_network->path ); |
9 | 65 |
} |
0 | 66 |
|
67 |
/** |
|
68 |
* @since 2.6.0 |
|
69 |
*/ |
|
9 | 70 |
if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) { |
0 | 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 |
*/ |
|
9 | 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 |
} |
|
0 | 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 |
|
9 | 101 |
* |
0 | 102 |
* @since 3.0.0 |
103 |
*/ |
|
9 | 104 |
if ( ! defined( 'WPMU_SENDFILE' ) ) { |
0 | 105 |
define( 'WPMU_SENDFILE', false ); |
9 | 106 |
} |
0 | 107 |
|
108 |
/** |
|
109 |
* Optional support for X-Accel-Redirect header |
|
9 | 110 |
* |
0 | 111 |
* @since 3.0.0 |
112 |
*/ |
|
9 | 113 |
if ( ! defined( 'WPMU_ACCEL_REDIRECT' ) ) { |
0 | 114 |
define( 'WPMU_ACCEL_REDIRECT', false ); |
9 | 115 |
} |
0 | 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 |
function ms_subdomain_constants() { |
|
9 | 129 |
static $subdomain_error = null; |
5 | 130 |
static $subdomain_error_warn = null; |
0 | 131 |
|
5 | 132 |
if ( false === $subdomain_error ) { |
0 | 133 |
return; |
5 | 134 |
} |
0 | 135 |
|
5 | 136 |
if ( $subdomain_error ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
$vhost_deprecated = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
/* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL, 3: wp-config.php, 4: is_subdomain_install() */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
__( '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.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
'<code>VHOST</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
'<code>SUBDOMAIN_INSTALL</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
'<code>wp-config.php</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
'<code>is_subdomain_install()</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
); |
5 | 145 |
if ( $subdomain_error_warn ) { |
0 | 146 |
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 ); |
147 |
} else { |
|
9 | 148 |
_deprecated_argument( 'define()', '3.0.0', $vhost_deprecated ); |
0 | 149 |
} |
150 |
return; |
|
151 |
} |
|
152 |
||
153 |
if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { |
|
5 | 154 |
$subdomain_error = true; |
16 | 155 |
if ( SUBDOMAIN_INSTALL !== ( 'yes' === VHOST ) ) { |
5 | 156 |
$subdomain_error_warn = true; |
0 | 157 |
} |
158 |
} elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { |
|
5 | 159 |
$subdomain_error = false; |
0 | 160 |
define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); |
161 |
} elseif ( defined( 'VHOST' ) ) { |
|
5 | 162 |
$subdomain_error = true; |
16 | 163 |
define( 'SUBDOMAIN_INSTALL', 'yes' === VHOST ); |
0 | 164 |
} else { |
5 | 165 |
$subdomain_error = false; |
0 | 166 |
define( 'SUBDOMAIN_INSTALL', false ); |
167 |
define( 'VHOST', 'no' ); |
|
168 |
} |
|
169 |
} |