Changeset 54247 for trunk/src/wp-admin/includes/template.php
- Timestamp:
- 09/20/2022 09:57:43 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/template.php
r54071 r54247 1562 1562 * 1563 1563 * @since 2.7.0 1564 * @since 6.1.0 Added an `$args` parameter for the section's HTML wrapper and class name. 1564 1565 * 1565 1566 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages. … … 1571 1572 * 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using 1572 1573 * add_options_page(); 1573 */ 1574 function add_settings_section( $id, $title, $callback, $page ) { 1574 * @param array $args { 1575 * Arguments used to create the settings section. 1576 * 1577 * @type string $before_section HTML content to prepend to the section's HTML output. 1578 * Receives the section's class name as `%s`. Default empty. 1579 * @type string $after_section HTML content to append to the section's HTML output. Default empty. 1580 * @type string $section_class The class name to use for the section. Default empty. 1581 * } 1582 */ 1583 function add_settings_section( $id, $title, $callback, $page, $args = array() ) { 1575 1584 global $wp_settings_sections; 1585 1586 $defaults = array( 1587 'id' => $id, 1588 'title' => $title, 1589 'callback' => $callback, 1590 'before_section' => '', 1591 'after_section' => '', 1592 'section_class' => '', 1593 ); 1594 1595 $section = wp_parse_args( $args, $defaults ); 1576 1596 1577 1597 if ( 'misc' === $page ) { … … 1601 1621 } 1602 1622 1603 $wp_settings_sections[ $page ][ $id ] = array( 1604 'id' => $id, 1605 'title' => $title, 1606 'callback' => $callback, 1607 ); 1623 $wp_settings_sections[ $page ][ $id ] = $section; 1608 1624 } 1609 1625 … … 1701 1717 1702 1718 foreach ( (array) $wp_settings_sections[ $page ] as $section ) { 1719 if ( '' !== $section['before_section'] ) { 1720 if ( '' !== $section['section_class'] ) { 1721 echo wp_kses_post( sprintf( $section['before_section'], esc_attr( $section['section_class'] ) ) ); 1722 } else { 1723 echo wp_kses_post( $section['before_section'] ); 1724 } 1725 } 1726 1703 1727 if ( $section['title'] ) { 1704 1728 echo "<h2>{$section['title']}</h2>\n"; … … 1715 1739 do_settings_fields( $page, $section['id'] ); 1716 1740 echo '</table>'; 1741 1742 if ( '' !== $section['after_section'] ) { 1743 echo wp_kses_post( $section['after_section'] ); 1744 } 1717 1745 } 1718 1746 }
Note: See TracChangeset
for help on using the changeset viewer.