PluginProbe
Super RSS Reader – Add attractive RSS Feed Widget / 4.3
Super RSS Reader – Add attractive RSS Feed Widget v4.3
trunk 0.8 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 3.0 3.1 3.2 4.0 4.0.1 4.1 4.2 4.3 4.4 4.4.1 4.5 4.6 4.7 4.8 All 33 releases
super-rss-reader / includes / widget-admin.php

widget-admin.php in Super RSS Reader – Add attractive RSS Feed Widget 4.3, at includes/widget-admin.php

327 lines 21.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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' => __( 'An RSS feed reader widget with advanced features', 'super-rss-reader' )
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 '<!-- Start - Super RSS Reader v' . SRR_VERSION . '-->
34 <div class="super-rss-reader-widget">';
35
36 SRR_Widget::render_feed( $instance );
37
38 echo '</div><!-- End - Super RSS Reader -->';
39 echo $after_widget;
40
41 }
42
43 // Save settings
44 public function update( $new_instance, $old_instance ){
45
46 $instance = $old_instance;
47
48 $instance[ 'title' ] = stripslashes( $new_instance['title'] );
49 $instance[ 'urls' ] = stripslashes( $new_instance['urls']) ;
50 $instance[ 'tab_titles' ] = stripslashes( $new_instance['tab_titles'] );
51
52 $instance[ 'count' ] = intval( $new_instance['count'] );
53 $instance[ 'show_date' ] = intval( isset( $new_instance['show_date'] ) ? $new_instance['show_date'] : 0 );
54 $instance[ 'show_desc' ] = intval( isset( $new_instance['show_desc'] ) ? $new_instance['show_desc'] : 0 );
55 $instance[ 'show_author' ] = intval( isset( $new_instance['show_author'] ) ? $new_instance['show_author'] : 0 );
56 $instance[ 'show_thumb' ] = intval( isset( $new_instance['show_thumb'] ) ? $new_instance['show_thumb'] : 0 );
57 $instance[ 'strip_desc' ] = intval( $new_instance['strip_desc'] );
58 $instance[ 'strip_title' ] = intval( $new_instance['strip_title'] );
59 $instance[ 'date_format' ] = stripslashes( $new_instance['date_format'] );
60 $instance[ 'order_by' ] = stripslashes( $new_instance['order_by'] );
61 $instance[ 'read_more' ] = stripslashes( $new_instance['read_more'] );
62 $instance[ 'add_nofollow' ] = intval( isset( $new_instance['add_nofollow'] ) ? $new_instance['add_nofollow'] : 0 );
63 $instance[ 'open_newtab' ] = intval( isset( $new_instance['open_newtab'] ) ? $new_instance['open_newtab'] : 0 );
64 $instance[ 'rich_desc' ] = intval( isset( $new_instance['rich_desc'] ) ? $new_instance['rich_desc'] : 0 );
65 $instance[ 'thumbnail_position' ] = stripslashes( $new_instance['thumbnail_position'] );
66 $instance[ 'thumbnail_size' ] = stripslashes( $new_instance['thumbnail_size'] );
67 $instance[ 'thumbnail_default' ] = stripslashes( $new_instance['thumbnail_default'] );
68
69 $instance[ 'color_style' ] = stripslashes( $new_instance['color_style']);
70 $instance[ 'display_type' ] = stripslashes( $new_instance['display_type']);
71 $instance[ 'visible_items' ] = intval( $new_instance['visible_items']);
72 $instance[ 'ticker_speed' ] = intval( $new_instance['ticker_speed']);
73
74 return $instance;
75 }
76
77 // Widget form
78 public function form( $instance ){
79
80 $instance = wp_parse_args( (array) $instance, SRR_Options::defaults() );
81
82 $title = htmlspecialchars( isset( $instance['title'] ) ? $instance[ 'title' ] : '' );
83 $urls = htmlspecialchars($instance['urls']);
84 $tab_titles = htmlspecialchars($instance['tab_titles']);
85
86 $count = intval($instance['count']);
87 $show_date = intval($instance['show_date']);
88 $show_desc = intval($instance['show_desc']);
89 $show_author = intval($instance['show_author']);
90 $show_thumb = intval($instance['show_thumb']);
91 $open_newtab = intval($instance['open_newtab']);
92 $add_nofollow = intval($instance['add_nofollow']);
93 $strip_desc = intval($instance['strip_desc']);
94 $strip_title = intval($instance['strip_title']);
95 $date_format = htmlspecialchars($instance['date_format']);
96 $order_by = htmlspecialchars($instance['order_by']);
97 $read_more = htmlspecialchars($instance['read_more']);
98 $rich_desc = intval($instance['rich_desc']);
99 $thumbnail_position = htmlspecialchars($instance['thumbnail_position']);
100 $thumbnail_size = htmlspecialchars($instance['thumbnail_size']);
101 $thumbnail_default = htmlspecialchars($instance['thumbnail_default']);
102
103 $color_style = stripslashes($instance['color_style']);
104 $display_type = stripslashes($instance['display_type']);
105 $visible_items = intval($instance['visible_items']);
106 $ticker_speed = intval($instance['ticker_speed']);
107
108 $option_lists = SRR_Options::select_options();
109
110 // Replacing commas with new lines
111 $urls = str_replace( ',', "\n", $urls );
112 $tab_titles = str_replace( ',', "\n", $tab_titles );
113
114 ?>
115
116 <div class="srr_settings">
117
118 <div class="srr_row">
119 <div class="srr_label srr_xsm"><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'super-rss-reader' ); ?></label></div>
120 <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>
121 </div>
122
123 <div class="srr_row">
124 <div class="srr_label srr_xsm"><label for="<?php echo $this->get_field_id('urls'); ?>"><?php _e( 'URL(s)', 'super-rss-reader' ); ?></label></div>
125 <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>
126 <small class="srr_small_text"><?php _e( 'Can enter multiple RSS/atom feed URLs in new line', 'super-rss-reader' ); ?></small></div>
127 </div>
128
129 <div class="srr_row">
130 <div class="srr_label srr_xsm"><label for="<?php echo $this->get_field_id('tab_titles'); ?>"><?php _e( 'Tab titles', 'super-rss-reader' ); ?></label></div>
131 <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>
132 <small class="srr_small_text"><?php _e( 'Enter corresponding tab titles in new line. Leave empty to take from feed.', 'super-rss-reader' ); ?></small></div>
133 </div>
134
135 <ul class="srr_tab_list">
136 <li><a href="#" data-tab="general" class="active"><?php _e( 'General', 'super-rss-reader' ); ?></a></li>
137 <li><a href="#" data-tab="content"><?php _e( 'Content', 'super-rss-reader' ); ?></a></li>
138 <li><a href="#" data-tab="display"><?php _e( 'Display', 'super-rss-reader' ); ?></a></li>
139 </ul>
140
141 <section data-tab-id="general" class="active">
142
143 <div class="srr_row">
144 <div class="srr_label"><label for="<?php echo $this->get_field_id('count');?>"><?php _e( 'Total items to show', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'Number of feed items to be displayed', 'super-rss-reader' ) ); ?></div>
145 <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" /></div>
146 </div>
147
148 <div class="srr_row">
149 <div class="srr_label"><label for="<?php echo $this->get_field_id('show_desc'); ?>"><?php _e( 'Show Description', 'super-rss-reader' ); ?></label></div>
150 <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>
151 </div>
152
153 <div class="srr_row">
154 <div class="srr_label"><label for="<?php echo $this->get_field_id('show_date'); ?>"><?php _e( 'Show Date', 'super-rss-reader' ); ?></label></div>
155 <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>
156 </div>
157
158 <div class="srr_row">
159 <div class="srr_label"><label for="<?php echo $this->get_field_id('show_author'); ?>"><?php _e( 'Show Author', 'super-rss-reader' ); ?></label></div>
160 <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>
161 </div>
162
163 <div class="srr_row">
164 <div class="srr_label"><label for="<?php echo $this->get_field_id('show_thumb'); ?>"><?php _e( 'Show thumbnail if present', 'super-rss-reader' ); ?></label></div>
165 <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>
166 </div>
167 </section>
168
169 <section data-tab-id="content">
170
171 <div class="srr_row">
172 <div class="srr_label"><label for="<?php echo $this->get_field_id('add_nofollow'); ?>"><?php _e( 'Add "no follow" attribute to links', 'super-rss-reader' ); ?></label></div>
173 <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>
174 </div>
175
176 <div class="srr_row">
177 <div class="srr_label"><label for="<?php echo $this->get_field_id('open_newtab'); ?>"><?php _e( 'Open links in new tab', 'super-rss-reader' ); ?></label></div>
178 <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>
179 </div>
180
181 <div class="srr_row">
182 <div class="srr_label"><label for="<?php echo $this->get_field_id('strip_title'); ?>"><?php _e( 'Trim title to words', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'The number of words to be displayed. Use 0 to disable trimming', 'super-rss-reader' ) ); ?></div>
183 <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" /></div>
184 </div>
185
186 <div class="srr_row">
187 <div class="srr_label"><label for="<?php echo $this->get_field_id('date_format'); ?>"><?php _e( 'Date format', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'The format of the feed item date.', 'super-rss-reader' ) ); ?></div>
188 <div class="srr_field"><input id="<?php echo $this->get_field_id('date_format'); ?>" name="<?php echo $this->get_field_name('date_format'); ?>" type="text" value="<?php echo $date_format; ?>" class="widefat" /><div><a href="https://wordpress.org/support/article/formatting-date-and-time/" target="_blank"><?php _e( 'Refer format codes here', 'super-rss-reader' ); ?></a></div></div>
189 </div>
190
191 <div class="srr_row">
192 <div class="srr_label"><label for="<?php echo $this->get_field_id('order_by');?>"><?php _e( 'Order feed items by', 'super-rss-reader' ); ?></label></div>
193 <div class="srr_field">
194 <?php
195 echo '<select name="' . $this->get_field_name('order_by') . '" id="' . $this->get_field_id('order_by') . '">';
196 foreach( $option_lists[ 'order_by' ] as $k => $v ){
197 echo '<option value="' . $k . '" ' . selected( $order_by, $k ) . '>' . $v . '</option>';
198 }
199 echo '</select>';
200 ?>
201 </div>
202 </div>
203
204 <h4><?php _e( 'Description', 'super-rss-reader' ); ?></h4>
205
206 <div class="srr_row">
207 <div class="srr_label"><label for="<?php echo $this->get_field_id('strip_desc');?>"><?php _e( 'Trim description to words', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'The number of words to be displayed. Use 0 to disable trimming', 'super-rss-reader' ) ); ?></div>
208 <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" /></div>
209 </div>
210
211 <div class="srr_row">
212 <div class="srr_label"><label for="<?php echo $this->get_field_id('read_more'); ?>"><?php _e( 'Read more text', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'Leave blank to hide read more text', 'super-rss-reader' ) ); ?></div>
213 <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" /></div>
214 </div>
215
216 <div class="srr_row">
217 <div class="srr_label"><label for="<?php echo $this->get_field_id('rich_desc'); ?>"><?php _e( 'Enable rich description', 'super-rss-reader' ); ?></label></div>
218 <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>
219 </div>
220
221 <?php if( $rich_desc == 1 ): ?>
222 <span class="srr_note"><?php _e( '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.', 'super-rss-reader' ); ?></span>
223 <?php endif; ?>
224
225 <h4><?php _e( 'Thumbnail', 'super-rss-reader' ); ?></h4>
226
227 <div class="srr_row">
228 <div class="srr_label"><label for="<?php echo $this->get_field_id('thumbnail_position');?>"><?php _e( 'Thumbnail position', 'super-rss-reader' ); ?></label></div>
229 <div class="srr_field">
230 <?php
231 echo '<select name="' . $this->get_field_name('thumbnail_position') . '" id="' . $this->get_field_id('thumbnail_position') . '">';
232 foreach( $option_lists[ 'thumbnail_position' ] as $k => $v ){
233 echo '<option value="' . $k . '" ' . selected( $thumbnail_position, $k ) . '>' . $v . '</option>';
234 }
235 echo '</select>';
236 ?>
237 </div>
238 </div>
239
240 <div class="srr_row">
241 <div class="srr_label"><label for="<?php echo $this->get_field_id('thumbnail_size'); ?>"><?php _e( 'Thumbnail size', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'The size of the thumbnail including the units. Example 64px, 10%', 'super-rss-reader' ) ); ?></div>
242 <div class="srr_field"><input id="<?php echo $this->get_field_id('thumbnail_size');?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>" type="text" value="<?php echo $thumbnail_size; ?>" class="widefat" /></div>
243 </div>
244
245 <div class="srr_row">
246 <div class="srr_label"><label for="<?php echo $this->get_field_id('thumbnail_default'); ?>"><?php _e( 'Default thumbnail image', 'super-rss-reader' ); ?></label><?php $this->tt( __( 'The URL of the default thumbnail image if not present. Leave empty to skip thumbnail if not present.', 'super-rss-reader' ) ); ?></div>
247 <div class="srr_field"><input id="<?php echo $this->get_field_id('thumbnail_default');?>" name="<?php echo $this->get_field_name('thumbnail_default'); ?>" type="text" value="<?php echo $thumbnail_default; ?>" class="widefat" /></div>
248 </div>
249
250 </section>
251
252 <section data-tab-id="display">
253
254 <div class="srr_row">
255 <div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('color_style');?>"><?php _e( 'Color theme', 'super-rss-reader' ); ?></label></div>
256 <div class="srr_field">
257 <?php
258 echo '<select name="' . $this->get_field_name('color_style') . '" id="' . $this->get_field_id('color_style') . '">';
259 foreach( $option_lists[ 'color_style' ] as $k => $v ){
260 echo '<option value="' . $k . '" ' . selected( $color_style, $k ) . '>' . $v . '</option>';
261 }
262 echo '</select>';
263 ?>
264 </div>
265 </div>
266
267 <div class="srr_row">
268 <div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('display_type');?>"><?php _e( 'Display type', 'super-rss-reader' ); ?></label></div>
269 <div class="srr_field">
270 <?php
271 echo '<select name="' . $this->get_field_name('display_type') . '" id="' . $this->get_field_id('display_type') . '">';
272 foreach( $option_lists[ 'display_type' ] as $k => $v ){
273 echo '<option value="' . $k . '" ' . selected( $display_type, $k ) . '>' . $v . '</option>';
274 }
275 echo '</select>';
276 ?>
277 </div>
278 </div>
279
280 <div class="srr_row">
281 <div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('ticker_speed');?>"><?php _e( 'Ticker speed', 'super-rss-reader' ); ?></label></div>
282 <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>
283 </div>
284
285 <div class="srr_row">
286 <div class="srr_label srr_sm"><label for="<?php echo $this->get_field_id('visible_items');?>"><?php _e( 'Widget height', 'super-rss-reader' ); ?><?php $this->tt( __( 'The height of the widget when display type is "ticker"', 'super-rss-reader' ) ); ?></label></div>
287 <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; ?>" /><br/>
288 <small class="srr_small_text"><?php _e( 'Set value less than 20 to show visible feed items. Example: <b>5</b> items', 'super-rss-reader' ); ?></small></br>
289 <small class="srr_small_text"><?php _e( 'Set value greater than 20 for fixed widget height. Example: <b>400</b> px', 'super-rss-reader' ); ?></small></div>
290 </div>
291
292 </section>
293
294 </div>
295
296 <div class="srr_pro">
297 <div class="srr_pro_intro">
298 <div><span class="srr_pro_label">PRO</span></div>
299 <p>Get the PRO version to enjoy more features like<br/> <span>Shortcode, Grid display, Custom feed item template</span> and more !</p>
300 <div><span class="dashicons dashicons-arrow-down-alt2 srr_pro_more"></span></div>
301 </div>
302 <div class="srr_pro_details">
303 <ul class="srr_pro_features">
304 <li>Shortcode - <span>Display RSS feed anywhere in your website</span></li>
305 <li>Grid display - <span>Display feed item in rows and columns</span></li>
306 <li>Custom template - <span>Change order of feed item content, add HTML</span></li>
307 <li>4+ new color themes</li>
308 <li>Updates and support for 1 year</li>
309 </ul>
310 <p><a href="https://www.aakashweb.com/wordpress-plugins/super-rss-reader-pro/?utm_source=admin&utm_medium=widget-get&utm_campaign=srr-pro#purchase" class="button button-primary">Get PRO version</a> <a href="https://www.aakashweb.com/wordpress-plugins/super-rss-reader-pro/?utm_source=admin&utm_medium=widget-info&utm_campaign=srr-pro" class="button">More information</a></p>
311 </div>
312 </div>
313
314 <div class="srr_info">
315 <p><a href="https://www.aakashweb.com/docs/super-rss-reader/" target="_blank">Docs</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>
316 </div>
317
318 <?php
319 }
320
321 public function tt( $text ){
322 echo '<div class="srr_tt" tabindex="0"><span class="dashicons dashicons-editor-help"></span><span class="srr_tt_text"><span>' . $text . '</span></span></div>';
323 }
324
325 }
326
327 ?>