]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-settings.php
WordPress 4.6.1
[autoinstalls/wordpress.git] / wp-settings.php
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  * @internal This file must be parsable by PHP4.
9  *
10  * @package WordPress
11  */
12
13 /**
14  * Stores the location of the WordPress directory of functions, classes, and core content.
15  *
16  * @since 1.0.0
17  */
18 define( 'WPINC', 'wp-includes' );
19
20 // Include files required for initialization.
21 require( ABSPATH . WPINC . '/load.php' );
22 require( ABSPATH . WPINC . '/default-constants.php' );
23 require( ABSPATH . WPINC . '/plugin.php' );
24
25 /*
26  * These can't be directly globalized in version.php. When updating,
27  * we're including version.php from another install and don't want
28  * these values to be overridden if already set.
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
33 /**
34  * If not already configured, `$blog_id` will default to 1 in a single site
35  * configuration. In multisite, it will be overridden by default in ms-settings.php.
36  *
37  * @global int $blog_id
38  * @since 2.0.0
39  */
40 global $blog_id;
41
42 // Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE.
43 wp_initial_constants();
44
45 // Check for the required PHP version and for the MySQL extension or a database drop-in.
46 wp_check_php_mysql_versions();
47
48 // Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
49 @ini_set( 'magic_quotes_runtime', 0 );
50 @ini_set( 'magic_quotes_sybase',  0 );
51
52 // WordPress calculates offsets from UTC.
53 date_default_timezone_set( 'UTC' );
54
55 // Turn register_globals off.
56 wp_unregister_GLOBALS();
57
58 // Standardize $_SERVER variables across setups.
59 wp_fix_server_vars();
60
61 // Check if we have received a request due to missing favicon.ico
62 wp_favicon_request();
63
64 // Check if we're in maintenance mode.
65 wp_maintenance();
66
67 // Start loading timer.
68 timer_start();
69
70 // Check if we're in WP_DEBUG mode.
71 wp_debug_mode();
72
73 /**
74  * Filters whether to enable loading of the advanced-cache.php drop-in.
75  *
76  * This filter runs before it can be used by plugins. It is designed for non-web
77  * run-times. If false is returned, advanced-cache.php will never be loaded.
78  *
79  * @since 4.6.0
80  *
81  * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present).
82  *                                    Default true.
83  */
84 if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) ) {
85 // For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
86         WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
87 }
88
89 // Define WP_LANG_DIR if not set.
90 wp_set_lang_dir();
91
92 // Load early WordPress files.
93 require( ABSPATH . WPINC . '/compat.php' );
94 require( ABSPATH . WPINC . '/functions.php' );
95 require( ABSPATH . WPINC . '/class-wp.php' );
96 require( ABSPATH . WPINC . '/class-wp-error.php' );
97 require( ABSPATH . WPINC . '/pomo/mo.php' );
98
99 // Include the wpdb class and, if present, a db.php database drop-in.
100 global $wpdb;
101 require_wp_db();
102
103 // Set the database table prefix and the format specifiers for database table columns.
104 $GLOBALS['table_prefix'] = $table_prefix;
105 wp_set_wpdb_vars();
106
107 // Start the WordPress object cache, or an external object cache if the drop-in is present.
108 wp_start_object_cache();
109
110 // Attach the default filters.
111 require( ABSPATH . WPINC . '/default-filters.php' );
112
113 // Initialize multisite if enabled.
114 if ( is_multisite() ) {
115         require( ABSPATH . WPINC . '/class-wp-site-query.php' );
116         require( ABSPATH . WPINC . '/class-wp-network-query.php' );
117         require( ABSPATH . WPINC . '/ms-blogs.php' );
118         require( ABSPATH . WPINC . '/ms-settings.php' );
119 } elseif ( ! defined( 'MULTISITE' ) ) {
120         define( 'MULTISITE', false );
121 }
122
123 register_shutdown_function( 'shutdown_action_hook' );
124
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
132 // Run the installer if WordPress is not installed.
133 wp_not_installed();
134
135 // Load most of WordPress.
136 require( ABSPATH . WPINC . '/class-wp-walker.php' );
137 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
138 require( ABSPATH . WPINC . '/formatting.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 . '/query.php' );
144 require( ABSPATH . WPINC . '/date.php' );
145 require( ABSPATH . WPINC . '/theme.php' );
146 require( ABSPATH . WPINC . '/class-wp-theme.php' );
147 require( ABSPATH . WPINC . '/template.php' );
148 require( ABSPATH . WPINC . '/user.php' );
149 require( ABSPATH . WPINC . '/class-wp-user-query.php' );
150 require( ABSPATH . WPINC . '/session.php' );
151 require( ABSPATH . WPINC . '/meta.php' );
152 require( ABSPATH . WPINC . '/class-wp-meta-query.php' );
153 require( ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php' );
154 require( ABSPATH . WPINC . '/general-template.php' );
155 require( ABSPATH . WPINC . '/link-template.php' );
156 require( ABSPATH . WPINC . '/author-template.php' );
157 require( ABSPATH . WPINC . '/post.php' );
158 require( ABSPATH . WPINC . '/class-walker-page.php' );
159 require( ABSPATH . WPINC . '/class-walker-page-dropdown.php' );
160 require( ABSPATH . WPINC . '/class-wp-post-type.php' );
161 require( ABSPATH . WPINC . '/class-wp-post.php' );
162 require( ABSPATH . WPINC . '/post-template.php' );
163 require( ABSPATH . WPINC . '/revision.php' );
164 require( ABSPATH . WPINC . '/post-formats.php' );
165 require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
166 require( ABSPATH . WPINC . '/category.php' );
167 require( ABSPATH . WPINC . '/class-walker-category.php' );
168 require( ABSPATH . WPINC . '/class-walker-category-dropdown.php' );
169 require( ABSPATH . WPINC . '/category-template.php' );
170 require( ABSPATH . WPINC . '/comment.php' );
171 require( ABSPATH . WPINC . '/class-wp-comment.php' );
172 require( ABSPATH . WPINC . '/class-wp-comment-query.php' );
173 require( ABSPATH . WPINC . '/class-walker-comment.php' );
174 require( ABSPATH . WPINC . '/comment-template.php' );
175 require( ABSPATH . WPINC . '/rewrite.php' );
176 require( ABSPATH . WPINC . '/class-wp-rewrite.php' );
177 require( ABSPATH . WPINC . '/feed.php' );
178 require( ABSPATH . WPINC . '/bookmark.php' );
179 require( ABSPATH . WPINC . '/bookmark-template.php' );
180 require( ABSPATH . WPINC . '/kses.php' );
181 require( ABSPATH . WPINC . '/cron.php' );
182 require( ABSPATH . WPINC . '/deprecated.php' );
183 require( ABSPATH . WPINC . '/script-loader.php' );
184 require( ABSPATH . WPINC . '/taxonomy.php' );
185 require( ABSPATH . WPINC . '/class-wp-term.php' );
186 require( ABSPATH . WPINC . '/class-wp-term-query.php' );
187 require( ABSPATH . WPINC . '/class-wp-tax-query.php' );
188 require( ABSPATH . WPINC . '/update.php' );
189 require( ABSPATH . WPINC . '/canonical.php' );
190 require( ABSPATH . WPINC . '/shortcodes.php' );
191 require( ABSPATH . WPINC . '/embed.php' );
192 require( ABSPATH . WPINC . '/class-wp-embed.php' );
193 require( ABSPATH . WPINC . '/class-wp-oembed-controller.php' );
194 require( ABSPATH . WPINC . '/media.php' );
195 require( ABSPATH . WPINC . '/http.php' );
196 require( ABSPATH . WPINC . '/class-http.php' );
197 require( ABSPATH . WPINC . '/class-wp-http-streams.php' );
198 require( ABSPATH . WPINC . '/class-wp-http-curl.php' );
199 require( ABSPATH . WPINC . '/class-wp-http-proxy.php' );
200 require( ABSPATH . WPINC . '/class-wp-http-cookie.php' );
201 require( ABSPATH . WPINC . '/class-wp-http-encoding.php' );
202 require( ABSPATH . WPINC . '/class-wp-http-response.php' );
203 require( ABSPATH . WPINC . '/class-wp-http-requests-response.php' );
204 require( ABSPATH . WPINC . '/widgets.php' );
205 require( ABSPATH . WPINC . '/class-wp-widget.php' );
206 require( ABSPATH . WPINC . '/class-wp-widget-factory.php' );
207 require( ABSPATH . WPINC . '/nav-menu.php' );
208 require( ABSPATH . WPINC . '/nav-menu-template.php' );
209 require( ABSPATH . WPINC . '/admin-bar.php' );
210 require( ABSPATH . WPINC . '/rest-api.php' );
211 require( ABSPATH . WPINC . '/rest-api/class-wp-rest-server.php' );
212 require( ABSPATH . WPINC . '/rest-api/class-wp-rest-response.php' );
213 require( ABSPATH . WPINC . '/rest-api/class-wp-rest-request.php' );
214
215 // Load multisite-specific files.
216 if ( is_multisite() ) {
217         require( ABSPATH . WPINC . '/ms-functions.php' );
218         require( ABSPATH . WPINC . '/ms-default-filters.php' );
219         require( ABSPATH . WPINC . '/ms-deprecated.php' );
220 }
221
222 // Define constants that rely on the API to obtain the default value.
223 // Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
224 wp_plugin_directory_constants();
225
226 $GLOBALS['wp_plugin_paths'] = array();
227
228 // Load must-use plugins.
229 foreach ( wp_get_mu_plugins() as $mu_plugin ) {
230         include_once( $mu_plugin );
231 }
232 unset( $mu_plugin );
233
234 // Load network activated plugins.
235 if ( is_multisite() ) {
236         foreach ( wp_get_active_network_plugins() as $network_plugin ) {
237                 wp_register_plugin_realpath( $network_plugin );
238                 include_once( $network_plugin );
239         }
240         unset( $network_plugin );
241 }
242
243 /**
244  * Fires once all must-use and network-activated plugins have loaded.
245  *
246  * @since 2.8.0
247  */
248 do_action( 'muplugins_loaded' );
249
250 if ( is_multisite() )
251         ms_cookie_constants(  );
252
253 // Define constants after multisite is loaded.
254 wp_cookie_constants();
255
256 // Define and enforce our SSL constants
257 wp_ssl_constants();
258
259 // Create common globals.
260 require( ABSPATH . WPINC . '/vars.php' );
261
262 // Make taxonomies and posts available to plugins and themes.
263 // @plugin authors: warning: these get registered again on the init hook.
264 create_initial_taxonomies();
265 create_initial_post_types();
266
267 // Register the default theme directory root
268 register_theme_directory( get_theme_root() );
269
270 // Load active plugins.
271 foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
272         wp_register_plugin_realpath( $plugin );
273         include_once( $plugin );
274 }
275 unset( $plugin );
276
277 // Load pluggable functions.
278 require( ABSPATH . WPINC . '/pluggable.php' );
279 require( ABSPATH . WPINC . '/pluggable-deprecated.php' );
280
281 // Set internal encoding.
282 wp_set_internal_encoding();
283
284 // Run wp_cache_postload() if object cache is enabled and the function exists.
285 if ( WP_CACHE && function_exists( 'wp_cache_postload' ) )
286         wp_cache_postload();
287
288 /**
289  * Fires once activated plugins have loaded.
290  *
291  * Pluggable functions are also available at this point in the loading order.
292  *
293  * @since 1.5.0
294  */
295 do_action( 'plugins_loaded' );
296
297 // Define constants which affect functionality if not already defined.
298 wp_functionality_constants();
299
300 // Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
301 wp_magic_quotes();
302
303 /**
304  * Fires when comment cookies are sanitized.
305  *
306  * @since 2.0.11
307  */
308 do_action( 'sanitize_comment_cookies' );
309
310 /**
311  * WordPress Query object
312  * @global WP_Query $wp_the_query
313  * @since 2.0.0
314  */
315 $GLOBALS['wp_the_query'] = new WP_Query();
316
317 /**
318  * Holds the reference to @see $wp_the_query
319  * Use this global for WordPress queries
320  * @global WP_Query $wp_query
321  * @since 1.5.0
322  */
323 $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
324
325 /**
326  * Holds the WordPress Rewrite object for creating pretty URLs
327  * @global WP_Rewrite $wp_rewrite
328  * @since 1.5.0
329  */
330 $GLOBALS['wp_rewrite'] = new WP_Rewrite();
331
332 /**
333  * WordPress Object
334  * @global WP $wp
335  * @since 2.0.0
336  */
337 $GLOBALS['wp'] = new WP();
338
339 /**
340  * WordPress Widget Factory Object
341  * @global WP_Widget_Factory $wp_widget_factory
342  * @since 2.8.0
343  */
344 $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory();
345
346 /**
347  * WordPress User Roles
348  * @global WP_Roles $wp_roles
349  * @since 2.0.0
350  */
351 $GLOBALS['wp_roles'] = new WP_Roles();
352
353 /**
354  * Fires before the theme is loaded.
355  *
356  * @since 2.6.0
357  */
358 do_action( 'setup_theme' );
359
360 // Define the template related constants.
361 wp_templating_constants(  );
362
363 // Load the default text localization domain.
364 load_default_textdomain();
365
366 $locale = get_locale();
367 $locale_file = WP_LANG_DIR . "/$locale.php";
368 if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) )
369         require( $locale_file );
370 unset( $locale_file );
371
372 // Pull in locale data after loading text domain.
373 require_once( ABSPATH . WPINC . '/locale.php' );
374
375 /**
376  * WordPress Locale object for loading locale domain date and various strings.
377  * @global WP_Locale $wp_locale
378  * @since 2.1.0
379  */
380 $GLOBALS['wp_locale'] = new WP_Locale();
381
382 // Load the functions for the active theme, for both parent and child theme if applicable.
383 if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) {
384         if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
385                 include( STYLESHEETPATH . '/functions.php' );
386         if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
387                 include( TEMPLATEPATH . '/functions.php' );
388 }
389
390 /**
391  * Fires after the theme is loaded.
392  *
393  * @since 3.0.0
394  */
395 do_action( 'after_setup_theme' );
396
397 // Set up current user.
398 $GLOBALS['wp']->init();
399
400 /**
401  * Fires after WordPress has finished loading but before any headers are sent.
402  *
403  * Most of WP is loaded at this stage, and the user is authenticated. WP continues
404  * to load on the {@see 'init'} hook that follows (e.g. widgets), and many plugins instantiate
405  * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
406  *
407  * If you wish to plug an action once WP is loaded, use the {@see 'wp_loaded'} hook below.
408  *
409  * @since 1.5.0
410  */
411 do_action( 'init' );
412
413 // Check site status
414 if ( is_multisite() ) {
415         if ( true !== ( $file = ms_site_check() ) ) {
416                 require( $file );
417                 die();
418         }
419         unset($file);
420 }
421
422 /**
423  * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
424  *
425  * Ajax requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
426  * users not logged in.
427  *
428  * @link https://codex.wordpress.org/AJAX_in_Plugins
429  *
430  * @since 3.0.0
431  */
432 do_action( 'wp_loaded' );