// Define constants after multisite is loaded.
// Define and enforce our SSL constants.
// Create common globals.
require ABSPATH . WPINC . '/vars.php';
// Make taxonomies and posts available to plugins and themes.
// @plugin authors: warning: these get registered again on the init hook.
create_initial_taxonomies();
create_initial_post_types();
wp_start_scraping_edited_file_errors();
// Register the default theme directory root.
register_theme_directory( get_theme_root() );
if ( ! is_multisite() && wp_is_fatal_error_handler_enabled() ) {
// Handle users requesting a recovery mode link and initiating recovery mode.
wp_recovery_mode()->initialize();
// To make get_plugin_data() available in a way that's compatible with plugins also loading this file, see #62244.
require_once ABSPATH . 'wp-admin/includes/plugin.php';
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
wp_register_plugin_realpath( $plugin );
$plugin_data = get_plugin_data( $plugin, false, false );
$textdomain = $plugin_data['TextDomain'];
if ( $plugin_data['DomainPath'] ) {
$GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] );
$GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) );
$_wp_plugin_file = $plugin;
$plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
* Fires once a single activated plugin has loaded.
* @param string $plugin Full path to the plugin's main file.
do_action( 'plugin_loaded', $plugin );
unset( $plugin, $_wp_plugin_file, $plugin_data, $textdomain );
// Load pluggable functions.
require ABSPATH . WPINC . '/pluggable.php';
require ABSPATH . WPINC . '/pluggable-deprecated.php';
// Set internal encoding.
wp_set_internal_encoding();
// Run wp_cache_postload() if object cache is enabled and the function exists.
if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) {
* Fires once activated plugins have loaded.
* Pluggable functions are also available at this point in the loading order.
do_action( 'plugins_loaded' );
// Define constants which affect functionality if not already defined.
wp_functionality_constants();
// Add magic quotes and set up $_REQUEST ( $_GET + $_POST ).
* Fires when comment cookies are sanitized.
do_action( 'sanitize_comment_cookies' );
* @global WP_Query $wp_the_query WordPress Query object.
$GLOBALS['wp_the_query'] = new WP_Query();
* Holds the reference to {@see $wp_the_query}.
* Use this global for WordPress queries
* @global WP_Query $wp_query WordPress Query object.
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
* Holds the WordPress Rewrite object for creating pretty URLs
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
* @global WP $wp Current WordPress environment instance.
$GLOBALS['wp'] = new WP();
* WordPress Widget Factory Object
* @global WP_Widget_Factory $wp_widget_factory
$GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
* @global WP_Roles $wp_roles WordPress role management object.
$GLOBALS['wp_roles'] = new WP_Roles();
* Fires before the theme is loaded.
do_action( 'setup_theme' );
// Define the template related constants and globals.
wp_templating_constants();
wp_set_template_globals();
// Load the default text localization domain.
load_default_textdomain();
$locale_file = WP_LANG_DIR . "/$locale.php";
if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) {
* WordPress Locale object for loading locale domain date and various strings.
* @global WP_Locale $wp_locale WordPress date and time locale object.
$GLOBALS['wp_locale'] = new WP_Locale();
* WordPress Locale Switcher object for switching locales.
* @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
$GLOBALS['wp_locale_switcher'] = new WP_Locale_Switcher();
$GLOBALS['wp_locale_switcher']->init();
// Load the functions for the active theme, for both parent and child theme if applicable.
foreach ( wp_get_active_and_valid_themes() as $theme ) {
$wp_theme = wp_get_theme( basename( $theme ) );
$wp_theme->load_textdomain();
if ( file_exists( $theme . '/functions.php' ) ) {
include $theme . '/functions.php';
unset( $theme, $wp_theme );
* Fires after the theme is loaded.
do_action( 'after_setup_theme' );
// Create an instance of WP_Site_Health so that Cron events may fire.
if ( ! class_exists( 'WP_Site_Health' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
WP_Site_Health::get_instance();
* Fires after WordPress has finished loading but before any headers are sent.
* Most of WP is loaded at this stage, and the user is authenticated. WP continues
* to load on the {@see 'init'} hook that follows (e.g. widgets), and many plugins instantiate
* themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
* If you wish to plug an action once WP is loaded, use the {@see 'wp_loaded'} hook below.
* This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
* Ajax requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
* @link https://developer.wordpress.org/plugins/javascript/ajax
do_action( 'wp_loaded' );