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.
8 * @subpackage Deprecated
13 * Deprecated functions come here to die.
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.
22 * @see get_blog_details()
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 );
30 return get_blog_details( $GLOBALS['current_site']->blog_id );
36 * @deprecated Use wp_generate_password()
37 * @see wp_generate_password()
39 function generate_random_password( $len = 8 ) {
40 _deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' );
41 return wp_generate_password( $len );
45 * Determine if user is a site admin.
47 * Plugins should use is_multisite() instead of checking if this function exists
48 * to determine if multisite is enabled.
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.
55 * @deprecated Use is_super_admin()
56 * @see is_super_admin()
60 function is_site_admin( $user_login = '' ) {
61 _deprecated_function( __FUNCTION__, '3.0', 'is_super_admin()' );
63 if ( empty( $user_login ) ) {
64 $user_id = get_current_user_id();
68 $user = get_user_by( 'login', $user_login );
69 if ( ! $user->exists() )
74 return is_super_admin( $user_id );
77 if ( !function_exists( 'graceful_fail' ) ) :
81 * @deprecated Use wp_die()
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',
89 <html xmlns="http://www.w3.org/1999/xhtml"><head>
90 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
92 <style type="text/css">
97 line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
108 <p class="message">%s</p>
111 die( sprintf( $message_template, $message ) );
118 * @deprecated Use get_user_by()
121 function get_user_details( $username ) {
122 _deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' );
123 return get_user_by('login', $username);
129 * @deprecated Use clean_post_cache()
130 * @see clean_post_cache()
132 function clear_global_post_cache( $post_id ) {
133 _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' );
139 * @deprecated Use is_main_site()
140 * @see is_main_site()
142 function is_main_blog() {
143 _deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' );
144 return is_main_site();
150 * @deprecated Use is_email()
153 function validate_email( $email, $check_domain = true) {
154 _deprecated_function( __FUNCTION__, '3.0', 'is_email()' );
155 return is_email( $email, $check_domain );
161 * @deprecated No alternative available. For performance reasons this function is not recommended.
163 function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
164 _deprecated_function( __FUNCTION__, '3.0', 'wp_get_sites()' );
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 );
169 foreach ( (array) $blogs as $details ) {
170 $blog_list[ $details['blog_id'] ] = $details;
171 $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'" );
176 if ( false == is_array( $blogs ) )
180 return array_slice( $blogs, $start, count( $blogs ) );
182 return array_slice( $blogs, $start, $num );
188 * @deprecated No alternative available. For performance reasons this function is not recommended.
190 function get_most_active_blogs( $num = 10, $display = true ) {
191 _deprecated_function( __FUNCTION__, '3.0' );
193 $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
194 if ( is_array( $blogs ) ) {
196 foreach ( (array) $blogs as $key => $details ) {
197 $most_active[ $details['blog_id'] ] = $details['postcount'];
198 $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
200 arsort( $most_active );
201 reset( $most_active );
202 foreach ( (array) $most_active as $key => $details )
203 $t[ $key ] = $blog_list[ $key ];
205 unset( $most_active );
209 if ( $display == true ) {
210 if ( is_array( $most_active ) ) {
211 reset( $most_active );
212 foreach ( (array) $most_active as $key => $details ) {
213 $url = esc_url('http://' . $details['domain'] . $details['path']);
214 echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
218 return array_slice( $most_active, 0, $num );
222 * Redirect a user based on $_GET or $_POST arguments.
224 * The function looks for redirect arguments in the following order:
227 * 3) $_SERVER['HTTP_REFERER']
228 * 4) $_GET['redirect']
229 * 5) $_POST['redirect']
234 * @deprecated Use wp_redirect()
238 function wpmu_admin_do_redirect( $url = '' ) {
239 _deprecated_function( __FUNCTION__, '3.3' );
242 if ( isset( $_GET['ref'] ) )
244 if ( isset( $_POST['ref'] ) )
245 $ref = $_POST['ref'];
248 $ref = wpmu_admin_redirect_add_updated_param( $ref );
252 if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
253 wp_redirect( $_SERVER['HTTP_REFERER'] );
257 $url = wpmu_admin_redirect_add_updated_param( $url );
258 if ( isset( $_GET['redirect'] ) ) {
259 if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
260 $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
261 } elseif ( isset( $_POST['redirect'] ) ) {
262 $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
269 * Adds an 'updated=true' argument to a URL.
273 * @deprecated Use add_query_arg()
278 function wpmu_admin_redirect_add_updated_param( $url = '' ) {
279 _deprecated_function( __FUNCTION__, '3.3' );
281 if ( strpos( $url, 'updated=true' ) === false ) {
282 if ( strpos( $url, '?' ) === false )
283 return $url . '?updated=true';
285 return $url . '&updated=true';
291 * Get a numeric user ID from either an email address or a login.
293 * A numeric string is considered to be an existing user ID
294 * and is simply returned as such.
298 * @deprecated Use get_user_by()
300 * @param string $string Either an email address or a login.
303 function get_user_id_from_string( $string ) {
304 _deprecated_function( __FUNCTION__, '3.6', 'get_user_by()' );
306 if ( is_email( $string ) )
307 $user = get_user_by( 'email', $string );
308 elseif ( is_numeric( $string ) )
311 $user = get_user_by( 'login', $string );
319 * Get a full blog URL, given a domain and a path.
324 * @param string $domain
325 * @param string $path
328 function get_blogaddress_by_domain( $domain, $path ) {
329 _deprecated_function( __FUNCTION__, '3.7' );
331 if ( is_subdomain_install() ) {
332 $url = "http://" . $domain.$path;
334 if ( $domain != $_SERVER['HTTP_HOST'] ) {
335 $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
336 $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
337 // we're not installing the main blog
338 if ( $blogname != 'www.' )
339 $url .= $blogname . '/';
340 } else { // main blog
341 $url = 'http://' . $domain . $path;
344 return esc_url_raw( $url );