<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13062] trunk/wp-includes/default-constants.php:
Improve the implementation of the default constant defining functions.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13062">13062</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2010-02-12 07:52:58 +0000 (Fri, 12 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Improve the implementation of the default constant defining functions. See <a href="http://trac.wordpress.org/ticket/11881">#11881</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesdefaultconstantsphp">trunk/wp-includes/default-constants.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesdefaultconstantsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-constants.php (13061 => 13062)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-constants.php        2010-02-12 06:11:46 UTC (rev 13061)
+++ trunk/wp-includes/default-constants.php        2010-02-12 07:52:58 UTC (rev 13062)
</span><span class="lines">@@ -6,269 +6,287 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Defines WordPress default constants.
- *
</del><ins>+ * Defines initial WordPress constants
+ *
</ins><span class="cx"> * @since 3.0.0
</span><del>- * @param $context
</del><span class="cx"> */
</span><del>-function wp_default_constants( $context ) {
</del><ins>+function wp_initial_constants( ) {
+        global $blog_id;
</ins><span class="cx">
</span><del>-        switch( $context ) {
</del><ins>+        // set memory limits
+        if ( !defined('WP_MEMORY_LIMIT') ) {
+                if( is_multisite() ) {
+                        define('WP_MEMORY_LIMIT', '64M');
+                } else {
+                        define('WP_MEMORY_LIMIT', '32M');
+                }
+        }
</ins><span class="cx">
</span><del>-                case 'init' :
</del><ins>+        /**
+         * The $blog_id global, which you can change in the config allows you to create a simple
+         * multiple blog installation using just one WordPress and changing $blog_id around.
+         *
+         * @global int $blog_id
+         * @since 2.0.0
+         */
+        if ( ! isset($blog_id) )
+                $blog_id = 1;
</ins><span class="cx">
</span><del>-                        // set memory limits
-                        if ( !defined('WP_MEMORY_LIMIT') ) {
-                                if( is_multisite() ) {
-                                        define('WP_MEMORY_LIMIT', '64M');
-                                } else {
-                                        define('WP_MEMORY_LIMIT', '32M');
-                                }
-                        }
</del><ins>+        // set memory limits.
+        if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
+                @ini_set('memory_limit', WP_MEMORY_LIMIT);
</ins><span class="cx">
</span><del>-                        /**
-                         * The $blog_id global, which you can change in the config allows you to create a simple
-                         * multiple blog installation using just one WordPress and changing $blog_id around.
-                         *
-                         * @global int $blog_id
-                         * @since 2.0.0
-                         */
-                        if ( ! isset($blog_id) )
-                                $blog_id = 1;
</del><ins>+        if ( !defined('WP_CONTENT_DIR') )
+                define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
</ins><span class="cx">
</span><del>-                        // set memory limits.
-                        if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
-                                @ini_set('memory_limit', WP_MEMORY_LIMIT);
</del><ins>+        // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
+        if ( !defined('WP_DEBUG') )
+                define( 'WP_DEBUG', false );
</ins><span class="cx">
</span><del>-                        if ( !defined('WP_CONTENT_DIR') )
-                                define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
</del><ins>+        // Add define('WP_DEBUG_DISPLAY', false); to wp-config.php to use the globally configured setting for display_errors and not force it to On
+        if ( !defined('WP_DEBUG_DISPLAY') )
+                define( 'WP_DEBUG_DISPLAY', true );
</ins><span class="cx">
</span><del>-                        // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
-                        if ( !defined('WP_DEBUG') )
-                                define( 'WP_DEBUG', false );
</del><ins>+        // Add define('WP_DEBUG_LOG', true); to enable php debug logging to WP_CONTENT_DIR/debug.log
+        if ( !defined('WP_DEBUG_LOG') )
+                define('WP_DEBUG_LOG', false);
</ins><span class="cx">
</span><del>-                        // Add define('WP_DEBUG_DISPLAY', false); to wp-config.php to use the globally configured setting for display_errors and not force it to On
-                        if ( !defined('WP_DEBUG_DISPLAY') )
-                                define( 'WP_DEBUG_DISPLAY', true );
</del><ins>+        if ( !defined('WP_CACHE') )
+                define('WP_CACHE', false);
</ins><span class="cx">
</span><del>-                        // Add define('WP_DEBUG_LOG', true); to enable php debug logging to WP_CONTENT_DIR/debug.log
-                        if ( !defined('WP_DEBUG_LOG') )
-                                define('WP_DEBUG_LOG', false);
</del><ins>+        /**
+         * Private
+         */
+        if ( !defined('MEDIA_TRASH') )
+                define('MEDIA_TRASH', false);
</ins><span class="cx">
</span><del>-                        if ( !defined('WP_CACHE') )
-                                define('WP_CACHE', false);
</del><ins>+        if ( !defined('SHORTINIT') )
+                define('SHORTINIT', false);
+}
</ins><span class="cx">
</span><del>-                        /**
-                         * Private
-                         */
-                        if ( !defined('MEDIA_TRASH') )
-                                define('MEDIA_TRASH', false);
</del><ins>+/**
+ * Defines plugin directory WordPress constants
+ *
+ * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
+ *
+ * @since 3.0.0
+ */
+function wp_plugin_directory_constants( ) {
+        if ( !defined('WP_CONTENT_URL') )
+                define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
</ins><span class="cx">
</span><del>-                        if ( !defined('SHORTINIT') )
-                                define('SHORTINIT', false);
-                        break;
</del><ins>+        /**
+         * Allows for the plugins directory to be moved from the default location.
+         *
+         * @since 2.6.0
+         */
+        if ( !defined('WP_PLUGIN_DIR') )
+                define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
</ins><span class="cx">
</span><del>-                case 'wp_included':
</del><ins>+        /**
+         * Allows for the plugins directory to be moved from the default location.
+         *
+         * @since 2.6.0
+         */
+        if ( !defined('WP_PLUGIN_URL') )
+                define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
</ins><span class="cx">
</span><del>-                        if ( !defined('WP_CONTENT_URL') )
-                                define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
</del><ins>+        /**
+         * Allows for the plugins directory to be moved from the default location.
+         *
+         * @since 2.1.0
+         * @deprecated
+         */
+        if ( !defined('PLUGINDIR') )
+                define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
</ins><span class="cx">
</span><del>-                        /**
-                         * Allows for the plugins directory to be moved from the default location.
-                         *
-                         * @since 2.6.0
-                         */
-                        if ( !defined('WP_PLUGIN_DIR') )
-                                define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
</del><ins>+        /**
+         * Allows for the mu-plugins directory to be moved from the default location.
+         *
+         * @since 2.8.0
+         */
+        if ( !defined('WPMU_PLUGIN_DIR') )
+                define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
</ins><span class="cx">
</span><del>-                        /**
-                         * Allows for the plugins directory to be moved from the default location.
-                         *
-                         * @since 2.6.0
-                         */
-                        if ( !defined('WP_PLUGIN_URL') )
-                                define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
</del><ins>+        /**
+         * Allows for the mu-plugins directory to be moved from the default location.
+         *
+         * @since 2.8.0
+         */
+        if ( !defined('WPMU_PLUGIN_URL') )
+                define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
</ins><span class="cx">
</span><del>-                        /**
-                         * Allows for the plugins directory to be moved from the default location.
-                         *
-                         * @since 2.1.0
-                         * @deprecated
-                         */
-                        if ( !defined('PLUGINDIR') )
-                                define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
</del><ins>+        /**
+         * Allows for the mu-plugins directory to be moved from the default location.
+         *
+         * @since 2.8.0
+         * @deprecated
+         */
+        if ( !defined( 'MUPLUGINDIR' ) )
+                define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
+}
</ins><span class="cx">
</span><del>-                        /**
-                         * Allows for the mu-plugins directory to be moved from the default location.
-                         *
-                         * @since 2.8.0
-                         */
-                        if ( !defined('WPMU_PLUGIN_DIR') )
-                                define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
</del><ins>+/**
+ * Defines cookie related WordPress constants
+ *
+ * Defines constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
+ * @since 3.0.0
+ */
+function wp_cookie_constants( ) {
+        global $wp_default_secret_key;
</ins><span class="cx">
</span><del>-                        /**
-                         * Allows for the mu-plugins directory to be moved from the default location.
-                         *
-                         * @since 2.8.0
-                         */
-                        if ( !defined('WPMU_PLUGIN_URL') )
-                                define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
</del><ins>+        /**
+         * Used to guarantee unique hash cookies
+         * @since 1.5
+         */
+        if ( !defined( 'COOKIEHASH' ) ) {
+                $siteurl = get_site_option( 'siteurl' );
+                if ( $siteurl )
+                        define( 'COOKIEHASH', md5( $siteurl ) );
+                else
+                        define( 'COOKIEHASH', '' );
+        }
</ins><span class="cx">
</span><del>-                        /**
-                         * Allows for the mu-plugins directory to be moved from the default location.
-                         *
-                         * @since 2.8.0
-                         * @deprecated
-                         */
-                        if ( !defined( 'MUPLUGINDIR' ) )
-                                define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
-                        break;
</del><ins>+        /**
+         * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
+         * @since 2.5.0
+         */
+        $wp_default_secret_key = 'put your unique phrase here';
</ins><span class="cx">
</span><del>-                case 'ms_loaded';
</del><ins>+        /**
+         * @since 2.0.0
+         */
+        if ( !defined('USER_COOKIE') )
+                define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
</ins><span class="cx">
</span><del>-                        global $wp_default_secret_key;
</del><ins>+        /**
+         * @since 2.0.0
+         */
+        if ( !defined('PASS_COOKIE') )
+                define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
</ins><span class="cx">
</span><del>-                        /**
-                         * Used to guarantee unique hash cookies
-                         * @since 1.5
-                         */
-                        if ( !defined( 'COOKIEHASH' ) ) {
-                                $siteurl = get_site_option( 'siteurl' );
-                                if ( $siteurl )
-                                        define( 'COOKIEHASH', md5( $siteurl ) );
-                                else
-                                        define( 'COOKIEHASH', '' );
-                        }
</del><ins>+        /**
+         * @since 2.5.0
+         */
+        if ( !defined('AUTH_COOKIE') )
+                define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
</ins><span class="cx">
</span><del>-                        /**
-                         * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
-                         * @since 2.5.0
-                         */
-                        $wp_default_secret_key = 'put your unique phrase here';
</del><ins>+        /**
+         * @since 2.6.0
+         */
+        if ( !defined('SECURE_AUTH_COOKIE') )
+                define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.0.0
-                         */
-                        if ( !defined('USER_COOKIE') )
-                                define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
</del><ins>+        /**
+         * @since 2.6.0
+         */
+        if ( !defined('LOGGED_IN_COOKIE') )
+                define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.0.0
-                         */
-                        if ( !defined('PASS_COOKIE') )
-                                define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
</del><ins>+        /**
+         * @since 2.3.0
+         */
+        if ( !defined('TEST_COOKIE') )
+                define('TEST_COOKIE', 'wordpress_test_cookie');
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.5.0
-                         */
-                        if ( !defined('AUTH_COOKIE') )
-                                define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
</del><ins>+        /**
+         * @since 1.2.0
+         */
+        if ( !defined('COOKIEPATH') )
+                define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.6.0
-                         */
-                        if ( !defined('SECURE_AUTH_COOKIE') )
-                                define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
</del><ins>+        /**
+         * @since 1.5.0
+         */
+        if ( !defined('SITECOOKIEPATH') )
+                define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.6.0
-                         */
-                        if ( !defined('LOGGED_IN_COOKIE') )
-                                define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
</del><ins>+        /**
+         * @since 2.6.0
+         */
+        if ( !defined('ADMIN_COOKIE_PATH') )
+                define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.3.0
-                         */
-                        if ( !defined('TEST_COOKIE') )
-                                define('TEST_COOKIE', 'wordpress_test_cookie');
</del><ins>+        /**
+         * @since 2.6.0
+         */
+        if ( !defined('PLUGINS_COOKIE_PATH') )
+                define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 1.2.0
-                         */
-                        if ( !defined('COOKIEPATH') )
-                                define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
</del><ins>+        /**
+         * @since 2.0.0
+         */
+        if ( !defined('COOKIE_DOMAIN') )
+                define('COOKIE_DOMAIN', false);
+}
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 1.5.0
-                         */
-                        if ( !defined('SITECOOKIEPATH') )
-                                define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
</del><ins>+/**
+ * Defines cookie related WordPress constants
+ *
+ * @since 3.0.0
+ */
+function wp_ssl_constants( ) {
+        /**
+         * @since 2.6.0
+         */
+        if ( !defined('FORCE_SSL_ADMIN') )
+                define('FORCE_SSL_ADMIN', false);
+        force_ssl_admin(FORCE_SSL_ADMIN);
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.6.0
-                         */
-                        if ( !defined('ADMIN_COOKIE_PATH') )
-                                define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
</del><ins>+        /**
+         * @since 2.6.0
+         */
+        if ( !defined('FORCE_SSL_LOGIN') )
+                define('FORCE_SSL_LOGIN', false);
+        force_ssl_login(FORCE_SSL_LOGIN);
+}
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.6.0
-                         */
-                        if ( !defined('PLUGINS_COOKIE_PATH') )
-                                define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
</del><ins>+/**
+ * Defines functionality related WordPress constants
+ *
+ * @since 3.0.0
+ */
+function wp_functionality_constants( ) {
+        /**
+         * @since 2.5.0
+         */
+        if ( !defined( 'AUTOSAVE_INTERVAL' ) )
+                define( 'AUTOSAVE_INTERVAL', 60 );
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.0.0
-                         */
-                        if ( !defined('COOKIE_DOMAIN') )
-                                define('COOKIE_DOMAIN', false);
</del><ins>+        /**
+         * @since 2.9.0
+         */
+        if ( !defined( 'EMPTY_TRASH_DAYS' ) )
+                define( 'EMPTY_TRASH_DAYS', 30 );
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.6.0
-                         */
-                        if ( !defined('FORCE_SSL_ADMIN') )
-                                define('FORCE_SSL_ADMIN', false);
-                        force_ssl_admin(FORCE_SSL_ADMIN);
</del><ins>+        if ( !defined('WP_POST_REVISIONS') )
+                define('WP_POST_REVISIONS', true);
+}
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.6.0
-                         */
-                        if ( !defined('FORCE_SSL_LOGIN') )
-                                define('FORCE_SSL_LOGIN', false);
-                        force_ssl_login(FORCE_SSL_LOGIN);
</del><ins>+/**
+ * Defines templating related WordPress constants
+ *
+ * @since 3.0.0
+ */
+function wp_templating_constants( ) {
+        /**
+         * Web Path to the current active template directory
+         * @since 1.5.0
+         */
+        define('TEMPLATEPATH', get_template_directory());
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.5.0
-                         */
-                        if ( !defined( 'AUTOSAVE_INTERVAL' ) )
-                                define( 'AUTOSAVE_INTERVAL', 60 );
</del><ins>+        /**
+         * Web Path to the current active template stylesheet directory
+         * @since 2.1.0
+         */
+        define('STYLESHEETPATH', get_stylesheet_directory());
</ins><span class="cx">
</span><del>-                        /**
-                         * @since 2.9.0
-                         */
-                        if ( !defined( 'EMPTY_TRASH_DAYS' ) )
-                                define( 'EMPTY_TRASH_DAYS', 30 );
-                        break;
-
-                case 'plugins_loaded':
-
-                        if ( !defined('WP_POST_REVISIONS') )
-                        define('WP_POST_REVISIONS', true);
-                        break;
-
-                case 'setup_theme':
-
-                        /**
-                         * Web Path to the current active template directory
-                         * @since 1.5.0
-                         */
-                        define('TEMPLATEPATH', get_template_directory());
-
-                        /**
-                         * Web Path to the current active template stylesheet directory
-                         * @since 2.1.0
-                         */
-                        define('STYLESHEETPATH', get_stylesheet_directory());
-
-                        /**
-                         * Slug of the fallback theme for this install.
-                         * Will be used as the fallback if the current theme doesn't exist.
-                         * @since 3.0.0
-                         */
-                        define( 'WP_FALLBACK_THEME', 'twentyten' );
-                        break;
-
-        }
-
</del><ins>+        /**
+         * Slug of the fallback theme for this install.
+         * Will be used as the fallback if the current theme doesn't exist.
+         * @since 3.0.0
+         */
+        define( 'WP_FALLBACK_THEME', 'twentyten' );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>