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