do_settings_fields()
最后更新于:2021-11-26 03:58:20
do_settings_fields( string$page, string$section)Print 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.
源文件
文件: gc-admin/includes/template.php
function do_settings_fields( $page, $section ) {
global $gc_settings_fields;
if ( ! isset( $gc_settings_fields[ $page ][ $section ] ) ) {
return;
}
foreach ( (array) $gc_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>';
}
}