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 |
global $wpdb; |
|
20 |
|
|
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 |
|
|
24 |
if ( ! get_site_option( 'ms_files_rewriting' ) ) |
|
25 |
return; |
|
26 |
|
|
27 |
// Base uploads dir relative to ABSPATH |
|
28 |
if ( !defined( 'UPLOADBLOGSDIR' ) ) |
|
29 |
define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); |
|
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' ) ) { |
|
34 |
define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" ); |
|
35 |
|
|
36 |
// Uploads dir relative to ABSPATH |
|
37 |
if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) |
|
38 |
define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" ); |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Defines Multisite cookie constants. |
|
44 |
* |
|
45 |
* @since 3.0.0 |
|
46 |
*/ |
|
47 |
function ms_cookie_constants( ) { |
5
|
48 |
$current_site = get_current_site(); |
0
|
49 |
|
|
50 |
/** |
|
51 |
* @since 1.2.0 |
|
52 |
*/ |
|
53 |
if ( !defined( 'COOKIEPATH' ) ) |
|
54 |
define( 'COOKIEPATH', $current_site->path ); |
|
55 |
|
|
56 |
/** |
|
57 |
* @since 1.5.0 |
|
58 |
*/ |
|
59 |
if ( !defined( 'SITECOOKIEPATH' ) ) |
|
60 |
define( 'SITECOOKIEPATH', $current_site->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 |
|
|
73 |
/** |
|
74 |
* @since 2.0.0 |
|
75 |
*/ |
|
76 |
if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) { |
|
77 |
if ( !empty( $current_site->cookie_domain ) ) |
|
78 |
define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain); |
|
79 |
else |
|
80 |
define('COOKIE_DOMAIN', '.' . $current_site->domain); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Defines Multisite file constants. |
|
86 |
* |
|
87 |
* Exists for backward compatibility with legacy file-serving through |
|
88 |
* wp-includes/ms-files.php (wp-content/blogs.php in MU). |
|
89 |
* |
|
90 |
* @since 3.0.0 |
|
91 |
*/ |
|
92 |
function ms_file_constants() { |
|
93 |
/** |
|
94 |
* Optional support for X-Sendfile header |
|
95 |
* @since 3.0.0 |
|
96 |
*/ |
|
97 |
if ( !defined( 'WPMU_SENDFILE' ) ) |
|
98 |
define( 'WPMU_SENDFILE', false ); |
|
99 |
|
|
100 |
/** |
|
101 |
* Optional support for X-Accel-Redirect header |
|
102 |
* @since 3.0.0 |
|
103 |
*/ |
|
104 |
if ( !defined( 'WPMU_ACCEL_REDIRECT' ) ) |
|
105 |
define( 'WPMU_ACCEL_REDIRECT', false ); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Defines Multisite subdomain constants and handles warnings and notices. |
|
110 |
* |
|
111 |
* VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool. |
|
112 |
* |
|
113 |
* On first call, the constants are checked and defined. On second call, |
|
114 |
* we will have translations loaded and can trigger warnings easily. |
|
115 |
* |
|
116 |
* @since 3.0.0 |
|
117 |
*/ |
|
118 |
function ms_subdomain_constants() { |
5
|
119 |
static $subdomain_error = null; |
|
120 |
static $subdomain_error_warn = null; |
0
|
121 |
|
5
|
122 |
if ( false === $subdomain_error ) { |
0
|
123 |
return; |
5
|
124 |
} |
0
|
125 |
|
5
|
126 |
if ( $subdomain_error ) { |
0
|
127 |
$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.' ); |
5
|
128 |
if ( $subdomain_error_warn ) { |
0
|
129 |
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 ); |
|
130 |
} else { |
|
131 |
_deprecated_argument( 'define()', '3.0', $vhost_deprecated ); |
|
132 |
} |
|
133 |
return; |
|
134 |
} |
|
135 |
|
|
136 |
if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { |
5
|
137 |
$subdomain_error = true; |
|
138 |
if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) { |
|
139 |
$subdomain_error_warn = true; |
0
|
140 |
} |
|
141 |
} elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { |
5
|
142 |
$subdomain_error = false; |
0
|
143 |
define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); |
|
144 |
} elseif ( defined( 'VHOST' ) ) { |
5
|
145 |
$subdomain_error = true; |
0
|
146 |
define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST ); |
|
147 |
} else { |
5
|
148 |
$subdomain_error = false; |
0
|
149 |
define( 'SUBDOMAIN_INSTALL', false ); |
|
150 |
define( 'VHOST', 'no' ); |
|
151 |
} |
|
152 |
} |
|
153 |
add_action( 'init', 'ms_subdomain_constants' ); |