| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contains WordPress widget class |
| 4 |
* |
| 5 |
*/ |
| 6 |
|
| 7 |
class super_rss_reader_widget extends WP_Widget{ |
| 8 |
|
| 9 |
// Initialize |
| 10 |
public function __construct(){ |
| 11 |
$widget_ops = array( |
| 12 |
'classname' => 'widget_super_rss_reader', |
| 13 |
'description' => 'Enhanced RSS feed reader widget with advanced features.' |
| 14 |
); |
| 15 |
|
| 16 |
$control_ops = array('width' => 500, 'height' => 500); |
| 17 |
parent::__construct('super_rss_reader', 'Super RSS Reader', $widget_ops, $control_ops); |
| 18 |
} |
| 19 |
|
| 20 |
// Display the Widget |
| 21 |
public function widget( $args, $instance ){ |
| 22 |
|
| 23 |
extract( $args ); |
| 24 |
|
| 25 |
if( empty( $instance[ 'title' ] ) ){ |
| 26 |
$title = ''; |
| 27 |
}else{ |
| 28 |
$title = $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; |
| 29 |
} |
| 30 |
|
| 31 |
echo $before_widget . $title; |
| 32 |
|
| 33 |
echo "\n" . ' |
| 34 |
<!-- Start - Super RSS Reader v' . SRR_VERSION . '--> |
| 35 |
<div class="super-rss-reader-widget">' . "\n"; |
| 36 |
|
| 37 |
SRR_Widget::render_feed( $instance ); |
| 38 |
|
| 39 |
echo "\n" . '</div> |
| 40 |
<!-- End - Super RSS Reader --> |
| 41 |
' . "\n"; |
| 42 |
echo $after_widget; |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
// Save settings |
| 47 |
public function update( $new_instance, $old_instance ){ |
| 48 |
|
| 49 |
$instance = $old_instance; |
| 50 |
|
| 51 |
$instance[ 'title' ] = stripslashes( $new_instance['title'] ); |
| 52 |
$instance[ 'urls' ] = stripslashes( $new_instance['urls']) ; |
| 53 |
$instance[ 'tab_titles' ] = stripslashes( $new_instance['tab_titles'] ); |
| 54 |
|
| 55 |
$instance[ 'count' ] = intval( $new_instance['count'] ); |
| 56 |
$instance[ 'show_date' ] = intval( isset( $new_instance['show_date'] ) ? $new_instance['show_date'] : 0 ); |
| 57 |
$instance[ 'show_desc' ] = intval( isset( $new_instance['show_desc'] ) ? $new_instance['show_desc'] : 0 ); |
| 58 |
$instance[ 'show_author' ] = intval( isset( $new_instance['show_author'] ) ? $new_instance['show_author'] : 0 ); |
| 59 |
$instance[ 'show_thumb' ] = intval( isset( $new_instance['show_thumb'] ) ? $new_instance['show_thumb'] : 0 ); |
| 60 |
$instance[ 'strip_desc' ] = intval( $new_instance['strip_desc'] ); |
| 61 |
$instance[ 'strip_title' ] = intval( $new_instance['strip_title'] ); |
| 62 |
$instance[ 'read_more' ] = stripslashes( $new_instance['read_more'] ); |
| 63 |
$instance[ 'add_nofollow' ] = intval( isset( $new_instance['add_nofollow'] ) ? $new_instance['add_nofollow'] : 0 ); |
| 64 |
$instance[ 'open_newtab' ] = intval( isset( $new_instance['open_newtab'] ) ? $new_instance['open_newtab'] : 0 ); |
| 65 |
$instance[ 'rich_desc' ] = intval( isset( $new_instance['rich_desc'] ) ? $new_instance['rich_desc'] : 0 ); |
| 66 |
|
| 67 |
$instance[ 'color_style' ] = stripslashes( $new_instance['color_style']); |
| 68 |
$instance[ 'display_type' ] = stripslashes( $new_instance['display_type']); |
| 69 |
$instance[ 'visible_items' ] = intval( $new_instance['visible_items']); |
| 70 |
$instance[ 'ticker_speed' ] = intval( $new_instance['ticker_speed']); |
| 71 |
|
| 72 |
return $instance; |
| 73 |
} |
| 74 |
|
| 75 |
// Widget form |
| 76 |
public function form( $instance ){ |
| 77 |
|
| 78 |
$instance = wp_parse_args( (array) $instance, SRR_Options::default_options() ); |
| 79 |
|
| 80 |
$title = htmlspecialchars( isset( $instance['title'] ) ? $instance[ 'title' ] : '' ); |
| 81 |
$urls = htmlspecialchars($instance['urls']); |
| 82 |
$tab_titles = htmlspecialchars($instance['tab_titles']); |
| 83 |
|
| 84 |
$count = intval($instance['count']); |
| 85 |
$show_date = intval($instance['show_date']); |
| 86 |
$show_desc = intval($instance['show_desc']); |
| 87 |
$show_author = intval($instance['show_author']); |
| 88 |
$show_thumb = intval($instance['show_thumb']); |
| 89 |
$open_newtab = intval($instance['open_newtab']); |
| 90 |
$add_nofollow = intval($instance['add_nofollow']); |
| 91 |
$strip_desc = intval($instance['strip_desc']); |
| 92 |
$strip_title = intval($instance['strip_title']); |
| 93 |
$read_more = htmlspecialchars($instance['read_more']); |
| 94 |
$rich_desc = intval($instance['rich_desc']); |
| 95 |
|
| 96 |
$color_style = stripslashes($instance['color_style']); |
| 97 |
$display_type = stripslashes($instance['display_type']); |
| 98 |
$visible_items = intval($instance['visible_items']); |
| 99 |
$ticker_speed = intval($instance['ticker_speed']); |
| 100 |
|
| 101 |
// Replacing commas with new lines |
| 102 |
$urls = str_replace( ',', "\n", $urls ); |
| 103 |
$tab_titles = str_replace( ',', "\n", $tab_titles ); |
| 104 |
|
| 105 |
?> |
| 106 |
|
| 107 |
<div class="srr_settings"> |
| 108 |
|
| 109 |
<section> |
| 110 |
|
| 111 |
<div class="srr_row"> |
| 112 |
<div class="srr_label srr_xsm"><label for="<?php echo $this->get_field_id('title'); ?>">Title</label></div> |
| 113 |
<div class="srr_field"><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"/></div> |
| 114 |
</div> |
| 115 |
|
| 116 |
<div class="srr_row"> |
| 117 |
<div class="srr_label srr_xsm"><label for="<?php echo $this->get_field_id('urls'); ?>">URL(s)</label></div> |
| 118 |
<div class="srr_field"><textarea id="<?php echo $this->get_field_id('urls');?>" name="<?php echo $this->get_field_name('urls'); ?>" class="widefat"><?php echo $urls; ?></textarea> |
| 119 |
<small class="srr_small_text">Can enter multiple RSS/atom feed URLs in new line</small></div> |
| 120 |
</div> |
| 121 |
|
| 122 |
<div class="srr_row"> |
| 123 |
<div class="srr_label srr_xsm"><label for="<?php echo $this->get_field_id('tab_titles'); ?>">Tab titles</label></div> |
| 124 |
<div class="srr_field"><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> |
| 125 |
<small class="srr_small_text">Enter corresponding tab titles in new line.</small></div> |
| 126 |
</div> |
| 127 |
|
| 128 |
</section> |
| 129 |
|
| 130 |
<h4>Display</h4> |
| 131 |
|
| 132 |
<section data-tab-id="display"> |
| 133 |
<div class="srr_row"> |
| 134 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('show_desc'); ?>">Show Description</label></div> |
| 135 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 136 |
</div> |
| 137 |
|
| 138 |
<div class="srr_row"> |
| 139 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('show_date'); ?>">Show Date</label></div> |
| 140 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 141 |
</div> |
| 142 |
|
| 143 |
<div class="srr_row"> |
| 144 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('show_author'); ?>">Show Author</label></div> |
| 145 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 146 |
</div> |
| 147 |
|
| 148 |
<div class="srr_row"> |
| 149 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('show_thumb'); ?>">Show thumbnail if present</label></div> |
| 150 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 151 |
</div> |
| 152 |
</section> |
| 153 |
|
| 154 |
<h4>Content</h4> |
| 155 |
|
| 156 |
<section data-tab-id="content"> |
| 157 |
|
| 158 |
<div class="srr_row"> |
| 159 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('count');?>">Total items to show:</label></div> |
| 160 |
<div class="srr_field"><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"/></div> |
| 161 |
</div> |
| 162 |
|
| 163 |
<div class="srr_row"> |
| 164 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('strip_desc');?>">Trim description to words:</label></div> |
| 165 |
<div class="srr_field"><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 words to be displayed. Use 0 to disable stripping"/></div> |
| 166 |
</div> |
| 167 |
|
| 168 |
<div class="srr_row"> |
| 169 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('read_more'); ?>">Read more text:</label></div> |
| 170 |
<div class="srr_field"><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"/></div> |
| 171 |
</div> |
| 172 |
|
| 173 |
<div class="srr_row"> |
| 174 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('add_nofollow'); ?>">Add "no follow" attribute to links</label></div> |
| 175 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 176 |
</div> |
| 177 |
|
| 178 |
<div class="srr_row"> |
| 179 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('open_newtab'); ?>">Open links in new tab</label></div> |
| 180 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 181 |
</div> |
| 182 |
|
| 183 |
<div class="srr_row"> |
| 184 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('strip_title'); ?>">Trim title to words:</label></div> |
| 185 |
<div class="srr_field"><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 words to be displayed. Use 0 to disable stripping"/></div> |
| 186 |
</div> |
| 187 |
|
| 188 |
<div class="srr_row"> |
| 189 |
<div class="srr_label"><label for="<?php echo $this->get_field_id('rich_desc'); ?>">Enable rich description</label></div> |
| 190 |
<div class="srr_field"><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"' : ""; ?> /></div> |
| 191 |
</div> |
| 192 |
|
| 193 |
</section> |
| 194 |
|
| 195 |
<?php if( $rich_desc == 1 ): ?> |
| 196 |
<span class="srr_note">Note: You have enabled "Full/Rich HTML". If no description is present, then the full content will be displayed. 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> |
| 197 |
<?php endif; ?> |
| 198 |
|
| 199 |
<h4>Style</h4> |
| 200 |
<section> |
| 201 |
|
| 202 |
<div class="srr_row"> |
| 203 |
<div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('color_style');?>">Color theme: </label></div> |
| 204 |
<div class="srr_field"> |
| 205 |
<?php |
| 206 |
$color_themes = SRR_Options::color_themes(); |
| 207 |
echo '<select name="' . $this->get_field_name('color_style') . '" id="' . $this->get_field_id('color_style') . '">'; |
| 208 |
foreach($color_themes as $k => $v){ |
| 209 |
echo '<option value="' . $v . '" ' . ($color_style == $v ? 'selected="selected"' : "") . '>' . $k . '</option>'; |
| 210 |
} |
| 211 |
echo '</select>'; |
| 212 |
?> |
| 213 |
</div> |
| 214 |
</div> |
| 215 |
|
| 216 |
<div class="srr_row"> |
| 217 |
<div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('visible_items');?>">Widget height:</label></div> |
| 218 |
<div class="srr_field"><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/> |
| 219 |
<small class="srr_small_text">Set value less than 20 to show visible feed items. Example: <b>5</b> items</small></br> |
| 220 |
<small class="srr_small_text">Set value greater than 20 for fixed widget height. Example: <b>400</b> px</small></div> |
| 221 |
</div> |
| 222 |
|
| 223 |
<div class="srr_row"> |
| 224 |
<div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('display_type');?>">Display type: </label></div> |
| 225 |
<div class="srr_field"> |
| 226 |
<?php |
| 227 |
$display_types = SRR_Options::display_types(); |
| 228 |
echo '<select name="' . $this->get_field_name('display_type') . '" id="' . $this->get_field_id('display_type') . '">'; |
| 229 |
foreach($display_types as $k => $v){ |
| 230 |
echo '<option value="' . $k . '" ' . ($display_type == $k ? 'selected="selected"' : "") . '>' . $v . '</option>'; |
| 231 |
} |
| 232 |
echo '</select>'; |
| 233 |
?> |
| 234 |
</div> |
| 235 |
</div> |
| 236 |
|
| 237 |
<div class="srr_row"> |
| 238 |
<div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('ticker_speed');?>">Ticker speed: </label></div> |
| 239 |
<div class="srr_field"><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</div> |
| 240 |
</div> |
| 241 |
|
| 242 |
</section> |
| 243 |
|
| 244 |
</div> |
| 245 |
|
| 246 |
<div class="srr_coffee"> |
| 247 |
<p>Thank you for using Super RSS Reader. If you found it useful, please buy me a coffee !</p> |
| 248 |
<div class="srr_coffee_wrap"> |
| 249 |
<select class="srr_coffee_amt"> |
| 250 |
<option value="6" selected="selected">$6</option> |
| 251 |
<option value="7">$7</option> |
| 252 |
<option value="8">$8</option> |
| 253 |
<option value="9">$9</option> |
| 254 |
<option value="10">$10</option> |
| 255 |
<option value="11">$11</option> |
| 256 |
<option value="12">$12</option> |
| 257 |
<option value="13">$13</option> |
| 258 |
<option value="14">$14</option> |
| 259 |
<option value="15">$15</option> |
| 260 |
<option value="">Custom</option> |
| 261 |
</select> |
| 262 |
<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> |
| 263 |
</div> |
| 264 |
</div> |
| 265 |
|
| 266 |
<div class="srr_info"> |
| 267 |
<p><a href="https://www.aakashweb.com/docs/super-rss-reader/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> |
| 268 |
</div> |
| 269 |
|
| 270 |
<?php |
| 271 |
} |
| 272 |
} |
| 273 |
|
| 274 |
?> |