WordPress函数文档do_settings_sections()
输出所有的设置项目单元 描述 Prints out all settings sections added t…
输出所有的设置项目单元
描述
Prints out all settings sections added to a particular settings page.
用法
<?php do_settings_sections( $page ); ?>
参数
$page
(string) (必填) The slug name of the page whose settings sections you want to output. This should match the page name used in add_settings_section().
默认值: None
注意
This will output the section titles wrapped in h3 tags and the settings fields wrapped in tables.
源文件
do_settings_sections() 函数的代码位于 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
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Prints out all settings sections added to a particular settings page
*
* Part of the Settings API. Use this in a settings page callback function
* to output all the sections and fields that were added to that $page with
* add_settings_section() and add_settings_field()
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
* @since 2.7.0
*
* @param string $page The slug name of the page whos settings sections you want to output
*/
function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
if ( ! isset( $wp_settings_sections[$page] ) )
return;
foreach ( (array) $wp_settings_sections[$page] as $section ) {
if ( $section[‘title’] )
echo “<h3>{$section[‘title’]}</h3>
“;
if ( $section[‘callback’] )
call_user_func( $section[‘callback’], $section );
if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section[‘id’]] ) )
continue;
echo ‘<table class=”form-table”>’;
do_settings_fields( $page, $section[‘id’] );
echo ‘</table>’;
}
}
|
相关
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_sections
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!