get_dashboard_blog()
云策文档标注
概述
get_dashboard_blog() 函数用于获取“仪表板博客”,即无博客用户编辑个人资料数据的博客。该功能在 WordPress 3.1 中已被弃用,由用户管理替代。
关键要点
- 函数已弃用:自 WordPress 3.1.0 起,推荐使用 get_site() 替代。
- 返回类型:返回 WP_Site 对象,表示当前站点。
- 功能背景:仪表板博客功能在 WordPress 3.1 中被移除,用户管理取代了其角色。
代码示例
function get_dashboard_blog() {
_deprecated_function( __FUNCTION__, '3.1.0', 'get_site()' );
if ( $blog = get_site_option( 'dashboard_blog' ) ) {
return get_site( $blog );
}
return get_site( get_network()->site_id );
}注意事项
- 调用此函数会触发 _deprecated_function() 警告,提示使用 get_site()。
- 函数内部逻辑:先尝试从网络选项获取 dashboard_blog,否则返回网络的主站点。
原文内容
Get the “dashboard blog”, the blog where users without a blog edit their profile data.
Description
Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin.
See also
Source
function get_dashboard_blog() {
_deprecated_function( __FUNCTION__, '3.1.0', 'get_site()' );
if ( $blog = get_site_option( 'dashboard_blog' ) ) {
return get_site( $blog );
}
return get_site( get_network()->site_id );
}
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Deprecated. Use get_site() |
| MU (3.0.0) | Introduced. |