diff --git src/wp-includes/widgets/class-wp-widget-rss.php src/wp-includes/widgets/class-wp-widget-rss.php
index 570e7bba43..b47968d1d2 100644
|
|
class WP_Widget_RSS extends WP_Widget { |
37 | 37 | * Outputs the content for the current RSS widget instance. |
38 | 38 | * |
39 | 39 | * @since 2.8.0 |
| 40 | * @since 5.3.0 Do not display the widget to non-admin users if there are |
| 41 | * no RSS items fetched. |
40 | 42 | * |
41 | 43 | * @param array $args Display arguments including 'before_title', 'after_title', |
42 | 44 | * 'before_widget', and 'after_widget'. |
… |
… |
class WP_Widget_RSS extends WP_Widget { |
66 | 68 | $desc = ''; |
67 | 69 | $link = ''; |
68 | 70 | |
| 71 | // Do not display the widget to non-admin users if there are no RSS feed items fetched. |
| 72 | if ( ! current_user_can( 'edit_theme_options' ) && ( is_wp_error( $rss ) || $rss->get_item_quantity() <= 0 ) ) { |
| 73 | return; |
| 74 | } |
| 75 | |
69 | 76 | if ( ! is_wp_error( $rss ) ) { |
70 | 77 | $desc = esc_attr( strip_tags( html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); |
71 | 78 | if ( empty( $title ) ) { |
… |
… |
class WP_Widget_RSS extends WP_Widget { |
76 | 83 | $link = substr( $link, 1 ); |
77 | 84 | } |
78 | 85 | } |
79 | | |
| 86 | |
80 | 87 | if ( empty( $title ) ) { |
81 | 88 | $title = ! empty( $desc ) ? $desc : __( 'Unknown Feed' ); |
82 | 89 | } |