~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

Viewing changes to wp-settings.php

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

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