wp/wp-includes/load.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * These functions are needed to load WordPress.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @internal This file must be parsable by PHP4.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * Turn register globals off.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    13
 * @since 2.1.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    15
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
 * @return null Will return null if register_globals PHP directive was disabled.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
function wp_unregister_GLOBALS() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	if ( !ini_get( 'register_globals' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	if ( isset( $_REQUEST['GLOBALS'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		die( 'GLOBALS overwrite attempt detected' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	// Variables that shouldn't be unset
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
	foreach ( $input as $k => $v )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
			unset( $GLOBALS[$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
 * Fix `$_SERVER` variables for various setups.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
 * @global string $PHP_SELF The filename of the currently executing script,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
 *                          relative to the document root.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
function wp_fix_server_vars() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	global $PHP_SELF;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	$default_server_values = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
		'SERVER_SOFTWARE' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		'REQUEST_URI' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	$_SERVER = array_merge( $default_server_values, $_SERVER );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
	// Fix for IIS when running with PHP ISAPI
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    55
	if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
		// IIS Mod-Rewrite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
		if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		// IIS Isapi_Rewrite
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
		elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
			// Use ORIG_PATH_INFO if there is no PATH_INFO
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
			if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
				$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
			// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
			if ( isset( $_SERVER['PATH_INFO'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
				if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
					$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
					$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
			// Append the query string if it exists and isn't null
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
	// Fix for Dreamhost and other PHP as CGI hosts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
		unset( $_SERVER['PATH_INFO'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
	// Fix empty PHP_SELF
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
	$PHP_SELF = $_SERVER['PHP_SELF'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
	if ( empty( $PHP_SELF ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
 * Check for the required PHP version, and the MySQL extension or
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   100
 * a database drop-in.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
 * Dies if requirements are not met.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   107
 * @global string $required_php_version The required PHP version string.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
 * @global string $wp_version           The WordPress version string.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
function wp_check_php_mysql_versions() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
	global $required_php_version, $wp_version;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
	$php_version = phpversion();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
	if ( version_compare( $required_php_version, $php_version, '>' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
		wp_load_translations_early();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   116
		header( 'Content-Type: text/html; charset=utf-8' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
		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 ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   120
	if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
		wp_load_translations_early();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
		 header( 'Content-Type: text/html; charset=utf-8' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
		die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
 * Don't load all of WordPress when handling a favicon.ico request.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   129
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
 * Instead, send the headers for a zero-length favicon and bail.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
function wp_favicon_request() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
	if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		header('Content-Type: image/vnd.microsoft.icon');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
		header('Content-Length: 0');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   143
 * Die with a maintenance message when conditions are met.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
 * Checks for a file in the WordPress root directory named ".maintenance".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 * This file will contain the variable $upgrading, set to the time the file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
 * was created. If the file was created less than 10 minutes ago, WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 * enters maintenance mode and displays a message.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
 * The default message can be replaced by using a drop-in (maintenance.php in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
 * the wp-content directory).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
 * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
function wp_maintenance() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
	if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
	global $upgrading;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	include( ABSPATH . '.maintenance' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
	// If the $upgrading timestamp is older than 10 minutes, don't die.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	if ( ( time() - $upgrading ) >= 600 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		require_once( WP_CONTENT_DIR . '/maintenance.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
		die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
	wp_load_translations_early();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
	$protocol = $_SERVER["SERVER_PROTOCOL"];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
	if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
		$protocol = 'HTTP/1.0';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
	header( "$protocol 503 Service Unavailable", true, 503 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
	header( 'Content-Type: text/html; charset=utf-8' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
	header( 'Retry-After: 600' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
	<!DOCTYPE html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
	<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
	<head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
		<title><?php _e( 'Maintenance' ); ?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	</head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
	<body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		<h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
	</body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	</html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
 * Start the WordPress micro-timer.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   201
 * @since 0.71
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
 * @global float $timestart Unix timestamp set at the beginning of the page load.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
 * @see timer_stop()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
 * @return bool Always returns true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
function timer_start() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
	global $timestart;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	$timestart = microtime( true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   216
 * Retrieve or display the time from the page start to when function is called.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
 * @since 0.71
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   219
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   220
 * @global float   $timestart Seconds from when timer_start() is called.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   221
 * @global float   $timeend   Seconds from when function is called.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   223
 * @param int|bool $display   Whether to echo or return the results. Accepts 0|false for return,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   224
 *                            1|true for echo. Default 0|false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
 * @param int      $precision The number of digits from the right of the decimal to display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
 *                            Default 3.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
 * @return string The "second.microsecond" finished time calculation. The number is formatted
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
 *                for human consumption, both localized and rounded.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
function timer_stop( $display = 0, $precision = 3 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
	global $timestart, $timeend;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
	$timeend = microtime( true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
	$timetotal = $timeend - $timestart;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
	$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
	if ( $display )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
		echo $r;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
	return $r;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   241
 * Set PHP error reporting based on WordPress debug settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   242
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   243
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   244
 * All three can be defined in wp-config.php, and by default are set to false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   246
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   247
 * display internal notices: when a deprecated WordPress function, function
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   248
 * argument, or file is used. Deprecated code may be removed from a later
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
 * version.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
 * in their development environments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
 * is true.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   257
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   258
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   259
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   260
 * as false will force errors to be hidden.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   262
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   263
 * directory.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
 * Errors are never displayed for XML-RPC requests.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   267
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
function wp_debug_mode() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
	if ( WP_DEBUG ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
		error_reporting( E_ALL );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		if ( WP_DEBUG_DISPLAY )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
			ini_set( 'display_errors', 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		elseif ( null !== WP_DEBUG_DISPLAY )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
			ini_set( 'display_errors', 0 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
		if ( WP_DEBUG_LOG ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
			ini_set( 'log_errors', 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
			ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		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 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
	if ( defined( 'XMLRPC_REQUEST' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
		ini_set( 'display_errors', 0 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   291
 * Set the location of the language directory.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   293
 * To set directory manually, define the `WP_LANG_DIR` constant
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   294
 * in wp-config.php.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   296
 * If the language directory exists within `WP_CONTENT_DIR`, it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
 * is used. Otherwise the language directory is assumed to live
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   298
 * in `WPINC`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
function wp_set_lang_dir() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
	if ( !defined( 'WP_LANG_DIR' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
		if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
			 * Server path of the language directory.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   308
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   309
			 * No leading slash, no trailing slash, full path, not relative to ABSPATH
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   310
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
			 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
			define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
			if ( !defined( 'LANGDIR' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
				// Old static relative path maintained for limited backwards compatibility - won't work in some cases
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
				define( 'LANGDIR', 'wp-content/languages' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
		} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
			 * Server path of the language directory.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
			 * No leading slash, no trailing slash, full path, not relative to `ABSPATH`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   323
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   324
			 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   325
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   326
			define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
			if ( !defined( 'LANGDIR' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
				// Old relative path maintained for backwards compatibility
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
				define( 'LANGDIR', WPINC . '/languages' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   336
 * Load the database class file and instantiate the `$wpdb` global.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
 * @since 2.5.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   340
 * @global wpdb $wpdb The WordPress database class.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
function require_wp_db() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
	require_once( ABSPATH . WPINC . '/wp-db.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
		require_once( WP_CONTENT_DIR . '/db.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
	if ( isset( $wpdb ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   356
 * Set the database table prefix and the format specifiers for database
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
 * table columns.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   359
 * Columns not listed here default to `%s`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   361
 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   362
 * @access private
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
 * @global wpdb   $wpdb         The WordPress database class.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
 * @global string $table_prefix The database table prefix.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
function wp_set_wpdb_vars() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	global $wpdb, $table_prefix;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
	if ( !empty( $wpdb->error ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
		dead_db();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
		'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
		'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
		// multisite:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
		'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
	$prefix = $wpdb->set_prefix( $table_prefix );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
	if ( is_wp_error( $prefix ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
		wp_load_translations_early();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
		wp_die( __( '<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
 * Access/Modify private global variable `$_wp_using_ext_object_cache`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   391
 * Toggle `$_wp_using_ext_object_cache` on and off without directly
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
 * touching global.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   396
 * @param bool $using Whether external object cache is being used.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
 * @return bool The current 'using' setting.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
function wp_using_ext_object_cache( $using = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
	global $_wp_using_ext_object_cache;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
	$current_using = $_wp_using_ext_object_cache;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
	if ( null !== $using )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
		$_wp_using_ext_object_cache = $using;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
	return $current_using;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   408
 * Start the WordPress object cache.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
 * If an object-cache.php file exists in the wp-content directory,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
 * it uses that drop-in as an external object cache.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
 * @global int $blog_id Blog ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
function wp_start_object_cache() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
	global $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
	$first_init = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
 	if ( ! function_exists( 'wp_cache_init' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
		if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
			require_once ( WP_CONTENT_DIR . '/object-cache.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
			if ( function_exists( 'wp_cache_init' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
				wp_using_ext_object_cache( true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
		$first_init = true;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   430
	} elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   431
		/*
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   432
		 * Sometimes advanced-cache.php can load object-cache.php before
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   433
		 * it is loaded here. This breaks the function_exists check above
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   434
		 * and can result in `$_wp_using_ext_object_cache` being set
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   435
		 * incorrectly. Double check if an external cache exists.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   436
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
		wp_using_ext_object_cache( true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
	if ( ! wp_using_ext_object_cache() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
		require_once ( ABSPATH . WPINC . '/cache.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
	/*
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   444
	 * If cache supports reset, reset instead of init if already
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   445
	 * initialized. Reset signals to the cache that global IDs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   446
	 * have changed and it may need to update keys and cleanup caches.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   447
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
	if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
		wp_cache_switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
	elseif ( function_exists( 'wp_cache_init' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
		wp_cache_init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   454
		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' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
		wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   460
 * Redirect to the installer if WordPress is not installed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   462
 * Dies with an error message when Multisite is enabled.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   464
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
function wp_not_installed() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
	if ( is_multisite() ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   469
		if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
			nocache_headers();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
			wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   473
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   474
	} elseif ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   475
		nocache_headers();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   476
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
		require( ABSPATH . WPINC . '/kses.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		require( ABSPATH . WPINC . '/pluggable.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
		require( ABSPATH . WPINC . '/formatting.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
		$link = wp_guess_url() . '/wp-admin/install.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
		wp_redirect( $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
		die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   489
 * Retrieve an array of must-use plugin files.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   491
 * The default directory is wp-content/mu-plugins. To change the default
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   492
 * directory manually, define `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL`
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
 * in wp-config.php.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   495
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   497
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   498
 * @return array Files to include.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
function wp_get_mu_plugins() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
	$mu_plugins = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
	if ( !is_dir( WPMU_PLUGIN_DIR ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
		return $mu_plugins;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
	if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
		return $mu_plugins;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
	while ( ( $plugin = readdir( $dh ) ) !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
		if ( substr( $plugin, -4 ) == '.php' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
			$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
	closedir( $dh );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
	sort( $mu_plugins );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
	return $mu_plugins;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   517
 * Retrieve an array of active and valid plugin files.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   519
 * While upgrading or installing WordPress, no plugins are returned.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   520
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   521
 * The default directory is wp-content/plugins. To change the default
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   522
 * directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL`
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
 * in wp-config.php.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   525
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   527
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   528
 * @return array Files.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
function wp_get_active_and_valid_plugins() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
	$plugins = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
	$active_plugins = (array) get_option( 'active_plugins', array() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
	// Check for hacks file if the option is enabled
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
	if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
		_deprecated_file( 'my-hacks.php', '1.5' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
		array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
	if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
		return $plugins;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
	$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
	foreach ( $active_plugins as $plugin ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		if ( ! validate_file( $plugin ) // $plugin must validate as file
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
			&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
			// not already included as a network plugin
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
			&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
			)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
	return $plugins;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   558
 * Set internal encoding.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   560
 * In most cases the default internal encoding is latin1, which is
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   561
 * of no use, since we want to use the `mb_` functions for `utf-8` strings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   563
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
function wp_set_internal_encoding() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
	if ( function_exists( 'mb_internal_encoding' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
		$charset = get_option( 'blog_charset' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
		if ( ! $charset || ! @mb_internal_encoding( $charset ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
			mb_internal_encoding( 'UTF-8' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   575
 * Add magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   577
 * Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   578
 * `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   580
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
function wp_magic_quotes() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
	// If already slashed, strip.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
	if ( get_magic_quotes_gpc() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
		$_GET    = stripslashes_deep( $_GET    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
		$_POST   = stripslashes_deep( $_POST   );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
		$_COOKIE = stripslashes_deep( $_COOKIE );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
	// Escape with wpdb.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
	$_GET    = add_magic_quotes( $_GET    );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
	$_POST   = add_magic_quotes( $_POST   );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
	$_COOKIE = add_magic_quotes( $_COOKIE );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
	$_SERVER = add_magic_quotes( $_SERVER );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
	// Force REQUEST to be GET + POST.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
	$_REQUEST = array_merge( $_GET, $_POST );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
 * Runs just before PHP shuts down execution.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
 * @since 1.2.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
function shutdown_action_hook() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
	 * Fires just before PHP shuts down execution.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
	 * @since 1.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
	do_action( 'shutdown' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   614
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
	wp_cache_close();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
 * Copy an object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
 * @since 2.7.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   622
 * @deprecated 3.2.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   624
 * @param object $object The object to clone.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   625
 * @return object The cloned object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
function wp_clone( $object ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
	// Use parens for clone to accommodate PHP 4. See #17880
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
	return clone( $object );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
 * Whether the current request is for an administrative interface page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
 * Does not check if the user is an administrator; {@see current_user_can()}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
 * for checking roles and capabilities.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
 * @since 1.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
 * @return bool True if inside WordPress administration interface, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
function is_admin() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
	if ( isset( $GLOBALS['current_screen'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
		return $GLOBALS['current_screen']->in_admin();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
	elseif ( defined( 'WP_ADMIN' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
		return WP_ADMIN;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
 * Whether the current request is for a site's admininstrative interface.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
 * e.g. `/wp-admin/`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   655
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   656
 * Does not check if the user is an administrator; {@see current_user_can()}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   657
 * for checking roles and capabilities.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   661
 * @return bool True if inside WordPress blog administration pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
function is_blog_admin() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
	if ( isset( $GLOBALS['current_screen'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
		return $GLOBALS['current_screen']->in_admin( 'site' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
	elseif ( defined( 'WP_BLOG_ADMIN' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
		return WP_BLOG_ADMIN;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   673
 * Whether the current request is for the network administrative interface.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   675
 * e.g. `/wp-admin/network/`
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   676
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   677
 * Does not check if the user is an administrator; {@see current_user_can()}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   678
 * for checking roles and capabilities.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
 * @return bool True if inside WordPress network administration pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
function is_network_admin() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
	if ( isset( $GLOBALS['current_screen'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
		return $GLOBALS['current_screen']->in_admin( 'network' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
	elseif ( defined( 'WP_NETWORK_ADMIN' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
		return WP_NETWORK_ADMIN;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   694
 * Whether the current request is for a user admin screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   695
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   696
 * e.g. `/wp-admin/user/`
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   698
 * Does not inform on whether the user is an admin! Use capability
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   699
 * checks to tell if the user should be accessing a section or not
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   700
 * {@see current_user_can()}.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
 * @return bool True if inside WordPress user administration pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
function is_user_admin() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
	if ( isset( $GLOBALS['current_screen'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
		return $GLOBALS['current_screen']->in_admin( 'user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
	elseif ( defined( 'WP_USER_ADMIN' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
		return WP_USER_ADMIN;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   716
 * If Multisite is enabled.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   720
 * @return bool True if Multisite is enabled, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
function is_multisite() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
	if ( defined( 'MULTISITE' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
		return MULTISITE;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
	if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
 * Retrieve the current blog ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
 * @return int Blog id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
function get_current_blog_id() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
	global $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
	return absint($blog_id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   745
 * Attempt an early load of translations.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   747
 * Used for errors encountered during the initial loading process, before
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   748
 * the locale has been properly detected and loaded.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   750
 * Designed for unusual load sequences (like setup-config.php) or for when
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   751
 * the script will then terminate with an error, otherwise there is a risk
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   752
 * that a file can be double-included.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
 * @access private
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   756
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   757
 * @global $wp_locale The WordPress date and time locale object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
function wp_load_translations_early() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
	global $text_direction, $wp_locale;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
	static $loaded = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
	if ( $loaded )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
	$loaded = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
	if ( function_exists( 'did_action' ) && did_action( 'init' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
	// We need $wp_local_package
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
	require ABSPATH . WPINC . '/version.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
	// Translation and localization
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
	require_once ABSPATH . WPINC . '/pomo/mo.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
	require_once ABSPATH . WPINC . '/l10n.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
	require_once ABSPATH . WPINC . '/locale.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
	// General libraries
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
	require_once ABSPATH . WPINC . '/plugin.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
	$locales = $locations = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
	while ( true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
		if ( defined( 'WPLANG' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
			if ( '' == WPLANG )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
			$locales[] = WPLANG;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
		if ( isset( $wp_local_package ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
			$locales[] = $wp_local_package;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
		if ( ! $locales )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
		if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
			$locations[] = WP_LANG_DIR;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
		if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
			$locations[] = WP_CONTENT_DIR . '/languages';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
		if ( @is_dir( ABSPATH . 'wp-content/languages' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
			$locations[] = ABSPATH . 'wp-content/languages';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
		if ( @is_dir( ABSPATH . WPINC . '/languages' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
			$locations[] = ABSPATH . WPINC . '/languages';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
		if ( ! $locations )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
		$locations = array_unique( $locations );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
		foreach ( $locales as $locale ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
			foreach ( $locations as $location ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
				if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
					load_textdomain( 'default', $location . '/' . $locale . '.mo' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
					if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
						load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
					break 2;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
	$wp_locale = new WP_Locale();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
}