]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/ms-deprecated.php
Wordpress 3.0.6-scripts
[autoinstalls/wordpress.git] / wp-includes / ms-deprecated.php
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  * @since unknown
18  * @deprecated 3.0.0
19  * @deprecated Use wp_generate_password()
20  * @see wp_generate_password()
21  */
22 function generate_random_password( $len = 8 ) {
23         _deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' );
24         return wp_generate_password( $len );
25 }
26
27 /**
28  * Determine if user is a site admin.
29  *
30  * Plugins should use is_multisite() instead of checking if this function exists
31  * to determine if multisite is enabled.
32  *
33  * This function must reside in a file included only if is_multisite() due to
34  * legacy function_exists() checks to determine if multisite is enabled.
35  *
36  * @since MU
37  * @deprecated 3.0.0
38  * @deprecated Use is_super_admin()
39  * @see is_super_admin()
40  * @see is_multisite()
41  *
42  */
43 function is_site_admin( $user_login = '' ) {
44         _deprecated_function( __FUNCTION__, '3.0', 'is_super_admin()' );
45
46         if ( empty( $user_login ) ) {
47                 $user_id = get_current_user_id();
48                 if ( !$user_id )
49                         return false;
50         } else {
51                 $user = get_user_by( 'login', $user_login );
52                 if ( empty( $user->ID ) )
53                         return false;
54                 $user_id = $user->ID;
55         }
56
57         return is_super_admin( $user_id );
58 }
59
60 if ( !function_exists( 'graceful_fail' ) ) :
61 /**
62  * @since MU
63  * @deprecated 3.0.0
64  * @deprecated Use wp_die()
65  * @see wp_die()
66  */
67 function graceful_fail( $message ) {
68         _deprecated_function( __FUNCTION__, '3.0', 'wp_die()' );
69         $message = apply_filters( 'graceful_fail', $message );
70         $message_template = apply_filters( 'graceful_fail_template',
71 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
72 <html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">
73 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
74 <title>Error!</title>
75 <style type="text/css">
76 img {
77         border: 0;
78 }
79 body {
80 line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
81 text-align: center;
82 }
83 .message {
84         font-size: 22px;
85         width: 350px;
86         margin: auto;
87 }
88 </style>
89 </head>
90 <body>
91 <p class="message">%s</p>
92 </body>
93 </html>' );
94         die( sprintf( $message_template, $message ) );
95 }
96 endif;
97
98 /**
99  * @since MU
100  * @deprecated 3.0.0
101  * @deprecated Use get_user_by()
102  * @see get_user_by()
103  */
104 function get_user_details( $username ) {
105         _deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' );
106         return get_user_by('login', $username);
107 }
108
109 /**
110  * @since MU
111  * @deprecated 3.0.0
112  * @deprecated Use clean_post_cache()
113  * @see clean_post_cache()
114  */
115 function clear_global_post_cache( $post_id ) {
116         _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' );
117 }
118
119 /**
120  * @since MU
121  * @deprecated 3.0.0
122  * @deprecated Use is_main_site()
123  * @see is_main_site()
124  */
125 function is_main_blog() {
126         _deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' );
127         return is_main_site();
128 }
129
130 /**
131  * @since MU
132  * @deprecated 3.0.0
133  * @deprecated Use is_email()
134  * @see is_email()
135  */
136 function validate_email( $email, $check_domain = true) {
137         _deprecated_function( __FUNCTION__, '3.0', 'is_email()' );
138         return is_email( $email, $check_domain );
139 }
140
141 /**
142  * @since MU
143  * @deprecated 3.0.0
144  * @deprecated Don't use this, really.
145  */
146 function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
147         _deprecated_function( __FUNCTION__, '3.0', "Don't use this, really." );
148
149         global $wpdb;
150         $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 );
151
152         foreach ( (array) $blogs as $details ) {
153                 $blog_list[ $details['blog_id'] ] = $details;
154                 $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'" );
155         }
156         unset( $blogs );
157         $blogs = $blog_list;
158
159         if ( false == is_array( $blogs ) )
160                 return array();
161
162         if ( $num == 'all' )
163                 return array_slice( $blogs, $start, count( $blogs ) );
164         else
165                 return array_slice( $blogs, $start, $num );
166 }
167
168 /**
169  * @since MU
170  * @deprecated 3.0.0
171  * @deprecated Don't use this, really.
172  */
173 function get_most_active_blogs( $num = 10, $display = true ) {
174         _deprecated_function( __FUNCTION__, '3.0', "Don't use this, really." );
175
176         $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
177         if ( is_array( $blogs ) ) {
178                 reset( $blogs );
179                 foreach ( (array) $blogs as $key => $details ) {
180                         $most_active[ $details['blog_id'] ] = $details['postcount'];
181                         $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
182                 }
183                 arsort( $most_active );
184                 reset( $most_active );
185                 foreach ( (array) $most_active as $key => $details )
186                         $t[ $key ] = $blog_list[ $key ];
187
188                 unset( $most_active );
189                 $most_active = $t;
190         }
191
192         if ( $display == true ) {
193                 if ( is_array( $most_active ) ) {
194                         reset( $most_active );
195                         foreach ( (array) $most_active as $key => $details ) {
196                                 $url = esc_url('http://' . $details['domain'] . $details['path']);
197                                 echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
198                         }
199                 }
200         }
201         return array_slice( $most_active, 0, $num );
202 }
203 ?>