没有hooks 修改的输出do_settings_sections()
.
因此,您唯一的选择是编写自定义版本的函数do_settings_sections()
和do_settings_fields()
. 它们位于/wp-admin/includes/template.php, 第1159-1174行和第1190-1207行(wordpress版本3.2.1)(do not 在此处修改)。
您可以在您的插件中包含类似的内容(不是说这一定是可取的,请考虑与wp未来版本的兼容性):
function custom_do_settings_sections($page) {
global $wp_settings_sections, $wp_settings_fields;
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
return;
foreach( (array) $wp_settings_sections[$page] as $section ) {
echo "<h3>{$section[\'title\']}</h3>\\n";
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 \'<div class="settings-form-wrapper">\';
custom_do_settings_fields($page, $section[\'id\']);
echo \'</div>\';
}
}
function custom_do_settings_fields($page, $section) {
global $wp_settings_fields;
if ( !isset($wp_settings_fields) ||
!isset($wp_settings_fields[$page]) ||
!isset($wp_settings_fields[$page][$section]) )
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
echo \'<div class="settings-form-row">\';
if ( !empty($field[\'args\'][\'label_for\']) )
echo \'<p><label for="\' . $field[\'args\'][\'label_for\'] . \'">\' .
$field[\'title\'] . \'</label><br />\';
else
echo \'<p>\' . $field[\'title\'] . \'<br />\';
call_user_func($field[\'callback\'], $field[\'args\']);
echo \'</p></div>\';
}
}