Ticket #22487: section-priority.patch
| File section-priority.patch, 1.9 KB (added by alexmansfield, 6 months ago) |
|---|
-
wp-admin/includes/template.php
988 988 * @param string $callback Function that echos out any content at the top of the section (between heading and fields). 989 989 * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page(); 990 990 */ 991 function add_settings_section($id, $title, $callback, $page ) {991 function add_settings_section($id, $title, $callback, $page, $priority = 10) { 992 992 global $wp_settings_sections; 993 993 994 994 if ( 'misc' == $page ) { … … 1008 1008 if ( !isset($wp_settings_sections[$page][$id]) ) 1009 1009 $wp_settings_sections[$page][$id] = array(); 1010 1010 1011 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback );1011 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'priority' => $priority); 1012 1012 } 1013 1013 1014 1014 /** … … 1075 1075 if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) ) 1076 1076 return; 1077 1077 1078 uasort($wp_settings_sections[$page], 'compare_priority'); 1079 1078 1080 foreach ( (array) $wp_settings_sections[$page] as $section ) { 1079 1081 if ( $section['title'] ) 1080 1082 echo "<h3>{$section['title']}</h3>\n"; … … 1091 1093 } 1092 1094 1093 1095 /** 1096 * Helper function to compare two objects by priority. 1097 * 1098 * @since 3.4.0 1099 * 1100 * @param object $a Object A. 1101 * @param object $b Object B. 1102 */ 1103 function compare_priority( $a, $b ) { 1104 $ap = $a['priority']; 1105 $bp = $b['priority']; 1106 1107 if ( $ap == $bp ) 1108 return 0; 1109 return ( $ap > $bp ) ? 1 : -1; 1110 } 1111 1112 /** 1094 1113 * Print out the settings fields for a particular settings section 1095 1114 * 1096 1115 * Part of the Settings API. Use this in a settings page to output
