wp-settings.php 18.9 KB
Newer Older
godog's avatar
godog committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
/**
 * Used to set up and fix common variables and include
 * the WordPress procedural and class library.
 *
 * Allows for some configuration in wp-config.php (see default-constants.php)
 *
 * @package WordPress
 */

/**
 * Stores the location of the WordPress directory of functions, classes, and core content.
 *
 * @since 1.0.0
 */
define( 'WPINC', 'wp-includes' );

agata's avatar
agata committed
18 19 20
/**
 * Version information for the current WordPress release.
 *
agata's avatar
agata committed
21 22 23
 * These can't be directly globalized in version.php. When updating,
 * we're including version.php from another installation and don't want
 * these values to be overridden if already set.
agata's avatar
agata committed
24 25 26 27 28 29 30
 *
 * @global string $wp_version             The WordPress version string.
 * @global int    $wp_db_version          WordPress database version.
 * @global string $tinymce_version        TinyMCE version.
 * @global string $required_php_version   The required PHP version string.
 * @global string $required_mysql_version The required MySQL version string.
 * @global string $wp_local_package       Locale code of the package.
agata's avatar
agata committed
31 32
 */
global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package;
agata's avatar
agata committed
33 34
require ABSPATH . WPINC . '/version.php';
require ABSPATH . WPINC . '/load.php';
agata's avatar
agata committed
35 36 37 38 39

// Check for the required PHP version and for the MySQL extension or a database drop-in.
wp_check_php_mysql_versions();

// Include files required for initialization.
agata's avatar
agata committed
40 41 42 43 44 45 46 47 48 49
require ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php';
require ABSPATH . WPINC . '/class-wp-fatal-error-handler.php';
require ABSPATH . WPINC . '/class-wp-recovery-mode-cookie-service.php';
require ABSPATH . WPINC . '/class-wp-recovery-mode-key-service.php';
require ABSPATH . WPINC . '/class-wp-recovery-mode-link-service.php';
require ABSPATH . WPINC . '/class-wp-recovery-mode-email-service.php';
require ABSPATH . WPINC . '/class-wp-recovery-mode.php';
require ABSPATH . WPINC . '/error-protection.php';
require ABSPATH . WPINC . '/default-constants.php';
require_once ABSPATH . WPINC . '/plugin.php';
lucha's avatar
lucha committed
50

lechuck's avatar
lechuck committed
51 52 53 54 55 56 57 58 59
/**
 * If not already configured, `$blog_id` will default to 1 in a single site
 * configuration. In multisite, it will be overridden by default in ms-settings.php.
 *
 * @global int $blog_id
 * @since 2.0.0
 */
global $blog_id;

lechuck's avatar
lechuck committed
60
// Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE.
lechuck's avatar
lechuck committed
61
wp_initial_constants();
godog's avatar
godog committed
62

agata's avatar
agata committed
63 64 65
// Make sure we register the shutdown handler for fatal errors as soon as possible.
wp_register_fatal_error_handler();

lechuck's avatar
lechuck committed
66 67
// WordPress calculates offsets from UTC.
date_default_timezone_set( 'UTC' );
godog's avatar
godog committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

// Turn register_globals off.
wp_unregister_GLOBALS();

// Standardize $_SERVER variables across setups.
wp_fix_server_vars();

// Check if we're in maintenance mode.
wp_maintenance();

// Start loading timer.
timer_start();

// Check if we're in WP_DEBUG mode.
wp_debug_mode();

lucha's avatar
lucha committed
84 85 86 87 88 89 90 91 92 93 94
/**
 * Filters whether to enable loading of the advanced-cache.php drop-in.
 *
 * This filter runs before it can be used by plugins. It is designed for non-web
 * run-times. If false is returned, advanced-cache.php will never be loaded.
 *
 * @since 4.6.0
 *
 * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present).
 *                                    Default true.
 */
agata's avatar
agata committed
95
if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) {
lucha's avatar
lucha committed
96
	// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
agata's avatar
agata committed
97
	include WP_CONTENT_DIR . '/advanced-cache.php';
lucha's avatar
lucha committed
98

agata's avatar
agata committed
99
	// Re-initialize any hooks added manually by advanced-cache.php.
lucha's avatar
lucha committed
100 101 102
	if ( $wp_filter ) {
		$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter );
	}
