Make WordPress Core

Ticket #32065: 32065.3.diff

File 32065.3.diff, 1.3 KB (added by donmhico, 6 years ago)
  • src/wp-includes/widgets/class-wp-widget-rss.php

    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 { 
    3737         * Outputs the content for the current RSS widget instance.
    3838         *
    3939         * @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.
    4042         *
    4143         * @param array $args     Display arguments including 'before_title', 'after_title',
    4244         *                        'before_widget', and 'after_widget'.
    class WP_Widget_RSS extends WP_Widget { 
    6668                $desc  = '';
    6769                $link  = '';
    6870
     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
    6976                if ( ! is_wp_error( $rss ) ) {
    7077                        $desc = esc_attr( strip_tags( html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
    7178                        if ( empty( $title ) ) {
    class WP_Widget_RSS extends WP_Widget { 
    7683                                $link = substr( $link, 1 );
    7784                        }
    7885                }
    79 
     86               
    8087                if ( empty( $title ) ) {
    8188                        $title = ! empty( $desc ) ? $desc : __( 'Unknown Feed' );
    8289                }