Code is Poetry.

WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2017-11-30 23:09:33 +00:00
parent ec6a089f98
commit 8f95800d52
1103 changed files with 105978 additions and 78184 deletions
+42 -23
View File
@@ -22,11 +22,14 @@ class WP_Widget_RSS extends WP_Widget {
* @since 2.8.0
*/
public function __construct() {
$widget_ops = array(
'description' => __( 'Entries from any RSS or Atom feed.' ),
$widget_ops = array(
'description' => __( 'Entries from any RSS or Atom feed.' ),
'customize_selective_refresh' => true,
);
$control_ops = array( 'width' => 400, 'height' => 200 );
$control_ops = array(
'width' => 400,
'height' => 200,
);
parent::__construct( 'rss', __( 'RSS' ), $widget_ops, $control_ops );
}
@@ -40,32 +43,38 @@ class WP_Widget_RSS extends WP_Widget {
* @param array $instance Settings for the current RSS widget instance.
*/
public function widget( $args, $instance ) {
if ( isset($instance['error']) && $instance['error'] )
if ( isset( $instance['error'] ) && $instance['error'] ) {
return;
}
$url = ! empty( $instance['url'] ) ? $instance['url'] : '';
while ( stristr($url, 'http') != $url )
$url = substr($url, 1);
while ( stristr( $url, 'http' ) != $url ) {
$url = substr( $url, 1 );
}
if ( empty($url) )
if ( empty( $url ) ) {
return;
}
// self-url destruction sequence
if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) )
if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) {
return;
}
$rss = fetch_feed($url);
$rss = fetch_feed( $url );
$title = $instance['title'];
$desc = '';
$link = '';
$desc = '';
$link = '';
if ( ! is_wp_error($rss) ) {
$desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
if ( empty($title) )
if ( ! is_wp_error( $rss ) ) {
$desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
if ( empty( $title ) ) {
$title = strip_tags( $rss->get_title() );
}
$link = strip_tags( $rss->get_permalink() );
while ( stristr($link, 'http') != $link )
$link = substr($link, 1);
while ( stristr( $link, 'http' ) != $link ) {
$link = substr( $link, 1 );
}
}
if ( empty( $title ) ) {
@@ -75,10 +84,11 @@ class WP_Widget_RSS extends WP_Widget {
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
$url = strip_tags( $url );
$url = strip_tags( $url );
$icon = includes_url( 'images/rss.png' );
if ( $title )
$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>';
if ( $title ) {
$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>';
}
echo $args['before_widget'];
if ( $title ) {
@@ -87,9 +97,10 @@ class WP_Widget_RSS extends WP_Widget {
wp_widget_rss_output( $rss, $instance );
echo $args['after_widget'];
if ( ! is_wp_error($rss) )
if ( ! is_wp_error( $rss ) ) {
$rss->__destruct();
unset($rss);
}
unset( $rss );
}
/**
@@ -103,7 +114,7 @@ class WP_Widget_RSS extends WP_Widget {
* @return array Updated settings to save.
*/
public function update( $new_instance, $old_instance ) {
$testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
$testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
return wp_widget_rss_process( $new_instance, $testurl );
}
@@ -116,7 +127,15 @@ class WP_Widget_RSS extends WP_Widget {
*/
public function form( $instance ) {
if ( empty( $instance ) ) {
$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
$instance = array(
'title' => '',
'url' => '',
'items' => 10,
'error' => false,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
);
}
$instance['number'] = $this->number;