lucha's avatar
lucha committed
103
}
godog's avatar
godog committed
104 105 106 107 108

// Define WP_LANG_DIR if not set.
wp_set_lang_dir();

// Load early WordPress files.
agata's avatar
agata committed
109 110 111 112 113 114 115 116 117 118
require ABSPATH . WPINC . '/compat.php';
require ABSPATH . WPINC . '/class-wp-list-util.php';
require ABSPATH . WPINC . '/formatting.php';
require ABSPATH . WPINC . '/meta.php';
require ABSPATH . WPINC . '/functions.php';
require ABSPATH . WPINC . '/class-wp-meta-query.php';
require ABSPATH . WPINC . '/class-wp-matchesmapregex.php';
require ABSPATH . WPINC . '/class-wp.php';
require ABSPATH . WPINC . '/class-wp-error.php';
require ABSPATH . WPINC . '/pomo/mo.php';
godog's avatar
godog committed
119

agata's avatar
agata committed
120 121 122 123
/**
 * @global wpdb $wpdb WordPress database abstraction object.
 * @since 0.71
 */
lucha's avatar
lucha committed
124
global $wpdb;
agata's avatar
agata committed
125
// Include the wpdb class and, if present, a db.php database drop-in.
godog's avatar
godog committed
126 127 128
require_wp_db();

// Set the database table prefix and the format specifiers for database table columns.
root's avatar
root committed
129
$GLOBALS['table_prefix'] = $table_prefix;
godog's avatar
godog committed
130 131 132 133 134
wp_set_wpdb_vars();

// Start the WordPress object cache, or an external object cache if the drop-in is present.
wp_start_object_cache();

lechuck's avatar
lechuck committed
135
// Attach the default filters.
agata's avatar
agata committed
136
require ABSPATH . WPINC . '/default-filters.php';
godog's avatar
godog committed
137 138 139

// Initialize multisite if enabled.
if ( is_multisite() ) {
agata's avatar
agata committed
140 141 142 143
	require ABSPATH . WPINC . '/class-wp-site-query.php';
	require ABSPATH . WPINC . '/class-wp-network-query.php';
	require ABSPATH . WPINC . '/ms-blogs.php';
	require ABSPATH . WPINC . '/ms-settings.php';
godog's avatar
godog committed
144 145 146 147
} elseif ( ! defined( 'MULTISITE' ) ) {
	define( 'MULTISITE', false );
}

root's avatar
root committed
148 149
register_shutdown_function( 'shutdown_action_hook' );

godog's avatar
godog committed
150
// Stop most of WordPress from being loaded if we just want the basics.
samba's avatar
samba committed
151
if ( SHORTINIT ) {
godog's avatar
godog committed
152
	return false;
samba's avatar
samba committed
153
}
godog's avatar
godog committed
154

lechuck's avatar
lechuck committed
155
// Load the L10n library.
agata's avatar
agata committed
156 157 158
require_once ABSPATH . WPINC . '/l10n.php';
require_once ABSPATH . WPINC . '/class-wp-locale.php';
require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php';
godog's avatar
godog committed
159 160 161 162 163

// Run the installer if WordPress is not installed.
wp_not_installed();

