[ Index ] |
WordPress Cross Reference |
[Summary view] [Print] [Text view]
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> 89 <html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11"> 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 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'" ); 172 } 173 unset( $blogs ); 174 $blogs = $blog_list; 175 176 if ( false == is_array( $blogs ) ) 177 return array(); 178 179 if ( $num == 'all' ) 180 return array_slice( $blogs, $start, count( $blogs ) ); 181 else 182 return array_slice( $blogs, $start, $num ); 183 } 184 185 /** 186 * @since MU 187 * @deprecated 3.0.0 188 * @deprecated No alternative available. For performance reasons this function is not recommended. 189 */ 190 function get_most_active_blogs( $num = 10, $display = true ) { 191 _deprecated_function( __FUNCTION__, '3.0' ); 192 193 $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details 194 if ( is_array( $blogs ) ) { 195 reset( $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!! 199 } 200 arsort( $most_active ); 201 reset( $most_active ); 202 foreach ( (array) $most_active as $key => $details ) 203 $t[ $key ] = $blog_list[ $key ]; 204 205 unset( $most_active ); 206 $most_active = $t; 207 } 208 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>"; 215 } 216 } 217 } 218 return array_slice( $most_active, 0, $num ); 219 } 220 221 /** 222 * Redirect a user based on $_GET or $_POST arguments. 223 * 224 * The function looks for redirect arguments in the following order: 225 * 1) $_GET['ref'] 226 * 2) $_POST['ref'] 227 * 3) $_SERVER['HTTP_REFERER'] 228 * 4) $_GET['redirect'] 229 * 5) $_POST['redirect'] 230 * 6) $url 231 * 232 * @since MU 233 * @deprecated 3.3.0 234 * @deprecated Use wp_redirect() 235 * @uses wpmu_admin_redirect_add_updated_param() 236 * 237 * @param string $url 238 */ 239 function wpmu_admin_do_redirect( $url = '' ) { 240 _deprecated_function( __FUNCTION__, '3.3' ); 241 242 $ref = ''; 243 if ( isset( $_GET['ref'] ) ) 244 $ref = $_GET['ref']; 245 if ( isset( $_POST['ref'] ) ) 246 $ref = $_POST['ref']; 247 248 if ( $ref ) { 249 $ref = wpmu_admin_redirect_add_updated_param( $ref ); 250 wp_redirect( $ref ); 251 exit(); 252 } 253 if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) { 254 wp_redirect( $_SERVER['HTTP_REFERER'] ); 255 exit(); 256 } 257 258 $url = wpmu_admin_redirect_add_updated_param( $url ); 259 if ( isset( $_GET['redirect'] ) ) { 260 if ( substr( $_GET['redirect'], 0, 2 ) == 's_' ) 261 $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) ); 262 } elseif ( isset( $_POST['redirect'] ) ) { 263 $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] ); 264 } 265 wp_redirect( $url ); 266 exit(); 267 } 268 269 /** 270 * Adds an 'updated=true' argument to a URL. 271 * 272 * @since MU 273 * @deprecated 3.3.0 274 * @deprecated Use add_query_arg() 275 * 276 * @param string $url 277 * @return string 278 */ 279 function wpmu_admin_redirect_add_updated_param( $url = '' ) { 280 _deprecated_function( __FUNCTION__, '3.3' ); 281 282 if ( strpos( $url, 'updated=true' ) === false ) { 283 if ( strpos( $url, '?' ) === false ) 284 return $url . '?updated=true'; 285 else 286 return $url . '&updated=true'; 287 } 288 return $url; 289 } 290 291 /** 292 * Get a numeric user ID from either an email address or a login. 293 * 294 * A numeric string is considered to be an existing user ID 295 * and is simply returned as such. 296 * 297 * @since MU 298 * @deprecated 3.6.0 299 * @deprecated Use get_user_by() 300 * @uses get_user_by() 301 * 302 * @param string $string Either an email address or a login. 303 * @return int 304 */ 305 function get_user_id_from_string( $string ) { 306 _deprecated_function( __FUNCTION__, '3.6', 'get_user_by()' ); 307 308 if ( is_email( $string ) ) 309 $user = get_user_by( 'email', $string ); 310 elseif ( is_numeric( $string ) ) 311 return $string; 312 else 313 $user = get_user_by( 'login', $string ); 314 315 if ( $user ) 316 return $user->ID; 317 return 0; 318 } 319 320 /** 321 * Get a full blog URL, given a domain and a path. 322 * 323 * @since MU 324 * @deprecated 3.7.0 325 * 326 * @param string $domain 327 * @param string $path 328 * @return string 329 */ 330 function get_blogaddress_by_domain( $domain, $path ) { 331 _deprecated_function( __FUNCTION__, '3.7' ); 332 333 if ( is_subdomain_install() ) { 334 $url = "http://" . $domain.$path; 335 } else { 336 if ( $domain != $_SERVER['HTTP_HOST'] ) { 337 $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 338 $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; 339 // we're not installing the main blog 340 if ( $blogname != 'www.' ) 341 $url .= $blogname . '/'; 342 } else { // main blog 343 $url = 'http://' . $domain . $path; 344 } 345 } 346 return esc_url_raw( $url ); 347 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 25 01:41:18 2014 | WordPress honlapkészítés: online1.hu |