Make WordPress Core

Opened 19 months ago

Closed 12 months ago

Last modified 12 months ago

#55448 closed defect (bug) (worksforme)

WP_Widget_Block outputs empty container if widget has no output

Reported by: stiofansisland's profile stiofansisland Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.8
Component: Widgets Keywords: has-patch
Focuses: ui Cc:


There are many widgets that for some reason or another will not output any content, this can be for many reasons, one example would be for a logged in/out user.

When you create your own widget class you have control of the widget() output function and can return an empty string to prevent any output.

The WP_Widget_Block class which is used as a sort of wrapper contains its own widget() class which prevents no output even if the block has no content.

This has left empty boxes showing for many plugins widgets on sites and breaks the backward compatibility of the widgets system.

This should be as easy fix, I will create and submit a patch soon.

Attachments (2)

55448.patch (1.4 KB) - added by stiofansisland 19 months ago.
55448.diff (1.3 KB) - added by stiofansisland 19 months ago.
Fix in .diff format

Download all attachments as: .zip

Change History (13)

19 months ago


19 months ago

Fix in .diff format

#1 @SergeyBiryukov
19 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 6.0

#2 @mehedi890
18 months ago

  • Keywords needs-testing added

Hi there!

I've tested this patch and its works for me
Still, I'm adding the needs-testing label to bring a few extra eyes to this ticket to see if it solves the issue.

#3 @welcher
18 months ago

The code looks good to me. I've not had a chance to test locally though.

#4 follow-up: @stiofansisland
18 months ago

If there is anything i can do to help with testing (demo sites etc) please let me know.

This ticket was mentioned in Slack in #core by chaion07. View the logs.

17 months ago

#6 @peterwilsoncc
17 months ago

  • Keywords needs-unit-tests added
  • Milestone changed from 6.0 to 6.1
  • Severity changed from major to normal
  • Version changed from 5.9.2 to 5.8

With RC1 due in a few hours, I've moved this on to the next milestone for further follow up.

I've set the version to 5.8 as that is when block widgets were introduced.

#7 in reply to: ↑ 4 @desrosj
12 months ago

  • Keywords reporter-feedback added

Replying to stiofansisland:

If there is anything i can do to help with testing (demo sites etc) please let me know.

Are you able to provide an example widget class that can be used to demonstrate the correct behavior and step by step instructions to reproduce the incorrect behavior? That would help with testing considerably. Thanks in advance!

This ticket was mentioned in Slack in #core by audrasjb. View the logs.

12 months ago

#9 @audrasjb
12 months ago

  • Milestone changed from 6.1 to Future Release

As per today's bug scrub:

This patch still needs testing (and testing info/example).
As 6.1 RC1 is planned next week, let's move it to Future Release to make sure it's fully tested before moving it back to another milestone.

#10 @stiofansisland
12 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

I can no longer replicate this. I guess something changed.

#11 @desrosj
12 months ago

  • Keywords needs-testing needs-unit-tests reporter-feedback removed
  • Milestone Future Release deleted

Thanks for confirming @stiofansisland!

Note: See TracTickets for help on using tickets.