Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55175 new enhancement

Widgets: Allow filtering args in `the_widget`

Reported by: noisysocks's profile noisysocks Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch
Focuses: Cc:


Originally reported in


### Description

currently it's not possible to change widgets before_title from <h2> to <h4> when you use new gutenberg widgets environment and legacy widgets like nav_menu
it's calling the_widget with $arg without any apply_filter in wp-includes/blocks/legacy-widget.php

### Step-by-step reproduction instructions

  1. Go to /wp-admin/widgets.php
  2. add Legacy Widget - Navigation Menu
  3. Enter some title
  4. On frontend it will be rendered as <h2> but there is no way how to change it to something else, like <h4> - no hook

### Screenshots, screen recording, code snippet

_No response_

### Environment info

_No response_

### Please confirm that you have searched existing issues in the repo.


### Please confirm that you have tested with all plugins deactivated except Gutenberg.


Attachments (1)

#55175.patch (466 bytes) - added by kajalgohel 2 years ago.

Download all attachments as: .zip

Change History (3)

#1 @noisysocks
2 years ago

Adding a new the_widget_args filter to the_widget makes sense to me.

$args = apply_filters( 'the_widget_args', $args, $instance, $widget );

2 years ago

#2 @kajalgohel
2 years ago

  • Keywords has-patch added; needs-patch removed

Added the Filter for the_widget()

Note: See TracTickets for help on using tickets.