# super-rss-reader/3.1/includes/widget-admin.php

Super RSS Reader – Add attractive RSS Feed Widget, version 3.1. 253 lines.

- Page: https://pluginprobe.com/plugins/super-rss-reader/3.1/code/includes/widget-admin.php
- Raw: https://pluginprobe.com/plugins/super-rss-reader/3.1/raw/includes/widget-admin.php
- Modified: 2020-04-16T15:40:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/super-rss-reader/3.1/code/includes/widget-admin.php#L10-L20`.

```php
<?php
/**
    * Contains WordPress widget class
    *
*/

class super_rss_reader_widget extends WP_Widget{

    // Initialize
    public function __construct(){
        $widget_ops = array(
            'classname' => 'widget_super_rss_reader',
            'description' => 'Enhanced RSS feed reader widget with advanced features.'
        );
        
        $control_ops = array('width' => 500, 'height' => 500);
        parent::__construct('super_rss_reader', 'Super RSS Reader', $widget_ops, $control_ops);
    }
    
    // Display the Widget
    public function widget( $args, $instance ){

        extract( $args );

        if( empty( $instance[ 'title' ] ) ){
            $title = '';
        }else{
            $title = $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
        }

        echo $before_widget . $title;

        echo "\n" . '
        <!-- Start - Super RSS Reader v' . SRR_VERSION . '-->
        <div class="super-rss-reader-widget">' . "\n";

        SRR_Widget::render_feed( $instance );

        echo "\n" . '</div>
        <!-- End - Super RSS Reader -->
        ' . "\n";
        echo $after_widget;

    }
    
    // Save settings
    public function update( $new_instance, $old_instance ){

        $instance = $old_instance;

        $instance[ 'title' ] = stripslashes( $new_instance['title'] );
        $instance[ 'urls' ] = stripslashes( $new_instance['urls']) ;
        $instance[ 'tab_titles' ] = stripslashes( $new_instance['tab_titles'] );
        
        $instance[ 'count' ] = intval( $new_instance['count'] );
        $instance[ 'show_date' ] = intval( $new_instance['show_date'] );
        $instance[ 'show_desc' ] = intval( $new_instance['show_desc'] );
        $instance[ 'show_author' ] = intval( $new_instance['show_author'] );
        $instance[ 'show_thumb' ] = stripslashes( $new_instance['show_thumb'] );
        $instance[ 'open_newtab' ] = intval( $new_instance['open_newtab'] );
        $instance[ 'add_nofollow' ] = intval( $new_instance['add_nofollow'] );
        $instance[ 'strip_desc' ] = intval( $new_instance['strip_desc'] );
        $instance[ 'strip_title' ] = intval( $new_instance['strip_title'] );
        $instance[ 'read_more' ] = stripslashes( $new_instance['read_more'] );
        $instance[ 'rich_desc' ] = stripslashes( $new_instance['rich_desc'] );
        
        $instance[ 'color_style' ] = stripslashes( $new_instance['color_style']);
        $instance[ 'enable_ticker' ] = intval( $new_instance['enable_ticker']);
        $instance[ 'visible_items' ] = intval( $new_instance['visible_items']);
        $instance[ 'ticker_speed' ] = intval( $new_instance['ticker_speed']);
        
        return $instance;
    }
    
    // Widget form
    public function form( $instance ){
        
        $instance = wp_parse_args((array) $instance, SRR_Widget::default_settings());
        
        $title = htmlspecialchars($instance['title']);
        $urls = htmlspecialchars($instance['urls']);
        $tab_titles = htmlspecialchars($instance['tab_titles']);
        
        $count = intval($instance['count']);
        $show_date = intval($instance['show_date']);
        $show_desc = intval($instance['show_desc']);
        $show_author = intval($instance['show_author']);
        $show_thumb = intval($instance['show_thumb']);
        $open_newtab = intval($instance['open_newtab']);
        $add_nofollow = intval($instance['add_nofollow']);
        $strip_desc = intval($instance['strip_desc']);
        $strip_title = intval($instance['strip_title']);
        $read_more = htmlspecialchars($instance['read_more']);
        $rich_desc = htmlspecialchars($instance['rich_desc']);
        
        $color_style = stripslashes($instance['color_style']);
        $enable_ticker = intval($instance['enable_ticker']);
        $visible_items = intval($instance['visible_items']);
        $ticker_speed = intval($instance['ticker_speed']);
        
        // Replacing commas with new lines
        $urls = str_replace( ',', "\n", $urls );
        $tab_titles = str_replace( ',', "\n", $tab_titles );

        ?>
        <div class="srr_settings">
        <table width="100%" height="72" border="0">
        <tr>
          <td width="13%" height="33"><label for="<?php echo $this->get_field_id('title'); ?>">Title</label></td>
          <td width="87%"><input id="<?php echo $this->get_field_id('title');?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" class="widefat"/></td>
        </tr>
        <tr>
            <td><label for="<?php echo $this->get_field_id('urls'); ?>">URL(s)</label></td>
            <td><textarea id="<?php echo $this->get_field_id('urls');?>" name="<?php echo $this->get_field_name('urls'); ?>" class="widefat"><?php echo $urls; ?></textarea>
            <small class="srr_small_text">Can enter multiple RSS/atom feed URLs in new line</small>
            </td>
        </tr>
        
        <tr>
            <td><label for="<?php echo $this->get_field_id('tab_titles'); ?>">Tab titles</label></td>
            <td><textarea id="<?php echo $this->get_field_id('tab_titles');?>" name="<?php echo $this->get_field_name('tab_titles'); ?>" class="widefat"><?php echo $tab_titles; ?></textarea>
            <small class="srr_small_text">Enter corresponding tab titles in new line.</small>
            </td>
        </tr>
        
        </table>
        </div>
        
        <div class="srr_settings">
        <h4>Settings</h4>
        <table width="100%" border="0">
          <tr height="30px">
            <td width="7%"><input id="<?php echo $this->get_field_id('show_desc'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('show_desc'); ?>" value="1" <?php echo $show_desc == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td width="43%"><label for="<?php echo $this->get_field_id('show_desc'); ?>">Show Description</label></td>
            <td width="7%"><input id="<?php echo $this->get_field_id('show_date'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('show_date'); ?>" value="1" <?php echo $show_date == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td width="43%"><label for="<?php echo $this->get_field_id('show_date'); ?>">Show Date</label></td>
          </tr>

          <tr height="30px">
            <td><input id="<?php echo $this->get_field_id('show_author'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('show_author'); ?>" value="1" <?php echo $show_author == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td><label for="<?php echo $this->get_field_id('show_author'); ?>">Show Author</label></td>
            <td><input id="<?php echo $this->get_field_id('show_thumb'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('show_thumb'); ?>" value="1" <?php echo $show_thumb == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td><label for="<?php echo $this->get_field_id('show_thumb'); ?>">Show thumbnail if present</label></td>
          </tr>

        </table>

        <h4></h4>

        <table width="100%" border="0">
          <tr height="30px">
            <td width="7%"><input id="<?php echo $this->get_field_id('rich_desc'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('rich_desc'); ?>" value="1" <?php echo $rich_desc == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td width="40%"><label for="<?php echo $this->get_field_id('rich_desc'); ?>">Enable full or rich description</label></td>
            <td width="28%"><label for="<?php echo $this->get_field_id('count');?>">Total items to show:</label></td>
            <td width="25%"><input id="<?php echo $this->get_field_id('count');?>" name="<?php echo $this->get_field_name('count'); ?>" type="number" value="<?php echo $count; ?>" class="widefat" title="No of feed items to parse"/></td>
          </tr>

          <tr height="30">
            <td><input id="<?php echo $this->get_field_id('add_nofollow'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('add_nofollow'); ?>" value="1" <?php echo $add_nofollow == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td><label for="<?php echo $this->get_field_id('add_nofollow'); ?>">Add "no follow" attribute to links</label></td>
            <td><label for="<?php echo $this->get_field_id('strip_desc');?>">Strip description characters:</label></td>
            <td><input id="<?php echo $this->get_field_id('strip_desc');?>" name="<?php echo $this->get_field_name('strip_desc'); ?>" type="number" value="<?php echo $strip_desc; ?>" class="widefat" title="The number of charaters to be displayed. Use 0 to disable stripping"/>          </td>
          </tr>

          <tr height="30">
            <td><input id="<?php echo $this->get_field_id('open_newtab'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('open_newtab'); ?>" value="1" <?php echo $open_newtab == "1" ? 'checked="checked"' : ""; ?> /></td>
            <td><label for="<?php echo $this->get_field_id('open_newtab'); ?>">Open links in new tab</label></td>
            <td><label for="<?php echo $this->get_field_id('read_more'); ?>">Read more text:</label></td>
            <td><input id="<?php echo $this->get_field_id('read_more'); ?>" name="<?php echo $this->get_field_name('read_more'); ?>" type="text" value="<?php echo $read_more; ?>" class="widefat" title="Leave blank to hide read more text"/></td>
          </tr>

          <tr height="30">
            <td></td>
            <td></td>
            <td><label for="<?php echo $this->get_field_id('strip_title'); ?>">Strip title characters:</label></td>
            <td><input id="<?php echo $this->get_field_id('strip_title');?>" name="<?php echo $this->get_field_name('strip_title'); ?>" type="number" value="<?php echo $strip_title; ?>" class="widefat" title="The number of charaters to be displayed. Use 0 to disable stripping"/></td>
          </tr>

        </table>
        </div>
        
        <?php if( $rich_desc == 1 ): ?>
        <span class="srr_note">Note: You have enabled "Full/Rich HTML" Please make sure that the feed(s) are from trusted sources and do not contain any harmful scripts. If there are some alignment issues in the description, please use custom CSS to fix that. </span>
        <?php endif; ?>
        
        <div class="srr_settings">
        <h4>Customization</h4>
        <table width="100%" height="109" border="0">
          <tr>
            <td height="32"><label for="<?php echo $this->get_field_id('color_style');?>">Color theme: </label></td>
            <td>
            <?php
            $color_themes = SRR_Widget::color_themes();
            echo '<select name="' . $this->get_field_name('color_style') . '" id="' . $this->get_field_id('color_style') . '">';
            foreach($color_themes as $k => $v){
                echo '<option value="' . $v . '" ' . ($color_style == $v ? 'selected="selected"' : "") .  '>' . $k . '</option>';
            }
            echo '</select>';
            ?>
            </td>
          </tr>
          <tr>
            <td height="36"><label for="<?php echo $this->get_field_id('visible_items');?>">Widget height:</label></td>
            <td><input id="<?php echo $this->get_field_id('visible_items');?>" name="<?php echo $this->get_field_name('visible_items'); ?>" type="number" value="<?php echo $visible_items; ?>" title="Height of the RSS feed."/><br/>
            <small class="srr_small_text">Set value less than 20 to show visible feed items. Example: <b>5</b> items</small></br>
            <small class="srr_small_text">Set value greater than 20 for fixed widget height. Example: <b>400</b> px</small></br>
            </td>
          </tr>
          <tr>
            <td height="33"><label for="<?php echo $this->get_field_id('enable_ticker'); ?>">Ticker animation:</label> </td>
            <td><input id="<?php echo $this->get_field_id('enable_ticker'); ?>" type="checkbox"  name="<?php echo $this->get_field_name('enable_ticker'); ?>" value="1" <?php echo $enable_ticker == "1" ? 'checked="checked"' : ""; ?> /></td>
          </tr>
          <tr>
            <td height="36"><label for="<?php echo $this->get_field_id('ticker_speed');?>">Ticker speed: </label></td>
            <td><input id="<?php echo $this->get_field_id('ticker_speed');?>" name="<?php echo $this->get_field_name('ticker_speed'); ?>" type="number" value="<?php echo $ticker_speed; ?>" title="Speed of the ticker in seconds"/> seconds
            </td>
          </tr>
        </table>
        </div>
        
        <div class="srr_coffee">
            <p>Thank you for using Super RSS Reader. If you found it useful, please buy me a coffee !</p>
            <div class="srr_coffee_wrap">
                <select class="srr_coffee_amt">
                    <option value="6" selected="selected">$6</option>
                    <option value="7">$7</option>
                    <option value="8">$8</option>
                    <option value="9">$9</option>
                    <option value="10">$10</option>
                    <option value="11">$11</option>
                    <option value="12">$12</option>
                    <option value="13">$13</option>
                    <option value="14">$14</option>
                    <option value="15">$15</option>
                    <option value="">Custom</option>
                </select>
                <a class="button button-primary srr_coffee_btn" href="https://www.paypal.me/vaakash/6" data-link="https://www.paypal.me/vaakash/" target="_blank">Buy me a coffee !</a>
            </div>
        </div>

        <div class="srr_survey">
          <p><a href="https://forms.gle/cvzQ7k2Lex5xZLDf9" class="button button-primary" target="_blank">Share a feature</a><span>Request feature</span> Want any feature you would like to see in Super RSS Reader plugin ? Please share your requirements and features in a quick form.</p>
        </div>

        <div class="srr_info">
          <p><a href="https://www.aakashweb.com/docs/super-rss-reader-doc/faq/" target="_blank">FAQ</a> | <a href="https://www.aakashweb.com/forum/discuss/wordpress-plugins/super-rss-reader/" target="_blank">Report issue</a> | <a href="https://wordpress.org/support/plugin/super-rss-reader/reviews/?rate=5#new-post" target="_blank">Rate 5 stars & review</a> | v<?php echo SRR_VERSION; ?></p>
        </div>

        <?php
    }
}

?>
```
