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