WordPress函数文档do_settings_fields()
输出所有的设置项目 描述 Prints out the settings fields for a parti…
输出所有的设置项目
描述
Prints out the settings fields for a particular settings section.
用法
<?php do_settings_fields( $page, $section ); ?>
参数
$page
(string) (必填) Slug title of the admin page whose settings fields you want to show. This should match the page name used in add_settings_section().
默认值: None
$section
(string) (必填) Slug title of the settings section whose fields you want to show. This should match the section ID used in add_settings_section().
默认值: None
注意
Should normally be called by do_settings_sections() rather than directly.
源文件
do_settings_fields() 函数的代码位于 wp-admin/includes/template.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
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Print out the settings fields for a particular settings section
*
* Part of the Settings API. Use this in a settings page to output
* a specific section. Should normally be called by do_settings_sections()
* rather than directly.
*
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
*
* @since 2.7.0
*
* @param string $page Slug title of the admin page who’s settings fields you want to show.
* @param string $section Slug title of the settings section who’s fields you want to show.
*/
function do_settings_fields($page, $section) {
global $wp_settings_fields;
if ( ! isset( $wp_settings_fields[$page][$section] ) )
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
$class = ”;
if ( ! empty( $field[‘args’][‘class’] ) ) {
$class = ‘ class=”‘ . esc_attr( $field[‘args’][‘class’] ) . ‘”‘;
}
echo “<tr{$class}>”;
if ( ! empty( $field[‘args’][‘label_for’] ) ) {
echo ‘<th scope=”row”><label for=”‘ . esc_attr( $field[‘args’][‘label_for’] ) . ‘”>’ . $field[‘title’] . ‘</label></th>’;
} else {
echo ‘<th scope=”row”>’ . $field[‘title’] . ‘</th>’;
}
echo ‘<td>’;
call_user_func($field[‘callback’], $field[‘args’]);
echo ‘</td>’;
echo ”;
}
}
</tr{$class}>
|
相关
Settings API:
register_setting(),
unregister_setting(),
add_settings_field(),
add_settings_section(),
add_settings_error(),
get_settings_errors(),
settings_errors()
- 原文:http://codex.wordpress.org/Function_Reference/do_settings_fields
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!