<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[15676] trunk/wp-includes/ms-blogs.php:
Add inline documentation for ms-blogs.php.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15676">15676</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-10-01 01:32:31 +0000 (Fri, 01 Oct 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add inline documentation for ms-blogs.php. See <a href="http://trac.wordpress.org/ticket/14953">#14953</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesmsblogsphp">trunk/wp-includes/ms-blogs.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesmsblogsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-blogs.php (15675 => 15676)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-blogs.php        2010-09-29 23:44:34 UTC (rev 15675)
+++ trunk/wp-includes/ms-blogs.php        2010-10-01 01:32:31 UTC (rev 15676)
</span><span class="lines">@@ -5,24 +5,46 @@
</span><span class="cx"> *
</span><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage Multisite
</span><del>- * @since 3.0.0
</del><ins>+ * @since MU
</ins><span class="cx"> */
</span><span class="cx">
</span><del>-// @todo use update_blog_details
</del><ins>+/**
+ * Update the last_updated field for the current blog.
+ *
+ * @since MU
+ */
</ins><span class="cx"> function wpmu_update_blogs_date() {
</span><span class="cx">         global $wpdb;
</span><span class="cx">
</span><ins>+        // TODO: use update_blog_details
+
</ins><span class="cx">         $wpdb->update( $wpdb->blogs, array('last_updated' => current_time('mysql', true)), array('blog_id' => $wpdb->blogid) );
</span><span class="cx">         refresh_blog_details( $wpdb->blogid );
</span><span class="cx">
</span><span class="cx">         do_action( 'wpmu_blog_updated', $wpdb->blogid );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Get a full blog URL, given a blog id.
+ *
+ * @since MU
+ *
+ * @param int $blog_id Blog ID
+ * @return string
+ */
</ins><span class="cx"> function get_blogaddress_by_id( $blog_id ) {
</span><span class="cx">         $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
</span><span class="cx">         return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Get a full blog URL, given a blog name.
+ *
+ * @since MU
+ *
+ * @param string $blogname The (subdomain or directory) name
+ * @return string
+ */
</ins><span class="cx"> function get_blogaddress_by_name( $blogname ) {
</span><span class="cx">         global $current_site;
</span><span class="cx">
</span><span class="lines">@@ -38,7 +60,16 @@
</span><span class="cx">         return esc_url( $url . '/' );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function get_blogaddress_by_domain( $domain, $path ){
</del><ins>+/**
+ * Get a full blog URL, given a domain and a path.
+ *
+ * @since MU
+ *
+ * @param string $domain
+ * @param string $path
+ * @return string
+ */
+function get_blogaddress_by_domain( $domain, $path ) {
</ins><span class="cx">         if ( is_subdomain_install() ) {
</span><span class="cx">                 $url = "http://".$domain.$path;
</span><span class="cx">         } else {
</span><span class="lines">@@ -55,6 +86,14 @@
</span><span class="cx">         return esc_url( $url );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Given a blog's (subdomain or directory) name, retrieve it's id.
+ *
+ * @since MU
+ *
+ * @param string $name
+ * @return int A blog id
+ */
</ins><span class="cx"> function get_id_from_blogname( $name ) {
</span><span class="cx">         global $wpdb, $current_site;
</span><span class="cx">         $blog_id = wp_cache_get( "get_id_from_blogname_" . $name, 'blog-details' );
</span><span class="lines">@@ -76,7 +115,8 @@
</span><span class="cx"> /**
</span><span class="cx"> * Retrieve the details for a blog from the blogs table and blog options.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since MU
+ *
</ins><span class="cx"> * @param int|string|array $fields A blog ID, a blog name, or an array of fields to query against.
</span><span class="cx"> * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
</span><span class="cx"> * @return object Blog details.
</span><span class="lines">@@ -202,7 +242,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Clear the blog details cache.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since MU
</ins><span class="cx"> *
</span><span class="cx"> * @param int $blog_id Blog ID
</span><span class="cx"> */
</span><span class="lines">@@ -220,7 +260,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Update the details for a blog. Updates the blogs table for a given blog id.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since MU
</ins><span class="cx"> *
</span><span class="cx"> * @param int $blog_id Blog ID
</span><span class="cx"> * @param array $details Array of details keyed by blogs table field names.
</span><span class="lines">@@ -280,13 +320,11 @@
</span><span class="cx"> * $blog_id. It returns $value.
</span><span class="cx"> * The 'option_$option' filter in get_option() is not called.
</span><span class="cx"> *
</span><del>- * @since NA
- * @package WordPress MU
- * @subpackage Option
</del><ins>+ * @since MU
</ins><span class="cx"> * @uses apply_filters() Calls 'blog_option_$optionname' with the option name value.
</span><span class="cx"> *
</span><span class="cx"> * @param int $blog_id is the id of the blog.
</span><del>- * @param string $setting Name of option to retrieve. Should already be SQL-escaped
</del><ins>+ * @param string $setting Name of option to retrieve. Should already be SQL-escaped.
</ins><span class="cx"> * @param string $default (optional) Default value returned if option not found.
</span><span class="cx"> * @return mixed Value set for the option.
</span><span class="cx"> */
</span><span class="lines">@@ -340,6 +378,15 @@
</span><span class="cx">         return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Add an option for a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $key The option key
+ * @param mixed $value The option value
+ */
</ins><span class="cx"> function add_blog_option( $id, $key, $value ) {
</span><span class="cx">         $id = (int) $id;
</span><span class="cx">
</span><span class="lines">@@ -349,6 +396,14 @@
</span><span class="cx">         wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Delete an option for a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $key The option key
+ */
</ins><span class="cx"> function delete_blog_option( $id, $key ) {
</span><span class="cx">         $id = (int) $id;
</span><span class="cx">
</span><span class="lines">@@ -358,6 +413,16 @@
</span><span class="cx">         wp_cache_set( $id."-".$key."-blog_option", '', 'site-options' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Update an option for a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $key The option key
+ * @param mixed $value The option value
+ * @param bool $refresh Wether to refresh blog details or not
+ */
</ins><span class="cx"> function update_blog_option( $id, $key, $value, $refresh = true ) {
</span><span class="cx">         $id = (int) $id;
</span><span class="cx">
</span><span class="lines">@@ -370,6 +435,23 @@
</span><span class="cx">         wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options');
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Switch the current blog.
+ *
+ * This function is useful if you need to pull posts, or other information,
+ * from other blogs. You can switch back afterwards using restore_current_blog().
+ *
+ * Things that aren't switched:
+ * - autoloaded options. See #14992
+ * - plugins. See #14941
+ *
+ * @see restore_current_blog()
+ * @since MU
+ *
+ * @param int $new_blog The id of the blog you want to switch to. Default: current blog
+ * @param bool $validate Wether to check if $new_blog exists before proceeding
+ * @return bool        True on success, False if the validation failed
+ */
</ins><span class="cx"> function switch_to_blog( $new_blog, $validate = false ) {
</span><span class="cx">         global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
</span><span class="cx">
</span><span class="lines">@@ -432,6 +514,14 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Restore the current blog, after calling switch_to_blog()
+ *
+ * @see switch_to_blog()
+ * @since MU
+ *
+ * @return bool True on success, False if we're already on the current blog
+ */
</ins><span class="cx"> function restore_current_blog() {
</span><span class="cx">         global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
</span><span class="cx">
</span><span class="lines">@@ -490,10 +580,27 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Check if a particular blog is archived.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @return string Wether the blog is archived or not
+ */
</ins><span class="cx"> function is_archived( $id ) {
</span><span class="cx">         return get_blog_status($id, 'archived');
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Update the 'archived' status of a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $archived The new status
+ * @return string $archived
+ */
</ins><span class="cx"> function update_archived( $id, $archived ) {
</span><span class="cx">         update_blog_status($id, 'archived', $archived);
</span><span class="cx">         return $archived;
</span><span class="lines">@@ -502,12 +609,13 @@
</span><span class="cx"> /**
</span><span class="cx"> * Update a blog details field.
</span><span class="cx"> *
</span><del>- * @since 3.0.0
</del><ins>+ * @since MU
</ins><span class="cx"> *
</span><span class="cx"> * @param int $blog_id BLog ID
</span><span class="cx"> * @param string $pref A field name
</span><span class="cx"> * @param string $value Value for $pref
</span><span class="cx"> * @param bool $refresh Whether to refresh the blog details cache. Default is true.
</span><ins>+ * @return string $value
</ins><span class="cx"> */
</span><span class="cx"> function update_blog_status( $blog_id, $pref, $value, $refresh = true ) {
</span><span class="cx">         global $wpdb;
</span><span class="lines">@@ -530,6 +638,15 @@
</span><span class="cx">         return $value;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Get a blog details field.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $pref A field name
+ * @return bool $value
+ */
</ins><span class="cx"> function get_blog_status( $id, $pref ) {
</span><span class="cx">         global $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -540,6 +657,16 @@
</span><span class="cx">         return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Get a list of most recently updated blogs.
+ *
+ * @since MU
+ *
+ * @param $deprecated Not used
+ * @param int $start The offset
+ * @param int $quantity The maximum number of blogs to retrieve. Default is 40.
+ * @return array The list of blogs
+ */
</ins><span class="cx"> function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
</span><span class="cx">         global $wpdb;
</span><span class="cx">         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 );
</span></span></pre>
</div>
</div>
</body>
</html>