Ticket #23253: 23253.diff
File 23253.diff, 3.6 KB (added by , 4 years ago) |
---|
-
wp-admin/includes/template.php
1667 1667 * add_settings_section() and add_settings_field() 1668 1668 * 1669 1669 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages. 1670 * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections.1671 1670 * @since 2.7.0 1672 1671 * 1673 1672 * @param string $page The slug name of the page whose settings sections you want to output. 1674 1673 */ 1675 1674 function do_settings_sections( $page ) { 1676 global $wp_settings_sections , $wp_settings_fields;1675 global $wp_settings_sections; 1677 1676 1678 1677 if ( ! isset( $wp_settings_sections[ $page ] ) ) { 1679 1678 return; … … 1680 1679 } 1681 1680 1682 1681 foreach ( (array) $wp_settings_sections[ $page ] as $section ) { 1683 if ( $section['title'] ) {1684 echo "<h2>{$section['title']}</h2>\n";1685 1682 render_settings_section( $page, $section ); 1683 } 1684 } 1686 1685 1687 if ( $section['callback'] ) { 1688 call_user_func( $section['callback'], $section ); 1689 } 1686 /** 1687 * Prints out a particular settings section added to a particular settings page 1688 * 1689 * Part of the Settings API. Use this in a settings page callback function 1690 * to output all the fields that were added into the $section_to_find for that $page with 1691 * add_settings_section() and add_settings_field() 1692 * 1693 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages. 1694 * 1695 * @param string $page The slug name of the page whose settings sections you want to output. 1696 * @param string $section_to_find The id of the section on $page you want to output. 1697 */ 1698 function do_settings_section( $page, $section_to_find ) { 1699 global $wp_settings_sections; 1690 1700 1691 if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) { 1692 continue; 1701 if ( ! isset( $wp_settings_sections[ $page ] ) ) { 1702 return; 1703 } 1704 1705 $found_section = false; 1706 foreach ( (array) $wp_settings_sections[ $page ] as $section ) { 1707 if ( $section['id'] == $section_to_find ) { 1708 $found_section = true; 1709 break; 1693 1710 } 1694 echo '<table class="form-table" role="presentation">';1695 do_settings_fields( $page, $section['id'] );1696 echo '</table>';1697 1711 } 1712 1713 if ( ! $found_section ) { 1714 return; 1715 } 1716 1717 render_settings_section( $page, $section ); 1698 1718 } 1699 1719 1700 1720 /** 1721 * Prints out a particular settings section added to a particular settings page 1722 * 1723 * Used by do_settings_sections() and do_settings_section() but not intended for public use 1724 * 1725 * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections. 1726 * 1727 * @param string $page The slug name of the page whose settings sections you want to output. 1728 * @param array $section The section array from $wp_settings_sections to be output. 1729 */ 1730 function render_settings_section( $page, $section ) { 1731 global $wp_settings_fields; 1732 1733 if ( ! is_array( $section ) || ! isset( $section['id'] ) ) { 1734 return; 1735 } 1736 1737 if ( $section['title'] ) { 1738 echo "<h2>{$section['title']}</h2>\n"; 1739 } 1740 1741 if ( $section['callback'] ) { 1742 call_user_func( $section['callback'], $section ); 1743 } 1744 1745 if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) { 1746 return; 1747 } 1748 echo '<table class="form-table" role="presentation">'; 1749 do_settings_fields( $page, $section['id'] ); 1750 echo '</table>'; 1751 } 1752 1753 /** 1701 1754 * Print out the settings fields for a particular settings section. 1702 1755 * 1703 1756 * Part of the Settings API. Use this in a settings page to output