// Load most of WordPress.
agata's avatar
agata committed
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
require ABSPATH . WPINC . '/class-wp-walker.php';
require ABSPATH . WPINC . '/class-wp-ajax-response.php';
require ABSPATH . WPINC . '/capabilities.php';
require ABSPATH . WPINC . '/class-wp-roles.php';
require ABSPATH . WPINC . '/class-wp-role.php';
require ABSPATH . WPINC . '/class-wp-user.php';
require ABSPATH . WPINC . '/class-wp-query.php';
require ABSPATH . WPINC . '/query.php';
require ABSPATH . WPINC . '/class-wp-date-query.php';
require ABSPATH . WPINC . '/theme.php';
require ABSPATH . WPINC . '/class-wp-theme.php';
require ABSPATH . WPINC . '/template.php';
require ABSPATH . WPINC . '/class-wp-user-request.php';
require ABSPATH . WPINC . '/user.php';
require ABSPATH . WPINC . '/class-wp-user-query.php';
require ABSPATH . WPINC . '/class-wp-session-tokens.php';
require ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php';
require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
require ABSPATH . WPINC . '/general-template.php';
require ABSPATH . WPINC . '/link-template.php';
require ABSPATH . WPINC . '/author-template.php';
require ABSPATH . WPINC . '/post.php';
require ABSPATH . WPINC . '/class-walker-page.php';
require ABSPATH . WPINC . '/class-walker-page-dropdown.php';
require ABSPATH . WPINC . '/class-wp-post-type.php';
require ABSPATH . WPINC . '/class-wp-post.php';
require ABSPATH . WPINC . '/post-template.php';
require ABSPATH . WPINC . '/revision.php';
require ABSPATH . WPINC . '/post-formats.php';
require ABSPATH . WPINC . '/post-thumbnail-template.php';
require ABSPATH . WPINC . '/category.php';
require ABSPATH . WPINC . '/class-walker-category.php';
require ABSPATH . WPINC . '/class-walker-category-dropdown.php';
require ABSPATH . WPINC . '/category-template.php';
require ABSPATH . WPINC . '/comment.php';
require ABSPATH . WPINC . '/class-wp-comment.php';
require ABSPATH . WPINC . '/class-wp-comment-query.php';
require ABSPATH . WPINC . '/class-walker-comment.php';
require ABSPATH . WPINC . '/comment-template.php';
require ABSPATH . WPINC . '/rewrite.php';
require ABSPATH . WPINC . '/class-wp-rewrite.php';
require ABSPATH . WPINC . '/feed.php';
require ABSPATH . WPINC . '/bookmark.php';
require ABSPATH . WPINC . '/bookmark-template.php';
require ABSPATH . WPINC . '/kses.php';
require ABSPATH . WPINC . '/cron.php';
require ABSPATH . WPINC . '/deprecated.php';
require ABSPATH . WPINC . '/script-loader.php';
require ABSPATH . WPINC . '/taxonomy.php';
require ABSPATH . WPINC . '/class-wp-taxonomy.php';
require ABSPATH . WPINC . '/class-wp-term.php';
require ABSPATH . WPINC . '/class-wp-term-query.php';
require ABSPATH . WPINC . '/class-wp-tax-query.php';
require ABSPATH . WPINC . '/update.php';
require ABSPATH . WPINC . '/canonical.php';
require ABSPATH . WPINC . '/shortcodes.php';
require ABSPATH . WPINC . '/embed.php';
require ABSPATH . WPINC . '/class-wp-embed.php';
require ABSPATH . WPINC . '/class-wp-oembed.php';
require ABSPATH . WPINC . '/class-wp-oembed-controller.php';
require ABSPATH . WPINC . '/media.php';
require ABSPATH . WPINC . '/http.php';
require ABSPATH . WPINC . '/class-http.php';
require ABSPATH . WPINC . '/class-wp-http-streams.php';
require ABSPATH . WPINC . '/class-wp-http-curl.php';
require ABSPATH . WPINC . '/class-wp-http-proxy.php';
require ABSPATH . WPINC . '/class-wp-http-cookie.php';
require ABSPATH . WPINC . '/class-wp-http-encoding.php';
require ABSPATH . WPINC . '/class-wp-http-response.php';
require ABSPATH . WPINC . '/class-wp-http-requests-response.php';
require ABSPATH . WPINC . '/class-wp-http-requests-hooks.php';
require ABSPATH . WPINC . '/widgets.php';
require ABSPATH . WPINC . '/class-wp-widget.php';
require ABSPATH . WPINC . '/class-wp-widget-factory.php';
require ABSPATH . WPINC . '/nav-menu.php';
require ABSPATH . WPINC . '/nav-menu-template.php';
require ABSPATH . WPINC . '/admin-bar.php';
require ABSPATH . WPINC . '/rest-api.php';
require ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php';
require ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php';
require ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-posts-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-search-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-blocks-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-block-renderer-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php';
require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-themes-controller.php';
require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php';
require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php';
require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-post-meta-fields.php';
require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-term-meta-fields.php';
require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-user-meta-fields.php';
require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-search-handler.php';
require ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php';
require ABSPATH . WPINC . '/class-wp-block-type.php';
require ABSPATH . WPINC . '/class-wp-block-styles-registry.php';
require ABSPATH . WPINC . '/class-wp-block-type-registry.php';
require ABSPATH . WPINC . '/class-wp-block-parser.php';
require ABSPATH . WPINC . '/blocks.php';
require ABSPATH . WPINC . '/blocks/archives.php';
require ABSPATH . WPINC . '/blocks/block.php';
require ABSPATH . WPINC . '/blocks/calendar.php';
require ABSPATH . WPINC . '/blocks/categories.php';
require ABSPATH . WPINC . '/blocks/latest-comments.php';
require ABSPATH . WPINC . '/blocks/latest-posts.php';
require ABSPATH . WPINC . '/blocks/rss.php';
require ABSPATH . WPINC . '/blocks/search.php';
require ABSPATH . WPINC . '/blocks/shortcode.php';
require ABSPATH . WPINC . '/blocks/social-link.php';
require ABSPATH . WPINC . '/blocks/tag-cloud.php';
lucha's avatar
lucha committed
284 285

