author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Deprecated functions from WordPress MU and the multisite feature. You shouldn't |
|
4 |
* use these functions and look for the alternatives instead. The functions will be |
|
5 |
* removed in a later version. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
* @subpackage Deprecated |
|
9 |
* @since 3.0.0 |
|
10 |
*/ |
|
11 |
||
12 |
/* |
|
13 |
* Deprecated functions come here to die. |
|
14 |
*/ |
|
15 |
||
16 |
/** |
|
17 |
* Get the "dashboard blog", the blog where users without a blog edit their profile data. |
|
18 |
* Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin. |
|
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 | 25 |
*/ |
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 | 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 | 33 |
} |
34 |
||
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 | 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 | 43 |
*/ |
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 | 46 |
return wp_generate_password( $len ); |
47 |
} |
|
48 |
||
49 |
/** |
|
50 |
* Determine if user is a site admin. |
|
51 |
* |
|
52 |
* Plugins should use is_multisite() instead of checking if this function exists |
|
53 |
* to determine if multisite is enabled. |
|
54 |
* |
|
55 |
* This function must reside in a file included only if is_multisite() due to |
|
56 |
* legacy function_exists() checks to determine if multisite is enabled. |
|
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 | 60 |
* @see is_super_admin() |
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 | 63 |
*/ |
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 | 66 |
|
67 |
if ( empty( $user_login ) ) { |
|
68 |
$user_id = get_current_user_id(); |
|
69 |
if ( !$user_id ) |
|
70 |
return false; |
|
71 |
} else { |
|
72 |
$user = get_user_by( 'login', $user_login ); |
|
73 |
if ( ! $user->exists() ) |
|
74 |
return false; |
|
75 |
$user_id = $user->ID; |
|
76 |
} |
|
77 |
||
78 |
return is_super_admin( $user_id ); |
|
79 |
} |
|
80 |
||
81 |
if ( !function_exists( 'graceful_fail' ) ) : |
|
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 | 87 |
* @see wp_die() |
88 |
*/ |
|
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 | 91 |
$message = apply_filters( 'graceful_fail', $message ); |
92 |
$message_template = apply_filters( 'graceful_fail_template', |
|
93 |
'<!DOCTYPE html> |
|
5 | 94 |
<html xmlns="http://www.w3.org/1999/xhtml"><head> |
0 | 95 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
96 |
<title>Error!</title> |
|
97 |
<style type="text/css"> |
|
98 |
img { |
|
99 |
border: 0; |
|
100 |
} |
|
101 |
body { |
|
102 |
line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto; |
|
103 |
text-align: center; |
|
104 |
} |
|
105 |
.message { |
|
106 |
font-size: 22px; |
|
107 |
width: 350px; |
|
108 |
margin: auto; |
|
109 |
} |
|
110 |
</style> |
|
111 |
</head> |
|
112 |
<body> |
|
113 |
<p class="message">%s</p> |
|
114 |
</body> |
|
115 |
</html>' ); |
|
116 |
die( sprintf( $message_template, $message ) ); |
|
117 |
} |
|
118 |
endif; |
|
119 |
||
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 | 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 | 128 |
*/ |
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 | 131 |
return get_user_by('login', $username); |
132 |
} |
|
133 |
||
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 | 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 | 142 |
*/ |
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 | 145 |
} |
146 |
||
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 | 152 |
* @see is_main_site() |
153 |
*/ |
|
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 | 156 |
return is_main_site(); |
157 |
} |
|
158 |
||
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 | 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 | 169 |
*/ |
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 | 172 |
return is_email( $email, $check_domain ); |
173 |
} |
|
174 |
||
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 | 185 |
*/ |
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 | 188 |
|
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 | 191 |
|
5 | 192 |
$blog_list = array(); |
0 | 193 |
foreach ( (array) $blogs as $details ) { |
194 |
$blog_list[ $details['blog_id'] ] = $details; |
|
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'" ); |
|
196 |
} |
|
197 |
||
5 | 198 |
if ( ! $blog_list ) { |
0 | 199 |
return array(); |
5 | 200 |
} |
0 | 201 |
|
5 | 202 |
if ( $num == 'all' ) { |
203 |
return array_slice( $blog_list, $start, count( $blog_list ) ); |
|
204 |
} else { |
|
205 |
return array_slice( $blog_list, $start, $num ); |
|
206 |
} |
|
0 | 207 |
} |
208 |
||
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 | 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 | 218 |
*/ |
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 | 221 |
|
222 |
$blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details |
|
223 |
if ( is_array( $blogs ) ) { |
|
224 |
reset( $blogs ); |
|
5 | 225 |
$most_active = array(); |
226 |
$blog_list = array(); |
|
0 | 227 |
foreach ( (array) $blogs as $key => $details ) { |
228 |
$most_active[ $details['blog_id'] ] = $details['postcount']; |
|
229 |
$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!! |
|
230 |
} |
|
231 |
arsort( $most_active ); |
|
232 |
reset( $most_active ); |
|
5 | 233 |
$t = array(); |
234 |
foreach ( (array) $most_active as $key => $details ) { |
|
0 | 235 |
$t[ $key ] = $blog_list[ $key ]; |
5 | 236 |
} |
0 | 237 |
unset( $most_active ); |
238 |
$most_active = $t; |
|
239 |
} |
|
240 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
if ( $display ) { |
0 | 242 |
if ( is_array( $most_active ) ) { |
243 |
reset( $most_active ); |
|
244 |
foreach ( (array) $most_active as $key => $details ) { |
|
245 |
$url = esc_url('http://' . $details['domain'] . $details['path']); |
|
246 |
echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>"; |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
return array_slice( $most_active, 0, $num ); |
|
251 |
} |
|
252 |
||
253 |
/** |
|
254 |
* Redirect a user based on $_GET or $_POST arguments. |
|
255 |
* |
|
256 |
* The function looks for redirect arguments in the following order: |
|
257 |
* 1) $_GET['ref'] |
|
258 |
* 2) $_POST['ref'] |
|
259 |
* 3) $_SERVER['HTTP_REFERER'] |
|
260 |
* 4) $_GET['redirect'] |
|
261 |
* 5) $_POST['redirect'] |
|
262 |
* 6) $url |
|
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 | 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 | 269 |
*/ |
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 | 272 |
|
273 |
$ref = ''; |
|
274 |
if ( isset( $_GET['ref'] ) ) |
|
275 |
$ref = $_GET['ref']; |
|
276 |
if ( isset( $_POST['ref'] ) ) |
|
277 |
$ref = $_POST['ref']; |
|
278 |
||
279 |
if ( $ref ) { |
|
280 |
$ref = wpmu_admin_redirect_add_updated_param( $ref ); |
|
281 |
wp_redirect( $ref ); |
|
282 |
exit(); |
|
283 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { |
0 | 285 |
wp_redirect( $_SERVER['HTTP_REFERER'] ); |
286 |
exit(); |
|
287 |
} |
|
288 |
||
289 |
$url = wpmu_admin_redirect_add_updated_param( $url ); |
|
290 |
if ( isset( $_GET['redirect'] ) ) { |
|
291 |
if ( substr( $_GET['redirect'], 0, 2 ) == 's_' ) |
|
292 |
$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) ); |
|
293 |
} elseif ( isset( $_POST['redirect'] ) ) { |
|
294 |
$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] ); |
|
295 |
} |
|
296 |
wp_redirect( $url ); |
|
297 |
exit(); |
|
298 |
} |
|
299 |
||
300 |
/** |
|
301 |
* Adds an 'updated=true' argument to a URL. |
|
302 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
* @deprecated 3.3.0 Use add_query_arg() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
* @see add_query_arg() |
0 | 306 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
* @param string $url Optional. Redirect URL. Default empty. |
0 | 308 |
* @return string |
309 |
*/ |
|
310 |
function wpmu_admin_redirect_add_updated_param( $url = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
_deprecated_function( __FUNCTION__, '3.3.0', 'add_query_arg()' ); |
0 | 312 |
|
313 |
if ( strpos( $url, 'updated=true' ) === false ) { |
|
314 |
if ( strpos( $url, '?' ) === false ) |
|
315 |
return $url . '?updated=true'; |
|
316 |
else |
|
317 |
return $url . '&updated=true'; |
|
318 |
} |
|
319 |
return $url; |
|
320 |
} |
|
321 |
||
322 |
/** |
|
323 |
* Get a numeric user ID from either an email address or a login. |
|
324 |
* |
|
325 |
* A numeric string is considered to be an existing user ID |
|
326 |
* and is simply returned as such. |
|
327 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
* @deprecated 3.6.0 Use get_user_by() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
* @see get_user_by() |
0 | 331 |
* |
332 |
* @param string $string Either an email address or a login. |
|
333 |
* @return int |
|
334 |
*/ |
|
335 |
function get_user_id_from_string( $string ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
_deprecated_function( __FUNCTION__, '3.6.0', 'get_user_by()' ); |
0 | 337 |
|
338 |
if ( is_email( $string ) ) |
|
339 |
$user = get_user_by( 'email', $string ); |
|
340 |
elseif ( is_numeric( $string ) ) |
|
341 |
return $string; |
|
342 |
else |
|
343 |
$user = get_user_by( 'login', $string ); |
|
344 |
||
345 |
if ( $user ) |
|
346 |
return $user->ID; |
|
347 |
return 0; |
|
348 |
} |
|
349 |
||
350 |
/** |
|
351 |
* Get a full blog URL, given a domain and a path. |
|
352 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
* @since MU (3.0.0) |
0 | 354 |
* @deprecated 3.7.0 |
355 |
* |
|
356 |
* @param string $domain |
|
357 |
* @param string $path |
|
358 |
* @return string |
|
359 |
*/ |
|
360 |
function get_blogaddress_by_domain( $domain, $path ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
_deprecated_function( __FUNCTION__, '3.7.0' ); |
0 | 362 |
|
363 |
if ( is_subdomain_install() ) { |
|
364 |
$url = "http://" . $domain.$path; |
|
365 |
} else { |
|
366 |
if ( $domain != $_SERVER['HTTP_HOST'] ) { |
|
367 |
$blogname = substr( $domain, 0, strpos( $domain, '.' ) ); |
|
368 |
$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; |
|
369 |
// we're not installing the main blog |
|
370 |
if ( $blogname != 'www.' ) |
|
371 |
$url .= $blogname . '/'; |
|
372 |
} else { // main blog |
|
373 |
$url = 'http://' . $domain . $path; |
|
374 |
} |
|
375 |
} |
|
376 |
return esc_url_raw( $url ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
* Create an empty blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
* @deprecated 4.4.0 |
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 |
* @param string $domain The new blog's domain. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
* @param string $path The new blog's path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
* @param string $weblog_title The new blog's title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* @param int $site_id Optional. Defaults to 1. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* @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
|
390 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
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
|
392 |
_deprecated_function( __FUNCTION__, '4.4.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
if ( empty($path) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
$path = '/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
// 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
|
398 |
if ( domain_exists($domain, $path, $site_id) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
return __( '<strong>ERROR</strong>: Site URL already taken.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
// 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
|
402 |
// 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
|
403 |
// Must restore table names at the end of function. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
return __( '<strong>ERROR</strong>: problem creating site entry.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
switch_to_blog($blog_id); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
install_blog($blog_id); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
return $blog_id; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
* Get the admin for a domain/path combination. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* @deprecated 4.4.0 |
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 |
* @global wpdb $wpdb WordPress database abstraction object. |
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 |
* @param string $domain Optional. Network domain. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* @param string $path Optional. Network path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
* @return array|false The network admins. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
function get_admin_users_for_domain( $domain = '', $path = '' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
_deprecated_function( __FUNCTION__, '4.4.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
global $wpdb; |
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 |
if ( ! $domain ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
$network_id = get_current_network_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
$_networks = get_networks( array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
'fields' => 'ids', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
'number' => 1, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
'domain' => $domain, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
'path' => $path, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
$network_id = ! empty( $_networks ) ? array_shift( $_networks ) : 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
if ( $network_id ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
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
|
446 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
return false; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
* 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
|
452 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
* @since 3.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
* @deprecated 4.6.0 Use get_sites() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* @see get_sites() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* @param array $args { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* Array of default arguments. Optional. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @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
|
461 |
* from all networks. Defaults to current network ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* @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
|
463 |
* @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
|
464 |
* @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
|
465 |
* @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
|
466 |
* @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
|
467 |
* @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
|
468 |
* @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
|
469 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
* @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
|
471 |
* 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
|
472 |
* 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
|
473 |
* 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
|
474 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
475 |
function wp_get_sites( $args = array() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
476 |
_deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
if ( wp_is_large_network() ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
479 |
return array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
$defaults = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
'network_id' => get_current_network_id(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
'public' => null, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
'archived' => null, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
'mature' => null, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
'spam' => null, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
'deleted' => null, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
'limit' => 100, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
'offset' => 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
$args = wp_parse_args( $args, $defaults ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
493 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
// Backwards compatibility |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
if( is_array( $args['network_id'] ) ){ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
$args['network__in'] = $args['network_id']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
$args['network_id'] = null; |
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
if( is_numeric( $args['limit'] ) ){ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
501 |
$args['number'] = $args['limit']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
$args['limit'] = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
503 |
} elseif ( ! $args['limit'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
$args['number'] = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
$args['limit'] = null; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
// Make sure count is disabled. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
$args['count'] = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
$_sites = get_sites( $args ); |
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 |
$results = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
foreach ( $_sites as $_site ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
$_site = get_site( $_site ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
$results[] = $_site->to_array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
} |
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 |
return $results; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
|
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 |
* 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
|
525 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
526 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
* @deprecated 4.9.0 |
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 |
* @global wpdb $wpdb WordPress database abstraction object. |
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 |
* @param string $key |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
* @param int $user_id Optional. Defaults to current user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
* @param int $blog_id Optional. Defaults to current blog. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
* @return bool |
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 |
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
|
537 |
global $wpdb; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
_deprecated_function( __FUNCTION__, '4.9.0' ); |
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 |
$current_user = wp_get_current_user(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
542 |
if ( $blog_id == 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
543 |
$blog_id = get_current_blog_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
$local_key = $wpdb->get_blog_prefix( $blog_id ) . $key; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
return isset( $current_user->$local_key ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
} |