目录
描述
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 34 35 36 37 |
/* ---------------------------------- * wordpress之魂 © http://wphun.com * ---------------------------------- */ /** * 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>'; } } |
- 原文:http://codex.wordpress.org/Function_Reference/do_settings_sections
- 翻译:黄聪@WordPress之魂