do_settings_sections()输出所有的设置项目单元

目录

描述

Prints out all settings sections added to a particular settings page.

do_settings_sections() 描述

用法

<?php do_settings_sections$page ); ?>

do_settings_sections() 用法

参数

$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

do_settings_sections() 参数

注意

This will output the section titles wrapped in h3 tags and the settings fields wrapped in tables.

do_settings_sections() 注意

源文件

do_settings_sections() 函数的代码位于 wp-admin/includes/template.php.

/* ----------------------------------
 * 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 "

{$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 '
'; } }

do_settings_sections() 源文件

相关