do_settings_sections()
do_settings_sections( string $page )
打印出添加到特定设置页的所有设置节
Prints out all settings sections added to a particular settings page
说明(Description)
设置API的一部分。在设置页回调函数中使用此函数,可以使用add_settings_section()和add_settings_field()输出添加到该$page的所有节和字段
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$page | (string) | 必需 | 要输出其设置节的页面的slug名称。 |
返回(Return)
无返回值
源码(Source)
/** * 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 "{$section['title']} "; 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 ''; do_settings_fields( $page, $section['id'] ); echo ''; } }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.7.0 | wp-admin/includes/template.php:1630 | 0 | 1 function |
do_settings_sections() 为WP2原创文章,链接:https://www.wp2.cn/functions/do_settings_sections/