do_settings_sections

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

Description

do_settings_sections( (string) $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()

Parameters (1)

0. $page (string)
The slug name of the page whose settings sections you want to output

Usage

  1. if ( !function_exists( 'do_settings_sections' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/template.php'; 
  3.  
  4. // The slug name of the page whose settings sections you want to output 
  5. $page = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = do_settings_sections($page); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/template.php  
  1. function do_settings_sections( $page ) { 
  2. global $wp_settings_sections, $wp_settings_fields; 
  3.  
  4. if ( ! isset( $wp_settings_sections[$page] ) ) 
  5. return; 
  6.  
  7. foreach ( (array) $wp_settings_sections[$page] as $section ) { 
  8. if ( $section['title'] ) 
  9. echo "<h2>{$section['title']}</h2>\n"; 
  10.  
  11. if ( $section['callback'] ) 
  12. call_user_func( $section['callback'], $section ); 
  13.  
  14. if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) 
  15. continue; 
  16. echo '<table class="form-table">'; 
  17. do_settings_fields( $page, $section['id'] ); 
  18. echo '</table>';