WordPress.org

Make WordPress Core

Ticket #11881: 11881.2.diff

File 11881.2.diff, 48.2 KB (added by nacin, 8 years ago)
  • wp-includes/default-constants.php

     
     1<?php
     2
     3/**
     4 * Defines constants and global variables that can be overridden, usually in wp-config.php.
     5 *
     6 * @package WordPress
     7 */
     8
     9// set memory limits
     10if ( !defined('WP_MEMORY_LIMIT') ) {
     11        if( is_multisite() ) {
     12                define('WP_MEMORY_LIMIT', '64M');
     13        } else {
     14                define('WP_MEMORY_LIMIT', '32M');
     15        }
     16}
     17
     18/**
     19 * The $blog_id global, which you can change in the config allows you to create a simple
     20 * multiple blog installation using just one WordPress and changing $blog_id around.
     21 *
     22 * @global int $blog_id
     23 * @since 2.0.0
     24 */
     25if ( ! isset($blog_id) )
     26        $blog_id = 1;
     27
     28// set memory limits.
     29if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
     30        @ini_set('memory_limit', WP_MEMORY_LIMIT);
     31
     32if ( !defined('WP_CONTENT_DIR') )
     33        define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
     34
     35// Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
     36if ( !defined('WP_DEBUG') )
     37        define( 'WP_DEBUG', false );
     38
     39// 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
     40if ( !defined('WP_DEBUG_DISPLAY') )
     41        define( 'WP_DEBUG_DISPLAY', true );
     42
     43// Add define('WP_DEBUG_LOG', true); to enable php debug logging to WP_CONTENT_DIR/debug.log
     44if ( !defined('WP_DEBUG_LOG') )
     45        define('WP_DEBUG_LOG', false);
     46
     47if ( !defined('WP_CACHE') )
     48        define('WP_CACHE', false);
     49
     50/**
     51 * Private
     52 */
     53if ( !defined('MEDIA_TRASH') )
     54        define('MEDIA_TRASH', false);
     55
     56if ( !defined('SHORTINIT') )
     57        define('SHORTINIT', false);
     58
     59function define_after_wp_includes() {
     60        if ( !defined('WP_CONTENT_URL') )
     61                define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
     62
     63        /**
     64         * Allows for the plugins directory to be moved from the default location.
     65         *
     66         * @since 2.6.0
     67         */
     68        if ( !defined('WP_PLUGIN_DIR') )
     69                define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
     70
     71        /**
     72         * Allows for the plugins directory to be moved from the default location.
     73         *
     74         * @since 2.6.0
     75         */
     76        if ( !defined('WP_PLUGIN_URL') )
     77                define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
     78
     79        /**
     80         * Allows for the plugins directory to be moved from the default location.
     81         *
     82         * @since 2.1.0
     83         */
     84        if ( !defined('PLUGINDIR') )
     85                define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH.  For back compat.
     86
     87        /**
     88         * Allows for the mu-plugins directory to be moved from the default location.
     89         *
     90         * @since 2.8.0
     91         */
     92        if ( !defined('WPMU_PLUGIN_DIR') )
     93                define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
     94
     95        /**
     96         * Allows for the mu-plugins directory to be moved from the default location.
     97         *
     98         * @since 2.8.0
     99         */
     100        if ( !defined('WPMU_PLUGIN_URL') )
     101                define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
     102
     103        /**
     104         * Allows for the mu-plugins directory to be moved from the default location.
     105         *
     106         * @since 2.8.0
     107         */
     108        if ( !defined( 'MUPLUGINDIR' ) )
     109                define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH.  For back compat.
     110}
     111
     112function define_after_ms_loaded() {
     113        global $wp_default_secret_key;
     114
     115        /**
     116         * Used to guarantee unique hash cookies
     117         * @since 1.5
     118         */
     119        if( !defined('COOKIEHASH') )
     120                        define('COOKIEHASH', md5(get_option('siteurl')));
     121
     122        /**
     123         * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
     124         * @since 2.5.0
     125         */
     126        $wp_default_secret_key = 'put your unique phrase here';
     127
     128        /**
     129         * It is possible to define this in wp-config.php
     130         * @since 2.0.0
     131         */
     132        if ( !defined('USER_COOKIE') )
     133                define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
     134
     135        /**
     136         * It is possible to define this in wp-config.php
     137         * @since 2.0.0
     138         */
     139        if ( !defined('PASS_COOKIE') )
     140                define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
     141
     142        /**
     143         * It is possible to define this in wp-config.php
     144         * @since 2.5.0
     145         */
     146        if ( !defined('AUTH_COOKIE') )
     147                define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
     148
     149        /**
     150         * It is possible to define this in wp-config.php
     151         * @since 2.6.0
     152         */
     153        if ( !defined('SECURE_AUTH_COOKIE') )
     154                define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
     155
     156        /**
     157         * It is possible to define this in wp-config.php
     158         * @since 2.6.0
     159         */
     160        if ( !defined('LOGGED_IN_COOKIE') )
     161                define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
     162
     163        /**
     164         * It is possible to define this in wp-config.php
     165         * @since 2.3.0
     166         */
     167        if ( !defined('TEST_COOKIE') )
     168                define('TEST_COOKIE', 'wordpress_test_cookie');
     169
     170        /**
     171         * It is possible to define this in wp-config.php
     172         * @since 1.2.0
     173         */
     174        if ( !defined('COOKIEPATH') )
     175                define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
     176
     177        /**
     178         * It is possible to define this in wp-config.php
     179         * @since 1.5.0
     180         */
     181        if ( !defined('SITECOOKIEPATH') )
     182                define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
     183
     184        /**
     185         * It is possible to define this in wp-config.php
     186         * @since 2.6.0
     187         */
     188        if ( !defined('ADMIN_COOKIE_PATH') )
     189                define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
     190
     191        /**
     192         * It is possible to define this in wp-config.php
     193         * @since 2.6.0
     194         */
     195        if ( !defined('PLUGINS_COOKIE_PATH') )
     196                define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
     197
     198        /**
     199         * It is possible to define this in wp-config.php
     200         * @since 2.0.0
     201         */
     202        if ( !defined('COOKIE_DOMAIN') )
     203                define('COOKIE_DOMAIN', false);
     204
     205        /**
     206         * It is possible to define this in wp-config.php
     207         * @since 2.6.0
     208         */
     209        if ( !defined('FORCE_SSL_ADMIN') )
     210                define('FORCE_SSL_ADMIN', false);
     211        force_ssl_admin(FORCE_SSL_ADMIN);
     212
     213        /**
     214         * It is possible to define this in wp-config.php
     215         * @since 2.6.0
     216         */
     217        if ( !defined('FORCE_SSL_LOGIN') )
     218                define('FORCE_SSL_LOGIN', false);
     219        force_ssl_login(FORCE_SSL_LOGIN);
     220
     221        /**
     222         * It is possible to define this in wp-config.php
     223         * @since 2.5.0
     224         */
     225        if ( !defined( 'AUTOSAVE_INTERVAL' ) )
     226                define( 'AUTOSAVE_INTERVAL', 60 );
     227
     228        /**
     229         * It is possible to define this in wp-config.php
     230         * @since 2.9.0
     231         */
     232        if ( !defined( 'EMPTY_TRASH_DAYS' ) )
     233                define( 'EMPTY_TRASH_DAYS', 30 );
     234
     235}
     236
     237function define_after_plugins_loaded() {
     238        if ( !defined('WP_POST_REVISIONS') )
     239                define('WP_POST_REVISIONS', true);
     240}
     241
     242function define_after_setup_theme() {
     243        /**
     244         * Web Path to the current active template directory
     245         * @since 1.5.0
     246         */
     247        define('TEMPLATEPATH', get_template_directory());
     248
     249        /**
     250         * Web Path to the current active template stylesheet directory
     251         * @since 2.1.0
     252         */
     253        define('STYLESHEETPATH', get_stylesheet_directory());
     254}
     255 No newline at end of file
  • wp-includes/load.php

     
     1<?php
     2
     3/**
     4 * Initialization functions.
     5 *
     6 * @package WordPress
     7 */
     8
     9/**
     10 * Whether Multisite support is enabled
     11 *
     12 * @since 3.0
     13 *
     14 * @return bool True if multisite is enabled, false otherwise.
     15 */
     16function is_multisite() {
     17        if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') || defined('SUNRISE') )
     18                return true;
     19
     20        return false;
     21}
     22
     23/**
     24 * Turn register globals off.
     25 *
     26 * @access private
     27 * @since 2.1.0
     28 * @return null Will return null if register_globals PHP directive was disabled
     29 */
     30function wp_unregister_GLOBALS() {
     31        if ( !ini_get('register_globals') )
     32                return;
     33
     34        if ( isset($_REQUEST['GLOBALS']) )
     35                die('GLOBALS overwrite attempt detected');
     36
     37        // Variables that shouldn't be unset
     38        $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
     39
     40        $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
     41        foreach ( $input as $k => $v )
     42                if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
     43                        $GLOBALS[$k] = NULL;
     44                        unset($GLOBALS[$k]);
     45                }
     46}
     47
     48function wp_fix_server_vars() {
     49        global $PHP_SELF;
     50        // Fix for IIS when running with PHP ISAPI
     51        if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
     52
     53                // IIS Mod-Rewrite
     54                if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
     55                        $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
     56                }
     57                // IIS Isapi_Rewrite
     58                else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
     59                        $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
     60                }
     61                else
     62                {
     63                        // Use ORIG_PATH_INFO if there is no PATH_INFO
     64                        if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
     65                                $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
     66
     67                        // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
     68                        if ( isset($_SERVER['PATH_INFO']) ) {
     69                                if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
     70                                        $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
     71                                else
     72                                        $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
     73                        }
     74
     75                        // Append the query string if it exists and isn't null
     76                        if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
     77                                $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
     78                        }
     79                }
     80        }
     81
     82        // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
     83        if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
     84                $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
     85
     86        // Fix for Dreamhost and other PHP as CGI hosts
     87        if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
     88                unset($_SERVER['PATH_INFO']);
     89
     90        // Fix empty PHP_SELF
     91        $PHP_SELF = $_SERVER['PHP_SELF'];
     92        if ( empty($PHP_SELF) )
     93                $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
     94}
     95
     96function wp_check_php_mysql_versions() {
     97        // we can probably extend this function to check if wp_die() exists then use translated strings, and then use it in install.php etc.
     98
     99        global $required_php_version, $wp_version;
     100        $php_version = phpversion();
     101        if ( version_compare( $required_php_version, $php_version, '>' ) )
     102                die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %1$s but WordPress %2%s requires at least %2%s.'/*/WP_I18N_OLD_PHP*/, $php_version, $wp_version, $required_php_version ) );
     103
     104        if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
     105                die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
     106}
     107
     108function wp_maintenance() {
     109        if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
     110                include(ABSPATH . '.maintenance');
     111                // If the $upgrading timestamp is older than 10 minutes, don't die.
     112                if ( ( time() - $upgrading ) < 600 ) {
     113                        if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
     114                                require_once( WP_CONTENT_DIR . '/maintenance.php' );
     115                                die();
     116                        }
     117
     118                        $protocol = $_SERVER["SERVER_PROTOCOL"];
     119                        if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
     120                                $protocol = 'HTTP/1.0';
     121                        header( "$protocol 503 Service Unavailable", true, 503 );
     122                        header( 'Content-Type: text/html; charset=utf-8' );
     123                        header( 'Retry-After: 600' );
     124        ?>
     125        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     126        <html xmlns="http://www.w3.org/1999/xhtml">
     127        <head>
     128        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     129                <title>Maintenance</title>
     130
     131        </head>
     132        <body>
     133                <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
     134        </body>
     135        </html>
     136        <?php
     137                        die();
     138                }
     139        }
     140}
     141
     142/**
     143 * PHP 4 standard microtime start capture.
     144 *
     145 * @access private
     146 * @since 0.71
     147 * @global int $timestart Seconds and Microseconds added together from when function is called.
     148 * @return bool Always returns true.
     149 */
     150function timer_start() {
     151        global $timestart;
     152        $mtime = explode(' ', microtime() );
     153        $mtime = $mtime[1] + $mtime[0];
     154        $timestart = $mtime;
     155        return true;
     156}
     157
     158/**
     159 * Return and/or display the time from the page start to when function is called.
     160 *
     161 * You can get the results and print them by doing:
     162 * <code>
     163 * $nTimePageTookToExecute = timer_stop();
     164 * echo $nTimePageTookToExecute;
     165 * </code>
     166 *
     167 * Or instead, you can do:
     168 * <code>
     169 * timer_stop(1);
     170 * </code>
     171 * which will do what the above does. If you need the result, you can assign it to a variable, but
     172 * most cases, you only need to echo it.
     173 *
     174 * @since 0.71
     175 * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
     176 * @global int $timeend  Seconds and Microseconds added together from when function is called
     177 *
     178 * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
     179 * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
     180 * @return float The "second.microsecond" finished time calculation
     181 */
     182function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
     183        global $timestart, $timeend;
     184        $mtime = microtime();
     185        $mtime = explode(' ',$mtime);
     186        $mtime = $mtime[1] + $mtime[0];
     187        $timeend = $mtime;
     188        $timetotal = $timeend-$timestart;
     189        $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
     190        if ( $display )
     191                echo $r;
     192        return $r;
     193}
     194
     195function wp_set_lang_dir() {
     196        if ( !defined('WP_LANG_DIR') ) {
     197                /**
     198                 * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
     199                 * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
     200                 *
     201                 * @since 2.1.0
     202                 */
     203                if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
     204                        define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     205                        if (!defined('LANGDIR')) {
     206                                // Old static relative path maintained for limited backwards compatibility - won't work in some cases
     207                                define('LANGDIR', 'wp-content/languages');
     208                        }
     209                } else {
     210                        define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     211                        if (!defined('LANGDIR')) {
     212                                // Old relative path maintained for backwards compatibility
     213                                define('LANGDIR', WPINC . '/languages');
     214                        }
     215                }
     216        }
     217}
     218
     219/**
     220 * Copy an object.
     221 *
     222 * Returns a cloned copy of an object.
     223 *
     224 * @since 2.7.0
     225 *
     226 * @param object $object The object to clone
     227 * @return object The cloned object
     228 */
     229function wp_clone( $object ) {
     230        static $can_clone;
     231        if ( !isset( $can_clone ) ) {
     232                $can_clone = version_compare( phpversion(), '5.0', '>=' );
     233        }
     234        return $can_clone ? clone( $object ) : $object;
     235}
     236
     237/**
     238 * Whether the current request is in WordPress admin Panel
     239 *
     240 * Does not inform on whether the user is an admin! Use capability checks to
     241 * tell if the user should be accessing a section or not.
     242 *
     243 * @since 1.5.1
     244 *
     245 * @return bool True if inside WordPress administration pages.
     246 */
     247function is_admin() {
     248        if ( defined('WP_ADMIN') )
     249                return WP_ADMIN;
     250        return false;
     251}
     252
     253function wp_start_object_cache() {
     254        global $_wp_using_ext_object_cache;
     255        if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) {
     256                require_once (WP_CONTENT_DIR . '/object-cache.php');
     257                $_wp_using_ext_object_cache = true;
     258        } else {
     259                require_once (ABSPATH . WPINC . '/cache.php');
     260                $_wp_using_ext_object_cache = false;
     261        }
     262
     263        wp_cache_init();
     264        if ( function_exists('wp_cache_add_global_groups') ) {
     265                        if( is_multisite() ) {
     266                                        wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
     267                        } else {
     268                                wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient'));
     269                        }
     270                wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
     271        }
     272}
     273
     274function wp_set_wpdb_vars() {
     275        global $wpdb;
     276        if ( !empty($wpdb->error) )
     277                dead_db();
     278
     279        /**
     280         * Format specifiers for DB columns. Columns not listed here default to %s.
     281         * @since 2.8.0
     282         * @see wpdb:$field_types
     283         * @see wpdb:prepare()
     284         * @see wpdb:insert()
     285         * @see wpdb:update()
     286         */
     287        $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
     288                'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
     289                'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
     290                'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
     291
     292        $prefix = $wpdb->set_prefix($table_prefix);
     293
     294        if ( is_wp_error($prefix) )
     295                wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/);
     296
     297}
     298
     299function wp_debug_mode() {
     300        if ( WP_DEBUG ) {
     301                if ( defined('E_DEPRECATED') )
     302                        error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
     303                else
     304                        error_reporting(E_ALL);
     305
     306                if ( WP_DEBUG_DISPLAY )
     307                        ini_set('display_errors', 1);
     308
     309                if ( WP_DEBUG_LOG ) {
     310                        ini_set('log_errors', 1);
     311                        ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
     312                }
     313        } else {
     314                if ( defined('E_RECOVERABLE_ERROR') )
     315                        error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
     316                else
     317                        error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
     318        }
     319}
     320
     321function wp_not_installed() {
     322        if( is_multisite() ) {
     323                        if ( !is_blog_installed() && !defined('WP_INSTALLING') ) {
     324                                        die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
     325                        }
     326        } elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
     327                if ( defined('WP_SITEURL') )
     328                        $link = WP_SITEURL . '/wp-admin/install.php';
     329                elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
     330                        $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
     331                else
     332                        $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
     333                require_once(ABSPATH . WPINC . '/kses.php');
     334                require_once(ABSPATH . WPINC . '/pluggable.php');
     335                require_once(ABSPATH . WPINC . '/formatting.php');
     336                wp_redirect($link);
     337                die();
     338        }
     339}
     340
     341function wp_load_mu_plugins() {
     342        if ( is_dir( WPMU_PLUGIN_DIR ) ) {
     343                if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
     344                        $mu_plugins = array ();
     345                        while ( ( $plugin = readdir( $dh ) ) !== false )
     346                                if ( substr( $plugin, -4 ) == '.php' )
     347                                        $mu_plugins[] = $plugin;
     348                        closedir( $dh );
     349                                        if( is_multisite() )
     350                                        sort( $mu_plugins );
     351                        foreach( $mu_plugins as $mu_plugin )
     352                                include_once( WPMU_PLUGIN_DIR . '/' . $mu_plugin );
     353                }
     354        }
     355}
     356
     357function wp_load_plugins() {
     358        // Check for hacks file if the option is enabled
     359        if ( get_option('hack_file') ) {
     360                if ( file_exists(ABSPATH . 'my-hacks.php') )
     361                        require(ABSPATH . 'my-hacks.php');
     362        }
     363
     364        $current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
     365        if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) {
     366                foreach ( $current_plugins as $plugin ) {
     367                        // check the $plugin filename
     368                        // Validate plugin filename
     369                        if ( validate_file($plugin) // $plugin must validate as file
     370                                || '.php' != substr($plugin, -4) // $plugin must end with '.php'
     371                                || !file_exists(WP_PLUGIN_DIR . '/' . $plugin)  // $plugin must exist
     372                                )
     373                                continue;
     374
     375                        include_once(WP_PLUGIN_DIR . '/' . $plugin);
     376                }
     377                unset($plugin);
     378        }
     379        unset($current_plugins);
     380
     381}
     382
     383function wp_magic_quotes() {
     384        // If already slashed, strip.
     385        if ( get_magic_quotes_gpc() ) {
     386                $_GET    = stripslashes_deep($_GET   );
     387                $_POST   = stripslashes_deep($_POST  );
     388                $_COOKIE = stripslashes_deep($_COOKIE);
     389        }
     390
     391        // Escape with wpdb.
     392        $_GET    = add_magic_quotes($_GET   );
     393        $_POST   = add_magic_quotes($_POST  );
     394        $_COOKIE = add_magic_quotes($_COOKIE);
     395        $_SERVER = add_magic_quotes($_SERVER);
     396
     397        // Force REQUEST to be GET + POST.  If SERVER, COOKIE, or ENV are needed, use those superglobals directly.
     398        $_REQUEST = array_merge($_GET, $_POST);
     399}
     400
     401function wp_set_locale() {
     402        global $locale, $locale_file, $wp_locale;
     403        /**
     404         * The locale of the blog
     405         * @since 1.5.0
     406         */
     407        $locale = get_locale();
     408        $locale_file = WP_LANG_DIR . "/$locale.php";
     409        if ( is_readable($locale_file) )
     410                require_once($locale_file);
     411
     412        // Pull in locale data after loading text domain.
     413        require_once(ABSPATH . WPINC . '/locale.php');
     414
     415        /**
     416         * WordPress Locale object for loading locale domain date and various strings.
     417         * @global object $wp_locale
     418         * @since 2.1.0
     419         */
     420        $wp_locale =& new WP_Locale();
     421}
     422
     423function wp_load_theme_functions() {
     424
     425        // Load functions for active theme.
     426        if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
     427                include(STYLESHEETPATH . '/functions.php');
     428        if ( file_exists(TEMPLATEPATH . '/functions.php') )
     429                include(TEMPLATEPATH . '/functions.php');
     430
     431        // Load in support for template functions which the theme supports
     432        require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
     433
     434}
     435
     436function wp_init_objects() {
     437        global $wp_the_query, $wp_query, $wp_rewrite, $wp, $wp_widget_factory;
     438        // PHP4 creates references to global variables, so =& will fail.
     439
     440        /**
     441         * WordPress Query object
     442         * @global object $wp_the_query
     443         * @since 2.0.0
     444         */
     445        $wp_the_query = new WP_Query();
     446
     447        /**
     448         * Holds the reference to @see $wp_the_query
     449         * Use this global for WordPress queries
     450         * @global object $wp_query
     451         * @since 1.5.0
     452         */
     453        $wp_query     = $wp_the_query;
     454
     455        /**
     456         * Holds the WordPress Rewrite object for creating pretty URLs
     457         * @global object $wp_rewrite
     458         * @since 1.5.0
     459         */
     460        $wp_rewrite   = new WP_Rewrite();
     461
     462        /**
     463         * WordPress Object
     464         * @global object $wp
     465         * @since 2.0.0
     466         */
     467        $wp           = new WP();
     468
     469        /**
     470         * WordPress Widget Factory Object
     471         * @global object $wp_widget_factory
     472         * @since 2.8.0
     473         */
     474        $wp_widget_factory = new WP_Widget_Factory();
     475}
     476
     477/**
     478 * Runs just before PHP shuts down execution.
     479 *
     480 * @access private
     481 * @since 1.2.0
     482 */
     483function shutdown_action_hook() {
     484        do_action('shutdown');
     485        wp_cache_close();
     486}
     487 No newline at end of file
  • wp-settings.php

     
    99 * @package WordPress
    1010 */
    1111
    12 
    1312/**
    14  * Whether Multisite support is enabled
     13 * Stores the location of the WordPress directory of functions, classes, and core content.
    1514 *
    16  * @since 3.0
    17  *
    18  * @return bool True if multisite is enabled, false otherwise.
     15 * @since 1.0.0
    1916 */
    20 function is_multisite() {
    21         if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') || defined('SUNRISE') )
    22                 return true;
     17define('WPINC', 'wp-includes');
    2318
    24         return false;
    25 }
     19require (ABSPATH . WPINC . '/load.php');
     20require (ABSPATH . WPINC . '/default-constants.php');
     21require (ABSPATH . WPINC . '/version.php');
    2622
    27 if ( !defined('WP_MEMORY_LIMIT') ) {
    28         if( is_multisite() ) {
    29                 define('WP_MEMORY_LIMIT', '64M');
    30         } else {
    31                 define('WP_MEMORY_LIMIT', '32M');
    32         }
    33 }
    34 
    35 if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
    36         @ini_set('memory_limit', WP_MEMORY_LIMIT);
    37 
    3823set_magic_quotes_runtime(0);
    3924@ini_set('magic_quotes_sybase', 0);
    4025
    4126if ( function_exists('date_default_timezone_set') )
    4227        date_default_timezone_set('UTC');
    4328
    44 /**
    45  * Turn register globals off.
    46  *
    47  * @access private
    48  * @since 2.1.0
    49  * @return null Will return null if register_globals PHP directive was disabled
    50  */
    51 function wp_unregister_GLOBALS() {
    52         if ( !ini_get('register_globals') )
    53                 return;
    54 
    55         if ( isset($_REQUEST['GLOBALS']) )
    56                 die('GLOBALS overwrite attempt detected');
    57 
    58         // Variables that shouldn't be unset
    59         $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
    60 
    61         $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
    62         foreach ( $input as $k => $v )
    63                 if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
    64                         $GLOBALS[$k] = NULL;
    65                         unset($GLOBALS[$k]);
    66                 }
    67 }
    68 
    6929wp_unregister_GLOBALS();
    7030
    7131unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
    7232
    73 /**
    74  * The $blog_id global, which you can change in the config allows you to create a simple
    75  * multiple blog installation using just one WordPress and changing $blog_id around.
    76  *
    77  * @global int $blog_id
    78  * @since 2.0.0
    79  */
    80 if ( ! isset($blog_id) )
    81         $blog_id = 1;
     33wp_fix_server_vars();
    8234
    83 // Fix for IIS when running with PHP ISAPI
    84 if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
     35wp_check_php_mysql_versions();
    8536
    86         // IIS Mod-Rewrite
    87         if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
    88                 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
    89         }
    90         // IIS Isapi_Rewrite
    91         else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
    92                 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    93         }
    94         else
    95         {
    96                 // Use ORIG_PATH_INFO if there is no PATH_INFO
    97                 if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
    98                         $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
     37wp_maintenance();
    9938
    100                 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
    101                 if ( isset($_SERVER['PATH_INFO']) ) {
    102                         if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
    103                                 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
    104                         else
    105                                 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
    106                 }
    107 
    108                 // Append the query string if it exists and isn't null
    109                 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
    110                         $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    111                 }
    112         }
    113 }
    114 
    115 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
    116 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
    117         $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
    118 
    119 // Fix for Dreamhost and other PHP as CGI hosts
    120 if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
    121         unset($_SERVER['PATH_INFO']);
    122 
    123 // Fix empty PHP_SELF
    124 $PHP_SELF = $_SERVER['PHP_SELF'];
    125 if ( empty($PHP_SELF) )
    126         $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
    127 
    128 if ( version_compare( '4.3', phpversion(), '>' ) ) {
    129         die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, phpversion() ) );
    130 }
    131 
    132 if ( !defined('WP_CONTENT_DIR') )
    133         define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
    134 
    135 if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
    136         include(ABSPATH . '.maintenance');
    137         // If the $upgrading timestamp is older than 10 minutes, don't die.
    138         if ( ( time() - $upgrading ) < 600 ) {
    139                 if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
    140                         require_once( WP_CONTENT_DIR . '/maintenance.php' );
    141                         die();
    142                 }
    143 
    144                 $protocol = $_SERVER["SERVER_PROTOCOL"];
    145                 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
    146                         $protocol = 'HTTP/1.0';
    147                 header( "$protocol 503 Service Unavailable", true, 503 );
    148                 header( 'Content-Type: text/html; charset=utf-8' );
    149                 header( 'Retry-After: 600' );
    150 ?>
    151 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    152 <html xmlns="http://www.w3.org/1999/xhtml">
    153 <head>
    154 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    155         <title>Maintenance</title>
    156 
    157 </head>
    158 <body>
    159         <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
    160 </body>
    161 </html>
    162 <?php
    163                 die();
    164         }
    165 }
    166 
    167 if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
    168         die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
    169 
    170 /**
    171  * PHP 4 standard microtime start capture.
    172  *
    173  * @access private
    174  * @since 0.71
    175  * @global int $timestart Seconds and Microseconds added together from when function is called.
    176  * @return bool Always returns true.
    177  */
    178 function timer_start() {
    179         global $timestart;
    180         $mtime = explode(' ', microtime() );
    181         $mtime = $mtime[1] + $mtime[0];
    182         $timestart = $mtime;
    183         return true;
    184 }
    185 
    186 /**
    187  * Return and/or display the time from the page start to when function is called.
    188  *
    189  * You can get the results and print them by doing:
    190  * <code>
    191  * $nTimePageTookToExecute = timer_stop();
    192  * echo $nTimePageTookToExecute;
    193  * </code>
    194  *
    195  * Or instead, you can do:
    196  * <code>
    197  * timer_stop(1);
    198  * </code>
    199  * which will do what the above does. If you need the result, you can assign it to a variable, but
    200  * most cases, you only need to echo it.
    201  *
    202  * @since 0.71
    203  * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
    204  * @global int $timeend  Seconds and Microseconds added together from when function is called
    205  *
    206  * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
    207  * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
    208  * @return float The "second.microsecond" finished time calculation
    209  */
    210 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
    211         global $timestart, $timeend;
    212         $mtime = microtime();
    213         $mtime = explode(' ',$mtime);
    214         $mtime = $mtime[1] + $mtime[0];
    215         $timeend = $mtime;
    216         $timetotal = $timeend-$timestart;
    217         $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
    218         if ( $display )
    219                 echo $r;
    220         return $r;
    221 }
    22239timer_start();
    22340
    224 // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
    225 if ( !defined('WP_DEBUG') )
    226         define( 'WP_DEBUG', false );
     41wp_debug_mode();
    22742
    228 if ( WP_DEBUG ) {
    229         if ( defined('E_DEPRECATED') )
    230                 error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
    231         else
    232                 error_reporting(E_ALL);
    233         // 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
    234         if ( ! defined('WP_DEBUG_DISPLAY') || WP_DEBUG_DISPLAY )
    235                 ini_set('display_errors', 1);
    236         // Add define('WP_DEBUG_LOG', true); to enable php debug logging to WP_CONTENT_DIR/debug.log
    237         if ( defined('WP_DEBUG_LOG') && WP_DEBUG_LOG ) {
    238                 ini_set('log_errors', 1);
    239                 ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
    240         }
    241 } else {
    242         if ( defined('E_RECOVERABLE_ERROR') )
    243                 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
    244         else
    245                 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
    246 }
    247 
    24843// For an advanced caching plugin to use, static because you would only want one
    249 if ( defined('WP_CACHE') && WP_CACHE )
     44if ( WP_CACHE )
    25045        @include WP_CONTENT_DIR . '/advanced-cache.php';
    25146
    252 /**
    253  * Private
    254  */
    255 if ( !defined('MEDIA_TRASH') )
    256         define('MEDIA_TRASH', false);
     47wp_set_lang_dir();
    25748
    258 /**
    259  * Stores the location of the WordPress directory of functions, classes, and core content.
    260  *
    261  * @since 1.0.0
    262  */
    263 define('WPINC', 'wp-includes');
    264 
    265 if ( !defined('WP_LANG_DIR') ) {
    266         /**
    267          * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
    268          * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
    269          *
    270          * @since 2.1.0
    271          */
    272         if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
    273                 define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
    274                 if (!defined('LANGDIR')) {
    275                         // Old static relative path maintained for limited backwards compatibility - won't work in some cases
    276                         define('LANGDIR', 'wp-content/languages');
    277                 }
    278         } else {
    279                 define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
    280                 if (!defined('LANGDIR')) {
    281                         // Old relative path maintained for backwards compatibility
    282                         define('LANGDIR', WPINC . '/languages');
    283                 }
    284         }
    285 }
    286 
    28749require (ABSPATH . WPINC . '/compat.php');
    28850require (ABSPATH . WPINC . '/functions.php');
    28951require (ABSPATH . WPINC . '/classes.php');
    29052
    29153require_wp_db();
    29254
    293 if ( !empty($wpdb->error) )
    294         dead_db();
     55wp_set_wpdb_vars();
    29556
    296 /**
    297  * Format specifiers for DB columns. Columns not listed here default to %s.
    298  * @since 2.8.0
    299  * @see wpdb:$field_types
    300  * @see wpdb:prepare()
    301  * @see wpdb:insert()
    302  * @see wpdb:update()
    303  */
    304 $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
    305         'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    306         'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    307         'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
     57wp_start_object_cache();
    30858
    309 $prefix = $wpdb->set_prefix($table_prefix);
    310 
    311 if ( is_wp_error($prefix) )
    312         wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/);
    313 
    314 /**
    315  * Copy an object.
    316  *
    317  * Returns a cloned copy of an object.
    318  *
    319  * @since 2.7.0
    320  *
    321  * @param object $object The object to clone
    322  * @return object The cloned object
    323  */
    324 function wp_clone( $object ) {
    325         static $can_clone;
    326         if ( !isset( $can_clone ) ) {
    327                 $can_clone = version_compare( phpversion(), '5.0', '>=' );
    328         }
    329         return $can_clone ? clone( $object ) : $object;
    330 }
    331 
    332 /**
    333  * Whether the current request is in WordPress admin Panel
    334  *
    335  * Does not inform on whether the user is an admin! Use capability checks to
    336  * tell if the user should be accessing a section or not.
    337  *
    338  * @since 1.5.1
    339  *
    340  * @return bool True if inside WordPress administration pages.
    341  */
    342 function is_admin() {
    343         if ( defined('WP_ADMIN') )
    344                 return WP_ADMIN;
    345         return false;
    346 }
    347 
    348 if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) {
    349         require_once (WP_CONTENT_DIR . '/object-cache.php');
    350         $_wp_using_ext_object_cache = true;
    351 } else {
    352         require_once (ABSPATH . WPINC . '/cache.php');
    353         $_wp_using_ext_object_cache = false;
    354 }
    355 
    356 wp_cache_init();
    357 if ( function_exists('wp_cache_add_global_groups') ) {
    358         if( is_multisite() ) {
    359                 wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
    360         } else {
    361                 wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient'));
    362         }
    363         wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
    364 }
    365 
    366 if( is_multisite() ) {
     59if( is_multisite() )
    36760    require (ABSPATH . WPINC . '/ms-load.php');
    368 }
    36961
    37062require (ABSPATH . WPINC . '/plugin.php');
    37163require (ABSPATH . WPINC . '/default-filters.php');
    37264include_once(ABSPATH . WPINC . '/pomo/mo.php');
    37365
    374 if( is_multisite() && defined( "SHORTINIT" ) && SHORTINIT ) // stop most of WP being loaded, we just want the basics
     66if( is_multisite() && SHORTINIT ) // stop most of WP being loaded, we just want the basics
    37567        return false;
    37668
    37769require_once (ABSPATH . WPINC . '/l10n.php');
    37870
    379 if( is_multisite() ) {
    380         if ( !is_blog_installed() && !defined('WP_INSTALLING') ) {
    381                 die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
    382         }
    383 } elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
    384         if ( defined('WP_SITEURL') )
    385                 $link = WP_SITEURL . '/wp-admin/install.php';
    386         elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
    387                 $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
    388         else
    389                 $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
    390         require_once(ABSPATH . WPINC . '/kses.php');
    391         require_once(ABSPATH . WPINC . '/pluggable.php');
    392         require_once(ABSPATH . WPINC . '/formatting.php');
    393         wp_redirect($link);
    394         die(); // have to die here ~ Mark
    395 }
     71wp_not_installed();
    39672
    39773require (ABSPATH . WPINC . '/formatting.php');
    39874require (ABSPATH . WPINC . '/capabilities.php');
     
    41591require (ABSPATH . WPINC . '/bookmark-template.php');
    41692require (ABSPATH . WPINC . '/kses.php');
    41793require (ABSPATH . WPINC . '/cron.php');
    418 require (ABSPATH . WPINC . '/version.php');
    41994require (ABSPATH . WPINC . '/deprecated.php');
    42095require (ABSPATH . WPINC . '/script-loader.php');
    42196require (ABSPATH . WPINC . '/taxonomy.php');
     
    432107        require_once( ABSPATH . WPINC . '/ms-deprecated.php' );
    433108}
    434109
    435 if ( !defined('WP_CONTENT_URL') )
    436         define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
     110define_after_wp_includes();
    437111
    438 /**
    439  * Allows for the plugins directory to be moved from the default location.
    440  *
    441  * @since 2.6.0
    442  */
    443 if ( !defined('WP_PLUGIN_DIR') )
    444         define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
    445 
    446 /**
    447  * Allows for the plugins directory to be moved from the default location.
    448  *
    449  * @since 2.6.0
    450  */
    451 if ( !defined('WP_PLUGIN_URL') )
    452         define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
    453 
    454 /**
    455  * Allows for the plugins directory to be moved from the default location.
    456  *
    457  * @since 2.1.0
    458  */
    459 if ( !defined('PLUGINDIR') )
    460         define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH.  For back compat.
    461 
    462112if( is_multisite() )
    463113        ms_network_settings();
    464 /**
    465  * Allows for the mu-plugins directory to be moved from the default location.
    466  *
    467  * @since 2.8.0
    468  */
    469 if ( !defined('WPMU_PLUGIN_DIR') )
    470         define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
    471114
    472 /**
    473  * Allows for the mu-plugins directory to be moved from the default location.
    474  *
    475  * @since 2.8.0
    476  */
    477 if ( !defined('WPMU_PLUGIN_URL') )
    478         define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
     115wp_load_mu_plugins();
    479116
    480117/**
    481  * Allows for the mu-plugins directory to be moved from the default location.
    482  *
    483  * @since 2.8.0
    484  */
    485 if ( !defined( 'MUPLUGINDIR' ) )
    486         define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH.  For back compat.
    487 
    488 if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    489         if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
    490                 $mu_plugins = array ();
    491                 while ( ( $plugin = readdir( $dh ) ) !== false )
    492                         if ( substr( $plugin, -4 ) == '.php' )
    493                                 $mu_plugins[] = $plugin;
    494                 closedir( $dh );
    495                 if( is_multisite() )
    496                         sort( $mu_plugins );
    497                 foreach( $mu_plugins as $mu_plugin )
    498                         include_once( WPMU_PLUGIN_DIR . '/' . $mu_plugin );
    499         }
    500 }
    501 /**
    502118 * Used to load network wide plugins
    503119 * @since 3.0
    504120 */
     
    515131    ms_site_check();
    516132    ms_network_cookies();
    517133}
    518 /**
    519  * Used to guarantee unique hash cookies
    520  * @since 1.5
    521  */
    522 if( !defined('COOKIEHASH') )
    523         define('COOKIEHASH', md5(get_option('siteurl')));
    524134
    525 /**
    526  * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
    527  * @since 2.5.0
    528  */
    529 $wp_default_secret_key = 'put your unique phrase here';
     135define_after_ms_loaded();
    530136
    531 /**
    532  * It is possible to define this in wp-config.php
    533  * @since 2.0.0
    534  */
    535 if ( !defined('USER_COOKIE') )
    536         define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    537 
    538 /**
    539  * It is possible to define this in wp-config.php
    540  * @since 2.0.0
    541  */
    542 if ( !defined('PASS_COOKIE') )
    543         define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    544 
    545 /**
    546  * It is possible to define this in wp-config.php
    547  * @since 2.5.0
    548  */
    549 if ( !defined('AUTH_COOKIE') )
    550         define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    551 
    552 /**
    553  * It is possible to define this in wp-config.php
    554  * @since 2.6.0
    555  */
    556 if ( !defined('SECURE_AUTH_COOKIE') )
    557         define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    558 
    559 /**
    560  * It is possible to define this in wp-config.php
    561  * @since 2.6.0
    562  */
    563 if ( !defined('LOGGED_IN_COOKIE') )
    564         define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    565 
    566 /**
    567  * It is possible to define this in wp-config.php
    568  * @since 2.3.0
    569  */
    570 if ( !defined('TEST_COOKIE') )
    571         define('TEST_COOKIE', 'wordpress_test_cookie');
    572 
    573 /**
    574  * It is possible to define this in wp-config.php
    575  * @since 1.2.0
    576  */
    577 if ( !defined('COOKIEPATH') )
    578         define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
    579 
    580 /**
    581  * It is possible to define this in wp-config.php
    582  * @since 1.5.0
    583  */
    584 if ( !defined('SITECOOKIEPATH') )
    585         define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
    586 
    587 /**
    588  * It is possible to define this in wp-config.php
    589  * @since 2.6.0
    590  */
    591 if ( !defined('ADMIN_COOKIE_PATH') )
    592         define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
    593 
    594 /**
    595  * It is possible to define this in wp-config.php
    596  * @since 2.6.0
    597  */
    598 if ( !defined('PLUGINS_COOKIE_PATH') )
    599         define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
    600 
    601 /**
    602  * It is possible to define this in wp-config.php
    603  * @since 2.0.0
    604  */
    605 if ( !defined('COOKIE_DOMAIN') )
    606         define('COOKIE_DOMAIN', false);
    607 
    608 /**
    609  * It is possible to define this in wp-config.php
    610  * @since 2.6.0
    611  */
    612 if ( !defined('FORCE_SSL_ADMIN') )
    613         define('FORCE_SSL_ADMIN', false);
    614 force_ssl_admin(FORCE_SSL_ADMIN);
    615 
    616 /**
    617  * It is possible to define this in wp-config.php
    618  * @since 2.6.0
    619  */
    620 if ( !defined('FORCE_SSL_LOGIN') )
    621         define('FORCE_SSL_LOGIN', false);
    622 force_ssl_login(FORCE_SSL_LOGIN);
    623 
    624 /**
    625  * It is possible to define this in wp-config.php
    626  * @since 2.5.0
    627  */
    628 if ( !defined( 'AUTOSAVE_INTERVAL' ) )
    629         define( 'AUTOSAVE_INTERVAL', 60 );
    630 
    631 /**
    632  * It is possible to define this in wp-config.php
    633  * @since 2.9.0
    634  */
    635 if ( !defined( 'EMPTY_TRASH_DAYS' ) )
    636         define( 'EMPTY_TRASH_DAYS', 30 );
    637 
    638137require (ABSPATH . WPINC . '/vars.php');
    639138
    640139// make taxonomies available to plugins and themes
    641140// @plugin authors: warning: this gets registered again on the init hook
    642141create_initial_taxonomies();
    643142
    644 // Check for hacks file if the option is enabled
    645 if ( get_option('hack_file') ) {
    646         if ( file_exists(ABSPATH . 'my-hacks.php') )
    647                 require(ABSPATH . 'my-hacks.php');
    648 }
     143wp_load_plugins();
    649144
    650 $current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
    651 if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) {
    652         foreach ( $current_plugins as $plugin ) {
    653                 // check the $plugin filename
    654                 // Validate plugin filename
    655                 if ( validate_file($plugin) // $plugin must validate as file
    656                         || '.php' != substr($plugin, -4) // $plugin must end with '.php'
    657                         || !file_exists(WP_PLUGIN_DIR . '/' . $plugin)  // $plugin must exist
    658                         )
    659                         continue;
    660 
    661                 include_once(WP_PLUGIN_DIR . '/' . $plugin);
    662         }
    663         unset($plugin);
    664 }
    665 unset($current_plugins);
    666 
    667145require (ABSPATH . WPINC . '/pluggable.php');
    668146
    669147/*
     
    675153                mb_internal_encoding('UTF-8');
    676154}
    677155
    678 
    679 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
     156if ( WP_CACHE && function_exists('wp_cache_postload') )
    680157        wp_cache_postload();
    681158
    682159do_action('plugins_loaded');
    683160
    684 $default_constants = array( 'WP_POST_REVISIONS' => true );
    685 foreach ( $default_constants as $c => $v )
    686         @define( $c, $v ); // will fail if the constant is already defined
    687 unset($default_constants, $c, $v);
     161wp_magic_quotes();
    688162
    689 // If already slashed, strip.
    690 if ( get_magic_quotes_gpc() ) {
    691         $_GET    = stripslashes_deep($_GET   );
    692         $_POST   = stripslashes_deep($_POST  );
    693         $_COOKIE = stripslashes_deep($_COOKIE);
    694 }
    695 
    696 // Escape with wpdb.
    697 $_GET    = add_magic_quotes($_GET   );
    698 $_POST   = add_magic_quotes($_POST  );
    699 $_COOKIE = add_magic_quotes($_COOKIE);
    700 $_SERVER = add_magic_quotes($_SERVER);
    701 
    702 // Force REQUEST to be GET + POST.  If SERVER, COOKIE, or ENV are needed, use those superglobals directly.
    703 $_REQUEST = array_merge($_GET, $_POST);
    704 
    705163do_action('sanitize_comment_cookies');
    706164
    707 /**
    708  * WordPress Query object
    709  * @global object $wp_the_query
    710  * @since 2.0.0
    711  */
    712 $wp_the_query =& new WP_Query();
     165wp_init_objects();
    713166
    714 /**
    715  * Holds the reference to @see $wp_the_query
    716  * Use this global for WordPress queries
    717  * @global object $wp_query
    718  * @since 1.5.0
    719  */
    720 $wp_query     =& $wp_the_query;
    721 
    722 /**
    723  * Holds the WordPress Rewrite object for creating pretty URLs
    724  * @global object $wp_rewrite
    725  * @since 1.5.0
    726  */
    727 $wp_rewrite   =& new WP_Rewrite();
    728 
    729 /**
    730  * WordPress Object
    731  * @global object $wp
    732  * @since 2.0.0
    733  */
    734 $wp           =& new WP();
    735 
    736 /**
    737  * WordPress Widget Factory Object
    738  * @global object $wp_widget_factory
    739  * @since 2.8.0
    740  */
    741 $wp_widget_factory =& new WP_Widget_Factory();
    742 
    743167do_action('setup_theme');
    744168
    745 /**
    746  * Web Path to the current active template directory
    747  * @since 1.5.0
    748  */
    749 define('TEMPLATEPATH', get_template_directory());
     169define_after_setup_theme();
    750170
    751 /**
    752  * Web Path to the current active template stylesheet directory
    753  * @since 2.1.0
    754  */
    755 define('STYLESHEETPATH', get_stylesheet_directory());
    756 
    757171// Load the default text localization domain.
    758172load_default_textdomain();
    759173
    760 /**
    761  * The locale of the blog
    762  * @since 1.5.0
    763  */
    764 $locale = get_locale();
    765 $locale_file = WP_LANG_DIR . "/$locale.php";
    766 if ( is_readable($locale_file) )
    767         require_once($locale_file);
     174wp_set_locale();
    768175
    769 // Pull in locale data after loading text domain.
    770 require_once(ABSPATH . WPINC . '/locale.php');
     176wp_load_theme_functions();
    771177
    772 /**
    773  * WordPress Locale object for loading locale domain date and various strings.
    774  * @global object $wp_locale
    775  * @since 2.1.0
    776  */
    777 $wp_locale =& new WP_Locale();
    778 
    779 // Load functions for active theme.
    780 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
    781         include(STYLESHEETPATH . '/functions.php');
    782 if ( file_exists(TEMPLATEPATH . '/functions.php') )
    783         include(TEMPLATEPATH . '/functions.php');
    784 
    785 // Load in support for template functions which the theme supports
    786 require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
    787 
    788 /**
    789  * Runs just before PHP shuts down execution.
    790  *
    791  * @access private
    792  * @since 1.2.0
    793  */
    794 function shutdown_action_hook() {
    795         do_action('shutdown');
    796         wp_cache_close();
    797 }
    798178register_shutdown_function('shutdown_action_hook');
    799179
    800180$wp->init();  // Sets up current user.