wp/wp-includes/ms-blogs.php
author ymh <ymh.work@gmail.com>
Wed, 06 Nov 2013 03:21:17 +0000
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
first import
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 * Site/blog functions that work with the blogs table and related data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * Update the last_updated field for the current blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
function wpmu_update_blogs_date() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
	do_action( 'wpmu_blog_updated', $wpdb->blogid );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
 * Get a full blog URL, given a blog id.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
 * @param int $blog_id Blog ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
function get_blogaddress_by_id( $blog_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	$bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
 * Get a full blog URL, given a blog name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
 * @param string $blogname The (subdomain or directory) name
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
function get_blogaddress_by_name( $blogname ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	if ( is_subdomain_install() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
		if ( $blogname == 'main' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
			$blogname = 'www';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		$url = rtrim( network_home_url(), '/' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
		if ( !empty( $blogname ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
			$url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		$url = network_home_url( $blogname );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
	return esc_url( $url . '/' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
 * Given a blog's (subdomain or directory) slug, retrieve its id.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
 * @param string $slug
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
 * @return int A blog id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
function get_id_from_blogname( $slug ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	global $wpdb, $current_site;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	$slug = trim( $slug, '/' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	$blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	if ( $blog_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		return $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	if ( is_subdomain_install() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
		$domain = $slug . '.' . $current_site->domain;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		$path = $current_site->path;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		$domain = $current_site->domain;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		$path = $current_site->path . $slug . '/';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
	$blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	wp_cache_set( 'get_id_from_blogname_' . $slug, $blog_id, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	return $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
 * Retrieve the details for a blog from the blogs table and blog options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
 * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
 * @return object Blog details.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
function get_blog_details( $fields = null, $get_all = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	if ( is_array($fields ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
		if ( isset($fields['blog_id']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			$blog_id = $fields['blog_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		} elseif ( isset($fields['domain']) && isset($fields['path']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
			$key = md5( $fields['domain'] . $fields['path'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
			$blog = wp_cache_get($key, 'blog-lookup');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
			if ( false !== $blog )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
				return $blog;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
				$nowww = substr( $fields['domain'], 4 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
			if ( $blog ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
				$blog_id = $blog->blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
				return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		} elseif ( isset($fields['domain']) && is_subdomain_install() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
			$key = md5( $fields['domain'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
			$blog = wp_cache_get($key, 'blog-lookup');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			if ( false !== $blog )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
				return $blog;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
				$nowww = substr( $fields['domain'], 4 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
			if ( $blog ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
				$blog_id = $blog->blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
				return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
		if ( ! $fields )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			$blog_id = get_current_blog_id();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
		elseif ( ! is_numeric( $fields ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
			$blog_id = get_id_from_blogname( $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
			$blog_id = $fields;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
	$blog_id = (int) $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
	$all = $get_all == true ? '' : 'short';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
	$details = wp_cache_get( $blog_id . $all, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	if ( $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
		if ( ! is_object( $details ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
			if ( $details == -1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
				return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
				// Clear old pre-serialized objects. Cache clients do better with that.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
				wp_cache_delete( $blog_id . $all, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
				unset($details);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
			return $details;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
	// Try the other cache.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	if ( $get_all ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		$details = wp_cache_get( $blog_id . 'short', 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
		$details = wp_cache_get( $blog_id, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
		// If short was requested and full cache is set, we can return.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		if ( $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
			if ( ! is_object( $details ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
				if ( $details == -1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
					return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
					// Clear old pre-serialized objects. Cache clients do better with that.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
					wp_cache_delete( $blog_id, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
					unset($details);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
				return $details;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	if ( empty($details) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		$details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		if ( ! $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
			// Set the full cache.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
			wp_cache_set( $blog_id, -1, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	if ( ! $get_all ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		wp_cache_set( $blog_id . $all, $details, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
		return $details;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
	switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
	$details->blogname		= get_option( 'blogname' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	$details->siteurl		= get_option( 'siteurl' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
	$details->post_count	= get_option( 'post_count' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
	$details = apply_filters( 'blog_details', $details );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	wp_cache_set( $blog_id . $all, $details, 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
	$key = md5( $details->domain . $details->path );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
	wp_cache_set( $key, $details, 'blog-lookup' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	return $details;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
 * Clear the blog details cache.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
 * @param int $blog_id Blog ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
function refresh_blog_details( $blog_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
	$blog_id = (int) $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
	$details = get_blog_details( $blog_id, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
	if ( ! $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
		// Make sure clean_blog_cache() gets the blog ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
		// when the blog has been previously cached as
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
		// non-existent.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
		$details = (object) array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
			'blog_id' => $blog_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
			'domain' => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
			'path' => null
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
	clean_blog_cache( $details );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
	do_action( 'refresh_blog_details', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
 * Update the details for a blog. Updates the blogs table for a given blog id.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
 * @param int $blog_id Blog ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
 * @param array $details Array of details keyed by blogs table field names.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
 * @return bool True if update succeeds, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
function update_blog_details( $blog_id, $details = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
	if ( empty($details) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
	if ( is_object($details) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
		$details = get_object_vars($details);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
	$current_details = get_blog_details($blog_id, false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
	if ( empty($current_details) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
	$current_details = get_object_vars($current_details);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
	$details = array_merge($current_details, $details);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
	$details['last_updated'] = current_time('mysql', true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
	$update_details = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
	$fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
	foreach ( array_intersect( array_keys( $details ), $fields ) as $field )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		$update_details[$field] = $details[$field];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
	$result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	if ( false === $result )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	// If spam status changed, issue actions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
	if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
		if ( $details[ 'spam' ] == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
			do_action( 'make_spam_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
			do_action( 'make_ham_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
	// If mature status changed, issue actions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
	if ( $details[ 'mature' ] != $current_details[ 'mature' ] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
		if ( $details[ 'mature' ] == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
			do_action( 'mature_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
			do_action( 'unmature_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
	// If archived status changed, issue actions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
	if ( $details[ 'archived' ] != $current_details[ 'archived' ] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
		if ( $details[ 'archived' ] == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
			do_action( 'archive_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
			do_action( 'unarchive_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
	// If deleted status changed, issue actions.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
	if ( $details[ 'deleted' ] != $current_details[ 'deleted' ] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
		if ( $details[ 'deleted' ] == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
			do_action( 'make_delete_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
			do_action( 'make_undelete_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
	if ( isset( $details[ 'public' ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
		switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
		update_option( 'blog_public', $details[ 'public' ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
		restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
	refresh_blog_details($blog_id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
 * Clean the blog cache
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
 * @param stdClass $blog The blog details as returned from get_blog_details()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
function clean_blog_cache( $blog ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	$blog_id = $blog->blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
	$domain_path_key = md5( $blog->domain . $blog->path );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
	wp_cache_delete( $blog_id , 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
	wp_cache_delete( $blog_id . 'short' , 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
	wp_cache_delete(  $domain_path_key, 'blog-lookup' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
	wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
	wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
	wp_cache_delete( 'get_id_from_blogname_' . trim( $blog->path, '/' ), 'blog-details' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
	wp_cache_delete( $domain_path_key, 'blog-id-cache' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
 * Retrieve option value for a given blog id based on name of option.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
 * If the option does not exist or does not have a value, then the return value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
 * will be false. This is useful to check whether you need to install an option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
 * and is commonly used during installation of plugin options and to test
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
 * whether upgrading is required.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
 * If the option was serialized then it will be unserialized when it is returned.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
 * @param int $id A blog ID. Can be null to refer to the current blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
 * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
 * @param mixed $default Optional. Default value to return if the option does not exist.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
 * @return mixed Value set for the option.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
function get_blog_option( $id, $option, $default = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
	$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
	if ( empty( $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
		$id = get_current_blog_id();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	if ( get_current_blog_id() == $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		return get_option( $option, $default );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
	switch_to_blog( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	$value = get_option( $option, $default );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	return apply_filters( 'blog_option_' . $option, $value, $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
 * Add a new option for a given blog id.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
 * You do not need to serialize values. If the value needs to be serialized, then
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
 * it will be serialized before it is inserted into the database. Remember,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
 * resources can not be serialized or added as an option.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
 * You can create options without values and then update the values later.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
 * Existing options will not be updated and checks are performed to ensure that you
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
 * aren't adding a protected WordPress option. Care should be taken to not name
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
 * options the same as the ones which are protected.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
 * @param int $id A blog ID. Can be null to refer to the current blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
 * @param string $option Name of option to add. Expected to not be SQL-escaped.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
 * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
 * @return bool False if option was not added and true if option was added.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
function add_blog_option( $id, $option, $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
	$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
	if ( empty( $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
		$id = get_current_blog_id();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
	if ( get_current_blog_id() == $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
		return add_option( $option, $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
	switch_to_blog( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
	$return = add_option( $option, $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
	return $return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
 * Removes option by name for a given blog id. Prevents removal of protected WordPress options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
 * @param int $id A blog ID. Can be null to refer to the current blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
 * @param string $option Name of option to remove. Expected to not be SQL-escaped.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
 * @return bool True, if option is successfully deleted. False on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
function delete_blog_option( $id, $option ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
	$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
	if ( empty( $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
		$id = get_current_blog_id();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
	if ( get_current_blog_id() == $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
		return delete_option( $option );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
	switch_to_blog( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
	$return = delete_option( $option );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
	return $return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
 * Update an option for a particular blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
 * @param int $id The blog id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
 * @param string $option The option key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
 * @param mixed $value The option value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
 * @return bool True on success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
function update_blog_option( $id, $option, $value, $deprecated = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
	$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
	if ( null !== $deprecated  )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
		_deprecated_argument( __FUNCTION__, '3.1' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
	if ( get_current_blog_id() == $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
		return update_option( $option, $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
	switch_to_blog( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
	$return = update_option( $option, $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
	refresh_blog_details( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
	return $return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
 * Switch the current blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
 * This function is useful if you need to pull posts, or other information,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
 * from other blogs. You can switch back afterwards using restore_current_blog().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
 * Things that aren't switched:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
 *  - autoloaded options. See #14992
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
 *  - plugins. See #14941
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
 * @see restore_current_blog()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
 * @param int $new_blog The id of the blog you want to switch to. Default: current blog
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
 * @param bool $deprecated Deprecated argument
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
 * @return bool True on success, false if the validation failed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
function switch_to_blog( $new_blog, $deprecated = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
	global $wpdb, $wp_roles;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
	if ( empty( $new_blog ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
		$new_blog = $GLOBALS['blog_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
	$GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
	/* If we're switching to the same blog id that we're on,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
	* set the right vars, do the associated actions, but skip
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
	* the extra unnecessary work */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
	if ( $new_blog == $GLOBALS['blog_id'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
		do_action( 'switch_blog', $new_blog, $new_blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
		$GLOBALS['switched'] = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
	$wpdb->set_blog_id( $new_blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
	$prev_blog_id = $GLOBALS['blog_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
	$GLOBALS['blog_id'] = $new_blog;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
		wp_cache_switch_to_blog( $new_blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
		global $wp_object_cache;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
			$global_groups = $wp_object_cache->global_groups;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
			$global_groups = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
		wp_cache_init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
			if ( is_array( $global_groups ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
				wp_cache_add_global_groups( $global_groups );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
			wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
	if ( did_action( 'init' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
		$wp_roles->reinit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
		$current_user = wp_get_current_user();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
		$current_user->for_blog( $new_blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
	do_action( 'switch_blog', $new_blog, $prev_blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
	$GLOBALS['switched'] = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
 * Restore the current blog, after calling switch_to_blog()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
 * @see switch_to_blog()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
 * @return bool True on success, false if we're already on the current blog
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
function restore_current_blog() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
	global $wpdb, $wp_roles;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
	if ( empty( $GLOBALS['_wp_switched_stack'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	$blog = array_pop( $GLOBALS['_wp_switched_stack'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
	if ( $GLOBALS['blog_id'] == $blog ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
		do_action( 'switch_blog', $blog, $blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
		// If we still have items in the switched stack, consider ourselves still 'switched'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
		$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
	$wpdb->set_blog_id( $blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
	$prev_blog_id = $GLOBALS['blog_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
	$GLOBALS['blog_id'] = $blog;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
		wp_cache_switch_to_blog( $blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
		global $wp_object_cache;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
			$global_groups = $wp_object_cache->global_groups;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
			$global_groups = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
		wp_cache_init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
			if ( is_array( $global_groups ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
				wp_cache_add_global_groups( $global_groups );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
			wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
	if ( did_action( 'init' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
		$wp_roles->reinit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
		$current_user = wp_get_current_user();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
		$current_user->for_blog( $blog );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
	do_action( 'switch_blog', $blog, $prev_blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
	// If we still have items in the switched stack, consider ourselves still 'switched'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
 * Determines if switch_to_blog() is in effect
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
 * @return bool True if switched, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
function ms_is_switched() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
	return ! empty( $GLOBALS['_wp_switched_stack'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
 * Check if a particular blog is archived.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
 * @param int $id The blog id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
 * @return string Whether the blog is archived or not
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
function is_archived( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
	return get_blog_status($id, 'archived');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
 * Update the 'archived' status of a particular blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
 * @param int $id The blog id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
 * @param string $archived The new status
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
 * @return string $archived
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   633
function update_archived( $id, $archived ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
	update_blog_status($id, 'archived', $archived);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
	return $archived;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
 * Update a blog details field.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
 * @param int $blog_id BLog ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
 * @param string $pref A field name
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
 * @param string $value Value for $pref
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
 * @return string $value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
	if ( null !== $deprecated  )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
		_deprecated_argument( __FUNCTION__, '3.1' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
	if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
		return $value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
	$result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
	if ( false === $result )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
	refresh_blog_details( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
	if ( 'spam' == $pref )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
		( $value == 1 ) ? do_action( 'make_spam_blog', $blog_id ) :	do_action( 'make_ham_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
	elseif ( 'mature' == $pref )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
		( $value == 1 ) ? do_action( 'mature_blog', $blog_id ) : do_action( 'unmature_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
	elseif ( 'archived' == $pref )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
		( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
	elseif ( 'deleted' == $pref )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
		( $value == 1 ) ? do_action( 'make_delete_blog', $blog_id ) : do_action( 'make_undelete_blog', $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
	elseif ( 'public' == $pref )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
		do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
	return $value;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
 * Get a blog details field.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
 * @param int $id The blog id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
 * @param string $pref A field name
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
 * @return bool $value
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
function get_blog_status( $id, $pref ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
	$details = get_blog_details( $id, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
	if ( $details )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
		return $details->$pref;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
 * Get a list of most recently updated blogs.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
 * @since MU
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
 * @param mixed $deprecated Not used
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
 * @param int $start The offset
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
 * @param int $quantity The maximum number of blogs to retrieve. Default is 40.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
 * @return array The list of blogs
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
	if ( ! empty( $deprecated ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
		_deprecated_argument( __FUNCTION__, 'MU' ); // never used
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
	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 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
 * Handler for updating the blog date when a post is published or an already published post is changed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
 * @param string $new_status The new post status
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
 * @param string $old_status The old post status
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
 * @param object $post Post object
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
	$post_type_obj = get_post_type_object( $post->post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
	if ( ! $post_type_obj->public )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
	if ( 'publish' != $new_status && 'publish' != $old_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
	// Post was freshly published, published post was saved, or published post was unpublished.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
	wpmu_update_blogs_date();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
 * Handler for updating the blog date when a published post is deleted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
 * @param int $post_id Post ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
function _update_blog_date_on_post_delete( $post_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
	$post = get_post( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
	$post_type_obj = get_post_type_object( $post->post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
	if ( ! $post_type_obj->public )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
	if ( 'publish' != $post->post_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
	wpmu_update_blogs_date();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757