WordPress.org

Make WordPress Core

Ticket #17163: ticket.17163.diff

File ticket.17163.diff, 3.5 KB (added by ptahdunbar, 4 years ago)
  • wp-admin/includes/template.php

     
    11551155        if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) 
    11561156                return; 
    11571157 
     1158        $callback = apply_filters( 'do_settings_section_callback-' . $page, 'do_settings_section_output' ); 
     1159         
     1160        if ( !function_exists($callback) ) 
     1161                return false; 
     1162 
    11581163        foreach ( (array) $wp_settings_sections[$page] as $section ) { 
    1159                 echo "<h3>{$section['title']}</h3>\n"; 
    1160                 call_user_func($section['callback'], $section); 
    11611164                if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) 
    11621165                        continue; 
    1163                 echo '<table class="form-table">'; 
    1164                 do_settings_fields($page, $section['id']); 
    1165                 echo '</table>'; 
     1166 
     1167                call_user_func( $callback, $page, $section ); 
    11661168        } 
    11671169} 
    11681170 
    11691171/** 
     1172 * Prints a settings section. 
     1173 * 
     1174 * Part of the Settings API. Used as the default way of displaying a settings section. 
     1175 * To display your setting's section differently, use the 'do_settings_section_callback-$page' 
     1176 * and provide a callback function where $page is the slug the section appears on. 
     1177 * 
     1178 * @since 3.2.0 
     1179 * 
     1180 * @param string $page  The slug name of the page whos settings sections you want to output. 
     1181 * @param array $section A registered section. 
     1182 */ 
     1183function do_settings_section_output( $page, $section ) { 
     1184        echo "<h3>{$section['title']}</h3>\n"; 
     1185        call_user_func( $section['callback'], $section ); 
     1186 
     1187        echo '<table class="form-table">'; 
     1188        do_settings_fields( $page, $section['id'] ); 
     1189        echo '</table>'; 
     1190} 
     1191 
     1192/** 
    11701193 * Print out the settings fields for a particular settings section 
    11711194 * 
    11721195 * Part of the Settings API. Use this in a settings page to output 
     
    11861209        if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) 
    11871210                return; 
    11881211 
     1212        $callback = apply_filters( 'do_settings_fields_callback-' . $page, 'do_settings_fields_output' ); 
     1213         
     1214        if ( !function_exists($callback) ) 
     1215                return false; 
     1216 
    11891217        foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { 
    1190                 echo '<tr valign="top">'; 
    1191                 if ( !empty($field['args']['label_for']) ) 
    1192                         echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>'; 
    1193                 else 
    1194                         echo '<th scope="row">' . $field['title'] . '</th>'; 
    1195                 echo '<td>'; 
    1196                 call_user_func($field['callback'], $field['args']); 
    1197                 echo '</td>'; 
    1198                 echo '</tr>'; 
     1218                call_user_func( $callback, $field ); 
    11991219        } 
    12001220} 
    12011221 
    12021222/** 
     1223 * Prints a settings field. 
     1224 * 
     1225 * Part of the Settings API. Used as the default way of displaying a settings field. 
     1226 * To display your setting's field differently, use the 'do_settings_fields_callback-$page' 
     1227 * and provide a callback function where $page is the $page the setting appears on. 
     1228 * 
     1229 * @since 3.2.0 
     1230 * 
     1231 * @param array $field A registered field within the settings API. 
     1232 */ 
     1233function do_settings_fields_output( $field ) { 
     1234        echo '<tr valign="top">'; 
     1235        if ( !empty($field['args']['label_for']) ) 
     1236                echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>'; 
     1237        else 
     1238                echo '<th scope="row">' . $field['title'] . '</th>'; 
     1239        echo '<td>'; 
     1240        call_user_func($field['callback'], $field['args']); 
     1241        echo '</td>'; 
     1242        echo '</tr>'; 
     1243} 
     1244 
     1245/** 
    12031246 * Register a settings error to be displayed to the user 
    12041247 * 
    12051248 * Part of the Settings API. Use this to show messages to users about settings validation