Ticket #52224: 52224.3.diff
File 52224.3.diff, 12.9 KB (added by , 4 years ago) |
---|
-
src/wp-content/themes/twentyseventeen/style.css
2662 2662 2663 2663 /* RSS Widget */ 2664 2664 2665 .widget_rss .widget-title .rsswidget:first-child {2665 .widget_rss .widget-title .rsswidget:first-child:not(.rss-widget-title) { 2666 2666 float: right; 2667 2667 } 2668 2668 -
src/wp-content/themes/twentytwenty/style-rtl.css
4286 4286 4287 4287 /* Widget: RSS ------------------------------- */ 4288 4288 4289 .widget_rss .widget-title a.rsswidget:first-of-type {4289 .widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) { 4290 4290 display: none; 4291 4291 } 4292 4292 -
src/wp-content/themes/twentytwenty/style.css
4320 4320 4321 4321 /* Widget: RSS ------------------------------- */ 4322 4322 4323 .widget_rss .widget-title a.rsswidget:first-of-type {4323 .widget_rss .widget-title a.rsswidget:first-of-type:not(.rss-widget-title) { 4324 4324 display: none; 4325 4325 } 4326 4326 -
src/wp-includes/widgets.php
1529 1529 * Display the RSS entries in a list. 1530 1530 * 1531 1531 * @since 2.5.0 1532 * @since 5.9.0 Added `show_icon` argument. 1532 1533 * 1533 * @param string|array|object $rss RSS url.1534 * @param string|array|object $rss RSS URL. 1534 1535 * @param array $args Widget arguments. 1535 1536 */ 1536 1537 function wp_widget_rss_output( $rss, $args = array() ) { … … 1554 1555 'show_author' => 0, 1555 1556 'show_date' => 0, 1556 1557 'show_summary' => 0, 1558 'show_icon' => 1, 1557 1559 'items' => 0, 1558 1560 ); 1559 1561 $args = wp_parse_args( $args, $default_args ); … … 1565 1567 $show_summary = (int) $args['show_summary']; 1566 1568 $show_author = (int) $args['show_author']; 1567 1569 $show_date = (int) $args['show_date']; 1570 $show_icon = (int) $args['show_icon']; 1568 1571 1569 1572 if ( ! $rss->get_item_quantity() ) { 1570 1573 echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>'; … … 1637 1640 * 1638 1641 * The options for what fields are displayed for the RSS form are all booleans 1639 1642 * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author', 1640 * 'show_date'. 1643 * 'show_date', 'show_icon'. 1644 . 1641 1645 * 1642 1646 * @since 2.5.0 1647 * @since 5.9.0 Added `show_icon` argument. 1643 1648 * 1644 1649 * @param array|string $args Values for input fields. 1645 1650 * @param array $inputs Override default display options. … … 1652 1657 'show_summary' => true, 1653 1658 'show_author' => true, 1654 1659 'show_date' => true, 1660 'show_icon' => true, 1655 1661 ); 1656 1662 $inputs = wp_parse_args( $inputs, $default_inputs ); 1657 1663 … … 1666 1672 $args['show_summary'] = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary']; 1667 1673 $args['show_author'] = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author']; 1668 1674 $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']; 1669 1676 1670 1677 if ( ! empty( $args['error'] ) ) { 1671 1678 echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error'] . '</p>'; … … 1699 1706 <?php endif; if ( $inputs['show_date'] ) : ?> 1700 1707 <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'] ); ?>/> 1701 1708 <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 /> 1702 1714 <?php endif; ?> 1703 1715 </p> 1704 1716 <?php … … 1720 1732 * default, which is 10. 1721 1733 * 1722 1734 * 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. 1724 1736 * All respectively in the order of the array elements. 1725 1737 * 1726 1738 * @since 2.5.0 1739 * @since 5.9.0 Added `show_icon` argument. 1727 1740 * 1728 1741 * @param array $widget_rss RSS widget feed data. Expects unescaped data. 1729 1742 * @param bool $check_feed Optional. Whether to check feed for errors. Default true. … … 1739 1752 $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; 1740 1753 $show_author = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] : 0; 1741 1754 $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; 1742 1756 $error = false; 1743 1757 $link = ''; 1744 1758 … … 1758 1772 } 1759 1773 } 1760 1774 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' ); 1762 1776 } 1763 1777 1764 1778 /** -
src/wp-includes/widgets/class-wp-widget-rss.php
39 39 * Outputs the content for the current RSS widget instance. 40 40 * 41 41 * @since 2.8.0 42 * @since 5.9.0 Added `show_icon` argument. 42 43 * 43 44 * @param array $args Display arguments including 'before_title', 'after_title', 44 45 * 'before_widget', and 'after_widget'. … … 86 87 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ 87 88 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); 88 89 89 $url = strip_tags( $url );90 $icon = includes_url( 'images/rss.png' );91 90 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>'; 93 117 } 94 118 95 119 echo $args['before_widget']; … … 142 166 * Outputs the settings form for the RSS widget. 143 167 * 144 168 * @since 2.8.0 169 * @since 5.9.0 Added `show_icon` argument. 145 170 * 146 171 * @param array $instance Current settings. 147 172 */ … … 155 180 'show_summary' => 0, 156 181 'show_author' => 0, 157 182 'show_date' => 0, 183 'show_icon' => 1, 158 184 ); 159 185 } 160 186 $instance['number'] = $this->number; -
tests/phpunit/tests/rest-api/rest-widgets-controller.php
319 319 'id' => 'rss-1', 320 320 'id_base' => 'rss', 321 321 '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>', 323 323 'instance' => array( 324 324 'encoded' => base64_encode( 325 325 serialize( -
tests/phpunit/tests/widgets/wpWidgetRss.php
94 94 return array( 95 95 'when url is given' => array( 96 96 '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/">', 98 98 ), 99 99 ); 100 100 }