1<?php
2/**
3 * Used to set up and fix common variables and include
4 * the WordPress procedural and class library.
5 *
6 * Allows for some configuration in wp-config.php (see default-constants.php)
7 *
8 * @package WordPress
9 */
10
11/**
12 * Stores the location of the WordPress directory of functions, classes, and core content.
13 *
14 * @since 1.0.0
15 */
16define( 'WPINC', 'wp-includes' );
17
18/**
19 * Version information for the current WordPress release.
20 *
21 * These can't be directly globalized in version.php. When updating,
22 * we're including version.php from another installation and don't want
23 * these values to be overridden if already set.
24 *
25 * @global string $wp_version             The WordPress version string.
26 * @global int    $wp_db_version          WordPress database version.
27 * @global string $tinymce_version        TinyMCE version.
28 * @global string $required_php_version   The required PHP version string.
29 * @global string $required_mysql_version The required MySQL version string.
30 * @global string $wp_local_package       Locale code of the package.
31 */
32global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package;
33require ABSPATH . WPINC . '/version.php';
34require ABSPATH . WPINC . '/load.php';
35
36// Check for the required PHP version and for the MySQL extension or a database drop-in.
37wp_check_php_mysql_versions();
38
39// Include files required for initialization.
40require ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php';
41require ABSPATH . WPINC . '/class-wp-fatal-error-handler.php';
42require ABSPATH . WPINC . '/class-wp-recovery-mode-cookie-service.php';
43require ABSPATH . WPINC . '/class-wp-recovery-mode-key-service.php';
44require ABSPATH . WPINC . '/class-wp-recovery-mode-link-service.php';
45require ABSPATH . WPINC . '/class-wp-recovery-mode-email-service.php';
46require ABSPATH . WPINC . '/class-wp-recovery-mode.php';
47require ABSPATH . WPINC . '/error-protection.php';
48require ABSPATH . WPINC . '/default-constants.php';
49require_once ABSPATH . WPINC . '/plugin.php';
50
51/**
52 * If not already configured, `$blog_id` will default to 1 in a single site
53 * configuration. In multisite, it will be overridden by default in ms-settings.php.
54 *
55 * @global int $blog_id
56 * @since 2.0.0
57 */
58global $blog_id;
59
60// Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE.
61wp_initial_constants();
62
63// Make sure we register the shutdown handler for fatal errors as soon as possible.
64wp_register_fatal_error_handler();
65
66// WordPress calculates offsets from UTC.
67// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
68date_default_timezone_set( 'UTC' );
69
70// Standardize $_SERVER variables across setups.
71wp_fix_server_vars();
72
73// Check if we're in maintenance mode.
74wp_maintenance();
75
76// Start loading timer.
77timer_start();
78
79// Check if we're in WP_DEBUG mode.
80wp_debug_mode();
81
82/**
83 * Filters whether to enable loading of the advanced-cache.php drop-in.
84 *
85 * This filter runs before it can be used by plugins. It is designed for non-web
86 * run-times. If false is returned, advanced-cache.php will never be loaded.
87 *
88 * @since 4.6.0
89 *
90 * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present).
91 *                                    Default true.
92 */
93if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) {
94	// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
95	include WP_CONTENT_DIR . '/advanced-cache.php';
96
97	// Re-initialize any hooks added manually by advanced-cache.php.
98	if ( $wp_filter ) {
99		$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter );
100	}
101}
102
103// Define WP_LANG_DIR if not set.
104wp_set_lang_dir();
105
106// Load early WordPress files.
107require ABSPATH . WPINC . '/compat.php';
108require ABSPATH . WPINC . '/class-wp-list-util.php';
109require ABSPATH . WPINC . '/formatting.php';
110require ABSPATH . WPINC . '/meta.php';
111require ABSPATH . WPINC . '/functions.php';
112require ABSPATH . WPINC . '/class-wp-meta-query.php';
113require ABSPATH . WPINC . '/class-wp-matchesmapregex.php';
114require ABSPATH . WPINC . '/class-wp.php';
115require ABSPATH . WPINC . '/class-wp-error.php';
116require ABSPATH . WPINC . '/pomo/mo.php';
117
118/**
119 * @global wpdb $wpdb WordPress database abstraction object.
120 * @since 0.71
121 */
122global $wpdb;
123// Include the wpdb class and, if present, a db.php database drop-in.
124require_wp_db();
125
126// Set the database table prefix and the format specifiers for database table columns.
127$GLOBALS['table_prefix'] = $table_prefix;
128wp_set_wpdb_vars();
129
130// Start the WordPress object cache, or an external object cache if the drop-in is present.
131wp_start_object_cache();
132
133// Attach the default filters.
134require ABSPATH . WPINC . '/default-filters.php';
135
136// Initialize multisite if enabled.
137if ( is_multisite() ) {
138	require ABSPATH . WPINC . '/class-wp-site-query.php';
139	require ABSPATH . WPINC . '/class-wp-network-query.php';
140	require ABSPATH . WPINC . '/ms-blogs.php';
141	require ABSPATH . WPINC . '/ms-settings.php';
142} elseif ( ! defined( 'MULTISITE' ) ) {
143	define( 'MULTISITE', false );
144}
145
146register_shutdown_function( 'shutdown_action_hook' );
147
148// Stop most of WordPress from being loaded if we just want the basics.
149if ( SHORTINIT ) {
150	return false;
151}
152
153// Load the L10n library.
154require_once ABSPATH . WPINC . '/l10n.php';
155require_once ABSPATH . WPINC . '/class-wp-locale.php';
156require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php';
157
158// Run the installer if WordPress is not installed.
159wp_not_installed();
160
161// Load most of WordPress.
162require ABSPATH . WPINC . '/class-wp-walker.php';
163require ABSPATH . WPINC . '/class-wp-ajax-response.php';
164require ABSPATH . WPINC . '/capabilities.php';
165require ABSPATH . WPINC . '/class-wp-roles.php';
166require ABSPATH . WPINC . '/class-wp-role.php';
167require ABSPATH . WPINC . '/class-wp-user.php';
168require ABSPATH . WPINC . '/class-wp-query.php';
169require ABSPATH . WPINC . '/query.php';
170require ABSPATH . WPINC . '/class-wp-date-query.php';
171require ABSPATH . WPINC . '/theme.php';
172require ABSPATH . WPINC . '/class-wp-theme.php';
173require ABSPATH . WPINC . '/class-wp-theme-json.php';
174require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php';
175require ABSPATH . WPINC . '/class-wp-block-template.php';
176require ABSPATH . WPINC . '/block-template-utils.php';
177require ABSPATH . WPINC . '/block-template.php';
178require ABSPATH . WPINC . '/theme-templates.php';
179require ABSPATH . WPINC . '/template.php';
180require ABSPATH . WPINC . '/https-detection.php';
181require ABSPATH . WPINC . '/https-migration.php';
182require ABSPATH . WPINC . '/class-wp-user-request.php';
183require ABSPATH . WPINC . '/user.php';
184require ABSPATH . WPINC . '/class-wp-user-query.php';
185require ABSPATH . WPINC . '/class-wp-session-tokens.php';
186require ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php';
187require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
188require ABSPATH . WPINC . '/general-template.php';
189require ABSPATH . WPINC . '/link-template.php';
190require ABSPATH . WPINC . '/author-template.php';
191require ABSPATH . WPINC . '/robots-template.php';
192require ABSPATH . WPINC . '/post.php';
193require ABSPATH . WPINC . '/class-walker-page.php';
194require ABSPATH . WPINC . '/class-walker-page-dropdown.php';
195require ABSPATH . WPINC . '/class-wp-post-type.php';
196require ABSPATH . WPINC . '/class-wp-post.php';
197require ABSPATH . WPINC . '/post-template.php';
198require ABSPATH . WPINC . '/revision.php';
199require ABSPATH . WPINC . '/post-formats.php';
200require ABSPATH . WPINC . '/post-thumbnail-template.php';
201require ABSPATH . WPINC . '/category.php';
202require ABSPATH . WPINC . '/class-walker-category.php';
203require ABSPATH . WPINC . '/class-walker-category-dropdown.php';
204require ABSPATH . WPINC . '/category-template.php';
205require ABSPATH . WPINC . '/comment.php';
206require ABSPATH . WPINC . '/class-wp-comment.php';
207require ABSPATH . WPINC . '/class-wp-comment-query.php';
208require ABSPATH . WPINC . '/class-walker-comment.php';
209require ABSPATH . WPINC . '/comment-template.php';
210require ABSPATH . WPINC . '/rewrite.php';
211require ABSPATH . WPINC . '/class-wp-rewrite.php';
212require ABSPATH . WPINC . '/feed.php';
213require ABSPATH . WPINC . '/bookmark.php';
214require ABSPATH . WPINC . '/bookmark-template.php';
215require ABSPATH . WPINC . '/kses.php';
216require ABSPATH . WPINC . '/cron.php';
217require ABSPATH . WPINC . '/deprecated.php';
218require ABSPATH . WPINC . '/script-loader.php';
219require ABSPATH . WPINC . '/taxonomy.php';
220require ABSPATH . WPINC . '/class-wp-taxonomy.php';
221require ABSPATH . WPINC . '/class-wp-term.php';
222require ABSPATH . WPINC . '/class-wp-term-query.php';
223require ABSPATH . WPINC . '/class-wp-tax-query.php';
224require ABSPATH . WPINC . '/update.php';
225require ABSPATH . WPINC . '/canonical.php';
226require ABSPATH . WPINC . '/shortcodes.php';
227require ABSPATH . WPINC . '/embed.php';
228require ABSPATH . WPINC . '/class-wp-embed.php';
229require ABSPATH . WPINC . '/class-wp-oembed.php';
230require ABSPATH . WPINC . '/class-wp-oembed-controller.php';
231require ABSPATH . WPINC . '/media.php';
232require ABSPATH . WPINC . '/http.php';
233require ABSPATH . WPINC . '/class-http.php';
234require ABSPATH . WPINC . '/class-wp-http-streams.php';
235require ABSPATH . WPINC . '/class-wp-http-curl.php';
236require ABSPATH . WPINC . '/class-wp-http-proxy.php';
237require ABSPATH . WPINC . '/class-wp-http-cookie.php';
238require ABSPATH . WPINC . '/class-wp-http-encoding.php';
239require ABSPATH . WPINC . '/class-wp-http-response.php';
240require ABSPATH . WPINC . '/class-wp-http-requests-response.php';
241require ABSPATH . WPINC . '/class-wp-http-requests-hooks.php';
242require ABSPATH . WPINC . '/widgets.php';
243require ABSPATH . WPINC . '/class-wp-widget.php';
244require ABSPATH . WPINC . '/class-wp-widget-factory.php';
245require ABSPATH . WPINC . '/nav-menu.php';
246require ABSPATH . WPINC . '/nav-menu-template.php';
247require ABSPATH . WPINC . '/admin-bar.php';
248require ABSPATH . WPINC . '/class-wp-application-passwords.php';
249require ABSPATH . WPINC . '/rest-api.php';
250require ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php';
251require ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php';
252require ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php';
253require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-controller.php';
254require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-posts-controller.php';
255require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php';
256require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php';
257require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php';
258require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php';
259require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php';
260require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php';
261require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php';
262require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php';
263require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php';
264require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-search-controller.php';
265require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-blocks-controller.php';
266require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-types-controller.php';
267require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-renderer-controller.php';
268require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php';
269require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-themes-controller.php';
270require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-plugins-controller.php';
271require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-directory-controller.php';
272require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php';
273require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-application-passwords-controller.php';
274require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-site-health-controller.php';
275require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-sidebars-controller.php';
276require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widget-types-controller.php';
277require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widgets-controller.php';
278require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-templates-controller.php';
279require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php';
280require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php';
281require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-post-meta-fields.php';
282require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-term-meta-fields.php';
283require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-user-meta-fields.php';
284require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-search-handler.php';
285require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php';
286require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-term-search-handler.php';
287require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-format-search-handler.php';
288require ABSPATH . WPINC . '/sitemaps.php';
289require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps.php';
290require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-index.php';
291require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-provider.php';
292require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-registry.php';
293require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-renderer.php';
294require ABSPATH . WPINC . '/sitemaps/class-wp-sitemaps-stylesheet.php';
295require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-posts.php';
296require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-taxonomies.php';
297require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-users.php';
298require ABSPATH . WPINC . '/class-wp-block-editor-context.php';
299require ABSPATH . WPINC . '/class-wp-block-type.php';
300require ABSPATH . WPINC . '/class-wp-block-pattern-categories-registry.php';
301require ABSPATH . WPINC . '/class-wp-block-patterns-registry.php';
302require ABSPATH . WPINC . '/class-wp-block-styles-registry.php';
303require ABSPATH . WPINC . '/class-wp-block-type-registry.php';
304require ABSPATH . WPINC . '/class-wp-block.php';
305require ABSPATH . WPINC . '/class-wp-block-list.php';
306require ABSPATH . WPINC . '/class-wp-block-parser.php';
307require ABSPATH . WPINC . '/blocks.php';
308require ABSPATH . WPINC . '/blocks/index.php';
309require ABSPATH . WPINC . '/block-editor.php';
310require ABSPATH . WPINC . '/block-patterns.php';
311require ABSPATH . WPINC . '/class-wp-block-supports.php';
312require ABSPATH . WPINC . '/block-supports/align.php';
313require ABSPATH . WPINC . '/block-supports/border.php';
314require ABSPATH . WPINC . '/block-supports/colors.php';
315require ABSPATH . WPINC . '/block-supports/custom-classname.php';
316require ABSPATH . WPINC . '/block-supports/duotone.php';
317require ABSPATH . WPINC . '/block-supports/elements.php';
318require ABSPATH . WPINC . '/block-supports/generated-classname.php';
319require ABSPATH . WPINC . '/block-supports/layout.php';
320require ABSPATH . WPINC . '/block-supports/spacing.php';
321require ABSPATH . WPINC . '/block-supports/typography.php';
322
323$GLOBALS['wp_embed'] = new WP_Embed();
324
325// Load multisite-specific files.
326if ( is_multisite() ) {
327	require ABSPATH . WPINC . '/ms-functions.php';
328	require ABSPATH . WPINC . '/ms-default-filters.php';
329	require ABSPATH . WPINC . '/ms-deprecated.php';
330}
331
332// Define constants that rely on the API to obtain the default value.
333// Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
334wp_plugin_directory_constants();
335
336$GLOBALS['wp_plugin_paths'] = array();
337
338// Load must-use plugins.
339foreach ( wp_get_mu_plugins() as $mu_plugin ) {
340	include_once $mu_plugin;
341
342	/**
343	 * Fires once a single must-use plugin has loaded.
344	 *
345	 * @since 5.1.0
346	 *
347	 * @param string $mu_plugin Full path to the plugin's main file.
348	 */
349	do_action( 'mu_plugin_loaded', $mu_plugin );
350}
351unset( $mu_plugin );
352
353// Load network activated plugins.
354if ( is_multisite() ) {
355	foreach ( wp_get_active_network_plugins() as $network_plugin ) {
356		wp_register_plugin_realpath( $network_plugin );
357		include_once $network_plugin;
358
359		/**
360		 * Fires once a single network-activated plugin has loaded.
361		 *
362		 * @since 5.1.0
363		 *
364		 * @param string $network_plugin Full path to the plugin's main file.
365		 */
366		do_action( 'network_plugin_loaded', $network_plugin );
367	}
368	unset( $network_plugin );
369}
370
371/**
372 * Fires once all must-use and network-activated plugins have loaded.
373 *
374 * @since 2.8.0
375 */
376do_action( 'muplugins_loaded' );
377
378if ( is_multisite() ) {
379	ms_cookie_constants();
380}
381
382// Define constants after multisite is loaded.
383wp_cookie_constants();
384
385// Define and enforce our SSL constants.
386wp_ssl_constants();
387
388// Create common globals.
389require ABSPATH . WPINC . '/vars.php';
390
391// Make taxonomies and posts available to plugins and themes.
392// @plugin authors: warning: these get registered again on the init hook.
393create_initial_taxonomies();
394create_initial_post_types();
395
396wp_start_scraping_edited_file_errors();
397
398// Register the default theme directory root.
399register_theme_directory( get_theme_root() );
400
401if ( ! is_multisite() ) {
402	// Handle users requesting a recovery mode link and initiating recovery mode.
403	wp_recovery_mode()->initialize();
404}
405
406// Load active plugins.
407foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
408	wp_register_plugin_realpath( $plugin );
409	include_once $plugin;
410
411	/**
412	 * Fires once a single activated plugin has loaded.
413	 *
414	 * @since 5.1.0
415	 *
416	 * @param string $plugin Full path to the plugin's main file.
417	 */
418	do_action( 'plugin_loaded', $plugin );
419}
420unset( $plugin );
421
422// Load pluggable functions.
423require ABSPATH . WPINC . '/pluggable.php';
424require ABSPATH . WPINC . '/pluggable-deprecated.php';
425
426// Set internal encoding.
427wp_set_internal_encoding();
428
429// Run wp_cache_postload() if object cache is enabled and the function exists.
430if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) {
431	wp_cache_postload();
432}
433
434/**
435 * Fires once activated plugins have loaded.
436 *
437 * Pluggable functions are also available at this point in the loading order.
438 *
439 * @since 1.5.0
440 */
441do_action( 'plugins_loaded' );
442
443// Define constants which affect functionality if not already defined.
444wp_functionality_constants();
445
446// Add magic quotes and set up $_REQUEST ( $_GET + $_POST ).
447wp_magic_quotes();
448
449/**
450 * Fires when comment cookies are sanitized.
451 *
452 * @since 2.0.11
453 */
454do_action( 'sanitize_comment_cookies' );
455
456/**
457 * WordPress Query object
458 *
459 * @global WP_Query $wp_the_query WordPress Query object.
460 * @since 2.0.0
461 */
462$GLOBALS['wp_the_query'] = new WP_Query();
463
464/**
465 * Holds the reference to @see $wp_the_query
466 * Use this global for WordPress queries
467 *
468 * @global WP_Query $wp_query WordPress Query object.
469 * @since 1.5.0
470 */
471$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
472
473/**
474 * Holds the WordPress Rewrite object for creating pretty URLs
475 *
476 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
477 * @since 1.5.0
478 */
479$GLOBALS['wp_rewrite'] = new WP_Rewrite();
480
481/**
482 * WordPress Object
483 *
484 * @global WP $wp Current WordPress environment instance.
485 * @since 2.0.0
486 */
487$GLOBALS['wp'] = new WP();
488
489/**
490 * WordPress Widget Factory Object
491 *
492 * @global WP_Widget_Factory $wp_widget_factory
493 * @since 2.8.0
494 */
495$GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
496
497/**
498 * WordPress User Roles
499 *
500 * @global WP_Roles $wp_roles WordPress role management object.
501 * @since 2.0.0
502 */
503$GLOBALS['wp_roles'] = new WP_Roles();
504
505/**
506 * Fires before the theme is loaded.
507 *
508 * @since 2.6.0
509 */
510do_action( 'setup_theme' );
511
512// Define the template related constants.
513wp_templating_constants();
514
515// Load the default text localization domain.
516load_default_textdomain();
517
518$locale      = get_locale();
519$locale_file = WP_LANG_DIR . "/$locale.php";
520if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) {
521	require $locale_file;
522}
523unset( $locale_file );
524
525/**
526 * WordPress Locale object for loading locale domain date and various strings.
527 *
528 * @global WP_Locale $wp_locale WordPress date and time locale object.
529 * @since 2.1.0
530 */
531$GLOBALS['wp_locale'] = new WP_Locale();
532
533/**
534 * WordPress Locale Switcher object for switching locales.
535 *
536 * @since 4.7.0
537 *
538 * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
539 */
540$GLOBALS['wp_locale_switcher'] = new WP_Locale_Switcher();
541$GLOBALS['wp_locale_switcher']->init();
542
543// Load the functions for the active theme, for both parent and child theme if applicable.
544foreach ( wp_get_active_and_valid_themes() as $theme ) {
545	if ( file_exists( $theme . '/functions.php' ) ) {
546		include $theme . '/functions.php';
547	}
548}
549unset( $theme );
550
551/**
552 * Fires after the theme is loaded.
553 *
554 * @since 3.0.0
555 */
556do_action( 'after_setup_theme' );
557
558// Create an instance of WP_Site_Health so that Cron events may fire.
559if ( ! class_exists( 'WP_Site_Health' ) ) {
560	require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
561}
562WP_Site_Health::get_instance();
563
564// Set up current user.
565$GLOBALS['wp']->init();
566
567/**
568 * Fires after WordPress has finished loading but before any headers are sent.
569 *
570 * Most of WP is loaded at this stage, and the user is authenticated. WP continues
571 * to load on the {@see 'init'} hook that follows (e.g. widgets), and many plugins instantiate
572 * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
573 *
574 * If you wish to plug an action once WP is loaded, use the {@see 'wp_loaded'} hook below.
575 *
576 * @since 1.5.0
577 */
578do_action( 'init' );
579
580// Check site status.
581if ( is_multisite() ) {
582	$file = ms_site_check();
583	if ( true !== $file ) {
584		require $file;
585		die();
586	}
587	unset( $file );
588}
589
590/**
591 * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
592 *
593 * Ajax requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
594 * users not logged in.
595 *
596 * @link https://codex.wordpress.org/AJAX_in_Plugins
597 *
598 * @since 3.0.0
599 */
600do_action( 'wp_loaded' );
601