3 * Used to set up and fix common variables and include
4 * the WordPress procedural and class library.
6 * Allows for some configuration in wp-config.php (see default-constants.php)
8 * @internal This file must be parsable by PHP4.
14 * Stores the location of the WordPress directory of functions, classes, and core content.
18 define( 'WPINC', 'wp-includes' );
20 // Include files required for initialization.
21 require( ABSPATH . WPINC . '/load.php' );
22 require( ABSPATH . WPINC . '/default-constants.php' );
25 * These can't be directly globalized in version.php. When updating,
26 * we're including version.php from another install and don't want
27 * these values to be overridden if already set.
29 global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version;
30 require( ABSPATH . WPINC . '/version.php' );
32 // Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
33 wp_initial_constants();
35 // Check for the required PHP version and for the MySQL extension or a database drop-in.
36 wp_check_php_mysql_versions();
38 // Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
39 @ini_set( 'magic_quotes_runtime', 0 );
40 @ini_set( 'magic_quotes_sybase', 0 );
42 // WordPress calculates offsets from UTC.
43 date_default_timezone_set( 'UTC' );
45 // Turn register_globals off.
46 wp_unregister_GLOBALS();
48 // Standardize $_SERVER variables across setups.
51 // Check if we have received a request due to missing favicon.ico
54 // Check if we're in maintenance mode.
57 // Start loading timer.
60 // Check if we're in WP_DEBUG mode.
63 // For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
65 WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
67 // Define WP_LANG_DIR if not set.
70 // Load early WordPress files.
71 require( ABSPATH . WPINC . '/compat.php' );
72 require( ABSPATH . WPINC . '/functions.php' );
73 require( ABSPATH . WPINC . '/class-wp.php' );
74 require( ABSPATH . WPINC . '/class-wp-error.php' );
75 require( ABSPATH . WPINC . '/plugin.php' );
76 require( ABSPATH . WPINC . '/pomo/mo.php' );
78 // Include the wpdb class and, if present, a db.php database drop-in.
81 // Set the database table prefix and the format specifiers for database table columns.
82 $GLOBALS['table_prefix'] = $table_prefix;
85 // Start the WordPress object cache, or an external object cache if the drop-in is present.
86 wp_start_object_cache();
88 // Attach the default filters.
89 require( ABSPATH . WPINC . '/default-filters.php' );
91 // Initialize multisite if enabled.
92 if ( is_multisite() ) {
93 require( ABSPATH . WPINC . '/ms-blogs.php' );
94 require( ABSPATH . WPINC . '/ms-settings.php' );
95 } elseif ( ! defined( 'MULTISITE' ) ) {
96 define( 'MULTISITE', false );
99 register_shutdown_function( 'shutdown_action_hook' );
101 // Stop most of WordPress from being loaded if we just want the basics.
105 // Load the L10n library.
106 require_once( ABSPATH . WPINC . '/l10n.php' );
108 // Run the installer if WordPress is not installed.
111 // Load most of WordPress.
112 require( ABSPATH . WPINC . '/class-wp-walker.php' );
113 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
114 require( ABSPATH . WPINC . '/formatting.php' );
115 require( ABSPATH . WPINC . '/capabilities.php' );
116 require( ABSPATH . WPINC . '/query.php' );
117 require( ABSPATH . WPINC . '/date.php' );
118 require( ABSPATH . WPINC . '/theme.php' );
119 require( ABSPATH . WPINC . '/class-wp-theme.php' );
120 require( ABSPATH . WPINC . '/template.php' );
121 require( ABSPATH . WPINC . '/user.php' );
122 require( ABSPATH . WPINC . '/meta.php' );
123 require( ABSPATH . WPINC . '/general-template.php' );
124 require( ABSPATH . WPINC . '/link-template.php' );
125 require( ABSPATH . WPINC . '/author-template.php' );
126 require( ABSPATH . WPINC . '/post.php' );
127 require( ABSPATH . WPINC . '/post-template.php' );
128 require( ABSPATH . WPINC . '/revision.php' );
129 require( ABSPATH . WPINC . '/post-formats.php' );
130 require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
131 require( ABSPATH . WPINC . '/category.php' );
132 require( ABSPATH . WPINC . '/category-template.php' );
133 require( ABSPATH . WPINC . '/comment.php' );
134 require( ABSPATH . WPINC . '/comment-template.php' );
135 require( ABSPATH . WPINC . '/rewrite.php' );
136 require( ABSPATH . WPINC . '/feed.php' );
137 require( ABSPATH . WPINC . '/bookmark.php' );
138 require( ABSPATH . WPINC . '/bookmark-template.php' );
139 require( ABSPATH . WPINC . '/kses.php' );
140 require( ABSPATH . WPINC . '/cron.php' );
141 require( ABSPATH . WPINC . '/deprecated.php' );
142 require( ABSPATH . WPINC . '/script-loader.php' );
143 require( ABSPATH . WPINC . '/taxonomy.php' );
144 require( ABSPATH . WPINC . '/update.php' );
145 require( ABSPATH . WPINC . '/canonical.php' );
146 require( ABSPATH . WPINC . '/shortcodes.php' );
147 require( ABSPATH . WPINC . '/class-wp-embed.php' );
148 require( ABSPATH . WPINC . '/media.php' );
149 require( ABSPATH . WPINC . '/http.php' );
150 require( ABSPATH . WPINC . '/class-http.php' );
151 require( ABSPATH . WPINC . '/widgets.php' );
152 require( ABSPATH . WPINC . '/nav-menu.php' );
153 require( ABSPATH . WPINC . '/nav-menu-template.php' );
154 require( ABSPATH . WPINC . '/admin-bar.php' );
156 // Load multisite-specific files.
157 if ( is_multisite() ) {
158 require( ABSPATH . WPINC . '/ms-functions.php' );
159 require( ABSPATH . WPINC . '/ms-default-filters.php' );
160 require( ABSPATH . WPINC . '/ms-deprecated.php' );
163 // Define constants that rely on the API to obtain the default value.
164 // Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
165 wp_plugin_directory_constants();
167 // Load must-use plugins.
168 foreach ( wp_get_mu_plugins() as $mu_plugin ) {
169 include_once( $mu_plugin );
173 // Load network activated plugins.
174 if ( is_multisite() ) {
175 foreach( wp_get_active_network_plugins() as $network_plugin ) {
176 include_once( $network_plugin );
178 unset( $network_plugin );
182 * Fires once all must-use and network-activated plugins have loaded.
186 do_action( 'muplugins_loaded' );
188 if ( is_multisite() )
189 ms_cookie_constants( );
191 // Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
192 wp_cookie_constants();
194 // Define and enforce our SSL constants
197 // Create common globals.
198 require( ABSPATH . WPINC . '/vars.php' );
200 // Make taxonomies and posts available to plugins and themes.
201 // @plugin authors: warning: these get registered again on the init hook.
202 create_initial_taxonomies();
203 create_initial_post_types();
205 // Register the default theme directory root
206 register_theme_directory( get_theme_root() );
208 // Load active plugins.
209 foreach ( wp_get_active_and_valid_plugins() as $plugin )
210 include_once( $plugin );
213 // Load pluggable functions.
214 require( ABSPATH . WPINC . '/pluggable.php' );
215 require( ABSPATH . WPINC . '/pluggable-deprecated.php' );
217 // Set internal encoding.
218 wp_set_internal_encoding();
220 // Run wp_cache_postload() if object cache is enabled and the function exists.
221 if ( WP_CACHE && function_exists( 'wp_cache_postload' ) )
225 * Fires once activated plugins have loaded.
227 * Pluggable functions are also available at this point in the loading order.
231 do_action( 'plugins_loaded' );
233 // Define constants which affect functionality if not already defined.
234 wp_functionality_constants();
236 // Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
240 * Fires when comment cookies are sanitized.
244 do_action( 'sanitize_comment_cookies' );
247 * WordPress Query object
248 * @global object $wp_the_query
251 $wp_the_query = new WP_Query();
254 * Holds the reference to @see $wp_the_query
255 * Use this global for WordPress queries
256 * @global object $wp_query
259 $wp_query = $wp_the_query;
262 * Holds the WordPress Rewrite object for creating pretty URLs
263 * @global object $wp_rewrite
266 $GLOBALS['wp_rewrite'] = new WP_Rewrite();
276 * WordPress Widget Factory Object
277 * @global object $wp_widget_factory
280 $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
283 * WordPress User Roles
284 * @global object $wp_roles
287 $GLOBALS['wp_roles'] = new WP_Roles();
290 * Fires before the theme is loaded.
294 do_action( 'setup_theme' );
296 // Define the template related constants.
297 wp_templating_constants( );
299 // Load the default text localization domain.
300 load_default_textdomain();
302 $locale = get_locale();
303 $locale_file = WP_LANG_DIR . "/$locale.php";
304 if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) )
305 require( $locale_file );
306 unset( $locale_file );
308 // Pull in locale data after loading text domain.
309 require_once( ABSPATH . WPINC . '/locale.php' );
312 * WordPress Locale object for loading locale domain date and various strings.
313 * @global object $wp_locale
316 $GLOBALS['wp_locale'] = new WP_Locale();
318 // Load the functions for the active theme, for both parent and child theme if applicable.
319 if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
320 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
321 include( STYLESHEETPATH . '/functions.php' );
322 if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
323 include( TEMPLATEPATH . '/functions.php' );
327 * Fires after the theme is loaded.
331 do_action( 'after_setup_theme' );
333 // Set up current user.
337 * Fires after WordPress has finished loading but before any headers are sent.
339 * Most of WP is loaded at this stage, and the user is authenticated. WP continues
340 * to load on the init hook that follows (e.g. widgets), and many plugins instantiate
341 * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
343 * If you wish to plug an action once WP is loaded, use the wp_loaded hook below.
350 if ( is_multisite() ) {
351 if ( true !== ( $file = ms_site_check() ) ) {
359 * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
361 * AJAX requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
362 * users not logged in.
364 * @link http://codex.wordpress.org/AJAX_in_Plugins
368 do_action( 'wp_loaded' );