Ticket #14953: ms-blogs.diff
| File ms-blogs.diff, 7.2 KB (added by , 15 years ago) |
|---|
-
wp-includes/ms-blogs.php
8 8 * @since 3.0.0 9 9 */ 10 10 11 // @todo use update_blog_details 11 /** 12 * Update the last_updated field for the current blog. 13 * 14 * @since 3.0.0 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 ); 17 23 18 24 do_action( 'wpmu_blog_updated', $wpdb->blogid ); 19 25 } 20 26 27 /** 28 * Get a full blog URL, given a blog id. 29 * 30 * @since 3.0.0 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! 23 37 return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path ); 24 38 } 25 39 40 /** 41 * Get a full blog URL, given a blog name. 42 * 43 * @since 3.0.0 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; 28 50 … … 38 60 return esc_url( $url . '/' ); 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 3.0.0 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; 44 75 } else { … … 55 86 return esc_url( $url ); 56 87 } 57 88 89 /** 90 * Given a blog's (subdomain or directory) name, retrieve it's id. 91 * 92 * @since 3.0.0 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; 60 99 $blog_id = wp_cache_get( "get_id_from_blogname_" . $name, 'blog-details' ); … … 77 116 * Retrieve the details for a blog from the blogs table and blog options. 78 117 * 79 118 * @since 3.0.0 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. 82 122 * @return object Blog details. … … 280 320 * $blog_id. It returns $value. 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 3.0.0 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. 292 330 */ … … 340 378 return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id ); 341 379 } 342 380 381 /** 382 * Add an option for a particular blog. 383 * 384 * @since 3.0.0 385 * 386 * @param int $id The blog id 387 * @param string $key The option key 388 * @param mixed $value The option value 389 */ 343 390 function add_blog_option( $id, $key, $value ) { 344 391 $id = (int) $id; 345 392 … … 349 396 wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options' ); 350 397 } 351 398 399 /** 400 * Delete an option for a particular blog. 401 * 402 * @since 3.0.0 403 * 404 * @param int $id The blog id 405 * @param string $key The option key 406 */ 352 407 function delete_blog_option( $id, $key ) { 353 408 $id = (int) $id; 354 409 … … 358 413 wp_cache_set( $id."-".$key."-blog_option", '', 'site-options' ); 359 414 } 360 415 416 /** 417 * Update an option for a particular blog. 418 * 419 * @since 3.0.0 420 * 421 * @param int $id The blog id 422 * @param string $key The option key 423 * @param mixed $value The option value 424 * @param bool $refresh Wether to refresh blog details or not 425 */ 361 426 function update_blog_option( $id, $key, $value, $refresh = true ) { 362 427 $id = (int) $id; 363 428 … … 370 435 wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options'); 371 436 } 372 437 438 /** 439 * Switch the current blog. 440 * 441 * This function is useful if you need to pull posts, or other information, 442 * from other blogs. You can switch back afterwards using restore_current_blog(). 443 * 444 * Note: Autoloaded options are not switched. See #14992 445 * 446 * @see restore_current_blog() 447 * @since 3.0.0 448 * 449 * @param int $new_blog The id of the blog you want to switch to. Default: current blog 450 * @param bool $validate Wether to check if $new_blog exists before proceeding 451 * @return bool True on success, False if the validation failed 452 */ 373 453 function switch_to_blog( $new_blog, $validate = false ) { 374 454 global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; 375 455 … … 432 512 return true; 433 513 } 434 514 515 /** 516 * Restore the current blog, after calling switch_to_blog() 517 * 518 * @see switch_to_blog() 519 * @since 3.0.0 520 * 521 * @return bool True on success, False if we're already on the current blog 522 */ 435 523 function restore_current_blog() { 436 524 global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache; 437 525 … … 490 578 return true; 491 579 } 492 580 581 /** 582 * Check if a particular blog is archived. 583 * 584 * @since 3.0.0 585 * 586 * @param int $id The blog id 587 * @return string Wether the blog is archived or not 588 */ 493 589 function is_archived( $id ) { 494 590 return get_blog_status($id, 'archived'); 495 591 } 496 592 593 /** 594 * Update the 'archived' status of a particular blog. 595 * 596 * @since 3.0.0 597 * 598 * @param int $id The blog id 599 * @param string $archived The new status 600 * @return string $archived 601 */ 497 602 function update_archived( $id, $archived ) { 498 603 update_blog_status($id, 'archived', $archived); 499 604 return $archived; … … 508 613 * @param string $pref A field name 509 614 * @param string $value Value for $pref 510 615 * @param bool $refresh Whether to refresh the blog details cache. Default is true. 616 * @return string $value 511 617 */ 512 618 function update_blog_status( $blog_id, $pref, $value, $refresh = true ) { 513 619 global $wpdb; … … 530 636 return $value; 531 637 } 532 638 639 /** 640 * Get a blog details field. 641 * 642 * @since 3.0.0 643 * 644 * @param int $id The blog id 645 * @param string $pref A field name 646 * @return bool $value 647 */ 533 648 function get_blog_status( $id, $pref ) { 534 649 global $wpdb; 535 650 … … 540 655 return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) ); 541 656 } 542 657 658 /** 659 * Get a list of most recently updated blogs. 660 * 661 * @since 3.0.0 662 * 663 * @param $deprecated Not used 664 * @param int $start The offset 665 * @param int $quantity The maximum number of blogs to retrieve. Default is 40. 666 * @return array The list of blogs 667 */ 543 668 function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { 544 669 global $wpdb; 545 670 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 671 } 547 672 548 ?> 673 ?> 674 No newline at end of file