]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/ms-default-constants.php
WordPress 4.3
[autoinstalls/wordpress.git] / wp-includes / ms-default-constants.php
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  * @global wpdb $wpdb
19  */
20 function ms_upload_constants() {
21         global $wpdb;
22
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' );
25
26         if ( ! get_site_option( 'ms_files_rewriting' ) )
27                 return;
28
29         // Base uploads dir relative to ABSPATH
30         if ( !defined( 'UPLOADBLOGSDIR' ) )
31                 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
32
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/" );
37
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/" );
41         }
42 }
43
44 /**
45  * Defines Multisite cookie constants.
46  *
47  * @since 3.0.0
48  */
49 function ms_cookie_constants(  ) {
50         $current_site = get_current_site();
51
52         /**
53          * @since 1.2.0
54          */
55         if ( !defined( 'COOKIEPATH' ) )
56                 define( 'COOKIEPATH', $current_site->path );
57
58         /**
59          * @since 1.5.0
60          */
61         if ( !defined( 'SITECOOKIEPATH' ) )
62                 define( 'SITECOOKIEPATH', $current_site->path );
63
64         /**
65          * @since 2.6.0
66          */
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 );
70                 } else {
71                         define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
72                 }
73         }
74
75         /**
76          * @since 2.0.0
77          */
78         if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
79                 if ( !empty( $current_site->cookie_domain ) )
80                         define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
81                 else
82                         define('COOKIE_DOMAIN', '.' . $current_site->domain);
83         }
84 }
85
86 /**
87  * Defines Multisite file constants.
88  *
89  * Exists for backward compatibility with legacy file-serving through
90  * wp-includes/ms-files.php (wp-content/blogs.php in MU).
91  *
92  * @since 3.0.0
93  */
94 function ms_file_constants() {
95         /**
96          * Optional support for X-Sendfile header
97          * @since 3.0.0
98          */
99         if ( !defined( 'WPMU_SENDFILE' ) )
100                 define( 'WPMU_SENDFILE', false );
101
102         /**
103          * Optional support for X-Accel-Redirect header
104          * @since 3.0.0
105          */
106         if ( !defined( 'WPMU_ACCEL_REDIRECT' ) )
107                 define( 'WPMU_ACCEL_REDIRECT', false );
108 }
109
110 /**
111  * Defines Multisite subdomain constants and handles warnings and notices.
112  *
113  * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
114  *
115  * On first call, the constants are checked and defined. On second call,
116  * we will have translations loaded and can trigger warnings easily.
117  *
118  * @since 3.0.0
119  *
120  * @staticvar bool $subdomain_error
121  * @staticvar bool $subdomain_error_warn
122  */
123 function ms_subdomain_constants() {
124         static $subdomain_error = null;
125         static $subdomain_error_warn = null;
126
127         if ( false === $subdomain_error ) {
128                 return;
129         }
130
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 );
135                 } else {
136                         _deprecated_argument( 'define()', '3.0', $vhost_deprecated );
137                 }
138                 return;
139         }
140
141         if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
142                 $subdomain_error = true;
143                 if ( SUBDOMAIN_INSTALL !== ( 'yes' == VHOST ) ) {
144                         $subdomain_error_warn = true;
145                 }
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 );
152         } else {
153                 $subdomain_error = false;
154                 define( 'SUBDOMAIN_INSTALL', false );
155                 define( 'VHOST', 'no' );
156         }
157 }