Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#48033 closed enhancement (fixed)

Add a register_sidebar_defaults filter

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


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:

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 years ago.
Introduced new filter <code>register_sidebar_defaults</code>
widgets.2.diff (788 bytes) - added by patilvikasj 5 years ago.
Introduced new filter register_sidebar_defaults

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
5 years ago

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

5 years ago

Introduced new filter <code>register_sidebar_defaults</code>

5 years ago

Introduced new filter register_sidebar_defaults

#2 @patilvikasj
5 years ago

  • Keywords has-patch added; needs-patch removed

#3 @SergeyBiryukov
5 years ago

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

#4 @SergeyBiryukov
5 years 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.

#5 @desrosj
4 years ago

In 48045:

General: Continuing to work towards a passing PHP Compatibility scan.

  • Add phpcs:ignore statements to compatibility checks in PHPMailer.
  • Remove quotes around the assertion in an assert() call. This will trigger a deprecated notice under certain conditions on PHP 7.2.

Props jrf, desrosj.
See #49922, #48033.

Note: See TracTickets for help on using tickets.