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)
12 * Stores the location of the WordPress directory of functions, classes, and core content.
16 define( 'WPINC', 'wp-includes' );
18 // Include files required for initialization.
19 require( ABSPATH . WPINC . '/load.php' );
20 require( ABSPATH . WPINC . '/default-constants.php' );
21 require( ABSPATH . WPINC . '/version.php' );
23 // Set initial default constants including WP_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
24 wp_initial_constants( );
26 // Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
27 set_magic_quotes_runtime( 0 );
28 @ini_set( 'magic_quotes_sybase', 0 );
30 // Set default timezone in PHP 5.
31 if ( function_exists( 'date_default_timezone_set' ) )
32 date_default_timezone_set( 'UTC' );
34 // Turn register_globals off.
35 wp_unregister_GLOBALS();
37 // Ensure these global variables do not exist so they do not interfere with WordPress.
38 unset( $wp_filter, $cache_lastcommentmodified );
40 // Standardize $_SERVER variables across setups.
43 // Check for the required PHP version and for the MySQL extension or a database drop-in.
44 wp_check_php_mysql_versions();
46 // Check if we have recieved a request due to missing favicon.ico
49 // Check if we're in maintenance mode.
52 // Start loading timer.
55 // Check if we're in WP_DEBUG mode.
58 // For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
60 WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
62 // Define WP_LANG_DIR if not set.
65 // Load early WordPress files.
66 require( ABSPATH . WPINC . '/compat.php' );
67 require( ABSPATH . WPINC . '/functions.php' );
68 require( ABSPATH . WPINC . '/class-wp.php' );
69 require( ABSPATH . WPINC . '/class-wp-error.php' );
70 require( ABSPATH . WPINC . '/plugin.php' );
72 // Include the wpdb class and, if present, a db.php database drop-in.
75 // Set the database table prefix and the format specifiers for database table columns.
78 // Start the WordPress object cache, or an external object cache if the drop-in is present.
79 wp_start_object_cache();
81 // Load early WordPress files.
82 require( ABSPATH . WPINC . '/default-filters.php' );
83 require( ABSPATH . WPINC . '/pomo/mo.php' );
85 // Initialize multisite if enabled.
86 if ( is_multisite() ) {
87 require( ABSPATH . WPINC . '/ms-blogs.php' );
88 require( ABSPATH . WPINC . '/ms-settings.php' );
89 } elseif ( ! defined( 'MULTISITE' ) ) {
90 define( 'MULTISITE', false );
93 // Stop most of WordPress from being loaded if we just want the basics.
97 // Load the l18n library.
98 require( ABSPATH . WPINC . '/l10n.php' );
100 // Run the installer if WordPress is not installed.
103 // Load most of WordPress.
104 require( ABSPATH . WPINC . '/class-wp-walker.php' );
105 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
106 require( ABSPATH . WPINC . '/formatting.php' );
107 require( ABSPATH . WPINC . '/capabilities.php' );
108 require( ABSPATH . WPINC . '/query.php' );
109 require( ABSPATH . WPINC . '/theme.php' );
110 require( ABSPATH . WPINC . '/user.php' );
111 require( ABSPATH . WPINC . '/meta.php' );
112 require( ABSPATH . WPINC . '/general-template.php' );
113 require( ABSPATH . WPINC . '/link-template.php' );
114 require( ABSPATH . WPINC . '/author-template.php' );
115 require( ABSPATH . WPINC . '/post.php' );
116 require( ABSPATH . WPINC . '/post-template.php' );
117 require( ABSPATH . WPINC . '/category.php' );
118 require( ABSPATH . WPINC . '/category-template.php' );
119 require( ABSPATH . WPINC . '/comment.php' );
120 require( ABSPATH . WPINC . '/comment-template.php' );
121 require( ABSPATH . WPINC . '/rewrite.php' );
122 require( ABSPATH . WPINC . '/feed.php' );
123 require( ABSPATH . WPINC . '/bookmark.php' );
124 require( ABSPATH . WPINC . '/bookmark-template.php' );
125 require( ABSPATH . WPINC . '/kses.php' );
126 require( ABSPATH . WPINC . '/cron.php' );
127 require( ABSPATH . WPINC . '/deprecated.php' );
128 require( ABSPATH . WPINC . '/script-loader.php' );
129 require( ABSPATH . WPINC . '/taxonomy.php' );
130 require( ABSPATH . WPINC . '/update.php' );
131 require( ABSPATH . WPINC . '/canonical.php' );
132 require( ABSPATH . WPINC . '/shortcodes.php' );
133 require( ABSPATH . WPINC . '/media.php' );
134 require( ABSPATH . WPINC . '/http.php' );
135 require( ABSPATH . WPINC . '/class-http.php' );
136 require( ABSPATH . WPINC . '/widgets.php' );
137 require( ABSPATH . WPINC . '/nav-menu.php' );
138 require( ABSPATH . WPINC . '/nav-menu-template.php' );
139 require( ABSPATH . WPINC . '/admin-bar.php' );
141 // Load multisite-specific files.
142 if ( is_multisite() ) {
143 require( ABSPATH . WPINC . '/ms-functions.php' );
144 require( ABSPATH . WPINC . '/ms-default-filters.php' );
145 require( ABSPATH . WPINC . '/ms-deprecated.php' );
148 // Define constants that rely on the API to obtain the default value.
149 // Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
150 wp_plugin_directory_constants( );
152 // Load must-use plugins.
153 foreach ( wp_get_mu_plugins() as $mu_plugin ) {
154 include_once( $mu_plugin );
158 // Load network activated plugins.
159 if ( is_multisite() ) {
160 foreach( wp_get_active_network_plugins() as $network_plugin ) {
161 include_once( $network_plugin );
163 unset( $network_plugin );
166 do_action( 'muplugins_loaded' );
168 if ( is_multisite() )
169 ms_cookie_constants( );
171 // Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
172 wp_cookie_constants( );
174 // Define and enforce our SSL constants
177 // Create common globals.
178 require( ABSPATH . WPINC . '/vars.php' );
180 // Make taxonomies and posts available to plugins and themes.
181 // @plugin authors: warning: these get registered again on the init hook.
182 create_initial_taxonomies();
183 create_initial_post_types();
185 // Register the default theme directory root
186 register_theme_directory( get_theme_root() );
188 // Load active plugins.
189 foreach ( wp_get_active_and_valid_plugins() as $plugin )
190 include_once( $plugin );
193 // Load pluggable functions.
194 require( ABSPATH . WPINC . '/pluggable.php' );
195 require( ABSPATH . WPINC . '/pluggable-deprecated.php' );
197 // Set internal encoding.
198 wp_set_internal_encoding();
200 // Run wp_cache_postload() if object cache is enabled and the function exists.
201 if ( WP_CACHE && function_exists( 'wp_cache_postload' ) )
204 do_action( 'plugins_loaded' );
206 // Define constants which affect functionality if not already defined.
207 wp_functionality_constants( );
209 // Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
212 do_action( 'sanitize_comment_cookies' );
215 * WordPress Query object
216 * @global object $wp_the_query
219 $wp_the_query =& new WP_Query();
222 * Holds the reference to @see $wp_the_query
223 * Use this global for WordPress queries
224 * @global object $wp_query
227 $wp_query =& $wp_the_query;
230 * Holds the WordPress Rewrite object for creating pretty URLs
231 * @global object $wp_rewrite
234 $wp_rewrite =& new WP_Rewrite();
244 * WordPress Widget Factory Object
245 * @global object $wp_widget_factory
248 $wp_widget_factory =& new WP_Widget_Factory();
250 do_action( 'setup_theme' );
252 // Define the template related constants.
253 wp_templating_constants( );
255 // Load the default text localization domain.
256 load_default_textdomain();
258 // Find the blog locale.
259 $locale = get_locale();
260 $locale_file = WP_LANG_DIR . "/$locale.php";
261 if ( is_readable( $locale_file ) )
262 require( $locale_file );
265 // Pull in locale data after loading text domain.
266 require( ABSPATH . WPINC . '/locale.php' );
269 * WordPress Locale object for loading locale domain date and various strings.
270 * @global object $wp_locale
273 $wp_locale =& new WP_Locale();
275 // Load the functions for the active theme, for both parent and child theme if applicable.
276 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
277 include( STYLESHEETPATH . '/functions.php' );
278 if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
279 include( TEMPLATEPATH . '/functions.php' );
281 do_action( 'after_setup_theme' );
283 // Load any template functions the theme supports.
284 require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
286 register_shutdown_function( 'shutdown_action_hook' );
288 // Set up current user.
292 * Most of WP is loaded at this stage, and the user is authenticated. WP continues
293 * to load on the init hook that follows (e.g. widgets), and many plugins instantiate
294 * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
296 * If you wish to plug an action once WP is loaded, use the wp_loaded hook below.
301 if ( is_multisite() ) {
302 if ( true !== ( $file = ms_site_check() ) ) {
310 * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
312 * AJAX requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
313 * users not logged in.
315 * @link http://codex.wordpress.org/AJAX_in_Plugins
319 do_action('wp_loaded');