do_settings_fields()
do_settings_fields( string $page, string $section ) 打印出…
do_settings_fields( string $page, string $section )
打印出特定设置部分的设置字段。
Print out the settings fields for a particular settings section.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
设置API的一部分。在“设置”页中使用此选项可输出特定节。通常应该由do_settings_sections()调用,而不是直接调用。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $page | (string) | 必需 | 要显示其设置字段的管理页的Slug标题。 |
| $section | (string) | 必需 | 要显示其字段的设置节的Slug标题。 |
返回(Return)
无返回值
源码(Source)
/**
* 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 "";
if ( ! empty( $field['args']['label_for'] ) ) {
echo '' . $field['title'] . '';
} else {
echo '' . $field['title'] . '';
}
echo '';
call_user_func($field['callback'], $field['args']);
echo '';
echo '';
}
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.7.0 | wp-admin/includes/template.php:1669 | 1 function | 1 function |
笔记(Notes)
要在自定义页面设置中加载多个选项卡,需要使用此函数。
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!