3 * These functions are needed to load WordPress.
5 * @internal This file must be parsable by PHP4.
11 * Return the HTTP protocol sent by the server.
15 * @return string The HTTP protocol. Default: HTTP/1.0.
17 function wp_get_server_protocol() {
18 $protocol = $_SERVER['SERVER_PROTOCOL'];
19 if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
20 $protocol = 'HTTP/1.0';
26 * Turn register globals off.
31 function wp_unregister_GLOBALS() {
32 if ( !ini_get( 'register_globals' ) )
35 if ( isset( $_REQUEST['GLOBALS'] ) )
36 die( 'GLOBALS overwrite attempt detected' );
38 // Variables that shouldn't be unset
39 $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
41 $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
42 foreach ( $input as $k => $v )
43 if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
44 unset( $GLOBALS[$k] );
49 * Fix `$_SERVER` variables for various setups.
54 * @global string $PHP_SELF The filename of the currently executing script,
55 * relative to the document root.
57 function wp_fix_server_vars() {
60 $default_server_values = array(
61 'SERVER_SOFTWARE' => '',
65 $_SERVER = array_merge( $default_server_values, $_SERVER );
67 // Fix for IIS when running with PHP ISAPI
68 if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
71 if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
72 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
75 elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
76 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
78 // Use ORIG_PATH_INFO if there is no PATH_INFO
79 if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
80 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
82 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
83 if ( isset( $_SERVER['PATH_INFO'] ) ) {
84 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
85 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
87 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
90 // Append the query string if it exists and isn't null
91 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
92 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
97 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
98 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
99 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
101 // Fix for Dreamhost and other PHP as CGI hosts
102 if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
103 unset( $_SERVER['PATH_INFO'] );
105 // Fix empty PHP_SELF
106 $PHP_SELF = $_SERVER['PHP_SELF'];
107 if ( empty( $PHP_SELF ) )
108 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
112 * Check for the required PHP version, and the MySQL extension or
113 * a database drop-in.
115 * Dies if requirements are not met.
120 * @global string $required_php_version The required PHP version string.
121 * @global string $wp_version The WordPress version string.
123 function wp_check_php_mysql_versions() {
124 global $required_php_version, $wp_version;
125 $php_version = phpversion();
127 if ( version_compare( $required_php_version, $php_version, '>' ) ) {
128 wp_load_translations_early();
130 $protocol = wp_get_server_protocol();
131 header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
132 header( 'Content-Type: text/html; charset=utf-8' );
133 die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) );
136 if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
137 wp_load_translations_early();
139 $protocol = wp_get_server_protocol();
140 header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
141 header( 'Content-Type: text/html; charset=utf-8' );
142 die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) );
147 * Don't load all of WordPress when handling a favicon.ico request.
149 * Instead, send the headers for a zero-length favicon and bail.
153 function wp_favicon_request() {
154 if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
155 header('Content-Type: image/vnd.microsoft.icon');
161 * Die with a maintenance message when conditions are met.
163 * Checks for a file in the WordPress root directory named ".maintenance".
164 * This file will contain the variable $upgrading, set to the time the file
165 * was created. If the file was created less than 10 minutes ago, WordPress
166 * enters maintenance mode and displays a message.
168 * The default message can be replaced by using a drop-in (maintenance.php in
169 * the wp-content directory).
174 * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
176 function wp_maintenance() {
177 if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() )
182 include( ABSPATH . '.maintenance' );
183 // If the $upgrading timestamp is older than 10 minutes, don't die.
184 if ( ( time() - $upgrading ) >= 600 )
187 if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
188 require_once( WP_CONTENT_DIR . '/maintenance.php' );
192 wp_load_translations_early();
194 $protocol = wp_get_server_protocol();
195 header( "$protocol 503 Service Unavailable", true, 503 );
196 header( 'Content-Type: text/html; charset=utf-8' );
197 header( 'Retry-After: 600' );
200 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
202 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
203 <title><?php _e( 'Maintenance' ); ?></title>
207 <h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1>
215 * Start the WordPress micro-timer.
220 * @global float $timestart Unix timestamp set at the beginning of the page load.
223 * @return bool Always returns true.
225 function timer_start() {
227 $timestart = microtime( true );
232 * Retrieve or display the time from the page start to when function is called.
236 * @global float $timestart Seconds from when timer_start() is called.
237 * @global float $timeend Seconds from when function is called.
239 * @param int|bool $display Whether to echo or return the results. Accepts 0|false for return,
240 * 1|true for echo. Default 0|false.
241 * @param int $precision The number of digits from the right of the decimal to display.
243 * @return string The "second.microsecond" finished time calculation. The number is formatted
244 * for human consumption, both localized and rounded.
246 function timer_stop( $display = 0, $precision = 3 ) {
247 global $timestart, $timeend;
248 $timeend = microtime( true );
249 $timetotal = $timeend - $timestart;
250 $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
257 * Set PHP error reporting based on WordPress debug settings.
259 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
260 * All three can be defined in wp-config.php, and by default are set to false.
262 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
263 * display internal notices: when a deprecated WordPress function, function
264 * argument, or file is used. Deprecated code may be removed from a later
267 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
268 * in their development environments.
270 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
273 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
274 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
275 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
276 * as false will force errors to be hidden.
278 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
281 * Errors are never displayed for XML-RPC requests.
286 function wp_debug_mode() {
288 error_reporting( E_ALL );
290 if ( WP_DEBUG_DISPLAY )
291 ini_set( 'display_errors', 1 );
292 elseif ( null !== WP_DEBUG_DISPLAY )
293 ini_set( 'display_errors', 0 );
295 if ( WP_DEBUG_LOG ) {
296 ini_set( 'log_errors', 1 );
297 ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
300 error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
302 if ( defined( 'XMLRPC_REQUEST' ) )
303 ini_set( 'display_errors', 0 );
307 * Set the location of the language directory.
309 * To set directory manually, define the `WP_LANG_DIR` constant
312 * If the language directory exists within `WP_CONTENT_DIR`, it
313 * is used. Otherwise the language directory is assumed to live
319 function wp_set_lang_dir() {
320 if ( !defined( 'WP_LANG_DIR' ) ) {
321 if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) {
323 * Server path of the language directory.
325 * No leading slash, no trailing slash, full path, not relative to ABSPATH
329 define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
330 if ( !defined( 'LANGDIR' ) ) {
331 // Old static relative path maintained for limited backwards compatibility - won't work in some cases
332 define( 'LANGDIR', 'wp-content/languages' );
336 * Server path of the language directory.
338 * No leading slash, no trailing slash, full path, not relative to `ABSPATH`.
342 define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );
343 if ( !defined( 'LANGDIR' ) ) {
344 // Old relative path maintained for backwards compatibility
345 define( 'LANGDIR', WPINC . '/languages' );
352 * Load the database class file and instantiate the `$wpdb` global.
356 * @global wpdb $wpdb The WordPress database class.
358 function require_wp_db() {
361 require_once( ABSPATH . WPINC . '/wp-db.php' );
362 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
363 require_once( WP_CONTENT_DIR . '/db.php' );
365 if ( isset( $wpdb ) )
368 $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
372 * Set the database table prefix and the format specifiers for database
375 * Columns not listed here default to `%s`.
380 * @global wpdb $wpdb The WordPress database class.
381 * @global string $table_prefix The database table prefix.
383 function wp_set_wpdb_vars() {
384 global $wpdb, $table_prefix;
385 if ( !empty( $wpdb->error ) )
388 $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
389 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
390 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
391 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
393 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
396 $prefix = $wpdb->set_prefix( $table_prefix );
398 if ( is_wp_error( $prefix ) ) {
399 wp_load_translations_early();
401 /* translators: 1: $table_prefix 2: wp-config.php */
402 sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ),
403 '<code>$table_prefix</code>',
404 '<code>wp-config.php</code>'
411 * Toggle `$_wp_using_ext_object_cache` on and off without directly
416 * @global bool $_wp_using_ext_object_cache
418 * @param bool $using Whether external object cache is being used.
419 * @return bool The current 'using' setting.
421 function wp_using_ext_object_cache( $using = null ) {
422 global $_wp_using_ext_object_cache;
423 $current_using = $_wp_using_ext_object_cache;
424 if ( null !== $using )
425 $_wp_using_ext_object_cache = $using;
426 return $current_using;
430 * Start the WordPress object cache.
432 * If an object-cache.php file exists in the wp-content directory,
433 * it uses that drop-in as an external object cache.
438 * @global int $blog_id Blog ID.
440 function wp_start_object_cache() {
444 if ( ! function_exists( 'wp_cache_init' ) ) {
445 if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
446 require_once ( WP_CONTENT_DIR . '/object-cache.php' );
447 if ( function_exists( 'wp_cache_init' ) )
448 wp_using_ext_object_cache( true );
452 } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
454 * Sometimes advanced-cache.php can load object-cache.php before
455 * it is loaded here. This breaks the function_exists check above
456 * and can result in `$_wp_using_ext_object_cache` being set
457 * incorrectly. Double check if an external cache exists.
459 wp_using_ext_object_cache( true );
462 if ( ! wp_using_ext_object_cache() )
463 require_once ( ABSPATH . WPINC . '/cache.php' );
466 * If cache supports reset, reset instead of init if already
467 * initialized. Reset signals to the cache that global IDs
468 * have changed and it may need to update keys and cleanup caches.
470 if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
471 wp_cache_switch_to_blog( $blog_id );
472 elseif ( function_exists( 'wp_cache_init' ) )
475 if ( function_exists( 'wp_cache_add_global_groups' ) ) {
476 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) );
477 wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
482 * Redirect to the installer if WordPress is not installed.
484 * Dies with an error message when Multisite is enabled.
489 function wp_not_installed() {
490 if ( is_multisite() ) {
491 if ( ! is_blog_installed() && ! wp_installing() ) {
494 wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
496 } elseif ( ! is_blog_installed() && ! wp_installing() ) {
499 require( ABSPATH . WPINC . '/kses.php' );
500 require( ABSPATH . WPINC . '/pluggable.php' );
501 require( ABSPATH . WPINC . '/formatting.php' );
503 $link = wp_guess_url() . '/wp-admin/install.php';
505 wp_redirect( $link );
511 * Retrieve an array of must-use plugin files.
513 * The default directory is wp-content/mu-plugins. To change the default
514 * directory manually, define `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL`
520 * @return array Files to include.
522 function wp_get_mu_plugins() {
523 $mu_plugins = array();
524 if ( !is_dir( WPMU_PLUGIN_DIR ) )
526 if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
528 while ( ( $plugin = readdir( $dh ) ) !== false ) {
529 if ( substr( $plugin, -4 ) == '.php' )
530 $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
539 * Retrieve an array of active and valid plugin files.
541 * While upgrading or installing WordPress, no plugins are returned.
543 * The default directory is wp-content/plugins. To change the default
544 * directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL`
550 * @return array Files.
552 function wp_get_active_and_valid_plugins() {
554 $active_plugins = (array) get_option( 'active_plugins', array() );
556 // Check for hacks file if the option is enabled
557 if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
558 _deprecated_file( 'my-hacks.php', '1.5' );
559 array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
562 if ( empty( $active_plugins ) || wp_installing() )
565 $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
567 foreach ( $active_plugins as $plugin ) {
568 if ( ! validate_file( $plugin ) // $plugin must validate as file
569 && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
570 && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
571 // not already included as a network plugin
572 && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
574 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
580 * Set internal encoding.
582 * In most cases the default internal encoding is latin1, which is
583 * of no use, since we want to use the `mb_` functions for `utf-8` strings.
588 function wp_set_internal_encoding() {
589 if ( function_exists( 'mb_internal_encoding' ) ) {
590 $charset = get_option( 'blog_charset' );
591 if ( ! $charset || ! @mb_internal_encoding( $charset ) )
592 mb_internal_encoding( 'UTF-8' );
597 * Add magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`.
599 * Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`,
600 * `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly.
605 function wp_magic_quotes() {
606 // If already slashed, strip.
607 if ( get_magic_quotes_gpc() ) {
608 $_GET = stripslashes_deep( $_GET );
609 $_POST = stripslashes_deep( $_POST );
610 $_COOKIE = stripslashes_deep( $_COOKIE );
614 $_GET = add_magic_quotes( $_GET );
615 $_POST = add_magic_quotes( $_POST );
616 $_COOKIE = add_magic_quotes( $_COOKIE );
617 $_SERVER = add_magic_quotes( $_SERVER );
619 // Force REQUEST to be GET + POST.
620 $_REQUEST = array_merge( $_GET, $_POST );
624 * Runs just before PHP shuts down execution.
629 function shutdown_action_hook() {
631 * Fires just before PHP shuts down execution.
635 do_action( 'shutdown' );
646 * @param object $object The object to clone.
647 * @return object The cloned object.
649 function wp_clone( $object ) {
650 // Use parens for clone to accommodate PHP 4. See #17880
651 return clone( $object );
655 * Whether the current request is for an administrative interface page.
657 * Does not check if the user is an administrator; {@see current_user_can()}
658 * for checking roles and capabilities.
662 * @global WP_Screen $current_screen
664 * @return bool True if inside WordPress administration interface, false otherwise.
666 function is_admin() {
667 if ( isset( $GLOBALS['current_screen'] ) )
668 return $GLOBALS['current_screen']->in_admin();
669 elseif ( defined( 'WP_ADMIN' ) )
676 * Whether the current request is for a site's admininstrative interface.
680 * Does not check if the user is an administrator; {@see current_user_can()}
681 * for checking roles and capabilities.
685 * @global WP_Screen $current_screen
687 * @return bool True if inside WordPress blog administration pages.
689 function is_blog_admin() {
690 if ( isset( $GLOBALS['current_screen'] ) )
691 return $GLOBALS['current_screen']->in_admin( 'site' );
692 elseif ( defined( 'WP_BLOG_ADMIN' ) )
693 return WP_BLOG_ADMIN;
699 * Whether the current request is for the network administrative interface.
701 * e.g. `/wp-admin/network/`
703 * Does not check if the user is an administrator; {@see current_user_can()}
704 * for checking roles and capabilities.
708 * @global WP_Screen $current_screen
710 * @return bool True if inside WordPress network administration pages.
712 function is_network_admin() {
713 if ( isset( $GLOBALS['current_screen'] ) )
714 return $GLOBALS['current_screen']->in_admin( 'network' );
715 elseif ( defined( 'WP_NETWORK_ADMIN' ) )
716 return WP_NETWORK_ADMIN;
722 * Whether the current request is for a user admin screen.
724 * e.g. `/wp-admin/user/`
726 * Does not inform on whether the user is an admin! Use capability
727 * checks to tell if the user should be accessing a section or not
728 * {@see current_user_can()}.
732 * @global WP_Screen $current_screen
734 * @return bool True if inside WordPress user administration pages.
736 function is_user_admin() {
737 if ( isset( $GLOBALS['current_screen'] ) )
738 return $GLOBALS['current_screen']->in_admin( 'user' );
739 elseif ( defined( 'WP_USER_ADMIN' ) )
740 return WP_USER_ADMIN;
746 * If Multisite is enabled.
750 * @return bool True if Multisite is enabled, false otherwise.
752 function is_multisite() {
753 if ( defined( 'MULTISITE' ) )
756 if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
763 * Retrieve the current blog ID.
767 * @global int $blog_id
769 * @return int Blog id
771 function get_current_blog_id() {
773 return absint($blog_id);
777 * Attempt an early load of translations.
779 * Used for errors encountered during the initial loading process, before
780 * the locale has been properly detected and loaded.
782 * Designed for unusual load sequences (like setup-config.php) or for when
783 * the script will then terminate with an error, otherwise there is a risk
784 * that a file can be double-included.
789 * @global string $text_direction
790 * @global WP_Locale $wp_locale The WordPress date and time locale object.
792 * @staticvar bool $loaded
794 function wp_load_translations_early() {
795 global $text_direction, $wp_locale;
797 static $loaded = false;
802 if ( function_exists( 'did_action' ) && did_action( 'init' ) )
805 // We need $wp_local_package
806 require ABSPATH . WPINC . '/version.php';
808 // Translation and localization
809 require_once ABSPATH . WPINC . '/pomo/mo.php';
810 require_once ABSPATH . WPINC . '/l10n.php';
811 require_once ABSPATH . WPINC . '/locale.php';
814 require_once ABSPATH . WPINC . '/plugin.php';
816 $locales = $locations = array();
819 if ( defined( 'WPLANG' ) ) {
825 if ( isset( $wp_local_package ) )
826 $locales[] = $wp_local_package;
831 if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) )
832 $locations[] = WP_LANG_DIR;
834 if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) )
835 $locations[] = WP_CONTENT_DIR . '/languages';
837 if ( @is_dir( ABSPATH . 'wp-content/languages' ) )
838 $locations[] = ABSPATH . 'wp-content/languages';
840 if ( @is_dir( ABSPATH . WPINC . '/languages' ) )
841 $locations[] = ABSPATH . WPINC . '/languages';
846 $locations = array_unique( $locations );
848 foreach ( $locales as $locale ) {
849 foreach ( $locations as $location ) {
850 if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
851 load_textdomain( 'default', $location . '/' . $locale . '.mo' );
852 if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) )
853 load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
862 $wp_locale = new WP_Locale();
866 * Check or set whether WordPress is in "installation" mode.
868 * If the `WP_INSTALLING` constant is defined during the bootstrap, `wp_installing()` will default to `true`.
872 * @staticvar bool $installing
874 * @param bool $is_installing Optional. True to set WP into Installing mode, false to turn Installing mode off.
875 * Omit this parameter if you only want to fetch the current status.
876 * @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will
877 * report whether WP was in installing mode prior to the change to `$is_installing`.
879 function wp_installing( $is_installing = null ) {
880 static $installing = null;
882 // Support for the `WP_INSTALLING` constant, defined before WP is loaded.
883 if ( is_null( $installing ) ) {
884 $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING;
887 if ( ! is_null( $is_installing ) ) {
888 $old_installing = $installing;
889 $installing = $is_installing;
890 return (bool) $old_installing;
893 return (bool) $installing;