14 * wp-includes/ms-files.php (wp-content/blogs.php in MU). |
14 * wp-includes/ms-files.php (wp-content/blogs.php in MU). |
15 * |
15 * |
16 * @since 3.0.0 |
16 * @since 3.0.0 |
17 */ |
17 */ |
18 function ms_upload_constants() { |
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. |
19 // 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' ); |
20 add_filter( 'default_site_option_ms_files_rewriting', '__return_true' ); |
23 |
21 |
24 if ( ! get_site_option( 'ms_files_rewriting' ) ) |
22 if ( ! get_site_option( 'ms_files_rewriting' ) ) |
25 return; |
23 return; |
29 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); |
27 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); |
30 |
28 |
31 // Note, the main site in a post-MU network uses wp-content/uploads. |
29 // 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. |
30 // This is handled in wp_upload_dir() by ignoring UPLOADS for this case. |
33 if ( ! defined( 'UPLOADS' ) ) { |
31 if ( ! defined( 'UPLOADS' ) ) { |
34 define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" ); |
32 $site_id = get_current_blog_id(); |
|
33 |
|
34 define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' ); |
35 |
35 |
36 // Uploads dir relative to ABSPATH |
36 // Uploads dir relative to ABSPATH |
37 if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) |
37 if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) |
38 define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" ); |
38 define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' ); |
39 } |
39 } |
40 } |
40 } |
41 |
41 |
42 /** |
42 /** |
43 * Defines Multisite cookie constants. |
43 * Defines Multisite cookie constants. |
44 * |
44 * |
45 * @since 3.0.0 |
45 * @since 3.0.0 |
46 */ |
46 */ |
47 function ms_cookie_constants( ) { |
47 function ms_cookie_constants( ) { |
48 $current_site = get_current_site(); |
48 $current_network = get_network(); |
49 |
49 |
50 /** |
50 /** |
51 * @since 1.2.0 |
51 * @since 1.2.0 |
52 */ |
52 */ |
53 if ( !defined( 'COOKIEPATH' ) ) |
53 if ( !defined( 'COOKIEPATH' ) ) |
54 define( 'COOKIEPATH', $current_site->path ); |
54 define( 'COOKIEPATH', $current_network->path ); |
55 |
55 |
56 /** |
56 /** |
57 * @since 1.5.0 |
57 * @since 1.5.0 |
58 */ |
58 */ |
59 if ( !defined( 'SITECOOKIEPATH' ) ) |
59 if ( !defined( 'SITECOOKIEPATH' ) ) |
60 define( 'SITECOOKIEPATH', $current_site->path ); |
60 define( 'SITECOOKIEPATH', $current_network->path ); |
61 |
61 |
62 /** |
62 /** |
63 * @since 2.6.0 |
63 * @since 2.6.0 |
64 */ |
64 */ |
65 if ( !defined( 'ADMIN_COOKIE_PATH' ) ) { |
65 if ( !defined( 'ADMIN_COOKIE_PATH' ) ) { |
72 |
72 |
73 /** |
73 /** |
74 * @since 2.0.0 |
74 * @since 2.0.0 |
75 */ |
75 */ |
76 if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) { |
76 if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) { |
77 if ( !empty( $current_site->cookie_domain ) ) |
77 if ( !empty( $current_network->cookie_domain ) ) |
78 define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain); |
78 define('COOKIE_DOMAIN', '.' . $current_network->cookie_domain); |
79 else |
79 else |
80 define('COOKIE_DOMAIN', '.' . $current_site->domain); |
80 define('COOKIE_DOMAIN', '.' . $current_network->domain); |
81 } |
81 } |
82 } |
82 } |
83 |
83 |
84 /** |
84 /** |
85 * Defines Multisite file constants. |
85 * Defines Multisite file constants. |
112 * |
112 * |
113 * On first call, the constants are checked and defined. On second call, |
113 * On first call, the constants are checked and defined. On second call, |
114 * we will have translations loaded and can trigger warnings easily. |
114 * we will have translations loaded and can trigger warnings easily. |
115 * |
115 * |
116 * @since 3.0.0 |
116 * @since 3.0.0 |
|
117 * |
|
118 * @staticvar bool $subdomain_error |
|
119 * @staticvar bool $subdomain_error_warn |
117 */ |
120 */ |
118 function ms_subdomain_constants() { |
121 function ms_subdomain_constants() { |
119 static $subdomain_error = null; |
122 static $subdomain_error = null; |
120 static $subdomain_error_warn = null; |
123 static $subdomain_error_warn = null; |
121 |
124 |
122 if ( false === $subdomain_error ) { |
125 if ( false === $subdomain_error ) { |
123 return; |
126 return; |
124 } |
127 } |
125 |
128 |
126 if ( $subdomain_error ) { |
129 if ( $subdomain_error ) { |
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.' ); |
130 $vhost_deprecated = sprintf( |
|
131 /* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL, 3: wp-config.php, 4: is_subdomain_install() */ |
|
132 __( '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.' ), |
|
133 '<code>VHOST</code>', |
|
134 '<code>SUBDOMAIN_INSTALL</code>', |
|
135 '<code>wp-config.php</code>', |
|
136 '<code>is_subdomain_install()</code>' |
|
137 ); |
128 if ( $subdomain_error_warn ) { |
138 if ( $subdomain_error_warn ) { |
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 ); |
139 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 { |
140 } else { |
131 _deprecated_argument( 'define()', '3.0', $vhost_deprecated ); |
141 _deprecated_argument( 'define()', '3.0.0', $vhost_deprecated ); |
132 } |
142 } |
133 return; |
143 return; |
134 } |
144 } |
135 |
145 |
136 if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { |
146 if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { |