Changes from trunk/wp-includes/ms-blogs.php at r17005 to branches/3.0/wp-includes/ms-blogs.php at r15452
- File:
-
- 1 edited
-
branches/3.0/wp-includes/ms-blogs.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-includes/ms-blogs.php
r17005 r15452 6 6 * @package WordPress 7 7 * @subpackage Multisite 8 * @since MU8 * @since 3.0.0 9 9 */ 10 10 11 /** 12 * Update the last_updated field for the current blog. 13 * 14 * @since MU 15 */ 11 // @todo use update_blog_details 16 12 function wpmu_update_blogs_date() { 17 13 global $wpdb; 18 19 // TODO: use update_blog_details20 14 21 15 $wpdb->update( $wpdb->blogs, array('last_updated' => current_time('mysql', true)), array('blog_id' => $wpdb->blogid) ); … … 25 19 } 26 20 27 /**28 * Get a full blog URL, given a blog id.29 *30 * @since MU31 *32 * @param int $blog_id Blog ID33 * @return string34 */35 21 function get_blogaddress_by_id( $blog_id ) { 36 22 $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details! … … 38 24 } 39 25 40 /**41 * Get a full blog URL, given a blog name.42 *43 * @since MU44 *45 * @param string $blogname The (subdomain or directory) name46 * @return string47 */48 26 function get_blogaddress_by_name( $blogname ) { 49 27 global $current_site; … … 61 39 } 62 40 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 ) { 41 function get_blogaddress_by_domain( $domain, $path ){ 73 42 if ( is_subdomain_install() ) { 74 43 $url = "http://".$domain.$path; … … 87 56 } 88 57 89 /**90 * Given a blog's (subdomain or directory) name, retrieve it's id.91 *92 * @since MU93 *94 * @param string $name95 * @return int A blog id96 */97 58 function get_id_from_blogname( $name ) { 98 59 global $wpdb, $current_site; … … 116 77 * Retrieve the details for a blog from the blogs table and blog options. 117 78 * 118 * @since MU 119 * 79 * @since 3.0.0 120 80 * @param int|string|array $fields A blog ID, a blog name, or an array of fields to query against. 121 81 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true. … … 243 203 * Clear the blog details cache. 244 204 * 245 * @since MU205 * @since 3.0.0 246 206 * 247 207 * @param int $blog_id Blog ID … … 261 221 * Update the details for a blog. Updates the blogs table for a given blog id. 262 222 * 263 * @since MU223 * @since 3.0.0 264 224 * 265 225 * @param int $blog_id Blog ID … … 301 261 302 262 if ( isset($details[ 'public' ]) ) 303 update_blog_option( $blog_id, 'blog_public', $details[ 'public' ] );263 update_blog_option( $blog_id, 'blog_public', $details[ 'public' ], false ); 304 264 305 265 refresh_blog_details($blog_id); … … 321 281 * The 'option_$option' filter in get_option() is not called. 322 282 * 323 * @since MU 283 * @since NA 284 * @package WordPress MU 285 * @subpackage Option 324 286 * @uses apply_filters() Calls 'blog_option_$optionname' with the option name value. 325 287 * 326 288 * @param int $blog_id is the id of the blog. 327 * @param string $setting Name of option to retrieve. Should already be SQL-escaped .289 * @param string $setting Name of option to retrieve. Should already be SQL-escaped 328 290 * @param string $default (optional) Default value returned if option not found. 329 291 * @return mixed Value set for the option. … … 373 335 $value = untrailingslashit( $value ); 374 336 337 if (! @unserialize( $value ) ) 338 $value = stripslashes( $value ); 339 375 340 return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id ); 376 341 } 377 342 378 /**379 * Add an option for a particular blog.380 *381 * @since MU382 *383 * @param int $id The blog id384 * @param string $key The option key385 * @param mixed $value The option value386 */387 343 function add_blog_option( $id, $key, $value ) { 388 344 $id = (int) $id; … … 394 350 } 395 351 396 /**397 * Delete an option for a particular blog.398 *399 * @since MU400 *401 * @param int $id The blog id402 * @param string $key The option key403 */404 352 function delete_blog_option( $id, $key ) { 405 353 $id = (int) $id; … … 411 359 } 412 360 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 ) { 361 function update_blog_option( $id, $key, $value, $refresh = true ) { 423 362 $id = (int) $id; 424 425 if ( null !== $deprecated )426 _deprecated_argument( __FUNCTION__, '3.1' );427 363 428 364 switch_to_blog($id); … … 430 366 restore_current_blog(); 431 367 432 refresh_blog_details( $id );433 368 if ( $refresh == true ) 369 refresh_blog_details( $id ); 434 370 wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options'); 435 371 } 436 372 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 #14992445 * - plugins. See #14941446 *447 * @see restore_current_blog()448 * @since MU449 *450 * @param int $new_blog The id of the blog you want to switch to. Default: current blog451 * @param bool $validate Whether to check if $new_blog exists before proceeding452 * @return bool True on success, False if the validation failed453 */454 373 function switch_to_blog( $new_blog, $validate = false ) { 455 374 global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; … … 488 407 $wpdb->suppress_errors( false ); 489 408 } 490 409 491 410 if ( did_action('init') ) { 492 $current_user = wp_get_current_user(); 411 $current_user = wp_get_current_user(); 493 412 if ( is_object( $current_user ) ) 494 413 $current_user->for_blog( $blog_id ); … … 505 424 wp_cache_add_global_groups( $global_groups ); 506 425 else 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' ) );426 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient', 'global-posts' ) ); 508 427 wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); 509 428 } … … 514 433 } 515 434 516 /**517 * Restore the current blog, after calling switch_to_blog()518 *519 * @see switch_to_blog()520 * @since MU521 *522 * @return bool True on success, False if we're already on the current blog523 */524 435 function restore_current_blog() { 525 436 global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; … … 569 480 wp_cache_add_global_groups( $global_groups ); 570 481 else 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' ) );482 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient' ) ); 572 483 wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); 573 484 } … … 580 491 } 581 492 582 /**583 * Check if a particular blog is archived.584 *585 * @since MU586 *587 * @param int $id The blog id588 * @return string Whether the blog is archived or not589 */590 493 function is_archived( $id ) { 591 494 return get_blog_status($id, 'archived'); 592 495 } 593 496 594 /**595 * Update the 'archived' status of a particular blog.596 *597 * @since MU598 *599 * @param int $id The blog id600 * @param string $archived The new status601 * @return string $archived602 */603 497 function update_archived( $id, $archived ) { 604 498 update_blog_status($id, 'archived', $archived); … … 609 503 * Update a blog details field. 610 504 * 611 * @since MU505 * @since 3.0.0 612 506 * 613 507 * @param int $blog_id BLog ID 614 508 * @param string $pref A field name 615 509 * @param string $value Value for $pref 616 * @ return string $value510 * @param bool $refresh Whether to refresh the blog details cache. Default is true. 617 511 */ 618 function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { 619 global $wpdb; 620 621 if ( null !== $deprecated ) 622 _deprecated_argument( __FUNCTION__, '3.1' ); 512 function update_blog_status( $blog_id, $pref, $value, $refresh = true ) { 513 global $wpdb; 623 514 624 515 if ( !in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) … … 627 518 $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) ); 628 519 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 ); 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 } 639 529 640 530 return $value; 641 531 } 642 532 643 /**644 * Get a blog details field.645 *646 * @since MU647 *648 * @param int $id The blog id649 * @param string $pref A field name650 * @return bool $value651 */652 533 function get_blog_status( $id, $pref ) { 653 534 global $wpdb; … … 660 541 } 661 542 662 /**663 * Get a list of most recently updated blogs.664 *665 * @since MU666 *667 * @param mixed $deprecated Not used668 * @param int $start The offset669 * @param int $quantity The maximum number of blogs to retrieve. Default is 40.670 * @return array The list of blogs671 */672 543 function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { 673 544 global $wpdb; 674 675 if ( ! empty( $deprecated ) )676 _deprecated_argument( __FUNCTION__, 'MU' ); // never used677 678 545 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 ); 679 546 }
Note: See TracChangeset
for help on using the changeset viewer.