Make WordPress Core

Ticket #19709: 19709-2.diff

File 19709-2.diff, 4.7 KB (added by christophherr, 7 years ago)

Refreshes the patch and adds docs

  • src/wp-includes/widgets.php

     
    214214 * @param array|string $args {
    215215 *     Optional. Array or string of arguments for the sidebar being registered.
    216216 *
    217  *     @type string $name          The name or title of the sidebar displayed in the Widgets
    218  *                                 interface. Default 'Sidebar $instance'.
    219  *     @type string $id            The unique identifier by which the sidebar will be called.
    220  *                                 Default 'sidebar-$instance'.
    221  *     @type string $description   Description of the sidebar, displayed in the Widgets interface.
    222  *                                 Default empty string.
    223  *     @type string $class         Extra CSS class to assign to the sidebar in the Widgets interface.
    224  *                                 Default empty.
    225  *     @type string $before_widget HTML content to prepend to each widget's HTML output when
    226  *                                 assigned to this sidebar. Default is an opening list item element.
    227  *     @type string $after_widget  HTML content to append to each widget's HTML output when
    228  *                                 assigned to this sidebar. Default is a closing list item element.
    229  *     @type string $before_title  HTML content to prepend to the sidebar title when displayed.
    230  *                                 Default is an opening h2 element.
    231  *     @type string $after_title   HTML content to append to the sidebar title when displayed.
    232  *                                 Default is a closing h2 element.
     217 *     @type string $name           The name or title of the sidebar displayed in the Widgets
     218 *                                  interface. Default 'Sidebar $instance'.
     219 *     @type string $id             The unique identifier by which the sidebar will be called.
     220 *                                  Default 'sidebar-$instance'.
     221 *     @type string $description    Description of the sidebar, displayed in the Widgets interface.
     222 *                                  Default is an empty string.
     223 *     @type string $class          Extra CSS class to assign to the sidebar in the Widgets interface.
     224 *                                  Default is an empty string.
     225 *     @type string $before_widget  HTML content to prepend to each widget's HTML output when
     226 *                                  assigned to this sidebar. Default is an opening list item element.
     227 *     @type string $after_widget   HTML content to append to each widget's HTML output when
     228 *                                  assigned to this sidebar. Default is a closing list item element.
     229 *     @type string $before_title   HTML content to prepend to the sidebar title when displayed.
     230 *                                  Default is an opening h2 element.
     231 *     @type string $after_title    HTML content to append to the sidebar title when displayed.
     232 *                                  Default is a closing h2 element.
     233 *     @type string $before_sidebar HTML content to prepend to the sidebar.
     234 *                                  Outputs after the dynamic_sidebar_before action.
     235 *                                  Default is an empty string.
     236 *     @type string $after_sidebar  HTML content to append to the sidebar when displayed.
     237 *                                  Outputs before the dynamic_sidebar_after action.
     238 *                                  Default is an empty string.
    233239 * }
    234240 * @return string Sidebar ID added to $wp_registered_sidebars global.
    235241 */
     
    249255                'after_widget' => "</li>\n",
    250256                'before_title' => '<h2 class="widgettitle">',
    251257                'after_title' => "</h2>\n",
     258                'before_sidebar' => '',
     259                'after_sidebar' => '',
    252260        );
    253261
    254262        $sidebar = wp_parse_args( $args, $defaults );
     
    635643                return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
    636644        }
    637645
     646        $sidebar = $wp_registered_sidebars[$index];
     647  $sidebar['before_sidebar'] = sprintf( $sidebar['before_sidebar'], $sidebar['id'], $sidebar['class'] );
     648
    638649        /**
    639650         * Fires before widgets are rendered in a dynamic sidebar.
    640651         *
     
    648659         *                                Default true.
    649660         */
    650661        do_action( 'dynamic_sidebar_before', $index, true );
    651         $sidebar = $wp_registered_sidebars[$index];
    652662
     663        if ( ! empty( $sidebar['before_sidebar'] ) ) {
     664                        echo $sidebar['before_sidebar'];
     665  }
     666
    653667        $did_one = false;
    654668        foreach ( (array) $sidebars_widgets[$index] as $id ) {
    655669
     
    740754                }
    741755        }
    742756
     757        if ( ! empty( $sidebar['after_sidebar'] ) ) {
     758                      echo $sidebar['after_sidebar'];
     759        }
     760
    743761        /**
    744762         * Fires after widgets are rendered in a dynamic sidebar.
    745763         *