add_settings_section()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
add_settings_section( string $id, string $title, callable $callback, string $page, array $args = array() )
Описание
Часть Settings API. Используется для определения новых секций настроек на странице администрирования.
Отображайте секции настроек в функции обратного вызова страницы администрирования с помощью do_settings_sections() .
Добавляйте поля настроек в секцию с помощью add_settings_field() .
Аргумент $callback должен быть именем функции, которая выводит любое содержимое, отображаемое в верхней части секции настроек перед самими полями. При желании она может ничего не выводить.
Оригинал (английский)
Part of the Settings API. Use this to define new settings sections for an admin page.
Show settings sections in your admin page callback function with do_settings_sections() .
Add settings fields to your section with add_settings_field() .
The $callback argument should be the name of a function that echoes out any content you want to show at the top of the settings section before the actual fields. It can output nothing if you want.
Параметры
$id
string
обязательный
$title
string
обязательный
$callback
callable
обязательный
$page
string
обязательный
$args
array
необязательный
= array()
Исходный код
wp-admin/includes/template.php:1637
function add_settings_section( $id, $title, $callback, $page, $args = array() ) {
global $wp_settings_sections;
$defaults = array(
'id' => $id,
'title' => $title,
'callback' => $callback,
'before_section' => '',
'after_section' => '',
'section_class' => '',
);
$section = wp_parse_args( $args, $defaults );
if ( 'misc' === $page ) {
_deprecated_argument(
__FUNCTION__,
'3.0.0',
sprintf(
/* translators: %s: misc */
__( 'The "%s" options group has been removed. Use another settings group.' ),
'misc'
)
);
$page = 'general';
}
if ( 'privacy' === $page ) {
_deprecated_argument(
__FUNCTION__,
'3.5.0',
sprintf(
/* translators: %s: privacy */
__( 'The "%s" options group has been removed. Use another settings group.' ),
'privacy'
)
);
$page = 'reading';
}
$wp_settings_sections[ $page ][ $id ] = $section;
}
История изменений
| Версия | Описание |
|---|---|
| 6.1.0 | Added an $args parameter for the section’s HTML wrapper and class name. |
| 2.7.0 | Introduced. |

