Make the callback optional for add_settings_section(). Props lightningspirit. fixes #21630

git-svn-id: https://develop.svn.wordpress.org/trunk@21742 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-09-04 20:55:20 +00:00
parent a8549576b4
commit d31b2ea583

View File

@ -1106,20 +1106,23 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
* *
* @param string $page The slug name of the page whos settings sections you want to output * @param string $page The slug name of the page whos settings sections you want to output
*/ */
function do_settings_sections($page) { function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields; global $wp_settings_sections, $wp_settings_fields;
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) )
return; return;
foreach ( (array) $wp_settings_sections[$page] as $section ) { foreach ( (array) $wp_settings_sections[$page] as $section ) {
if ( $section['title'] ) if ( $section['title'] )
echo "<h3>{$section['title']}</h3>\n"; 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']]) ) 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; continue;
echo '<table class="form-table">'; echo '<table class="form-table">';
do_settings_fields($page, $section['id']); do_settings_fields( $page, $section['id'] );
echo '</table>'; echo '</table>';
} }
} }