author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 16 | a86126ab1dd4 |
child 21 | 48c4eec2b7e6 |
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' ) ) { |
19 | 71 |
$site_path = parse_url( get_option( 'siteurl' ), PHP_URL_PATH ); |
72 |
if ( ! is_subdomain_install() || is_string( $site_path ) && trim( $site_path, '/' ) ) { |
|
0 | 73 |
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH ); |
74 |
} else { |
|
75 |
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' ); |
|
76 |
} |
|
77 |
} |
|
78 |
||
79 |
/** |
|
80 |
* @since 2.0.0 |
|
81 |
*/ |
|
9 | 82 |
if ( ! defined( 'COOKIE_DOMAIN' ) && is_subdomain_install() ) { |
83 |
if ( ! empty( $current_network->cookie_domain ) ) { |
|
84 |
define( 'COOKIE_DOMAIN', '.' . $current_network->cookie_domain ); |
|
85 |
} else { |
|
86 |
define( 'COOKIE_DOMAIN', '.' . $current_network->domain ); |
|
87 |
} |
|
0 | 88 |
} |
89 |
} |
|
90 |
||
91 |
/** |
|
92 |
* Defines Multisite file constants. |
|
93 |
* |
|
94 |
* Exists for backward compatibility with legacy file-serving through |
|
95 |
* wp-includes/ms-files.php (wp-content/blogs.php in MU). |
|
96 |
* |
|
97 |
* @since 3.0.0 |
|
98 |
*/ |
|
99 |
function ms_file_constants() { |
|
100 |
/** |
|
101 |
* Optional support for X-Sendfile header |
|
9 | 102 |
* |
0 | 103 |
* @since 3.0.0 |
104 |
*/ |
|
9 | 105 |
if ( ! defined( 'WPMU_SENDFILE' ) ) { |
0 | 106 |
define( 'WPMU_SENDFILE', false ); |
9 | 107 |
} |
0 | 108 |
|
109 |
/** |
|
110 |
* Optional support for X-Accel-Redirect header |
|
9 | 111 |
* |
0 | 112 |
* @since 3.0.0 |
113 |
*/ |
|
9 | 114 |
if ( ! defined( 'WPMU_ACCEL_REDIRECT' ) ) { |
0 | 115 |
define( 'WPMU_ACCEL_REDIRECT', false ); |
9 | 116 |
} |
0 | 117 |
} |
118 |
||
119 |
/** |
|
120 |
* Defines Multisite subdomain constants and handles warnings and notices. |
|
121 |
* |
|
122 |
* VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool. |
|
123 |
* |
|
124 |
* On first call, the constants are checked and defined. On second call, |
|
125 |
* we will have translations loaded and can trigger warnings easily. |
|
126 |
* |
|
127 |
* @since 3.0.0 |
|
128 |
*/ |
|
129 |
function ms_subdomain_constants() { |
|
9 | 130 |
static $subdomain_error = null; |
5 | 131 |
static $subdomain_error_warn = null; |
0 | 132 |
|
5 | 133 |
if ( false === $subdomain_error ) { |
0 | 134 |
return; |
5 | 135 |
} |
0 | 136 |
|
5 | 137 |
if ( $subdomain_error ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
$vhost_deprecated = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
/* 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
|
140 |
__( '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
|
141 |
'<code>VHOST</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
'<code>SUBDOMAIN_INSTALL</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
'<code>wp-config.php</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
'<code>is_subdomain_install()</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
); |
5 | 146 |
if ( $subdomain_error_warn ) { |
0 | 147 |
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 ); |
148 |
} else { |
|
9 | 149 |
_deprecated_argument( 'define()', '3.0.0', $vhost_deprecated ); |
0 | 150 |
} |
151 |
return; |
|
152 |
} |
|
153 |
||
154 |
if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { |
|
5 | 155 |
$subdomain_error = true; |
16 | 156 |
if ( SUBDOMAIN_INSTALL !== ( 'yes' === VHOST ) ) { |
5 | 157 |
$subdomain_error_warn = true; |
0 | 158 |
} |
159 |
} elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { |
|
5 | 160 |
$subdomain_error = false; |
0 | 161 |
define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); |
162 |
} elseif ( defined( 'VHOST' ) ) { |
|
5 | 163 |
$subdomain_error = true; |
16 | 164 |
define( 'SUBDOMAIN_INSTALL', 'yes' === VHOST ); |
0 | 165 |
} else { |
5 | 166 |
$subdomain_error = false; |
0 | 167 |
define( 'SUBDOMAIN_INSTALL', false ); |
168 |
define( 'VHOST', 'no' ); |
|
169 |
} |
|
170 |
} |