函数原型
do_settings_fields( string $page, string $section )
函数描述
Prints out the settings fields for a particular settings section.
是否弃用
未弃用
函数参数
-
$page
string
Required - Slug title of the admin page whose settings fields you want to show.
-
$section
string
Required - Slug title of the settings section whose fields you want to show.
函数返回值
无
函数位置
File: wp-admin/includes/template.php.
函数源码
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>';
}
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |

