wp-settings.php 24 KB

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