wp_widget_rss_process example

if ( ! isset( $widget_options[ $widget_id ] ) ) {
        $widget_options[ $widget_id ] = array();
    }

    $number = 1; // Hack to use wp_widget_rss_form().
    $widget_options[ $widget_id ]['number'] = $number;

    if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
        $_POST['widget-rss'][ $number ]         = wp_unslash( $_POST['widget-rss'][ $number ] );
        $widget_options[ $widget_id ]           = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
        $widget_options[ $widget_id ]['number'] = $number;

        // Title is optional. If black, fill it if possible.         if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) {
            $rss = fetch_feed( $widget_options[ $widget_id ]['url'] );
            if ( is_wp_error( $rss ) ) {
                $widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) );
            } else {
                $widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) );
                $rss->__destruct();
                unset( $rss );
            }

    public function update( $new_instance$old_instance ) {
        $testurl = ( isset( $new_instance['url'] ) && ( ! isset( $old_instance['url'] ) || ( $new_instance['url'] !== $old_instance['url'] ) ) );
        return wp_widget_rss_process( $new_instance$testurl );
    }

    /** * Outputs the settings form for the RSS widget. * * @since 2.8.0 * * @param array $instance Current settings. */
    public function form( $instance ) {
        if ( empty( $instance ) ) {
            
Home | Imprint | This part of the site doesn't use cookies.