wp/wp-includes/widgets/class-wp-widget-rss.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    46 		if ( isset( $instance['error'] ) && $instance['error'] ) {
    46 		if ( isset( $instance['error'] ) && $instance['error'] ) {
    47 			return;
    47 			return;
    48 		}
    48 		}
    49 
    49 
    50 		$url = ! empty( $instance['url'] ) ? $instance['url'] : '';
    50 		$url = ! empty( $instance['url'] ) ? $instance['url'] : '';
    51 		while ( stristr( $url, 'http' ) != $url ) {
    51 		while ( stristr( $url, 'http' ) !== $url ) {
    52 			$url = substr( $url, 1 );
    52 			$url = substr( $url, 1 );
    53 		}
    53 		}
    54 
    54 
    55 		if ( empty( $url ) ) {
    55 		if ( empty( $url ) ) {
    56 			return;
    56 			return;
    57 		}
    57 		}
    58 
    58 
    59 		// self-url destruction sequence
    59 		// Self-URL destruction sequence.
    60 		if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) {
    60 		if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ), true ) ) {
    61 			return;
    61 			return;
    62 		}
    62 		}
    63 
    63 
    64 		$rss   = fetch_feed( $url );
    64 		$rss   = fetch_feed( $url );
    65 		$title = $instance['title'];
    65 		$title = $instance['title'];
    66 		$desc  = '';
    66 		$desc  = '';
    67 		$link  = '';
    67 		$link  = '';
    68 
    68 
    69 		if ( ! is_wp_error( $rss ) ) {
    69 		if ( ! is_wp_error( $rss ) ) {
    70 			$desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
    70 			$desc = esc_attr( strip_tags( html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
    71 			if ( empty( $title ) ) {
    71 			if ( empty( $title ) ) {
    72 				$title = strip_tags( $rss->get_title() );
    72 				$title = strip_tags( $rss->get_title() );
    73 			}
    73 			}
    74 			$link = strip_tags( $rss->get_permalink() );
    74 			$link = strip_tags( $rss->get_permalink() );
    75 			while ( stristr( $link, 'http' ) != $link ) {
    75 			while ( stristr( $link, 'http' ) !== $link ) {
    76 				$link = substr( $link, 1 );
    76 				$link = substr( $link, 1 );
    77 			}
    77 			}
    78 		}
    78 		}
    79 
    79 
    80 		if ( empty( $title ) ) {
    80 		if ( empty( $title ) ) {
    92 
    92 
    93 		echo $args['before_widget'];
    93 		echo $args['before_widget'];
    94 		if ( $title ) {
    94 		if ( $title ) {
    95 			echo $args['before_title'] . $title . $args['after_title'];
    95 			echo $args['before_title'] . $title . $args['after_title'];
    96 		}
    96 		}
       
    97 
       
    98 		$format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';
       
    99 
       
   100 		/** This filter is documented in wp-includes/widgets/class-wp-nav-menu-widget.php */
       
   101 		$format = apply_filters( 'navigation_widgets_format', $format );
       
   102 
       
   103 		if ( 'html5' === $format ) {
       
   104 			// The title may be filtered: Strip out HTML and make sure the aria-label is never empty.
       
   105 			$title      = trim( strip_tags( $title ) );
       
   106 			$aria_label = $title ? $title : __( 'RSS Feed' );
       
   107 			echo '<nav role="navigation" aria-label="' . esc_attr( $aria_label ) . '">';
       
   108 		}
       
   109 
    97 		wp_widget_rss_output( $rss, $instance );
   110 		wp_widget_rss_output( $rss, $instance );
       
   111 
       
   112 		if ( 'html5' === $format ) {
       
   113 			echo '</nav>';
       
   114 		}
       
   115 
    98 		echo $args['after_widget'];
   116 		echo $args['after_widget'];
    99 
   117 
   100 		if ( ! is_wp_error( $rss ) ) {
   118 		if ( ! is_wp_error( $rss ) ) {
   101 			$rss->__destruct();
   119 			$rss->__destruct();
   102 		}
   120 		}
   112 	 *                            WP_Widget::form().
   130 	 *                            WP_Widget::form().
   113 	 * @param array $old_instance Old settings for this instance.
   131 	 * @param array $old_instance Old settings for this instance.
   114 	 * @return array Updated settings to save.
   132 	 * @return array Updated settings to save.
   115 	 */
   133 	 */
   116 	public function update( $new_instance, $old_instance ) {
   134 	public function update( $new_instance, $old_instance ) {
   117 		$testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
   135 		$testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] !== $old_instance['url'] ) ) );
   118 		return wp_widget_rss_process( $new_instance, $testurl );
   136 		return wp_widget_rss_process( $new_instance, $testurl );
   119 	}
   137 	}
   120 
   138 
   121 	/**
   139 	/**
   122 	 * Outputs the settings form for the RSS widget.
   140 	 * Outputs the settings form for the RSS widget.