WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/19/2010 05:27:03 PM (11 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-settings.php

    r12735 r12762  
    1414 * @since 1.0.0
    1515 */
    16 define('WPINC', 'wp-includes');
    17 
    18 require (ABSPATH . WPINC . '/load.php');
    19 require (ABSPATH . WPINC . '/default-constants.php');
    20 require (ABSPATH . WPINC . '/version.php');
    21 
    22 wp_default_constants('init');
    23 
    24 set_magic_quotes_runtime(0);
    25 @ini_set('magic_quotes_sybase', 0);
    26 
    27 if ( function_exists('date_default_timezone_set') )
    28     date_default_timezone_set('UTC');
    29 
     16define( 'WPINC', 'wp-includes' );
     17
     18// Include files required for initialization.
     19require( ABSPATH . WPINC . '/load.php' );
     20require( ABSPATH . WPINC . '/default-constants.php' );
     21require( ABSPATH . WPINC . '/version.php' );
     22
     23// Set initial default constants including WP_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
     24wp_default_constants( 'init' );
     25
     26// Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
     27set_magic_quotes_runtime( 0 );
     28@ini_set( 'magic_quotes_sybase', 0 );
     29
     30// Set default timezone in PHP 5.
     31if ( function_exists( 'date_default_timezone_set' ) )
     32    date_default_timezone_set( 'UTC' );
     33
     34// Turn register_globals off.
    3035wp_unregister_GLOBALS();
    3136
     37// Ensure these global variables do not exist so they do not interfere with WordPress.
    3238unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
    3339
     40// Standardize $_SERVER variables across setups.
    3441wp_fix_server_vars();
    3542
     43// Check for the required PHP version and for the MySQL extension or a database drop-in.
    3644wp_check_php_mysql_versions();
    3745
     46// Check if we're in maintenance mode.
    3847wp_maintenance();
    3948
     49// Start loading timer.
    4050timer_start();
    4151
     52// Check if we're in WP_DEBUG mode.
    4253wp_debug_mode();
    4354
    44 // For an advanced caching plugin to use, static because you would only want one
     55// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
    4556if ( WP_CACHE )
    4657    @include WP_CONTENT_DIR . '/advanced-cache.php';
    4758
     59// Define WP_LANG_DIR if not set.
    4860wp_set_lang_dir();
    4961
    50 require (ABSPATH . WPINC . '/compat.php');
    51 require (ABSPATH . WPINC . '/functions.php');
    52 require (ABSPATH . WPINC . '/classes.php');
    53 
     62// Include early WordPress files.
     63require( ABSPATH . WPINC . '/compat.php' );
     64require( ABSPATH . WPINC . '/functions.php' );
     65require( ABSPATH . WPINC . '/classes.php' );
     66
     67// Include the wpdb class, or a db.php database drop-in if present.
    5468require_wp_db();
    5569
     70// Set the database table prefix and the format specifiers for database table columns.
    5671wp_set_wpdb_vars();
    5772
     73// Start the WordPress object cache, or an external object cache if the drop-in is present.
    5874wp_start_object_cache();
    5975
     76// Initialize multisite if enabled.
    6077if ( is_multisite() )
    61     require (ABSPATH . WPINC . '/ms-load.php');
    62 
    63 require (ABSPATH . WPINC . '/plugin.php');
    64 require (ABSPATH . WPINC . '/default-filters.php');
    65 include_once(ABSPATH . WPINC . '/pomo/mo.php');
    66 
    67 if ( SHORTINIT ) // stop most of WP being loaded, we just want the basics
     78    require( ABSPATH . WPINC . '/ms-load.php' );
     79
     80// Load early WordPress files.
     81require( ABSPATH . WPINC . '/plugin.php' );
     82require( ABSPATH . WPINC . '/default-filters.php' );
     83include_once( ABSPATH . WPINC . '/pomo/mo.php' );
     84
     85// Stop most of WordPress from being loaded if we just want the basics.
     86if ( SHORTINIT )
    6887    return false;
    6988
    70 require_once (ABSPATH . WPINC . '/l10n.php');
    71 
     89// Load the l18n library.
     90require_once ( ABSPATH . WPINC . '/l10n.php' );
     91
     92// Run the installer if WordPress is not installed.
    7293wp_not_installed();
    7394
    74 require (ABSPATH . WPINC . '/formatting.php');
    75 require (ABSPATH . WPINC . '/capabilities.php');
    76 require (ABSPATH . WPINC . '/query.php');
    77 require (ABSPATH . WPINC . '/theme.php');
    78 require (ABSPATH . WPINC . '/user.php');
    79 require (ABSPATH . WPINC . '/meta.php');
    80 require (ABSPATH . WPINC . '/general-template.php');
    81 require (ABSPATH . WPINC . '/link-template.php');
    82 require (ABSPATH . WPINC . '/author-template.php');
    83 require (ABSPATH . WPINC . '/post.php');
    84 require (ABSPATH . WPINC . '/post-template.php');
    85 require (ABSPATH . WPINC . '/category.php');
    86 require (ABSPATH . WPINC . '/category-template.php');
    87 require (ABSPATH . WPINC . '/comment.php');
    88 require (ABSPATH . WPINC . '/comment-template.php');
    89 require (ABSPATH . WPINC . '/rewrite.php');
    90 require (ABSPATH . WPINC . '/feed.php');
    91 require (ABSPATH . WPINC . '/bookmark.php');
    92 require (ABSPATH . WPINC . '/bookmark-template.php');
    93 require (ABSPATH . WPINC . '/kses.php');
    94 require (ABSPATH . WPINC . '/cron.php');
    95 require (ABSPATH . WPINC . '/deprecated.php');
    96 require (ABSPATH . WPINC . '/script-loader.php');
    97 require (ABSPATH . WPINC . '/taxonomy.php');
    98 require (ABSPATH . WPINC . '/update.php');
    99 require (ABSPATH . WPINC . '/canonical.php');
    100 require (ABSPATH . WPINC . '/shortcodes.php');
    101 require (ABSPATH . WPINC . '/media.php');
    102 require (ABSPATH . WPINC . '/http.php');
    103 require (ABSPATH . WPINC . '/widgets.php');
    104 
     95// Load most of WordPress.
     96require( ABSPATH . WPINC . '/formatting.php' );
     97require( ABSPATH . WPINC . '/capabilities.php' );
     98require( ABSPATH . WPINC . '/query.php' );
     99require( ABSPATH . WPINC . '/theme.php' );
     100require( ABSPATH . WPINC . '/user.php' );
     101require( ABSPATH . WPINC . '/meta.php' );
     102require( ABSPATH . WPINC . '/general-template.php' );
     103require( ABSPATH . WPINC . '/link-template.php' );
     104require( ABSPATH . WPINC . '/author-template.php' );
     105require( ABSPATH . WPINC . '/post.php' );
     106require( ABSPATH . WPINC . '/post-template.php' );
     107require( ABSPATH . WPINC . '/category.php' );
     108require( ABSPATH . WPINC . '/category-template.php' );
     109require( ABSPATH . WPINC . '/comment.php' );
     110require( ABSPATH . WPINC . '/comment-template.php' );
     111require( ABSPATH . WPINC . '/rewrite.php' );
     112require( ABSPATH . WPINC . '/feed.php' );
     113require( ABSPATH . WPINC . '/bookmark.php' );
     114require( ABSPATH . WPINC . '/bookmark-template.php' );
     115require( ABSPATH . WPINC . '/kses.php' );
     116require( ABSPATH . WPINC . '/cron.php' );
     117require( ABSPATH . WPINC . '/deprecated.php' );
     118require( ABSPATH . WPINC . '/script-loader.php' );
     119require( ABSPATH . WPINC . '/taxonomy.php' );
     120require( ABSPATH . WPINC . '/update.php' );
     121require( ABSPATH . WPINC . '/canonical.php' );
     122require( ABSPATH . WPINC . '/shortcodes.php' );
     123require( ABSPATH . WPINC . '/media.php' );
     124require( ABSPATH . WPINC . '/http.php' );
     125require( ABSPATH . WPINC . '/widgets.php' );
     126
     127// Load multisite-specific files.
    105128if ( is_multisite() ) {
    106129    require_once( ABSPATH . WPINC . '/ms-functions.php' );
     
    109132}
    110133
    111 wp_default_constants('wp_included');
    112 
     134// Define constants that rely on the API to obtain the default value.
     135wp_default_constants( 'wp_included' );
     136
     137// Set up multisite if enabled.
    113138if ( is_multisite() )
    114     ms_network_settings();
    115 
    116 wp_default_constants('ms_network_settings_loaded');
    117 
    118 wp_load_mu_plugins();
    119 
    120 /**
    121  * Used to load network wide plugins
    122  * @since 3.0
    123  */
    124 if ( is_multisite() )
    125     ms_network_plugins();
    126 
    127 do_action('muplugins_loaded');
    128 
    129 /**
    130  * Used to check site status
    131  * @since 3.0
    132  */
     139    ms_network_settings();
     140
     141// Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
     142wp_default_constants( 'ms_network_settings_loaded' );
     143
     144// Load must-use plugins.
     145foreach( wp_muplugins_to_load() as $mu_plugin )
     146    include_once( $mu_plugin );
     147unset( $mu_plugin );
     148
     149// Load network-wide plugins if multisite.
    133150if ( is_multisite() ) {
    134     ms_site_check();
     151    foreach ( ms_network_plugins() as $plugin_file )
     152        include_once( $plugin_file );
     153    unset( $plugin_file );
     154}
     155
     156do_action( 'muplugins_loaded' );
     157
     158// Check site status if multisite.
     159if ( is_multisite() ) {
     160    if ( true !== ( $file = ms_site_check() ) ) {
     161        require_once( $file );
     162        die();
     163    }
    135164    ms_network_cookies();
    136165}
    137166
    138 wp_default_constants('ms_loaded');
    139 
    140 require (ABSPATH . WPINC . '/vars.php');
    141 
    142 // make taxonomies available to plugins and themes
    143 // @plugin authors: warning: this gets registered again on the init hook
     167// Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
     168wp_default_constants( 'ms_loaded' );
     169
     170// Create common globals.
     171require( ABSPATH . WPINC . '/vars.php' );
     172
     173// Make taxonomies available to plugins and themes.
     174// @plugin authors: warning: this gets registered again on the init hook.
    144175create_initial_taxonomies();
    145176
    146 wp_load_plugins();
    147 
    148 require (ABSPATH . WPINC . '/pluggable.php');
    149 
     177// Load active plugins.
     178foreach( wp_plugins_to_load() as $plugin )
     179    include_once( $plugin );
     180unset( $plugin );
     181
     182// Load pluggable functions.
     183require( ABSPATH . WPINC . '/pluggable.php' );
     184
     185// Set internal encoding.
    150186wp_set_internal_encoding();
    151187
    152 if ( WP_CACHE && function_exists('wp_cache_postload') )
     188// Run wp_cache_postload() if object cache is enabled and the function exists.
     189if ( WP_CACHE && function_exists( 'wp_cache_postload' ) )
    153190    wp_cache_postload();
    154191
    155 do_action('plugins_loaded');
    156 
    157 wp_default_constants('plugins_loaded');
    158 
     192do_action( 'plugins_loaded' );
     193
     194// Define WP_POST_REVISIONS if not already defined.
     195wp_default_constants( 'plugins_loaded' );
     196
     197// Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
    159198wp_magic_quotes();
    160199
    161 do_action('sanitize_comment_cookies');
     200do_action( 'sanitize_comment_cookies' );
    162201
    163202/**
     
    174213 * @since 1.5.0
    175214 */
    176 $wp_query     =& $wp_the_query;
     215$wp_query =& $wp_the_query;
    177216
    178217/**
     
    181220 * @since 1.5.0
    182221 */
    183 $wp_rewrite   =& new WP_Rewrite();
     222$wp_rewrite =& new WP_Rewrite();
    184223
    185224/**
     
    188227 * @since 2.0.0
    189228 */
    190 $wp           =& new WP();
     229$wp =& new WP();
    191230
    192231/**
     
    197236$wp_widget_factory =& new WP_Widget_Factory();
    198237
    199 do_action('setup_theme');
    200 
    201 wp_default_constants('setup_theme');
     238do_action( 'setup_theme' );
     239
     240// Define the TEMPLATEPATH and STYLESHEETPATH constants.
     241wp_default_constants( 'setup_theme' );
    202242
    203243// Load the default text localization domain.
    204244load_default_textdomain();
    205245
    206 wp_find_locale();
     246// Find the blog locale.
     247$locale = get_locale();
     248$locale_file = WP_LANG_DIR . "/$locale.php";
     249if ( is_readable( $locale_file ) )
     250    require_once( $locale_file );
     251
     252// Pull in locale data after loading text domain.
     253require_once( ABSPATH . WPINC . '/locale.php' );
    207254
    208255/**
     
    213260$wp_locale =& new WP_Locale();
    214261
    215 wp_load_theme_functions();
    216 
    217 register_shutdown_function('shutdown_action_hook');
    218 
    219 $wp->init();  // Sets up current user.
     262// Load the functions for the active theme, for both parent and child theme if applicable.
     263if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
     264    include( STYLESHEETPATH . '/functions.php' );
     265if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
     266    include( TEMPLATEPATH . '/functions.php' );
     267
     268// Load any template functions the theme supports.
     269require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
     270
     271register_shutdown_function( 'shutdown_action_hook' );
     272
     273// Set up current user.
     274$wp->init();
    220275
    221276// Everything is loaded and initialized.
    222 do_action('init');
     277do_action( 'init' );
    223278
    224279?>
Note: See TracChangeset for help on using the changeset viewer.