Projects : mp-wp : mp-wp_genesis

mp-wp/wp-settings.php

Dir - Raw

1<?php
2/**
3 * Used to setup and fix common variables and include
4 * the WordPress procedural and class library.
5 *
6 * You should not have to change this file and allows
7 * for some configuration in wp-config.php.
8 *
9 * @package WordPress
10 */
11
12if ( !defined('WP_MEMORY_LIMIT') )
13 define('WP_MEMORY_LIMIT', '32M');
14
15if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
16 @ini_set('memory_limit', WP_MEMORY_LIMIT);
17
18
19/**
20 * Turn register globals off.
21 *
22 * @access private
23 * @since 2.1.0
24 * @return null Will return null if register_globals PHP directive was disabled
25 */
26function wp_unregister_GLOBALS() {
27 if ( !ini_get('register_globals') )
28 return;
29
30 if ( isset($_REQUEST['GLOBALS']) )
31 die('GLOBALS overwrite attempt detected');
32
33 // Variables that shouldn't be unset
34 $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
35
36 $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
37 foreach ( $input as $k => $v )
38 if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
39 $GLOBALS[$k] = NULL;
40 unset($GLOBALS[$k]);
41 }
42}
43
44wp_unregister_GLOBALS();
45
46unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
47
48/**
49 * The $blog_id global, which you can change in the config allows you to create a simple
50 * multiple blog installation using just one WordPress and changing $blog_id around.
51 *
52 * @global int $blog_id
53 * @since 2.0.0
54 */
55if ( ! isset($blog_id) )
56 $blog_id = 1;
57
58// Fix for IIS, which doesn't set REQUEST_URI
59if ( empty( $_SERVER['REQUEST_URI'] ) ) {
60
61 // IIS Mod-Rewrite
62 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
63 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
64 }
65 // IIS Isapi_Rewrite
66 else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
67 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
68 }
69 else
70 {
71 // Use ORIG_PATH_INFO if there is no PATH_INFO
72 if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
73 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
74
75 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
76 if ( isset($_SERVER['PATH_INFO']) ) {
77 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
78 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
79 else
80 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
81 }
82
83 // Append the query string if it exists and isn't null
84 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
85 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
86 }
87 }
88}
89
90// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
91if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
92 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
93
94// Fix for Dreamhost and other PHP as CGI hosts
95if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
96 unset($_SERVER['PATH_INFO']);
97
98// Fix empty PHP_SELF
99$PHP_SELF = $_SERVER['PHP_SELF'];
100if ( empty($PHP_SELF) )
101 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
102
103if ( version_compare( '4.3', phpversion(), '>' ) ) {
104 die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, phpversion() ) );
105}
106
107if ( !defined('WP_CONTENT_DIR') )
108 define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
109
110if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
111 include(ABSPATH . '.maintenance');
112 // If the $upgrading timestamp is older than 10 minutes, don't die.
113 if ( ( time() - $upgrading ) < 600 ) {
114 if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
115 require_once( WP_CONTENT_DIR . '/maintenance.php' );
116 die();
117 }
118
119 $protocol = $_SERVER["SERVER_PROTOCOL"];
120 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
121 $protocol = 'HTTP/1.0';
122 header( "$protocol 503 Service Unavailable", true, 503 );
123 header( 'Content-Type: text/html; charset=utf-8' );
124?>
125<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
126<html xmlns="http://www.w3.org/1999/xhtml">
127<head>
128<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
129 <title>Maintenance</title>
130
131</head>
132<body>
133 <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
134</body>
135</html>
136<?php
137 die();
138 }
139}
140
141if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
142 die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
143
144/**
145 * PHP 4 standard microtime start capture.
146 *
147 * @access private
148 * @since 0.71
149 * @global int $timestart Seconds and Microseconds added together from when function is called.
150 * @return bool Always returns true.
151 */
152function timer_start() {
153 global $timestart;
154 $mtime = explode(' ', microtime() );
155 $mtime = $mtime[1] + $mtime[0];
156 $timestart = $mtime;
157 return true;
158}
159
160/**
161 * Return and/or display the time from the page start to when function is called.
162 *
163 * You can get the results and print them by doing:
164 * <code>
165 * $nTimePageTookToExecute = timer_stop();
166 * echo $nTimePageTookToExecute;
167 * </code>
168 *
169 * Or instead, you can do:
170 * <code>
171 * timer_stop(1);
172 * </code>
173 * which will do what the above does. If you need the result, you can assign it to a variable, but
174 * most cases, you only need to echo it.
175 *
176 * @since 0.71
177 * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
178 * @global int $timeend Seconds and Microseconds added together from when function is called
179 *
180 * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
181 * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
182 * @return float The "second.microsecond" finished time calculation
183 */
184function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
185 global $timestart, $timeend;
186 $mtime = microtime();
187 $mtime = explode(' ',$mtime);
188 $mtime = $mtime[1] + $mtime[0];
189 $timeend = $mtime;
190 $timetotal = $timeend-$timestart;
191 $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
192 if ( $display )
193 echo $r;
194 return $r;
195}
196timer_start();
197
198// Add define('WP_DEBUG',true); to wp-config.php to enable display of notices during development.
199if (defined('WP_DEBUG') and WP_DEBUG == true) {
200 error_reporting(E_ALL);
201} else {
202 error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
203}
204
205// For an advanced caching plugin to use, static because you would only want one
206if ( defined('WP_CACHE') )
207 @include WP_CONTENT_DIR . '/advanced-cache.php';
208
209/**
210 * Stores the location of the WordPress directory of functions, classes, and core content.
211 *
212 * @since 1.0.0
213 */
214define('WPINC', 'wp-includes');
215
216if ( !defined('WP_LANG_DIR') ) {
217 /**
218 * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
219 * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
220 *
221 * @since 2.1.0
222 */
223 if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
224 define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
225 if (!defined('LANGDIR')) {
226 // Old static relative path maintained for limited backwards compatibility - won't work in some cases
227 define('LANGDIR', 'wp-content/languages');
228 }
229 } else {
230 define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
231 if (!defined('LANGDIR')) {
232 // Old relative path maintained for backwards compatibility
233 define('LANGDIR', WPINC . '/languages');
234 }
235 }
236}
237
238require (ABSPATH . WPINC . '/compat.php');
239require (ABSPATH . WPINC . '/functions.php');
240require (ABSPATH . WPINC . '/classes.php');
241
242require_wp_db();
243
244if ( !empty($wpdb->error) )
245 dead_db();
246
247$prefix = $wpdb->set_prefix($table_prefix);
248
249if ( is_wp_error($prefix) )
250 wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/);
251
252if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') )
253 require_once (WP_CONTENT_DIR . '/object-cache.php');
254else
255 require_once (ABSPATH . WPINC . '/cache.php');
256
257wp_cache_init();
258if ( function_exists('wp_cache_add_global_groups') ) {
259 wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta'));
260 wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
261}
262
263require (ABSPATH . WPINC . '/plugin.php');
264require (ABSPATH . WPINC . '/default-filters.php');
265include_once(ABSPATH . WPINC . '/streams.php');
266include_once(ABSPATH . WPINC . '/gettext.php');
267require_once (ABSPATH . WPINC . '/l10n.php');
268
269if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
270 if ( defined('WP_SITEURL') )
271 $link = WP_SITEURL . '/wp-admin/install.php';
272 elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
273 $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
274 else
275 $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
276 require_once(ABSPATH . WPINC . '/kses.php');
277 require_once(ABSPATH . WPINC . '/pluggable.php');
278 wp_redirect($link);
279 die(); // have to die here ~ Mark
280}
281
282require (ABSPATH . WPINC . '/formatting.php');
283require (ABSPATH . WPINC . '/capabilities.php');
284require (ABSPATH . WPINC . '/query.php');
285require (ABSPATH . WPINC . '/theme.php');
286require (ABSPATH . WPINC . '/user.php');
287require (ABSPATH . WPINC . '/general-template.php');
288require (ABSPATH . WPINC . '/link-template.php');
289require (ABSPATH . WPINC . '/author-template.php');
290require (ABSPATH . WPINC . '/post.php');
291require (ABSPATH . WPINC . '/post-template.php');
292require (ABSPATH . WPINC . '/category.php');
293require (ABSPATH . WPINC . '/category-template.php');
294require (ABSPATH . WPINC . '/comment.php');
295require (ABSPATH . WPINC . '/comment-template.php');
296require (ABSPATH . WPINC . '/rewrite.php');
297require (ABSPATH . WPINC . '/feed.php');
298require (ABSPATH . WPINC . '/bookmark.php');
299require (ABSPATH . WPINC . '/bookmark-template.php');
300require (ABSPATH . WPINC . '/kses.php');
301require (ABSPATH . WPINC . '/cron.php');
302require (ABSPATH . WPINC . '/version.php');
303require (ABSPATH . WPINC . '/deprecated.php');
304require (ABSPATH . WPINC . '/script-loader.php');
305require (ABSPATH . WPINC . '/taxonomy.php');
306require (ABSPATH . WPINC . '/update.php');
307require (ABSPATH . WPINC . '/canonical.php');
308require (ABSPATH . WPINC . '/shortcodes.php');
309require (ABSPATH . WPINC . '/media.php');
310require (ABSPATH . WPINC . '/http.php');
311
312if ( !defined('WP_CONTENT_URL') )
313 define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
314
315/**
316 * Allows for the plugins directory to be moved from the default location.
317 *
318 * @since 2.6.0
319 */
320if ( !defined('WP_PLUGIN_DIR') )
321 define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
322
323/**
324 * Allows for the plugins directory to be moved from the default location.
325 *
326 * @since 2.6.0
327 */
328if ( !defined('WP_PLUGIN_URL') )
329 define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
330
331/**
332 * Allows for the plugins directory to be moved from the default location.
333 *
334 * @since 2.1.0
335 */
336if ( !defined('PLUGINDIR') )
337 define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
338
339/**
340 * Used to guarantee unique hash cookies
341 * @since 1.5
342 */
343define('COOKIEHASH', md5(get_option('siteurl')));
344
345/**
346 * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
347 * @since 2.5.0
348 */
349$wp_default_secret_key = 'put your unique phrase here';
350
351/**
352 * It is possible to define this in wp-config.php
353 * @since 2.0.0
354 */
355if ( !defined('USER_COOKIE') )
356 define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
357
358/**
359 * It is possible to define this in wp-config.php
360 * @since 2.0.0
361 */
362if ( !defined('PASS_COOKIE') )
363 define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
364
365/**
366 * It is possible to define this in wp-config.php
367 * @since 2.5.0
368 */
369if ( !defined('AUTH_COOKIE') )
370 define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
371
372/**
373 * It is possible to define this in wp-config.php
374 * @since 2.6.0
375 */
376if ( !defined('SECURE_AUTH_COOKIE') )
377 define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
378
379/**
380 * It is possible to define this in wp-config.php
381 * @since 2.6.0
382 */
383if ( !defined('LOGGED_IN_COOKIE') )
384 define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
385
386/**
387 * It is possible to define this in wp-config.php
388 * @since 2.3.0
389 */
390if ( !defined('TEST_COOKIE') )
391 define('TEST_COOKIE', 'wordpress_test_cookie');
392
393/**
394 * It is possible to define this in wp-config.php
395 * @since 1.2.0
396 */
397if ( !defined('COOKIEPATH') )
398 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
399
400/**
401 * It is possible to define this in wp-config.php
402 * @since 1.5.0
403 */
404if ( !defined('SITECOOKIEPATH') )
405 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
406
407/**
408 * It is possible to define this in wp-config.php
409 * @since 2.6.0
410 */
411if ( !defined('ADMIN_COOKIE_PATH') )
412 define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
413
414/**
415 * It is possible to define this in wp-config.php
416 * @since 2.6.0
417 */
418if ( !defined('PLUGINS_COOKIE_PATH') )
419 define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
420
421/**
422 * It is possible to define this in wp-config.php
423 * @since 2.0.0
424 */
425if ( !defined('COOKIE_DOMAIN') )
426 define('COOKIE_DOMAIN', false);
427
428/**
429 * It is possible to define this in wp-config.php
430 * @since 2.6.0
431 */
432if ( !defined('FORCE_SSL_ADMIN') )
433 define('FORCE_SSL_ADMIN', false);
434force_ssl_admin(FORCE_SSL_ADMIN);
435
436/**
437 * It is possible to define this in wp-config.php
438 * @since 2.6.0
439 */
440if ( !defined('FORCE_SSL_LOGIN') )
441 define('FORCE_SSL_LOGIN', false);
442force_ssl_login(FORCE_SSL_LOGIN);
443
444/**
445 * It is possible to define this in wp-config.php
446 * @since 2.5.0
447 */
448if ( !defined( 'AUTOSAVE_INTERVAL' ) )
449 define( 'AUTOSAVE_INTERVAL', 60 );
450
451
452require (ABSPATH . WPINC . '/vars.php');
453
454// Check for hacks file if the option is enabled
455if (get_option('hack_file')) {
456 if (file_exists(ABSPATH . 'my-hacks.php'))
457 require(ABSPATH . 'my-hacks.php');
458}
459
460if ( get_option('active_plugins') && !defined('WP_INSTALLING') ) {
461 $current_plugins = get_option('active_plugins');
462 if ( is_array($current_plugins) ) {
463 foreach ($current_plugins as $plugin) {
464 if ( '' != $plugin && 0 == validate_file($plugin) && file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
465 include_once(WP_PLUGIN_DIR . '/' . $plugin);
466 }
467 }
468}
469
470require (ABSPATH . WPINC . '/pluggable.php');
471
472/*
473 * In most cases the default internal encoding is latin1, which is of no use,
474 * since we want to use the mb_ functions for utf-8 strings
475 */
476if (function_exists('mb_internal_encoding')) {
477 if (!@mb_internal_encoding(get_option('blog_charset')))
478 mb_internal_encoding('UTF-8');
479}
480
481
482if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
483 wp_cache_postload();
484
485do_action('plugins_loaded');
486
487$default_constants = array( 'WP_POST_REVISIONS' => true );
488foreach ( $default_constants as $c => $v )
489 @define( $c, $v ); // will fail if the constant is already defined
490unset($default_constants, $c, $v);
491
492// If already slashed, strip.
493if ( get_magic_quotes_gpc() ) {
494 $_GET = stripslashes_deep($_GET );
495 $_POST = stripslashes_deep($_POST );
496 $_COOKIE = stripslashes_deep($_COOKIE);
497}
498
499// Escape with wpdb.
500$_GET = add_magic_quotes($_GET );
501$_POST = add_magic_quotes($_POST );
502$_COOKIE = add_magic_quotes($_COOKIE);
503$_SERVER = add_magic_quotes($_SERVER);
504
505do_action('sanitize_comment_cookies');
506
507/**
508 * WordPress Query object
509 * @global object $wp_the_query
510 * @since 2.0.0
511 */
512$wp_the_query = new WP_Query();
513
514/**
515 * Holds the reference to @see $wp_the_query
516 * Use this global for WordPress queries
517 * @global object $wp_query
518 * @since 1.5.0
519 */
520$wp_query =& $wp_the_query;
521
522/**
523 * Holds the WordPress Rewrite object for creating pretty URLs
524 * @global object $wp_rewrite
525 * @since 1.5.0
526 */
527$wp_rewrite = new WP_Rewrite();
528
529/**
530 * WordPress Object
531 * @global object $wp
532 * @since 2.0.0
533 */
534$wp = new WP();
535
536do_action('setup_theme');
537
538/**
539 * Web Path to the current active template directory
540 * @since 1.5.0
541 */
542define('TEMPLATEPATH', get_template_directory());
543
544/**
545 * Web Path to the current active template stylesheet directory
546 * @since 2.1.0
547 */
548define('STYLESHEETPATH', get_stylesheet_directory());
549
550// Load the default text localization domain.
551load_default_textdomain();
552
553/**
554 * The locale of the blog
555 * @since 1.5.0
556 */
557$locale = get_locale();
558$locale_file = WP_LANG_DIR . "/$locale.php";
559if ( is_readable($locale_file) )
560 require_once($locale_file);
561
562// Pull in locale data after loading text domain.
563require_once(ABSPATH . WPINC . '/locale.php');
564
565/**
566 * WordPress Locale object for loading locale domain date and various strings.
567 * @global object $wp_locale
568 * @since 2.1.0
569 */
570$wp_locale = new WP_Locale();
571
572// Load functions for active theme.
573if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
574 include(STYLESHEETPATH . '/functions.php');
575if ( file_exists(TEMPLATEPATH . '/functions.php') )
576 include(TEMPLATEPATH . '/functions.php');
577
578/**
579 * Runs just before PHP shuts down execution.
580 *
581 * @access private
582 * @since 1.2.0
583 */
584function shutdown_action_hook() {
585 do_action('shutdown');
586 wp_cache_close();
587}
588register_shutdown_function('shutdown_action_hook');
589
590$wp->init(); // Sets up current user.
591
592// Everything is loaded and initialized.
593do_action('init');
594
595?>