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 |
* |
|
20 |
* @since MU |
|
21 |
* @deprecated 3.1.0 |
|
22 |
* @see get_blog_details() |
|
23 |
* @return int |
|
24 |
*/ |
|
25 |
function get_dashboard_blog() { |
|
26 |
_deprecated_function( __FUNCTION__, '3.1' ); |
|
27 |
if ( $blog = get_site_option( 'dashboard_blog' ) ) |
|
28 |
return get_blog_details( $blog ); |
|
29 |
|
|
30 |
return get_blog_details( $GLOBALS['current_site']->blog_id ); |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* @since MU |
|
35 |
* @deprecated 3.0.0 |
|
36 |
* @deprecated Use wp_generate_password() |
|
37 |
* @see wp_generate_password() |
|
38 |
*/ |
|
39 |
function generate_random_password( $len = 8 ) { |
|
40 |
_deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' ); |
|
41 |
return wp_generate_password( $len ); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Determine if user is a site admin. |
|
46 |
* |
|
47 |
* Plugins should use is_multisite() instead of checking if this function exists |
|
48 |
* to determine if multisite is enabled. |
|
49 |
* |
|
50 |
* This function must reside in a file included only if is_multisite() due to |
|
51 |
* legacy function_exists() checks to determine if multisite is enabled. |
|
52 |
* |
|
53 |
* @since MU |
|
54 |
* @deprecated 3.0.0 |
|
55 |
* @deprecated Use is_super_admin() |
|
56 |
* @see is_super_admin() |
|
57 |
* @see is_multisite() |
|
58 |
* |
|
59 |
*/ |
|
60 |
function is_site_admin( $user_login = '' ) { |
|
61 |
_deprecated_function( __FUNCTION__, '3.0', 'is_super_admin()' ); |
|
62 |
|
|
63 |
if ( empty( $user_login ) ) { |
|
64 |
$user_id = get_current_user_id(); |
|
65 |
if ( !$user_id ) |
|
66 |
return false; |
|
67 |
} else { |
|
68 |
$user = get_user_by( 'login', $user_login ); |
|
69 |
if ( ! $user->exists() ) |
|
70 |
return false; |
|
71 |
$user_id = $user->ID; |
|
72 |
} |
|
73 |
|
|
74 |
return is_super_admin( $user_id ); |
|
75 |
} |
|
76 |
|
|
77 |
if ( !function_exists( 'graceful_fail' ) ) : |
|
78 |
/** |
|
79 |
* @since MU |
|
80 |
* @deprecated 3.0.0 |
|
81 |
* @deprecated Use wp_die() |
|
82 |
* @see wp_die() |
|
83 |
*/ |
|
84 |
function graceful_fail( $message ) { |
|
85 |
_deprecated_function( __FUNCTION__, '3.0', 'wp_die()' ); |
|
86 |
$message = apply_filters( 'graceful_fail', $message ); |
|
87 |
$message_template = apply_filters( 'graceful_fail_template', |
|
88 |
'<!DOCTYPE html> |
5
|
89 |
<html xmlns="http://www.w3.org/1999/xhtml"><head> |
0
|
90 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
91 |
<title>Error!</title> |
|
92 |
<style type="text/css"> |
|
93 |
img { |
|
94 |
border: 0; |
|
95 |
} |
|
96 |
body { |
|
97 |
line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto; |
|
98 |
text-align: center; |
|
99 |
} |
|
100 |
.message { |
|
101 |
font-size: 22px; |
|
102 |
width: 350px; |
|
103 |
margin: auto; |
|
104 |
} |
|
105 |
</style> |
|
106 |
</head> |
|
107 |
<body> |
|
108 |
<p class="message">%s</p> |
|
109 |
</body> |
|
110 |
</html>' ); |
|
111 |
die( sprintf( $message_template, $message ) ); |
|
112 |
} |
|
113 |
endif; |
|
114 |
|
|
115 |
/** |
|
116 |
* @since MU |
|
117 |
* @deprecated 3.0.0 |
|
118 |
* @deprecated Use get_user_by() |
|
119 |
* @see get_user_by() |
|
120 |
*/ |
|
121 |
function get_user_details( $username ) { |
|
122 |
_deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' ); |
|
123 |
return get_user_by('login', $username); |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @since MU |
|
128 |
* @deprecated 3.0.0 |
|
129 |
* @deprecated Use clean_post_cache() |
|
130 |
* @see clean_post_cache() |
|
131 |
*/ |
|
132 |
function clear_global_post_cache( $post_id ) { |
|
133 |
_deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' ); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* @since MU |
|
138 |
* @deprecated 3.0.0 |
|
139 |
* @deprecated Use is_main_site() |
|
140 |
* @see is_main_site() |
|
141 |
*/ |
|
142 |
function is_main_blog() { |
|
143 |
_deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' ); |
|
144 |
return is_main_site(); |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* @since MU |
|
149 |
* @deprecated 3.0.0 |
|
150 |
* @deprecated Use is_email() |
|
151 |
* @see is_email() |
|
152 |
*/ |
|
153 |
function validate_email( $email, $check_domain = true) { |
|
154 |
_deprecated_function( __FUNCTION__, '3.0', 'is_email()' ); |
|
155 |
return is_email( $email, $check_domain ); |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* @since MU |
|
160 |
* @deprecated 3.0.0 |
|
161 |
* @deprecated No alternative available. For performance reasons this function is not recommended. |
|
162 |
*/ |
|
163 |
function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) { |
|
164 |
_deprecated_function( __FUNCTION__, '3.0', 'wp_get_sites()' ); |
|
165 |
|
|
166 |
global $wpdb; |
|
167 |
$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", $wpdb->siteid), ARRAY_A ); |
|
168 |
|
5
|
169 |
$blog_list = array(); |
0
|
170 |
foreach ( (array) $blogs as $details ) { |
|
171 |
$blog_list[ $details['blog_id'] ] = $details; |
|
172 |
$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'" ); |
|
173 |
} |
|
174 |
|
5
|
175 |
if ( ! $blog_list ) { |
0
|
176 |
return array(); |
5
|
177 |
} |
0
|
178 |
|
5
|
179 |
if ( $num == 'all' ) { |
|
180 |
return array_slice( $blog_list, $start, count( $blog_list ) ); |
|
181 |
} else { |
|
182 |
return array_slice( $blog_list, $start, $num ); |
|
183 |
} |
0
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* @since MU |
|
188 |
* @deprecated 3.0.0 |
|
189 |
* @deprecated No alternative available. For performance reasons this function is not recommended. |
|
190 |
*/ |
|
191 |
function get_most_active_blogs( $num = 10, $display = true ) { |
|
192 |
_deprecated_function( __FUNCTION__, '3.0' ); |
|
193 |
|
|
194 |
$blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details |
|
195 |
if ( is_array( $blogs ) ) { |
|
196 |
reset( $blogs ); |
5
|
197 |
$most_active = array(); |
|
198 |
$blog_list = array(); |
0
|
199 |
foreach ( (array) $blogs as $key => $details ) { |
|
200 |
$most_active[ $details['blog_id'] ] = $details['postcount']; |
|
201 |
$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!! |
|
202 |
} |
|
203 |
arsort( $most_active ); |
|
204 |
reset( $most_active ); |
5
|
205 |
$t = array(); |
|
206 |
foreach ( (array) $most_active as $key => $details ) { |
0
|
207 |
$t[ $key ] = $blog_list[ $key ]; |
5
|
208 |
} |
0
|
209 |
unset( $most_active ); |
|
210 |
$most_active = $t; |
|
211 |
} |
|
212 |
|
|
213 |
if ( $display == true ) { |
|
214 |
if ( is_array( $most_active ) ) { |
|
215 |
reset( $most_active ); |
|
216 |
foreach ( (array) $most_active as $key => $details ) { |
|
217 |
$url = esc_url('http://' . $details['domain'] . $details['path']); |
|
218 |
echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>"; |
|
219 |
} |
|
220 |
} |
|
221 |
} |
|
222 |
return array_slice( $most_active, 0, $num ); |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
226 |
* Redirect a user based on $_GET or $_POST arguments. |
|
227 |
* |
|
228 |
* The function looks for redirect arguments in the following order: |
|
229 |
* 1) $_GET['ref'] |
|
230 |
* 2) $_POST['ref'] |
|
231 |
* 3) $_SERVER['HTTP_REFERER'] |
|
232 |
* 4) $_GET['redirect'] |
|
233 |
* 5) $_POST['redirect'] |
|
234 |
* 6) $url |
|
235 |
* |
|
236 |
* @since MU |
|
237 |
* @deprecated 3.3.0 |
|
238 |
* @deprecated Use wp_redirect() |
|
239 |
* |
|
240 |
* @param string $url |
|
241 |
*/ |
|
242 |
function wpmu_admin_do_redirect( $url = '' ) { |
|
243 |
_deprecated_function( __FUNCTION__, '3.3' ); |
|
244 |
|
|
245 |
$ref = ''; |
|
246 |
if ( isset( $_GET['ref'] ) ) |
|
247 |
$ref = $_GET['ref']; |
|
248 |
if ( isset( $_POST['ref'] ) ) |
|
249 |
$ref = $_POST['ref']; |
|
250 |
|
|
251 |
if ( $ref ) { |
|
252 |
$ref = wpmu_admin_redirect_add_updated_param( $ref ); |
|
253 |
wp_redirect( $ref ); |
|
254 |
exit(); |
|
255 |
} |
|
256 |
if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) { |
|
257 |
wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
258 |
exit(); |
|
259 |
} |
|
260 |
|
|
261 |
$url = wpmu_admin_redirect_add_updated_param( $url ); |
|
262 |
if ( isset( $_GET['redirect'] ) ) { |
|
263 |
if ( substr( $_GET['redirect'], 0, 2 ) == 's_' ) |
|
264 |
$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) ); |
|
265 |
} elseif ( isset( $_POST['redirect'] ) ) { |
|
266 |
$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] ); |
|
267 |
} |
|
268 |
wp_redirect( $url ); |
|
269 |
exit(); |
|
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* Adds an 'updated=true' argument to a URL. |
|
274 |
* |
|
275 |
* @since MU |
|
276 |
* @deprecated 3.3.0 |
|
277 |
* @deprecated Use add_query_arg() |
|
278 |
* |
|
279 |
* @param string $url |
|
280 |
* @return string |
|
281 |
*/ |
|
282 |
function wpmu_admin_redirect_add_updated_param( $url = '' ) { |
|
283 |
_deprecated_function( __FUNCTION__, '3.3' ); |
|
284 |
|
|
285 |
if ( strpos( $url, 'updated=true' ) === false ) { |
|
286 |
if ( strpos( $url, '?' ) === false ) |
|
287 |
return $url . '?updated=true'; |
|
288 |
else |
|
289 |
return $url . '&updated=true'; |
|
290 |
} |
|
291 |
return $url; |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* Get a numeric user ID from either an email address or a login. |
|
296 |
* |
|
297 |
* A numeric string is considered to be an existing user ID |
|
298 |
* and is simply returned as such. |
|
299 |
* |
|
300 |
* @since MU |
|
301 |
* @deprecated 3.6.0 |
|
302 |
* @deprecated Use get_user_by() |
|
303 |
* |
|
304 |
* @param string $string Either an email address or a login. |
|
305 |
* @return int |
|
306 |
*/ |
|
307 |
function get_user_id_from_string( $string ) { |
|
308 |
_deprecated_function( __FUNCTION__, '3.6', 'get_user_by()' ); |
|
309 |
|
|
310 |
if ( is_email( $string ) ) |
|
311 |
$user = get_user_by( 'email', $string ); |
|
312 |
elseif ( is_numeric( $string ) ) |
|
313 |
return $string; |
|
314 |
else |
|
315 |
$user = get_user_by( 'login', $string ); |
|
316 |
|
|
317 |
if ( $user ) |
|
318 |
return $user->ID; |
|
319 |
return 0; |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* Get a full blog URL, given a domain and a path. |
|
324 |
* |
|
325 |
* @since MU |
|
326 |
* @deprecated 3.7.0 |
|
327 |
* |
|
328 |
* @param string $domain |
|
329 |
* @param string $path |
|
330 |
* @return string |
|
331 |
*/ |
|
332 |
function get_blogaddress_by_domain( $domain, $path ) { |
|
333 |
_deprecated_function( __FUNCTION__, '3.7' ); |
|
334 |
|
|
335 |
if ( is_subdomain_install() ) { |
|
336 |
$url = "http://" . $domain.$path; |
|
337 |
} else { |
|
338 |
if ( $domain != $_SERVER['HTTP_HOST'] ) { |
|
339 |
$blogname = substr( $domain, 0, strpos( $domain, '.' ) ); |
|
340 |
$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; |
|
341 |
// we're not installing the main blog |
|
342 |
if ( $blogname != 'www.' ) |
|
343 |
$url .= $blogname . '/'; |
|
344 |
} else { // main blog |
|
345 |
$url = 'http://' . $domain . $path; |
|
346 |
} |
|
347 |
} |
|
348 |
return esc_url_raw( $url ); |
5
|
349 |
} |