$GLOBALS['wp_embed'] = new WP_Embed();
godog's avatar
godog committed
286 287 288

// Load multisite-specific files.
if ( is_multisite() ) {
agata's avatar
agata committed
289 290 291
	require ABSPATH . WPINC . '/ms-functions.php';
	require ABSPATH . WPINC . '/ms-default-filters.php';
	require ABSPATH . WPINC . '/ms-deprecated.php';
godog's avatar
godog committed
292 293 294 295
}

// Define constants that rely on the API to obtain the default value.
// Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
lechuck's avatar
lechuck committed
296
wp_plugin_directory_constants();
godog's avatar
godog committed
297

lechuck's avatar
lechuck committed
298 299
$GLOBALS['wp_plugin_paths'] = array();

godog's avatar
godog committed
300 301
// Load must-use plugins.
foreach ( wp_get_mu_plugins() as $mu_plugin ) {
agata's avatar
agata committed
302
	include_once $mu_plugin;
samba's avatar
samba committed
303 304 305 306 307 308 309 310 311

	/**
	 * Fires once a single must-use plugin has loaded.
	 *
	 * @since 5.1.0
	 *
	 * @param string $mu_plugin Full path to the plugin's main file.
	 */
	do_action( 'mu_plugin_loaded', $mu_plugin );
godog's avatar
godog committed
312 313 314
}
unset( $mu_plugin );

root's avatar
root committed
315 316
// Load network activated plugins.
if ( is_multisite() ) {
lechuck's avatar
lechuck committed
317
	foreach ( wp_get_active_network_plugins() as $network_plugin ) {
lechuck's avatar
lechuck committed
318
		wp_register_plugin_realpath( $network_plugin );
agata's avatar
agata committed
319
		include_once $network_plugin;
samba's avatar
samba committed
320 321 322 323 324 325 326 327 328

		/**
		 * Fires once a single network-activated plugin has loaded.
		 *
		 * @since 5.1.0
		 *
		 * @param string $network_plugin Full path to the plugin's main file.
		 */
		do_action( 'network_plugin_loaded', $network_plugin );
root's avatar
root committed
329 330 331 332
	}
	unset( $network_plugin );
}

lucha's avatar
lucha committed
333 334 335 336 337
/**
 * Fires once all must-use and network-activated plugins have loaded.
 *
 * @since 2.8.0
 */
godog's avatar
godog committed
338 339
do_action( 'muplugins_loaded' );

samba's avatar
samba committed
340 341 342
if ( is_multisite() ) {
	ms_cookie_constants();
}
godog's avatar
godog committed
343

ale's avatar
ale committed
344
// Define constants after multisite is loaded.
lechuck's avatar
lechuck committed
345
wp_cookie_constants();
godog's avatar
godog committed
346

agata's avatar
agata committed
347
// Define and enforce our SSL constants.
lechuck's avatar
lechuck committed
348
wp_ssl_constants();
godog's avatar
godog committed
349 350

// Create common globals.
agata's avatar
agata committed
351
require ABSPATH . WPINC . '/vars.php';
godog's avatar
godog committed
352 353 354 355 356 357

// 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();

lucha's avatar
lucha committed
358 359
wp_start_scraping_edited_file_errors();

agata's avatar
agata committed
360
// Register the default theme directory root.
root's avatar
root committed
361 362
register_theme_directory( get_theme_root() );

agata's avatar
agata committed
363 364 365 366 367
if ( ! is_multisite() ) {
	// Handle users requesting a recovery mode link and initiating recovery mode.
	wp_recovery_mode()->initialize();
}

