WordPress函数文档choose_primary_blog()
选择主博客 描述 Displays a form table with fields letting the …
选择主博客
描述
Displays a form table with fields letting the user choose the primary blog.
用法
<?php choose_primary_blog(); ?>
参数
None.
源文件
choose_primary_blog() 函数的代码位于 wp-admin/includes/ms.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Handles the display of choosing a user’s primary site.
*
* This displays the user’s primary site and allows the user to choose
* which site is primary.
*
* @since 3.0.0
*/
function choose_primary_blog() {
?>
<table class=“form-table”>
<tr>
<?php translators:=“” my=“” sites=“” label=“” */=“”?>
<th scope=“row”><label for=“primary_blog”><?php _e(=“” ‘primary=”” site’=“” );=“”?></label></th>
<td>
<?php $all_blogs=“get_blogs_of_user(“ get_current_user_id()=“” );=“” $primary_blog=“get_user_meta(“ get_current_user_id(),=“” ‘primary_blog’,=“” true=“” );=“” if=“” (=“” count(=“” $all_blogs=“” )=“”?> 1 ) {
$found = false;
?>
<select name=“primary_blog” id=“primary_blog”>
<?php foreach(=“” (array)=“” $all_blogs=“” as=“” $blog=“” )=“” {=“” if=“” (=“” $primary_blog=“=” $blog-=“”?>userblog_id )
$found = true;
?><option value=“<?php echo $blog->userblog_id ?>“><?php selected(=“” $primary_blog,=“” $blog-=“”?>userblog_id ); ?>><?php echo=“” esc_url(=“” get_home_url(=“” $blog-=“”?>userblog_id ) ) ?><?php }=“”?>
</select>
<?php if=“” (=“” !$found=“” )=“” {=“” $blog=“reset(“ $all_blogs=“” );=“” update_user_meta(=“” get_current_user_id(),=“” ‘primary_blog’,=“” $blog-=“”?>userblog_id );
}
} elseif ( count( $all_blogs ) == 1 ) {
$blog = reset( $all_blogs );
echo esc_url( get_home_url( $blog->userblog_id ) );
if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it’s out of sync with blog list.
update_user_meta( get_current_user_id(), ‘primary_blog’, $blog->userblog_id );
} else {
echo “N/A”;
}
?>
</td>
</tr>
<?php if=“” (=“” in_array(=“” get_site_option(=“” ‘registration’=“” ),=“” array(=“” ‘all’,=“” ‘blog’=“” )=“” )=“” )=“” :=“”?>
<tr>
<th scope=“row” colspan=“2” class=“th-full”>
<?php *=“” this=“” filter=“” is=“” documented=“” in=“” wp–login.php=“” */=“” $sign_up_url=“apply_filters(“ ‘wp_signup_location’,=“” network_site_url(=“” ‘wp-signup.php’=“” )=“” );=“”?>
<a href=“<?php echo esc_url( $sign_up_url ); ?>“><?php _e(=“” ‘create=”” a=”” new=”” site’=“” );=“”?></a>
</th>
</tr>
<?php endif;=“”?>
</table>
<?php }=“”?>
|
- 原文:http://codex.wordpress.org/Function_Reference/choose_primary_blog
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!