do_settings_fields() - WordPress 函数参考中文文档

返回介绍

do_settings_fields()

发布于 2017-09-10 字数2170 浏览 875 评论 0

do_settings_fields( string $page,  string $section )

Print out the settings fields for a particular settings section


描述

Part of the Settings API. Use this in a settings page to output a specific section. Should normally be called by do_settings_sections() rather than directly.


参数

$page

(string)
(Required)
Slug title of the admin page who’s settings fields you want to show.

$section

(string)
(Required)
Slug title of the settings section who’s 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 描述
2.7.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    esc_attr()

Used By

  • wp-admin/includes/template.php:
    do_settings_sections()

User Contributed Notes

上一篇:do_robots()

下一篇:do_settings_sections()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!