Changes from branches/3.0/wp-includes/ms-blogs.php at r15452 to trunk/wp-includes/ms-blogs.php at r17005
- File:
-
- 1 edited
-
trunk/wp-includes/ms-blogs.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-blogs.php
r15452 r17005 6 6 * @package WordPress 7 7 * @subpackage Multisite 8 * @since 3.0.0 9 */ 10 11 // @todo use update_blog_details 8 * @since MU 9 */ 10 11 /** 12 * Update the last_updated field for the current blog. 13 * 14 * @since MU 15 */ 12 16 function wpmu_update_blogs_date() { 13 17 global $wpdb; 14 18 19 // TODO: use update_blog_details 20 15 21 $wpdb->update( $wpdb->blogs, array('last_updated' => current_time('mysql', true)), array('blog_id' => $wpdb->blogid) ); 16 22 refresh_blog_details( $wpdb->blogid ); … … 19 25 } 20 26 27 /** 28 * Get a full blog URL, given a blog id. 29 * 30 * @since MU 31 * 32 * @param int $blog_id Blog ID 33 * @return string 34 */ 21 35 function get_blogaddress_by_id( $blog_id ) { 22 36 $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details! … … 24 38 } 25 39 40 /** 41 * Get a full blog URL, given a blog name. 42 * 43 * @since MU 44 * 45 * @param string $blogname The (subdomain or directory) name 46 * @return string 47 */ 26 48 function get_blogaddress_by_name( $blogname ) { 27 49 global $current_site; … … 39 61 } 40 62 41 function get_blogaddress_by_domain( $domain, $path ){ 63 /** 64 * Get a full blog URL, given a domain and a path. 65 * 66 * @since MU 67 * 68 * @param string $domain 69 * @param string $path 70 * @return string 71 */ 72 function get_blogaddress_by_domain( $domain, $path ) { 42 73 if ( is_subdomain_install() ) { 43 74 $url = "http://".$domain.$path; … … 56 87 } 57 88 89 /** 90 * Given a blog's (subdomain or directory) name, retrieve it's id. 91 * 92 * @since MU 93 * 94 * @param string $name 95 * @return int A blog id 96 */ 58 97 function get_id_from_blogname( $name ) { 59 98 global $wpdb, $current_site; … … 77 116 * Retrieve the details for a blog from the blogs table and blog options. 78 117 * 79 * @since 3.0.0 118 * @since MU 119 * 80 120 * @param int|string|array $fields A blog ID, a blog name, or an array of fields to query against. 81 121 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true. … … 203 243 * Clear the blog details cache. 204 244 * 205 * @since 3.0.0245 * @since MU 206 246 * 207 247 * @param int $blog_id Blog ID … … 221 261 * Update the details for a blog. Updates the blogs table for a given blog id. 222 262 * 223 * @since 3.0.0263 * @since MU 224 264 * 225 265 * @param int $blog_id Blog ID … … 261 301 262 302 if ( isset($details[ 'public' ]) ) 263 update_blog_option( $blog_id, 'blog_public', $details[ 'public' ] , false);303 update_blog_option( $blog_id, 'blog_public', $details[ 'public' ] ); 264 304 265 305 refresh_blog_details($blog_id); … … 281 321 * The 'option_$option' filter in get_option() is not called. 282 322 * 283 * @since NA 284 * @package WordPress MU 285 * @subpackage Option 323 * @since MU 286 324 * @uses apply_filters() Calls 'blog_option_$optionname' with the option name value. 287 325 * 288 326 * @param int $blog_id is the id of the blog. 289 * @param string $setting Name of option to retrieve. Should already be SQL-escaped 327 * @param string $setting Name of option to retrieve. Should already be SQL-escaped. 290 328 * @param string $default (optional) Default value returned if option not found. 291 329 * @return mixed Value set for the option. … … 335 373 $value = untrailingslashit( $value ); 336 374 337 if (! @unserialize( $value ) )338 $value = stripslashes( $value );339 340 375 return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id ); 341 376 } 342 377 378 /** 379 * Add an option for a particular blog. 380 * 381 * @since MU 382 * 383 * @param int $id The blog id 384 * @param string $key The option key 385 * @param mixed $value The option value 386 */ 343 387 function add_blog_option( $id, $key, $value ) { 344 388 $id = (int) $id; … … 350 394 } 351 395 396 /** 397 * Delete an option for a particular blog. 398 * 399 * @since MU 400 * 401 * @param int $id The blog id 402 * @param string $key The option key 403 */ 352 404 function delete_blog_option( $id, $key ) { 353 405 $id = (int) $id; … … 359 411 } 360 412 361 function update_blog_option( $id, $key, $value, $refresh = true ) { 413 /** 414 * Update an option for a particular blog. 415 * 416 * @since MU 417 * 418 * @param int $id The blog id 419 * @param string $key The option key 420 * @param mixed $value The option value 421 */ 422 function update_blog_option( $id, $key, $value, $deprecated = null ) { 362 423 $id = (int) $id; 424 425 if ( null !== $deprecated ) 426 _deprecated_argument( __FUNCTION__, '3.1' ); 363 427 364 428 switch_to_blog($id); … … 366 430 restore_current_blog(); 367 431 368 if ( $refresh == true )369 refresh_blog_details( $id ); 432 refresh_blog_details( $id ); 433 370 434 wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options'); 371 435 } 372 436 437 /** 438 * Switch the current blog. 439 * 440 * This function is useful if you need to pull posts, or other information, 441 * from other blogs. You can switch back afterwards using restore_current_blog(). 442 * 443 * Things that aren't switched: 444 * - autoloaded options. See #14992 445 * - plugins. See #14941 446 * 447 * @see restore_current_blog() 448 * @since MU 449 * 450 * @param int $new_blog The id of the blog you want to switch to. Default: current blog 451 * @param bool $validate Whether to check if $new_blog exists before proceeding 452 * @return bool True on success, False if the validation failed 453 */ 373 454 function switch_to_blog( $new_blog, $validate = false ) { 374 455 global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; … … 407 488 $wpdb->suppress_errors( false ); 408 489 } 409 490 410 491 if ( did_action('init') ) { 411 $current_user = wp_get_current_user(); 492 $current_user = wp_get_current_user(); 412 493 if ( is_object( $current_user ) ) 413 494 $current_user->for_blog( $blog_id ); … … 424 505 wp_cache_add_global_groups( $global_groups ); 425 506 else 426 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', ' site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient', 'global-posts' ) );507 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) ); 427 508 wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); 428 509 } … … 433 514 } 434 515 516 /** 517 * Restore the current blog, after calling switch_to_blog() 518 * 519 * @see switch_to_blog() 520 * @since MU 521 * 522 * @return bool True on success, False if we're already on the current blog 523 */ 435 524 function restore_current_blog() { 436 525 global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; … … 480 569 wp_cache_add_global_groups( $global_groups ); 481 570 else 482 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', ' site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient' ) );571 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) ); 483 572 wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); 484 573 } … … 491 580 } 492 581 582 /** 583 * Check if a particular blog is archived. 584 * 585 * @since MU 586 * 587 * @param int $id The blog id 588 * @return string Whether the blog is archived or not 589 */ 493 590 function is_archived( $id ) { 494 591 return get_blog_status($id, 'archived'); 495 592 } 496 593 594 /** 595 * Update the 'archived' status of a particular blog. 596 * 597 * @since MU 598 * 599 * @param int $id The blog id 600 * @param string $archived The new status 601 * @return string $archived 602 */ 497 603 function update_archived( $id, $archived ) { 498 604 update_blog_status($id, 'archived', $archived); … … 503 609 * Update a blog details field. 504 610 * 505 * @since 3.0.0611 * @since MU 506 612 * 507 613 * @param int $blog_id BLog ID 508 614 * @param string $pref A field name 509 615 * @param string $value Value for $pref 510 * @ param bool $refresh Whether to refresh the blog details cache. Default is true.511 */ 512 function update_blog_status( $blog_id, $pref, $value, $ refresh = true) {616 * @return string $value 617 */ 618 function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { 513 619 global $wpdb; 620 621 if ( null !== $deprecated ) 622 _deprecated_argument( __FUNCTION__, '3.1' ); 514 623 515 624 if ( !in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) … … 518 627 $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) ); 519 628 520 if ( $refresh ) 521 refresh_blog_details($blog_id); 522 523 if ( $pref == 'spam' ) { 524 if ( $value == 1 ) 525 do_action( "make_spam_blog", $blog_id ); 526 else 527 do_action( "make_ham_blog", $blog_id ); 528 } 629 refresh_blog_details($blog_id); 630 631 if ( 'spam' == $pref ) 632 ( $value == 1 ) ? do_action( 'make_spam_blog', $blog_id ) : do_action( 'make_ham_blog', $blog_id ); 633 elseif ( 'mature' == $pref ) 634 ( $value == 1 ) ? do_action( 'mature_blog', $blog_id ) : do_action( 'unmature_blog', $blog_id ); 635 elseif ( 'archived' == $pref ) 636 ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id ); 637 elseif ( 'archived' == $pref ) 638 ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id ); 529 639 530 640 return $value; 531 641 } 532 642 643 /** 644 * Get a blog details field. 645 * 646 * @since MU 647 * 648 * @param int $id The blog id 649 * @param string $pref A field name 650 * @return bool $value 651 */ 533 652 function get_blog_status( $id, $pref ) { 534 653 global $wpdb; … … 541 660 } 542 661 662 /** 663 * Get a list of most recently updated blogs. 664 * 665 * @since MU 666 * 667 * @param mixed $deprecated Not used 668 * @param int $start The offset 669 * @param int $quantity The maximum number of blogs to retrieve. Default is 40. 670 * @return array The list of blogs 671 */ 543 672 function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { 544 673 global $wpdb; 674 675 if ( ! empty( $deprecated ) ) 676 _deprecated_argument( __FUNCTION__, 'MU' ); // never used 677 545 678 return $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' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A ); 546 679 }
Note: See TracChangeset
for help on using the changeset viewer.