Make WordPress Core

Ticket #17851: 17851.4.diff

File 17851.4.diff, 2.8 KB (added by costdev, 4 years ago)

Patch #17851.patch refreshed against trunk, updated with coding standards, docblock updates, and the new, but unused, $section variable is now used.

  • src/wp-admin/includes/template.php

    diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php
    index b367264435..737f02e40f 100644
    a b function do_accordion_sections( $screen, $context, $data_object ) { 
    15611561 * fields. It can output nothing if you want.
    15621562 *
    15631563 * @since 2.7.0
     1564 * @since 6.1.0 Added an `$args` parameter for the section's wrapper HTML and class name.
    15641565 *
    15651566 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages.
    15661567 *
    function do_accordion_sections( $screen, $context, $data_object ) { 
    15701571 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
    15711572 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
    15721573 *                           add_options_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 * }
    15731582 */
    1574 function add_settings_section( $id, $title, $callback, $page ) {
     1583function add_settings_section( $id, $title, $callback, $page, $args = array() ) {
    15751584        global $wp_settings_sections;
    15761585
     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 );
     1596
    15771597        if ( 'misc' === $page ) {
    15781598                _deprecated_argument(
    15791599                        __FUNCTION__,
    function add_settings_section( $id, $title, $callback, $page ) { 
    16001620                $page = 'reading';
    16011621        }
    16021622
    1603         $wp_settings_sections[ $page ][ $id ] = array(
    1604                 'id'       => $id,
    1605                 'title'    => $title,
    1606                 'callback' => $callback,
    1607         );
     1623        $wp_settings_sections[ $page ][ $id ] = $section;
    16081624}
    16091625
    16101626/**
    function do_settings_sections( $page ) { 
    17001716        }
    17011717
    17021718        foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
     1719                if ( '' !== $section['before_section'] ) {
     1720                        echo sprintf( $section['before_section'], $section['section_class'] );
     1721                }
     1722
    17031723                if ( $section['title'] ) {
    17041724                        echo "<h2>{$section['title']}</h2>\n";
    17051725                }
    function do_settings_sections( $page ) { 
    17141734                echo '<table class="form-table" role="presentation">';
    17151735                do_settings_fields( $page, $section['id'] );
    17161736                echo '</table>';
     1737
     1738                if ( '' !== $section['after_section'] ) {
     1739                        echo $section['after_section'];
     1740                }
    17171741        }
    17181742}
    17191743