Make WordPress Core


Ignore:
Timestamp:
01/19/2010 05:27:03 PM (14 years ago)
Author:
ryan
Message:

phpdoc for load.php, return some includes to global scope. Props nacin. see #11881

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r12755 r12762  
    1515 */
    1616function wp_unregister_GLOBALS() {
    17     if ( !ini_get('register_globals') )
     17    if ( !ini_get( 'register_globals' ) )
    1818        return;
    1919
    20     if ( isset($_REQUEST['GLOBALS']) )
    21         die('GLOBALS overwrite attempt detected');
     20    if ( isset( $_REQUEST['GLOBALS'] ) )
     21        die( 'GLOBALS overwrite attempt detected' );
    2222
    2323    // Variables that shouldn't be unset
    24     $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
    25 
    26     $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
     24    $noUnset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
     25
     26    $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
    2727    foreach ( $input as $k => $v )
    28         if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
     28        if ( !in_array( $k, $noUnset ) && isset( $GLOBALS[$k] ) ) {
    2929            $GLOBALS[$k] = NULL;
    30             unset($GLOBALS[$k]);
     30            unset( $GLOBALS[$k] );
    3131        }
    3232}
    3333
     34/**
     35 * Fix $_SERVER variables for various setups.
     36 *
     37 * @access private
     38 * @since 3.0.0
     39 */
    3440function wp_fix_server_vars() {
    3541    global $PHP_SELF;
     
    3844
    3945        // IIS Mod-Rewrite
    40         if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
     46        if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
    4147            $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
    4248        }
    4349        // IIS Isapi_Rewrite
    44         else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
     50        else if ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
    4551            $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    4652        }
     
    4854        {
    4955            // Use ORIG_PATH_INFO if there is no PATH_INFO
    50             if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
     56            if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
    5157                $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
    5258
    5359            // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
    54             if ( isset($_SERVER['PATH_INFO']) ) {
     60            if ( isset( $_SERVER['PATH_INFO'] ) ) {
    5561                if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
    5662                    $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
     
    6066
    6167            // Append the query string if it exists and isn't null
    62             if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
     68            if ( isset( $_SERVER['QUERY_STRING'] ) && !empty( $_SERVER['QUERY_STRING'] ) ) {
    6369                $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    6470            }
     
    6773
    6874    // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
    69     if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
     75    if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
    7076        $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
    7177
    7278    // Fix for Dreamhost and other PHP as CGI hosts
    73     if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
    74         unset($_SERVER['PATH_INFO']);
     79    if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
     80        unset( $_SERVER['PATH_INFO'] );
    7581
    7682    // Fix empty PHP_SELF
    7783    $PHP_SELF = $_SERVER['PHP_SELF'];
    78     if ( empty($PHP_SELF) )
    79         $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
    80 }
    81 
     84    if ( empty( $PHP_SELF ) )
     85        $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( "/(\?.*)?$/",'',$_SERVER["REQUEST_URI"] );
     86}
     87
     88/**
     89 * Check for the required PHP version, and the MySQL extension or a database drop-in.
     90 *
     91 * Dies if requirements are not met.
     92 *
     93 * @access private
     94 * @since 3.0.0
     95 */
    8296function wp_check_php_mysql_versions() {
    8397    // we can probably extend this function to check if wp_die() exists then use translated strings, and then use it in install.php etc.
     
    88102        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 ) );
    89103
    90     if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
     104    if ( !extension_loaded( 'mysql' ) && !file_exists( WP_CONTENT_DIR . '/db.php' ) )
    91105        die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
    92106}
    93107
     108/**
     109 * Dies with a maintenance message when conditions are met.
     110 *
     111 * Checks for a file in the WordPress root directory named ".maintenance".
     112 * This file will contain the variable $upgrading, set to the time the file
     113 * was created. If the file was created less than 10 minutes ago, WordPress
     114 * enters maintenance mode and displays a message.
     115 *
     116 * The default message can be replaced by using a drop-in (maintenance.php in
     117 * the wp-content directory).
     118 *
     119 * @access private
     120 * @since 3.0.0
     121 */
    94122function wp_maintenance() {
    95     if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
    96         include(ABSPATH . '.maintenance');
    97         // If the $upgrading timestamp is older than 10 minutes, don't die.
    98         if ( ( time() - $upgrading ) < 600 ) {
    99             if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
    100                 require_once( WP_CONTENT_DIR . '/maintenance.php' );
    101                 die();
    102             }
    103 
    104             $protocol = $_SERVER["SERVER_PROTOCOL"];
    105             if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
    106                 $protocol = 'HTTP/1.0';
    107             header( "$protocol 503 Service Unavailable", true, 503 );
    108             header( 'Content-Type: text/html; charset=utf-8' );
    109             header( 'Retry-After: 600' );
    110     ?>
     123    if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) )
     124        return;
     125
     126    include( ABSPATH . '.maintenance' );
     127    // If the $upgrading timestamp is older than 10 minutes, don't die.
     128    if ( ( time() - $upgrading ) >= 600 )
     129        return;
     130
     131    if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
     132        require_once( WP_CONTENT_DIR . '/maintenance.php' );
     133        die();
     134    }
     135
     136    $protocol = $_SERVER["SERVER_PROTOCOL"];
     137    if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
     138        $protocol = 'HTTP/1.0';
     139    header( "$protocol 503 Service Unavailable", true, 503 );
     140    header( 'Content-Type: text/html; charset=utf-8' );
     141    header( 'Retry-After: 600' );
     142?>
    111143    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    112144    <html xmlns="http://www.w3.org/1999/xhtml">
     
    120152    </body>
    121153    </html>
    122     <?php
    123             die();
    124         }
    125     }
     154<?php
     155    die();
    126156}
    127157
     
    136166function timer_start() {
    137167    global $timestart;
    138     $mtime = explode(' ', microtime() );
     168    $mtime = explode( ' ', microtime() );
    139169    $mtime = $mtime[1] + $mtime[0];
    140170    $timestart = $mtime;
     
    166196 * @return float The "second.microsecond" finished time calculation
    167197 */
    168 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
     198function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal
    169199    global $timestart, $timeend;
    170200    $mtime = microtime();
    171     $mtime = explode(' ',$mtime);
     201    $mtime = explode( ' ',$mtime );
    172202    $mtime = $mtime[1] + $mtime[0];
    173203    $timeend = $mtime;
    174204    $timetotal = $timeend-$timestart;
    175     $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
     205    $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
    176206    if ( $display )
    177207        echo $r;
     
    179209}
    180210
     211/**
     212 * Sets PHP error handling.
     213 *
     214 * Add <code>define('WP_DEBUG', true);</code> to wp-config.php to enable
     215 * the reporting of notices during development.
     216 *
     217 * Add <code>define('WP_DEBUG_DISPLAY', false);</code> to wp-config.php to
     218 * disable the display of errors.
     219 *
     220 * Add <code>define('WP_DEBUG_LOG', true);</code> to wp-config.php to log
     221 * eerrors to debug.log in the wp-content directory.
     222 *
     223 * @access private
     224 * @since 3.0.0
     225 */
    181226function wp_debug_mode() {
    182227    if ( WP_DEBUG ) {
    183         if ( defined('E_DEPRECATED') )
    184             error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
     228        if ( defined( 'E_DEPRECATED' ) )
     229            error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
    185230        else
    186             error_reporting(E_ALL);
     231            error_reporting( E_ALL );
    187232
    188233        if ( WP_DEBUG_DISPLAY )
    189             ini_set('display_errors', 1);
     234            ini_set( 'display_errors', 1 );
    190235
    191236        if ( WP_DEBUG_LOG ) {
    192             ini_set('log_errors', 1);
    193             ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
     237            ini_set( 'log_errors', 1 );
     238            ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
    194239        }
    195240    } else {
    196         if ( defined('E_RECOVERABLE_ERROR') )
    197             error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
     241        if ( defined( 'E_RECOVERABLE_ERROR' ) )
     242            error_reporting( E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
    198243        else
    199             error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
    200     }
    201 }
    202 
     244            error_reporting( E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING );
     245    }
     246}
     247
     248/**
     249 * Sets the location of the language directory.
     250 *
     251 * To set directory manually, define <code>WP_LANG_DIR</code> in wp-config.php.
     252 *
     253 * First looks for language folder in WP_CONTENT_DIR and uses that folder if it
     254 * exists. Or it uses the "languages" folder in WPINC.
     255 *
     256 * The WP_LANG_DIR constant was introduced in 2.1.0.
     257 *
     258 * @access private
     259 * @since 3.0.0
     260 */
    203261function wp_set_lang_dir() {
    204     if ( !defined('WP_LANG_DIR') ) {
    205         /**
    206          * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
    207          * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
    208          *
    209          * @since 2.1.0
    210          */
    211         if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
    212             define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
    213             if (!defined('LANGDIR')) {
     262    if ( !defined( 'WP_LANG_DIR' ) ) {
     263        if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) {
     264            define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     265            if ( !defined( 'LANGDIR' ) ) {
    214266                // Old static relative path maintained for limited backwards compatibility - won't work in some cases
    215                 define('LANGDIR', 'wp-content/languages');
     267                define( 'LANGDIR', 'wp-content/languages' );
    216268            }
    217269        } else {
    218             define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
    219             if (!defined('LANGDIR')) {
     270            define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     271            if ( !defined( 'LANGDIR' ) ) {
    220272                // Old relative path maintained for backwards compatibility
    221                 define('LANGDIR', WPINC . '/languages');
     273                define( 'LANGDIR', WPINC . '/languages' );
    222274            }
    223275        }
     
    225277}
    226278
     279/**
     280 * Sets the database table prefix and the format specifiers for database table columns.
     281 *
     282 * Columns not listed here default to %s.
     283 *
     284 * @see wpdb::$field_types Since 2.8.0
     285 * @see wpdb::prepare()
     286 * @see wpdb::insert()
     287 * @see wpdb::update()
     288 * @see wpdb::set_prefix()
     289 *
     290 * @access private
     291 * @since 3.0.0
     292 */
    227293function wp_set_wpdb_vars() {
    228294    global $wpdb, $table_prefix;
    229     if ( !empty($wpdb->error) )
     295    if ( !empty( $wpdb->error ) )
    230296        dead_db();
    231297
    232     /**
    233      * Format specifiers for DB columns. Columns not listed here default to %s.
    234      * @since 2.8.0
    235      * @see wpdb:$field_types
    236      * @see wpdb:prepare()
    237      * @see wpdb:insert()
    238      * @see wpdb:update()
    239      */
    240298    $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
    241299        'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    242300        'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    243         'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
    244 
    245     $prefix = $wpdb->set_prefix($table_prefix);
    246 
    247     if ( is_wp_error($prefix) )
    248         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*/);
    249 
    250 }
    251 
     301        'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d' );
     302
     303    $prefix = $wpdb->set_prefix( $table_prefix );
     304
     305    if ( is_wp_error( $prefix ) )
     306        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*/ );
     307}
     308
     309/**
     310 * Starts the WordPress object cache.
     311 *
     312 * If an object-cache.php file exists in the wp-content directory,
     313 * it uses that drop-in as an external object cache.
     314 *
     315 * @access private
     316 * @since 3.0.0
     317 */
    252318function wp_start_object_cache() {
    253319    global $_wp_using_ext_object_cache;
    254     if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) {
    255         require_once (WP_CONTENT_DIR . '/object-cache.php');
     320    if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
     321        require_once ( WP_CONTENT_DIR . '/object-cache.php' );
    256322        $_wp_using_ext_object_cache = true;
    257323    } else {
    258         require_once (ABSPATH . WPINC . '/cache.php');
     324        require_once ( ABSPATH . WPINC . '/cache.php' );
    259325        $_wp_using_ext_object_cache = false;
    260326    }
    261327
    262328    wp_cache_init();
    263 
    264     if ( function_exists('wp_cache_add_global_groups') ) {
    265         wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
    266         wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
    267     }
    268 }
    269 
     329    if ( function_exists( 'wp_cache_add_global_groups' ) ) {
     330        wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss' ) );
     331        wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
     332    }
     333}
     334
     335/**
     336 * Redirects to the installer if WordPress is not installed.
     337 *
     338 * Dies with an error message when multisite is enabled.
     339 *
     340 * @access private
     341 * @since 3.0.0
     342 */
    270343function wp_not_installed() {
    271344    if ( is_multisite() ) {
    272         if ( !is_blog_installed() && !defined('WP_INSTALLING') )
    273             die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here
    274     } elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
    275         if ( defined('WP_SITEURL') )
     345        if ( !is_blog_installed() && !defined( 'WP_INSTALLING' ) )
     346            wp_die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) );
     347    } elseif ( !is_blog_installed() && ( strpos( $_SERVER['PHP_SELF'], 'install.php' ) === false && !defined( 'WP_INSTALLING' ) ) ) {
     348        if ( defined( 'WP_SITEURL' ) )
    276349            $link = WP_SITEURL . '/wp-admin/install.php';
    277         elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
    278             $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
     350        elseif ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false )
     351            $link = preg_replace( '|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
    279352        else
    280             $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
    281         require_once(ABSPATH . WPINC . '/kses.php');
    282         require_once(ABSPATH . WPINC . '/pluggable.php');
    283         require_once(ABSPATH . WPINC . '/formatting.php');
    284         wp_redirect($link);
     353            $link = preg_replace( '|/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'wp-admin/install.php';
     354        require_once( ABSPATH . WPINC . '/kses.php' );
     355        require_once( ABSPATH . WPINC . '/pluggable.php' );
     356        require_once( ABSPATH . WPINC . '/formatting.php' );
     357        wp_redirect( $link );
    285358        die();
    286359    }
    287360}
    288361
    289 function wp_load_mu_plugins() {
    290     if ( is_dir( WPMU_PLUGIN_DIR ) ) {
    291         if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
    292             $mu_plugins = array ();
    293             while ( ( $plugin = readdir( $dh ) ) !== false ) {
    294                 if ( substr( $plugin, -4 ) == '.php' )
    295                     $mu_plugins[] = $plugin;
    296             }
    297             closedir( $dh );
    298             sort( $mu_plugins );
    299             foreach ( $mu_plugins as $mu_plugin )
    300                 include_once( WPMU_PLUGIN_DIR . '/' . $mu_plugin );
    301         }
    302     }
    303 }
    304 
    305 function wp_load_plugins() {
     362/**
     363 * Returns array of must-use plugin files to be included in global scope.
     364 *
     365 * The default directory is wp-content/mu-plugins. To change the default directory
     366 * manually, define <code>WPMU_PLUGIN_DIR</code> and <code>WPMU_PLUGIN_URL</code>
     367 * in wp-config.php.
     368 *
     369 * @access private
     370 * @since 3.0.0
     371 * @return array Files to include
     372 */
     373function wp_muplugins_to_load() {
     374    $mu_plugins = array();
     375    if ( !is_dir( WPMU_PLUGIN_DIR ) )
     376        return $mu_plugins;
     377    if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
     378        return $mu_plugins;
     379    while ( ( $plugin = readdir( $dh ) ) !== false ) {
     380        if ( substr( $plugin, -4 ) == '.php' )
     381            $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
     382    }
     383    closedir( $dh );
     384    sort( $mu_plugins );
     385
     386    return $mu_plugins;
     387}
     388
     389/**
     390 * Returns array of plugin files to be included in global scope.
     391 *
     392 * The default directory is wp-content/plugins. To change the default directory
     393 * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
     394 * in wp-config.php.
     395 *
     396 * @access private
     397 * @since 3.0.0
     398 * @return array Files to include
     399 */
     400function wp_plugins_to_load() {
     401    $plugins = array();
     402
    306403    // Check for hacks file if the option is enabled
    307     if ( get_option('hack_file') ) {
    308         if ( file_exists(ABSPATH . 'my-hacks.php') )
    309             require(ABSPATH . 'my-hacks.php');
    310     }
    311 
    312     $current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
    313     if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) {
    314         foreach ( $current_plugins as $plugin ) {
    315             // check the $plugin filename
    316             // Validate plugin filename
    317             if ( validate_file($plugin) // $plugin must validate as file
    318                 || '.php' != substr($plugin, -4) // $plugin must end with '.php'
    319                 || !file_exists(WP_PLUGIN_DIR . '/' . $plugin)  // $plugin must exist
    320                 )
    321                 continue;
    322 
    323             include_once(WP_PLUGIN_DIR . '/' . $plugin);
    324         }
    325         unset($plugin);
    326     }
    327     unset($current_plugins);
    328 }
    329 
     404    if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) )
     405            $plugins[] = ABSPATH . 'my-hacks.php';
     406
     407    $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
     408    if ( !is_array( $active_plugins ) || defined( 'WP_INSTALLING' ) )
     409        return $plugins;
     410    foreach ( $active_plugins as $plugin ) {
     411        if ( validate_file( $plugin ) // $plugin must validate as file
     412            || '.php' != substr( $plugin, -4 ) // $plugin must end with '.php'
     413            || !file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
     414            )
     415            continue;
     416        $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
     417    }
     418    return $plugins;
     419}
     420
     421/**
     422 * Sets internal encoding using mb_internal_encoding().
     423 *
     424 * In most cases the default internal encoding is latin1, which is of no use,
     425 * since we want to use the mb_ functions for utf-8 strings.
     426 *
     427 * @access private
     428 * @since 3.0.0
     429 */
    330430function wp_set_internal_encoding() {
    331     /*
    332      * In most cases the default internal encoding is latin1, which is of no use,
    333      * since we want to use the mb_ functions for utf-8 strings
    334      */
    335     if (function_exists('mb_internal_encoding')) {
    336         if (!@mb_internal_encoding(get_option('blog_charset')))
    337             mb_internal_encoding('UTF-8');
    338     }
    339 }
    340 
     431    if ( function_exists( 'mb_internal_encoding' ) ) {
     432        if ( !@mb_internal_encoding( get_option( 'blog_charset' ) ) )
     433            mb_internal_encoding( 'UTF-8' );
     434    }
     435}
     436
     437/**
     438 * Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
     439 *
     440 * Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
     441 * or $_ENV are needed, use those superglobals directly.
     442 *
     443 * @access private
     444 * @since 3.0.0
     445 */
    341446function wp_magic_quotes() {
    342447    // If already slashed, strip.
    343448    if ( get_magic_quotes_gpc() ) {
    344         $_GET    = stripslashes_deep($_GET   );
    345         $_POST   = stripslashes_deep($_POST  );
    346         $_COOKIE = stripslashes_deep($_COOKIE);
     449        $_GET    = stripslashes_deep( $_GET    );
     450        $_POST   = stripslashes_deep( $_POST   );
     451        $_COOKIE = stripslashes_deep( $_COOKIE );
    347452    }
    348453
    349454    // Escape with wpdb.
    350     $_GET    = add_magic_quotes($_GET   );
    351     $_POST   = add_magic_quotes($_POST  );
    352     $_COOKIE = add_magic_quotes($_COOKIE);
    353     $_SERVER = add_magic_quotes($_SERVER);
    354 
    355     // Force REQUEST to be GET + POST.  If SERVER, COOKIE, or ENV are needed, use those superglobals directly.
    356     $_REQUEST = array_merge($_GET, $_POST);
    357 }
    358 
    359 function wp_find_locale() {
    360     global $locale, $locale_file;
    361     /**
    362      * The locale of the blog
    363      * @since 1.5.0
    364      */
    365     $locale = get_locale();
    366     $locale_file = WP_LANG_DIR . "/$locale.php";
    367     if ( is_readable($locale_file) )
    368         require_once($locale_file);
    369 
    370     // Pull in locale data after loading text domain.
    371     require_once(ABSPATH . WPINC . '/locale.php');
    372 }
    373 
    374 function wp_load_theme_functions() {
    375     // Load functions for active theme.
    376     if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
    377         include(STYLESHEETPATH . '/functions.php');
    378     if ( file_exists(TEMPLATEPATH . '/functions.php') )
    379         include(TEMPLATEPATH . '/functions.php');
    380 
    381     // Load in support for template functions which the theme supports
    382     require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
     455    $_GET    = add_magic_quotes( $_GET    );
     456    $_POST   = add_magic_quotes( $_POST   );
     457    $_COOKIE = add_magic_quotes( $_COOKIE );
     458    $_SERVER = add_magic_quotes( $_SERVER );
     459
     460    // Force REQUEST to be GET + POST.
     461    $_REQUEST = array_merge( $_GET, $_POST );
    383462}
    384463
     
    390469 */
    391470function shutdown_action_hook() {
    392     do_action('shutdown');
     471    do_action( 'shutdown' );
    393472    wp_cache_close();
    394473}
     
    423502 */
    424503function is_admin() {
    425     if ( defined('WP_ADMIN') )
     504    if ( defined( 'WP_ADMIN' ) )
    426505        return WP_ADMIN;
    427506    return false;
     
    436515 */
    437516function is_multisite() {
    438     if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') || defined('SUNRISE') )
     517    if ( ( defined( 'MULTISITE' ) && MULTISITE ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
    439518        return true;
    440519
Note: See TracChangeset for help on using the changeset viewer.