WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 5 months ago

#48033 closed enhancement (fixed)

Add a register_sidebar_defaults filter

Reported by: powerbuoy Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.2.3
Component: Widgets Keywords: good-first-bug has-patch
Focuses: Cc:

Description

Being able to change the register_sidebar defaults on a theme basis would be excellent for those of us who don't render our widgets in a list.

Today we have to specify before_widget and after_widget on every call to register_sidebar, being able to do this instead would be an improvement:

<?php
add_filter('register_sidebar_defaults', function ($defaults) {
    $defaults['before_widget'] = '<article id="widget-%1$s" class="%2$s">';
    $defaults['after_widget'] = '</article>';

    return $defaults;
});

Attachments (2)

widgets.diff (519 bytes) - added by patilvikasj 5 months ago.
Introduced new filter <code>register_sidebar_defaults</code>
widgets.2.diff (788 bytes) - added by patilvikasj 5 months ago.
Introduced new filter register_sidebar_defaults

Download all attachments as: .zip

Change History (6)

#1 @SergeyBiryukov
6 months ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@patilvikasj
5 months ago

Introduced new filter <code>register_sidebar_defaults</code>

@patilvikasj
5 months ago

Introduced new filter register_sidebar_defaults

#2 @patilvikasj
5 months ago

  • Keywords has-patch added; needs-patch removed

#3 @SergeyBiryukov
5 months ago

  • Milestone changed from Future Release to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @SergeyBiryukov
5 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 46147:

Widgets: Introduce register_sidebar_defaults filter for default arguments in register_sidebar().

Props patilvikasj, powerbuoy.
Fixes #48033.

Note: See TracTickets for help on using tickets.