godog's avatar
godog committed
368
// Load active plugins.
lechuck's avatar
lechuck committed
369 370
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
	wp_register_plugin_realpath( $plugin );
agata's avatar
agata committed
371
	include_once $plugin;
samba's avatar
samba committed
372 373 374 375 376 377 378 379 380

	/**
	 * Fires once a single activated plugin has loaded.
	 *
	 * @since 5.1.0
	 *
	 * @param string $plugin Full path to the plugin's main file.
	 */
	do_action( 'plugin_loaded', $plugin );
lechuck's avatar
lechuck committed
381
}
godog's avatar
godog committed
382 383 384
unset( $plugin );

// Load pluggable functions.
agata's avatar
agata committed
385 386
require ABSPATH . WPINC . '/pluggable.php';
require ABSPATH . WPINC . '/pluggable-deprecated.php';
godog's avatar
godog committed
387 388 389 390 391

// Set internal encoding.
wp_set_internal_encoding();

// Run wp_cache_postload() if object cache is enabled and the function exists.
samba's avatar
samba committed
392
if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) {
godog's avatar
godog committed
393
	wp_cache_postload();
samba's avatar
samba committed
394
}
godog's avatar
godog committed
395

lucha's avatar
lucha committed
396 397 398 399 400
/**
 * Fires once activated plugins have loaded.
 *
 * Pluggable functions are also available at this point in the loading order.
 *
lucha's avatar
lucha committed
401
 * @since 1.5.0
lucha's avatar
lucha committed
402
 */
godog's avatar
godog committed
403 404 405
do_action( 'plugins_loaded' );

// Define constants which affect functionality if not already defined.
lechuck's avatar
lechuck committed
406
wp_functionality_constants();
godog's avatar
godog committed
407

agata's avatar
agata committed
408
// Add magic quotes and set up $_REQUEST ( $_GET + $_POST ).
godog's avatar
godog committed
409 410
wp_magic_quotes();

lucha's avatar
lucha committed
411 412 413 414 415
/**
 * Fires when comment cookies are sanitized.
 *
 * @since 2.0.11
 */
godog's avatar
godog committed
416 417 418 419
do_action( 'sanitize_comment_cookies' );

/**
 * WordPress Query object
samba's avatar
samba committed
420
 *
agata's avatar
agata committed
421
 * @global WP_Query $wp_the_query WordPress Query object.
godog's avatar
godog committed
422 423
 * @since 2.0.0
 */
lechuck's avatar
lechuck committed
424
$GLOBALS['wp_the_query'] = new WP_Query();
godog's avatar
godog committed
425 426 427 428

/**
 * Holds the reference to @see $wp_the_query
 * Use this global for WordPress queries
samba's avatar
samba committed
429
 *
agata's avatar
agata committed
430
 * @global WP_Query $wp_query WordPress Query object.
godog's avatar
godog committed
431 432
 * @since 1.5.0
 */
lechuck's avatar
lechuck committed
433
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
godog's avatar
godog committed
434 435 436

/**
 * Holds the WordPress Rewrite object for creating pretty URLs
samba's avatar
samba committed
437
 *
agata's avatar
agata committed
438
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
godog's avatar
godog committed
439 440
 * @since 1.5.0
 */
lechuck's avatar
lechuck committed
441
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
godog's avatar
godog committed
442 443 444

/**
 * WordPress Object
samba's avatar
samba committed
445
 *
agata's avatar
agata committed
446
 * @global WP $wp Current WordPress environment instance.
godog's avatar
godog committed
447 448
 * @since 2.0.0
 */
lechuck's avatar
lechuck committed
449
$GLOBALS['wp'] = new WP();
godog's avatar
godog committed
450 451 452

/**
 * WordPress Widget Factory Object
samba's avatar
samba committed
453
 *
lechuck's avatar
lechuck committed
454
 * @global WP_Widget_Factory $wp_widget_factory
godog's avatar
godog committed
455 456
 * @since 2.8.0
 */
root's avatar
root committed
457
$GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
godog's avatar
godog committed
458

lechuck's avatar
lechuck committed
459 460
/**
 * WordPress User Roles
samba's avatar
samba committed
461
 *
agata's avatar
agata committed
462
 * @global WP_Roles $wp_roles WordPress role management object.
lechuck's avatar
lechuck committed
463 464 465 466
 * @since 2.0.0
 */
