[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
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 22 if ( ! get_site_option( 'ms_files_rewriting' ) ) { 23 return; 24 } 25 26 // Base uploads dir relative to ABSPATH. 27 if ( ! defined( 'UPLOADBLOGSDIR' ) ) { 28 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); 29 } 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 $site_id = get_current_blog_id(); 35 36 define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/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/' . $site_id . '/files/' ); 41 } 42 } 43 } 44 45 /** 46 * Defines Multisite cookie constants. 47 * 48 * @since 3.0.0 49 */ 50 function ms_cookie_constants() { 51 $current_network = get_network(); 52 53 /** 54 * @since 1.2.0 55 */ 56 if ( ! defined( 'COOKIEPATH' ) ) { 57 define( 'COOKIEPATH', $current_network->path ); 58 } 59 60 /** 61 * @since 1.5.0 62 */ 63 if ( ! defined( 'SITECOOKIEPATH' ) ) { 64 define( 'SITECOOKIEPATH', $current_network->path ); 65 } 66 67 /** 68 * @since 2.6.0 69 */ 70 if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) { 71 $site_path = parse_url( get_option( 'siteurl' ), PHP_URL_PATH ); 72 if ( ! is_subdomain_install() || is_string( $site_path ) && trim( $site_path, '/' ) ) { 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 */ 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 } 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 102 * 103 * @since 3.0.0 104 */ 105 if ( ! defined( 'WPMU_SENDFILE' ) ) { 106 define( 'WPMU_SENDFILE', false ); 107 } 108 109 /** 110 * Optional support for X-Accel-Redirect header 111 * 112 * @since 3.0.0 113 */ 114 if ( ! defined( 'WPMU_ACCEL_REDIRECT' ) ) { 115 define( 'WPMU_ACCEL_REDIRECT', false ); 116 } 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() { 130 static $subdomain_error = null; 131 static $subdomain_error_warn = null; 132 133 if ( false === $subdomain_error ) { 134 return; 135 } 136 137 if ( $subdomain_error ) { 138 $vhost_deprecated = sprintf( 139 /* translators: 1: VHOST, 2: SUBDOMAIN_INSTALL, 3: wp-config.php, 4: is_subdomain_install() */ 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.' ), 141 '<code>VHOST</code>', 142 '<code>SUBDOMAIN_INSTALL</code>', 143 '<code>wp-config.php</code>', 144 '<code>is_subdomain_install()</code>' 145 ); 146 if ( $subdomain_error_warn ) { 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 { 149 _deprecated_argument( 'define()', '3.0.0', $vhost_deprecated ); 150 } 151 return; 152 } 153 154 if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { 155 $subdomain_error = true; 156 if ( SUBDOMAIN_INSTALL !== ( 'yes' === VHOST ) ) { 157 $subdomain_error_warn = true; 158 } 159 } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { 160 $subdomain_error = false; 161 define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); 162 } elseif ( defined( 'VHOST' ) ) { 163 $subdomain_error = true; 164 define( 'SUBDOMAIN_INSTALL', 'yes' === VHOST ); 165 } else { 166 $subdomain_error = false; 167 define( 'SUBDOMAIN_INSTALL', false ); 168 define( 'VHOST', 'no' ); 169 } 170 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |