Make WordPress Core

Ticket #52224: 52224.3.diff

File 52224.3.diff, 12.9 KB (added by sabernhardt, 4 years ago)
  • src/wp-content/themes/twentyseventeen/style.css

     
    26622662
    26632663/* RSS Widget */
    26642664
    2665 .widget_rss .widget-title .rsswidget:first-child {
     2665.widget_rss .widget-title .rsswidget:first-child:not(.rss-widget-title) {
    26662666        float: right;
    26672667}
    26682668
  • src/wp-content/themes/twentytwenty/style-rtl.css

     
    42864286
    42874287/* Widget: RSS ------------------------------- */
    42884288
    4289 .widget_rss .widget-title a.rsswidget:first-of-type {
     4289.widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) {
    42904290        display: none;
    42914291}
    42924292
  • src/wp-content/themes/twentytwenty/style.css

     
    43204320
    43214321/* Widget: RSS ------------------------------- */
    43224322
    4323 .widget_rss .widget-title a.rsswidget:first-of-type {
     4323.widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) {
    43244324        display: none;
    43254325}
    43264326
  • src/wp-includes/widgets.php

     
    15291529 * Display the RSS entries in a list.
    15301530 *
    15311531 * @since 2.5.0
     1532 * @since 5.9.0 Added `show_icon` argument.
    15321533 *
    1533  * @param string|array|object $rss  RSS url.
     1534 * @param string|array|object $rss  RSS URL.
    15341535 * @param array               $args Widget arguments.
    15351536 */
    15361537function wp_widget_rss_output( $rss, $args = array() ) {
     
    15541555                'show_author'  => 0,
    15551556                'show_date'    => 0,
    15561557                'show_summary' => 0,
     1558                'show_icon'    => 1,
    15571559                'items'        => 0,
    15581560        );
    15591561        $args         = wp_parse_args( $args, $default_args );
     
    15651567        $show_summary = (int) $args['show_summary'];
    15661568        $show_author  = (int) $args['show_author'];
    15671569        $show_date    = (int) $args['show_date'];
     1570        $show_icon    = (int) $args['show_icon'];
    15681571
    15691572        if ( ! $rss->get_item_quantity() ) {
    15701573                echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
     
    16371640 *
    16381641 * The options for what fields are displayed for the RSS form are all booleans
    16391642 * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
    1640  * 'show_date'.
     1643 * 'show_date', 'show_icon'.
     1644.
    16411645 *
    16421646 * @since 2.5.0
     1647 * @since 5.9.0 Added `show_icon` argument.
    16431648 *
    16441649 * @param array|string $args   Values for input fields.
    16451650 * @param array        $inputs Override default display options.
     
    16521657                'show_summary' => true,
    16531658                'show_author'  => true,
    16541659                'show_date'    => true,
     1660                'show_icon'    => true,
    16551661        );
    16561662        $inputs         = wp_parse_args( $inputs, $default_inputs );
    16571663
     
    16661672        $args['show_summary'] = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary'];
    16671673        $args['show_author']  = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author'];
    16681674        $args['show_date']    = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date'];
     1675        $args['show_icon']    = isset( $args['show_icon'] ) ? (int) $args['show_icon'] : (int) $inputs['show_icon'];
    16691676
    16701677        if ( ! empty( $args['error'] ) ) {
    16711678                echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error'] . '</p>';
     
    16991706        <?php endif; if ( $inputs['show_date'] ) : ?>
    17001707                <input id="rss-show-date-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>
    17011708                <label for="rss-show-date-<?php echo $esc_number; ?>"><?php _e( 'Display item date?' ); ?></label><br />
     1709        <?php endif;
     1710        /** This filter is documented in wp-includes/class-wp-widget-rss.php */
     1711        if ( apply_filters( 'rss_widget_feed_link', true ) && $inputs['show_icon'] ) : ?>
     1712                <input id="rss-show-icon-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_icon]" type="checkbox" value="1" <?php checked( $args['show_icon'] ); ?>/>
     1713                <label for="rss-show-icon-<?php echo $esc_number; ?>"><?php _e( 'Display feed icon?' ); ?></label><br />
    17021714        <?php endif; ?>
    17031715        </p>
    17041716        <?php
     
    17201732 * default, which is 10.
    17211733 *
    17221734 * The resulting array has the feed title, feed url, feed link (from channel),
    1723  * feed items, error (if any), and whether to show summary, author, and date.
     1735 * feed items, error (if any), and whether to show summary, author, date, and feed icon.
    17241736 * All respectively in the order of the array elements.
    17251737 *
    17261738 * @since 2.5.0
     1739 * @since 5.9.0 Added `show_icon` argument.
    17271740 *
    17281741 * @param array $widget_rss RSS widget feed data. Expects unescaped data.
    17291742 * @param bool  $check_feed Optional. Whether to check feed for errors. Default true.
     
    17391752        $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
    17401753        $show_author  = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] : 0;
    17411754        $show_date    = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
     1755        $show_icon    = isset( $widget_rss['show_icon'] ) ? (int) $widget_rss['show_icon'] : 0;
    17421756        $error        = false;
    17431757        $link         = '';
    17441758
     
    17581772                }
    17591773        }
    17601774
    1761         return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
     1775        return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date', 'show_icon' );
    17621776}
    17631777
    17641778/**
  • src/wp-includes/widgets/class-wp-widget-rss.php

     
    3939         * Outputs the content for the current RSS widget instance.
    4040         *
    4141         * @since 2.8.0
     42         * @since 5.9.0 Added `show_icon` argument.
    4243         *
    4344         * @param array $args     Display arguments including 'before_title', 'after_title',
    4445         *                        'before_widget', and 'after_widget'.
     
    8687                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    8788                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    8889
    89                 $url  = strip_tags( $url );
    90                 $icon = includes_url( 'images/rss.png' );
    9190                if ( $title ) {
    92                         $title = '<a class="rsswidget" href="' . esc_url( $url ) . '"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="' . esc_url( $icon ) . '" alt="RSS" /></a> <a class="rsswidget" href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a>';
     91                        $feed_link = '';
     92                        if ( ! isset( $instance['show_icon'] ) || $instance['show_icon'] ) {
     93                                $feed_url  = strip_tags( $url );
     94                                $feed_icon = includes_url( 'images/rss.png' );
     95                                $feed_link = sprintf(
     96                                        '<a class="rsswidget rss-widget-feed" href="%1$s"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="%2$s" alt="%3$s"%4$s /></a> ',
     97                                        esc_url( $feed_url ),
     98                                        esc_url( $feed_icon ),
     99                                        esc_attr__( 'RSS' ),
     100                                        ( wp_lazy_loading_enabled( 'img', 'rss_widget_feed_icon' ) ? ' loading="lazy"' : '' )
     101                                );
     102                        }
     103
     104                        /**
     105                         * Filters the classic RSS widget's feed icon link.
     106                         *
     107                         * Themes can remove the icon link by using `add_filter( 'rss_widget_feed_link', '__return_false' );`.
     108                         *
     109                         * @since 5.9.0
     110                         *
     111                         * @param string $feed_link HTML for link to RSS feed.
     112                         * @param array  $instance  Array of settings for the current widget.
     113                         */
     114                        $feed_link = apply_filters( 'rss_widget_feed_link', $feed_link, $instance );
     115
     116                        $title = $feed_link . '<a class="rsswidget rss-widget-title" href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a>';
    93117                }
    94118
    95119                echo $args['before_widget'];
     
    142166         * Outputs the settings form for the RSS widget.
    143167         *
    144168         * @since 2.8.0
     169         * @since 5.9.0 Added `show_icon` argument.
    145170         *
    146171         * @param array $instance Current settings.
    147172         */
     
    155180                                'show_summary' => 0,
    156181                                'show_author'  => 0,
    157182                                'show_date'    => 0,
     183                                'show_icon'    => 1,
    158184                        );
    159185                }
    160186                $instance['number'] = $this->number;
  • tests/phpunit/tests/rest-api/rest-widgets-controller.php

     
    319319                                        'id'       => 'rss-1',
    320320                                        'id_base'  => 'rss',
    321321                                        'sidebar'  => 'sidebar-1',
    322                                         'rendered' => '<a class="rsswidget" href="https://wordpress.org/news/feed"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="http://example.org/wp-includes/images/rss.png" alt="RSS" /></a> <a class="rsswidget" href="https://wordpress.org/news">RSS test</a><ul><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/introducing-learn-wordpress/\'>Introducing Learn WordPress</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/simone/\'>WordPress 5.6 “Simone”</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/state-of-the-word-2020/\'>State of the Word 2020</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/the-month-in-wordpress-november-2020/\'>The Month in WordPress: November 2020</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/wordpress-5-6-release-candidate-2/\'>WordPress 5.6 Release Candidate 2</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/wordpress-5-6-release-candidate/\'>WordPress 5.6 Release Candidate</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/wordpress-5-6-beta-4/\'>WordPress 5.6 Beta 4</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/wordpress-5-6-beta-3/\'>WordPress 5.6 Beta 3</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/the-month-in-wordpress-october-2020/\'>The Month in WordPress: October 2020</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/10/wordpress-5-5-3-maintenance-release/\'>WordPress 5.5.3 Maintenance Release</a></li></ul>',
     322                                        'rendered' => '<a class="rsswidget rss-widget-feed" href="https://wordpress.org/news/feed"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="http://example.org/wp-includes/images/rss.png" alt="RSS" loading="lazy" /></a> <a class="rsswidget rss-widget-title" href="https://wordpress.org/news">RSS test</a><ul><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/introducing-learn-wordpress/\'>Introducing Learn WordPress</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/simone/\'>WordPress 5.6 “Simone”</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/state-of-the-word-2020/\'>State of the Word 2020</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/the-month-in-wordpress-november-2020/\'>The Month in WordPress: November 2020</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/12/wordpress-5-6-release-candidate-2/\'>WordPress 5.6 Release Candidate 2</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/wordpress-5-6-release-candidate/\'>WordPress 5.6 Release Candidate</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/wordpress-5-6-beta-4/\'>WordPress 5.6 Beta 4</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/wordpress-5-6-beta-3/\'>WordPress 5.6 Beta 3</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/11/the-month-in-wordpress-october-2020/\'>The Month in WordPress: October 2020</a></li><li><a class=\'rsswidget\' href=\'https://wordpress.org/news/2020/10/wordpress-5-5-3-maintenance-release/\'>WordPress 5.5.3 Maintenance Release</a></li></ul>',
    323323                                        'instance' => array(
    324324                                                'encoded' => base64_encode(
    325325                                                        serialize(
  • tests/phpunit/tests/widgets/wpWidgetRss.php

     
    9494                return array(
    9595                        'when url is given' => array(
    9696                                'url' => 'https://wordpress.org/news/feed/',
    97                                 '<section id="widget_rss-5" class="widget widget_rss"><h2><a class="rsswidget" href="https://wordpress.org/news/feed/">',
     97                                '<section id="widget_rss-5" class="widget widget_rss"><h2><a class="rsswidget rss-widget-feed" href="https://wordpress.org/news/feed/">',
    9898                        ),
    9999                );
    100100        }