$GLOBALS['wp_roles'] = new WP_Roles();

lucha's avatar
lucha committed
467 468 469 470 471
/**
 * Fires before the theme is loaded.
 *
 * @since 2.6.0
 */
godog's avatar
godog committed
472 473 474
do_action( 'setup_theme' );

// Define the template related constants.
samba's avatar
samba committed
475
wp_templating_constants();
godog's avatar
godog committed
476 477 478 479

// Load the default text localization domain.
load_default_textdomain();

samba's avatar
samba committed
480
$locale      = get_locale();
godog's avatar
godog committed
481
$locale_file = WP_LANG_DIR . "/$locale.php";
samba's avatar
samba committed
482
if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) {
agata's avatar
agata committed
483
	require $locale_file;
samba's avatar
samba committed
484
}
lechuck's avatar
lechuck committed
485
unset( $locale_file );
godog's avatar
godog committed
486 487 488

/**
 * WordPress Locale object for loading locale domain date and various strings.
samba's avatar
samba committed
489
 *
agata's avatar
agata committed
490
 * @global WP_Locale $wp_locale WordPress date and time locale object.
godog's avatar
godog committed
491 492
 * @since 2.1.0
 */
root's avatar
root committed
493
$GLOBALS['wp_locale'] = new WP_Locale();
godog's avatar
godog committed
494

lucha's avatar
lucha committed
495
/**
agata's avatar
agata committed
496
 * WordPress Locale Switcher object for switching locales.
lucha's avatar
lucha committed
497 498 499 500 501 502 503 504
 *
 * @since 4.7.0
 *
 * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
 */
$GLOBALS['wp_locale_switcher'] = new WP_Locale_Switcher();
$GLOBALS['wp_locale_switcher']->init();

godog's avatar
godog committed
505
// Load the functions for the active theme, for both parent and child theme if applicable.
samba's avatar
samba committed
506 507 508 509
foreach ( wp_get_active_and_valid_themes() as $theme ) {
	if ( file_exists( $theme . '/functions.php' ) ) {
		include $theme . '/functions.php';
	}
shammash's avatar
shammash committed
510
}
samba's avatar
samba committed
511
unset( $theme );
godog's avatar
godog committed
512

lucha's avatar
lucha committed
513 514 515 516 517
/**
 * Fires after the theme is loaded.
 *
 * @since 3.0.0
 */
godog's avatar
godog committed
518 519
do_action( 'after_setup_theme' );

agata's avatar
agata committed
520 521 522 523 524 525
// 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();

godog's avatar
godog committed
526
// Set up current user.
lechuck's avatar
lechuck committed
527
$GLOBALS['wp']->init();
godog's avatar
godog committed
528 529

/**
lucha's avatar
lucha committed
530 531
 * Fires after WordPress has finished loading but before any headers are sent.
 *
godog's avatar
godog committed
532
 * Most of WP is loaded at this stage, and the user is authenticated. WP continues
lucha's avatar
lucha committed
533
 * to load on the {@see 'init'} hook that follows (e.g. widgets), and many plugins instantiate
godog's avatar
godog committed
534 535
 * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
 *
lucha's avatar
lucha committed
536
 * If you wish to plug an action once WP is loaded, use the {@see 'wp_loaded'} hook below.
lucha's avatar
lucha committed
537
 *
lucha's avatar
lucha committed
538
 * @since 1.5.0
godog's avatar
godog committed
539 540 541
 */
do_action( 'init' );

agata's avatar
agata committed
542
// Check site status.
godog's avatar
godog committed
543
if ( is_multisite() ) {
agata's avatar
agata committed
544 545
	$file = ms_site_check();
	if ( true !== $file ) {
agata's avatar
agata committed
546
		require $file;
godog's avatar
godog committed
547 548
		die();
	}
samba's avatar
samba committed
549
	unset( $file );
godog's avatar
godog committed
550 551 552 553 554
}

/**
 * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
 *
lucha's avatar
lucha committed
555
 * Ajax requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
godog's avatar
godog committed
556 557
 * users not logged in.
 *
ale's avatar
ale committed
558
 * @link https://codex.wordpress.org/AJAX_in_Plugins
godog's avatar
godog committed
559 560 561
 *
 * @since 3.0.0
 */
lucha's avatar
lucha committed
562
do_action( 'wp_loaded' );