wp/wp-includes/ms-deprecated.php
author ymh <ymh.work@gmail.com>
Tue, 22 Oct 2019 16:11:46 +0200
changeset 15 3d4e9c994f10
parent 9 177826044cd9
child 16 a86126ab1dd4
permissions -rw-r--r--
Upgrade jquery-ui in in-motion theme version from 1.8.14 to 1.8.22 to avoid 'a.curCSS is not a function' errors in console that caused problems with circles and navigation.
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
 * Deprecated functions from WordPress MU and the multisite feature. You shouldn't
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 * use these functions and look for the alternatives instead. The functions will be
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * removed in a later version.
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
 * @subpackage Deprecated
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
/*
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * Deprecated functions come here to die.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 * Get the "dashboard blog", the blog where users without a blog edit their profile data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 * Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    20
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
 * @deprecated 3.1.0 Use get_site()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    22
 * @see get_site()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    23
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    24
 * @return WP_Site Current site object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
function get_dashboard_blog() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    27
    _deprecated_function( __FUNCTION__, '3.1.0', 'get_site()' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
    if ( $blog = get_site_option( 'dashboard_blog' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    29
	    return get_site( $blog );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    30
    }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    32
    return get_site( get_network()->site_id );
0
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
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    36
 * Generates a random password.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    39
 * @deprecated 3.0.0 Use wp_generate_password()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
 * @see wp_generate_password()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    42
 * @param int $len Optional. The length of password to generate. Default 8.
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 generate_random_password( $len = 8 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    45
	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_generate_password()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	return wp_generate_password( $len );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 * Determine if user is a site admin.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
 * Plugins should use is_multisite() instead of checking if this function exists
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
 * to determine if multisite is enabled.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
 * This function must reside in a file included only if is_multisite() due to
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
 * legacy function_exists() checks to determine if multisite is enabled.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    58
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    59
 * @deprecated 3.0.0 Use is_super_admin()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
 * @see is_super_admin()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    62
 * @param string $user_login Optional. Username for the user to check. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
function is_site_admin( $user_login = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    65
	_deprecated_function( __FUNCTION__, '3.0.0', 'is_super_admin()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	if ( empty( $user_login ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
		$user_id = get_current_user_id();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
		if ( !$user_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
		$user = get_user_by( 'login', $user_login );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		if ( ! $user->exists() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
		$user_id = $user->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	return is_super_admin( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
if ( !function_exists( 'graceful_fail' ) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    83
 * Deprecated functionality to gracefully fail.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    84
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    85
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    86
 * @deprecated 3.0.0 Use wp_die()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
 * @see wp_die()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
function graceful_fail( $message ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    90
	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_die()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
	$message = apply_filters( 'graceful_fail', $message );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
	$message_template = apply_filters( 'graceful_fail_template',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
'<!DOCTYPE html>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
<html xmlns="http://www.w3.org/1999/xhtml"><head>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
<title>Error!</title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
<style type="text/css">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
img {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
	border: 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
body {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
text-align: center;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
.message {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
	font-size: 22px;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	width: 350px;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
	margin: auto;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
</style>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
</head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
<body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
<p class="message">%s</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
</body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
</html>' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
	die( sprintf( $message_template, $message ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   121
 * Deprecated functionality to retrieve user information.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   122
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   123
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   124
 * @deprecated 3.0.0 Use get_user_by()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
 * @see get_user_by()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   126
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   127
 * @param string $username Username.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
function get_user_details( $username ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   130
	_deprecated_function( __FUNCTION__, '3.0.0', 'get_user_by()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
	return get_user_by('login', $username);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   135
 * Deprecated functionality to clear the global post cache.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   136
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   137
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   138
 * @deprecated 3.0.0 Use clean_post_cache()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
 * @see clean_post_cache()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   140
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   141
 * @param int $post_id Post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
function clear_global_post_cache( $post_id ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   144
	_deprecated_function( __FUNCTION__, '3.0.0', 'clean_post_cache()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   148
 * Deprecated functionality to determin if the current site is the main site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   149
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   150
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   151
 * @deprecated 3.0.0 Use is_main_site()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
 * @see is_main_site()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
function is_main_blog() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   155
	_deprecated_function( __FUNCTION__, '3.0.0', 'is_main_site()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
	return is_main_site();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   160
 * Deprecated functionality to validate an email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   161
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   162
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   163
 * @deprecated 3.0.0 Use is_email()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
 * @see is_email()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   165
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   166
 * @param string $email        Email address to verify.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   167
 * @param bool   $check_domain Deprecated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   168
 * @return string|bool Either false or the valid email address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
function validate_email( $email, $check_domain = true) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   171
	_deprecated_function( __FUNCTION__, '3.0.0', 'is_email()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	return is_email( $email, $check_domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   176
 * Deprecated functionality to retrieve a list of all sites.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   177
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   178
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   179
 * @deprecated 3.0.0 Use wp_get_sites()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   180
 * @see wp_get_sites()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   181
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   182
 * @param int    $start      Optional. Offset for retrieving the blog list. Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   183
 * @param int    $num        Optional. Number of blogs to list. Default 10.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   184
 * @param string $deprecated Unused.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   187
	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_get_sites()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	global $wpdb;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   190
	$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", get_current_network_id() ), ARRAY_A );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
	$blog_list = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	foreach ( (array) $blogs as $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
		$blog_list[ $details['blog_id'] ] = $details;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
		$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   198
	if ( ! $blog_list ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		return array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   200
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
	if ( $num == 'all' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
		return array_slice( $blog_list, $start, count( $blog_list ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
		return array_slice( $blog_list, $start, $num );
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
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   210
 * Deprecated functionality to retrieve a list of the most active sites.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   211
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   212
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
 * @deprecated 3.0.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   214
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   215
 * @param int  $num     Optional. Number of activate blogs to retrieve. Default 10.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   216
 * @param bool $display Optional. Whether or not to display the most active blogs list. Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   217
 * @return array List of "most active" sites.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
function get_most_active_blogs( $num = 10, $display = true ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   220
	_deprecated_function( __FUNCTION__, '3.0.0' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
	$blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
	if ( is_array( $blogs ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		reset( $blogs );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
		$most_active = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
		$blog_list = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
		foreach ( (array) $blogs as $key => $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
			$most_active[ $details['blog_id'] ] = $details['postcount'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
		arsort( $most_active );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
		reset( $most_active );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
		$t = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
		foreach ( (array) $most_active as $key => $details ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
			$t[ $key ] = $blog_list[ $key ];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   236
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
		unset( $most_active );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
		$most_active = $t;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   241
	if ( $display ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
		if ( is_array( $most_active ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
			reset( $most_active );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
			foreach ( (array) $most_active as $key => $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
				$url = esc_url('http://' . $details['domain'] . $details['path']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
				echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
	return array_slice( $most_active, 0, $num );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
 * Redirect a user based on $_GET or $_POST arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
 * The function looks for redirect arguments in the following order:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
 * 1) $_GET['ref']
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
 * 2) $_POST['ref']
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
 * 3) $_SERVER['HTTP_REFERER']
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
 * 4) $_GET['redirect']
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
 * 5) $_POST['redirect']
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
 * 6) $url
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   264
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   265
 * @deprecated 3.3.0 Use wp_redirect()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   266
 * @see wp_redirect()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   268
 * @param string $url Optional. Redirect URL. Default empty.
0
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 wpmu_admin_do_redirect( $url = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   271
	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
	$ref = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   274
	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   275
		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   276
	} elseif ( isset( $_POST['ref'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   277
		$ref = $_POST[ 'ref' ];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   278
	} elseif ( isset( $_GET['ref'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   279
		$ref = $_GET[ 'ref' ];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   280
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	if ( $ref ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
		$ref = wpmu_admin_redirect_add_updated_param( $ref );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		wp_redirect( $ref );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   287
	if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
		wp_redirect( $_SERVER['HTTP_REFERER'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
		exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
	$url = wpmu_admin_redirect_add_updated_param( $url );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   293
	if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   294
		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   295
	} elseif ( isset( $_GET['redirect'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
		if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
	} elseif ( isset( $_POST['redirect'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
	wp_redirect( $url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
 * Adds an 'updated=true' argument to a URL.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   308
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
 * @deprecated 3.3.0 Use add_query_arg()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   310
 * @see add_query_arg()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   312
 * @param string $url Optional. Redirect URL. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
function wpmu_admin_redirect_add_updated_param( $url = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   316
	_deprecated_function( __FUNCTION__, '3.3.0', 'add_query_arg()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
	if ( strpos( $url, 'updated=true' ) === false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
		if ( strpos( $url, '?' ) === false )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
			return $url . '?updated=true';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
			return $url . '&updated=true';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
	return $url;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
 * Get a numeric user ID from either an email address or a login.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
 * A numeric string is considered to be an existing user ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
 * and is simply returned as such.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   333
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   334
 * @deprecated 3.6.0 Use get_user_by()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   335
 * @see get_user_by()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
 * @param string $string Either an email address or a login.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
 * @return int
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
function get_user_id_from_string( $string ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   341
	_deprecated_function( __FUNCTION__, '3.6.0', 'get_user_by()' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	if ( is_email( $string ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
		$user = get_user_by( 'email', $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
	elseif ( is_numeric( $string ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
		return $string;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
		$user = get_user_by( 'login', $string );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
	if ( $user )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
		return $user->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	return 0;
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
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
 * Get a full blog URL, given a domain and a path.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   358
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
 * @deprecated 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
 * @param string $domain
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
 * @param string $path
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
function get_blogaddress_by_domain( $domain, $path ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   366
	_deprecated_function( __FUNCTION__, '3.7.0' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	if ( is_subdomain_install() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		$url = "http://" . $domain.$path;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
		if ( $domain != $_SERVER['HTTP_HOST'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
			$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
			// we're not installing the main blog
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
			if ( $blogname != 'www.' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
				$url .= $blogname . '/';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
		} else { // main blog
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
			$url = 'http://' . $domain . $path;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
	return esc_url_raw( $url );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   382
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   383
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   384
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   385
 * Create an empty blog.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   386
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   387
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   388
 * @deprecated 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   389
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   390
 * @param string $domain       The new blog's domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   391
 * @param string $path         The new blog's path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   392
 * @param string $weblog_title The new blog's title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   393
 * @param int    $site_id      Optional. Defaults to 1.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   394
 * @return string|int The ID of the newly created blog
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   395
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   396
function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   397
	_deprecated_function( __FUNCTION__, '4.4.0' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   398
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   399
	if ( empty($path) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   400
		$path = '/';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   401
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   402
	// Check if the domain has been used already. We should return an error message.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   403
	if ( domain_exists($domain, $path, $site_id) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   404
		return __( '<strong>ERROR</strong>: Site URL already taken.' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   405
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   406
	// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   407
	// Need to get blog_id from wp_blogs, and create new table names.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   408
	// Must restore table names at the end of function.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   409
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   410
	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   411
		return __( '<strong>ERROR</strong>: problem creating site entry.' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   412
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   413
	switch_to_blog($blog_id);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   414
	install_blog($blog_id);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   415
	restore_current_blog();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   416
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   417
	return $blog_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   418
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   419
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   420
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   421
 * Get the admin for a domain/path combination.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   422
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   423
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   424
 * @deprecated 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   425
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   426
 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   427
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   428
 * @param string $domain Optional. Network domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   429
 * @param string $path   Optional. Network path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   430
 * @return array|false The network admins.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   431
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   432
function get_admin_users_for_domain( $domain = '', $path = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   433
	_deprecated_function( __FUNCTION__, '4.4.0' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   434
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   435
	global $wpdb;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   436
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   437
	if ( ! $domain ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   438
		$network_id = get_current_network_id();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   439
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   440
		$_networks  = get_networks( array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   441
			'fields' => 'ids',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   442
			'number' => 1,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   443
			'domain' => $domain,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   444
			'path'   => $path,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   445
		) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   446
		$network_id = ! empty( $_networks ) ? array_shift( $_networks ) : 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   447
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   448
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   449
	if ( $network_id )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   450
		return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $network_id ), ARRAY_A );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   451
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   452
	return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   453
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   454
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   455
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   456
 * Return an array of sites for a network or networks.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   457
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   458
 * @since 3.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   459
 * @deprecated 4.6.0 Use get_sites()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   460
 * @see get_sites()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   461
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   462
 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   463
 *     Array of default arguments. Optional.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   464
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   465
 *     @type int|array $network_id A network ID or array of network IDs. Set to null to retrieve sites
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   466
 *                                 from all networks. Defaults to current network ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   467
 *     @type int       $public     Retrieve public or non-public sites. Default null, for any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   468
 *     @type int       $archived   Retrieve archived or non-archived sites. Default null, for any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   469
 *     @type int       $mature     Retrieve mature or non-mature sites. Default null, for any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   470
 *     @type int       $spam       Retrieve spam or non-spam sites. Default null, for any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   471
 *     @type int       $deleted    Retrieve deleted or non-deleted sites. Default null, for any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   472
 *     @type int       $limit      Number of sites to limit the query to. Default 100.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   473
 *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   474
 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   475
 * @return array An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   476
 *               an associative array of site data arrays, each containing the site (network) ID, blog ID,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   477
 *               site domain and path, dates registered and modified, and the language ID. Also, boolean
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   478
 *               values for whether the site is public, archived, mature, spam, and/or deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   479
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   480
function wp_get_sites( $args = array() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   481
	_deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   482
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   483
	if ( wp_is_large_network() )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   484
		return array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   485
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   486
	$defaults = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   487
		'network_id' => get_current_network_id(),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   488
		'public'     => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   489
		'archived'   => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   490
		'mature'     => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   491
		'spam'       => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   492
		'deleted'    => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   493
		'limit'      => 100,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   494
		'offset'     => 0,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   495
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   496
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   497
	$args = wp_parse_args( $args, $defaults );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   498
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   499
	// Backwards compatibility
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   500
	if( is_array( $args['network_id'] ) ){
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   501
		$args['network__in'] = $args['network_id'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   502
		$args['network_id'] = null;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   503
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   504
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   505
	if( is_numeric( $args['limit'] ) ){
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   506
		$args['number'] = $args['limit'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   507
		$args['limit'] = null;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   508
	} elseif ( ! $args['limit'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   509
		$args['number'] = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   510
		$args['limit'] = null;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   511
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   512
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   513
	// Make sure count is disabled.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   514
	$args['count'] = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   515
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   516
	$_sites  = get_sites( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   517
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   518
	$results = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   519
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   520
	foreach ( $_sites as $_site ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   521
		$_site = get_site( $_site );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   522
		$results[] = $_site->to_array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   523
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   524
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   525
	return $results;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   526
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   527
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   528
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   529
 * Check whether a usermeta key has to do with the current blog.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   530
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   531
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   532
 * @deprecated 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   533
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   534
 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   535
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   536
 * @param string $key
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   537
 * @param int    $user_id Optional. Defaults to current user.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   538
 * @param int    $blog_id Optional. Defaults to current blog.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   539
 * @return bool
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   540
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   541
function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   542
	global $wpdb;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   543
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   544
	_deprecated_function( __FUNCTION__, '4.9.0' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   545
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   546
	$current_user = wp_get_current_user();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   547
	if ( $blog_id == 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   548
		$blog_id = get_current_blog_id();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   549
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   550
	$local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   551
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   552
	return isset( $current_user->$local_key );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   553
}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   554
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   555
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   556
 * Store basic site info in the blogs table.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   557
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   558
 * This function creates a row in the wp_blogs table and returns
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   559
 * the new blog's ID. It is the first step in creating a new blog.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   560
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   561
 * @since MU (3.0.0)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   562
 * @deprecated 5.1.0 Use `wp_insert_site()`
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   563
 * @see wp_insert_site()
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   564
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   565
 * @param string $domain  The domain of the new site.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   566
 * @param string $path    The path of the new site.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   567
 * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   568
 * @return int|false The ID of the new row
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   569
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   570
function insert_blog($domain, $path, $site_id) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   571
	_deprecated_function( __FUNCTION__, '5.1.0', 'wp_insert_site()' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   572
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   573
	$data = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   574
		'domain'  => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   575
		'path'    => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   576
		'site_id' => $site_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   577
	);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   578
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   579
	$site_id = wp_insert_site( $data );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   580
	if ( is_wp_error( $site_id ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   581
		return false;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   582
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   583
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   584
	clean_blog_cache( $site_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   585
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   586
	return $site_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   587
}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   588
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   589
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   590
 * Install an empty blog.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   591
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   592
 * Creates the new blog tables and options. If calling this function
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   593
 * directly, be sure to use switch_to_blog() first, so that $wpdb
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   594
 * points to the new blog.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   595
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   596
 * @since MU (3.0.0)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   597
 * @deprecated 5.1.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   598
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   599
 * @global wpdb     $wpdb
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   600
 * @global WP_Roles $wp_roles
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   601
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   602
 * @param int    $blog_id    The value returned by wp_insert_site().
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   603
 * @param string $blog_title The title of the new site.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   604
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   605
function install_blog( $blog_id, $blog_title = '' ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   606
	global $wpdb, $wp_roles;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   607
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   608
	_deprecated_function( __FUNCTION__, '5.1.0' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   609
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   610
	// Cast for security
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   611
	$blog_id = (int) $blog_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   612
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   613
	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   614
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   615
	$suppress = $wpdb->suppress_errors();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   616
	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   617
		die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   618
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   619
	$wpdb->suppress_errors( $suppress );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   620
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   621
	$url = get_blogaddress_by_id( $blog_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   622
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   623
	// Set everything up
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   624
	make_db_current_silent( 'blog' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   625
	populate_options();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   626
	populate_roles();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   627
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   628
	// populate_roles() clears previous role definitions so we start over.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   629
	$wp_roles = new WP_Roles();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   630
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   631
	$siteurl = $home = untrailingslashit( $url );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   632
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   633
	if ( ! is_subdomain_install() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   634
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   635
		if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   636
			$siteurl = set_url_scheme( $siteurl, 'https' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   637
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   638
		if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   639
			$home = set_url_scheme( $home, 'https' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   640
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   641
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   642
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   643
	update_option( 'siteurl', $siteurl );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   644
	update_option( 'home', $home );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   645
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   646
	if ( get_site_option( 'ms_files_rewriting' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   647
		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   648
	} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   649
		update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   650
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   651
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   652
	update_option( 'blogname', wp_unslash( $blog_title ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   653
	update_option( 'admin_email', '' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   654
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   655
	// remove all perms
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   656
	$table_prefix = $wpdb->get_blog_prefix();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   657
	delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   658
	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   659
}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   660
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   661
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   662
 * Set blog defaults.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   663
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   664
 * This function creates a row in the wp_blogs table.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   665
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   666
 * @since MU (3.0.0)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   667
 * @deprecated MU
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   668
 * @deprecated Use wp_install_defaults()
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   669
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   670
 * @global wpdb $wpdb WordPress database abstraction object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   671
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   672
 * @param int $blog_id Ignored in this function.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   673
 * @param int $user_id
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   674
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   675
function install_blog_defaults( $blog_id, $user_id ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   676
	global $wpdb;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   677
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   678
	_deprecated_function( __FUNCTION__, 'MU' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   679
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   680
	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   681
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   682
	$suppress = $wpdb->suppress_errors();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   683
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   684
	wp_install_defaults( $user_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   685
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   686
	$wpdb->suppress_errors( $suppress );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   687
}