update_blog_status

函数
update_blog_status ( $blog_id, $pref, $value, $deprecated = null )
参数
  • (int) $blog_id Blog ID.
    Required:
  • (string) $pref Field name.
    Required:
  • (string) $value Field value.
    Required:
  • (null) $deprecated Not used.
    Required:
    Default: null
返回值
  • (string|false) $value
定义位置
相关方法
update_blog_detailsget_blog_statusupdate_user_statusupdate_blog_optionupdate_blog_public
引入
-
弃用
-

update_blog_status: 这个函数更新WordPress多站点网络中的一个站点的状态。它需要两个参数,网站的ID和新的状态。

更新一个博客的细节字段。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
global $wpdb;
if ( null !== $deprecated ) {
_deprecated_argument( __FUNCTION__, '3.1.0' );
}
$allowed_field_names = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );
if ( ! in_array( $pref, $allowed_field_names, true ) ) {
return $value;
}
$result = wp_update_site(
$blog_id,
array(
$pref => $value,
)
);
if ( is_wp_error( $result ) ) {
return false;
}
return $value;
}
function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { global $wpdb; if ( null !== $deprecated ) { _deprecated_argument( __FUNCTION__, '3.1.0' ); } $allowed_field_names = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); if ( ! in_array( $pref, $allowed_field_names, true ) ) { return $value; } $result = wp_update_site( $blog_id, array( $pref => $value, ) ); if ( is_wp_error( $result ) ) { return false; } return $value; }
function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
	global $wpdb;

	if ( null !== $deprecated ) {
		_deprecated_argument( __FUNCTION__, '3.1.0' );
	}

	$allowed_field_names = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );

	if ( ! in_array( $pref, $allowed_field_names, true ) ) {
		return $value;
	}

	$result = wp_update_site(
		$blog_id,
		array(
			$pref => $value,
		)
	);

	if ( is_wp_error( $result ) ) {
		return false;
	}

	return $value;
}

常见问题

FAQs
查看更多 >