WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 21 months ago

#32065 new enhancement

Hide entire RSS widget when no items to display

Reported by: MadtownLems Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2
Component: Widgets Keywords: has-patch
Focuses: Cc:

Description

When a default RSS widget has no items to display, the following text is displayed: "An error has occurred, which probably means the feed is down. Try again later."

I don't believe that this message is particularly useful to readers and suggest that in the event that an RSS Widget is - for whatever reason - unable to display any items, that the widget just doesn't appear at all, rather than display an unhelpful and ugly message.

An alternative implementation is to conditionalize this output with something like current_user_can( 'edit_theme_options' ). This would allow users who can actually control Widgets to still see the output, but standard readers wouldn't have to see it.

Attachments (3)

32065.diff (6.9 KB) - added by donmhico 21 months ago.
32065.2.diff (1.3 KB) - added by donmhico 21 months ago.
32065.3.diff (1.3 KB) - added by donmhico 21 months ago.

Download all attachments as: .zip

Change History (7)

#1 @welcher
6 years ago

I think it's a good idea. Did you want to put together a patch to get the conversation started?

Related #23012.

Last edited 6 years ago by welcher (previous) (diff)

@donmhico
21 months ago

#2 follow-up: @donmhico
21 months ago

  • Keywords has-patch added

In my patch, 32065.diff, I added a new checkbox control in the widget which can be toggled to hide or display the RSS Widget for non-admin users if the RSS feed url has no items to display. By default, this is checked.

Also, like what @MadtownLems mentioned, only the admin users will see the widget with the error message - An error has occurred, which probably means the feed is down. Try again later.. This is so that the admin can easily know that his / her RSS widget has problems.

#3 in reply to: ↑ 2 @SergeyBiryukov
21 months ago

Replying to donmhico:

In my patch, 32065.diff, I added a new checkbox control in the widget which can be toggled to hide or display the RSS Widget for non-admin users if the RSS feed url has no items to display. By default, this is checked.

Thanks for the patch! I don't think a new checkbox is necessary here, per Decisions, not Options philosophy.

Just checking current_user_can( 'edit_theme_options' ) and returning early if there are no items seems enough.

@donmhico
21 months ago

@donmhico
21 months ago

#4 @donmhico
21 months ago

Thanks for the feedback @SergeyBiryukov. I've attached a new patch, 32065.3.diff, that reflects your input.

Note: See TracTickets for help on using tickets.