Make WordPress Core


Ignore:
Timestamp:
05/04/2010 08:48:28 PM (16 years ago)
Author:
nacin
Message:

Deprecate VHOST in favor of a boolean, SUBDOMAIN_INSTALL. Core will keep VHOST defined for plugins' sake, but you should only define SUBDOMAIN_INSTALL. Throws a notice if VHOST is defined, and a warning if they somehow conflict. Sunrise can still handle them. fixes #11796.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-default-constants.php

    r14380 r14452  
    9292                define( 'WPMU_ACCEL_REDIRECT', false );
    9393}
     94
     95/**
     96 * Defines Multisite subdomain constants and handles warnings and notices.
     97 *
     98 * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
     99 *
     100 * On first call, the constants are checked and defined. On second call,
     101 * we will have translations loaded and can trigger warnings easily.
     102 *
     103 * @since 3.0.0
     104 */
     105function ms_subdomain_constants() {
     106        static $error = null;
     107        static $error_warn = false;
     108       
     109        if ( false === $error )
     110                return;
     111
     112        if ( $error ) {
     113                $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.' );
     114                if ( $error_warn ) {
     115                        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 );
     116                } else {
     117                        _deprecated_argument( 'define()', '3.0', $vhost_deprecated );
     118                }
     119                return;
     120        }
     121
     122        if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
     123                if ( SUBDOMAIN_INSTALL == ( 'yes' == VHOST ) ) {
     124                        $error = true;
     125                } else {
     126                        $error = $error_warn = true;
     127                }
     128        } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
     129                define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
     130        } elseif ( defined( 'VHOST' ) ) {
     131                $error = true;
     132                define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
     133        } else {       
     134                define( 'SUBDOMAIN_INSTALL', false );
     135                define( 'VHOST', 'no' );
     136        }
     137}
     138add_action( 'init', 'ms_subdomain_constants' );
     139
    94140?>
Note: See TracChangeset for help on using the changeset viewer.