WP News and Scrolling Widgets - Version 3.2

Version Description

  • Widget Options like Show News date, Show News Categories, Select News Categories.
Download this release

Release Info

Developer anoopranawat
Plugin Icon 128x128 WP News and Scrolling Widgets
Version 3.2
Comparing to
See all releases

Code changes from version 3.1.1 to 3.2

Files changed (4) hide show
  1. css/stylenews.css +3 -1
  2. js/jcarousellite.js +8 -8
  3. readme.txt +13 -1
  4. sp-news-and-widget.php +155 -48
css/stylenews.css CHANGED
@@ -24,6 +24,8 @@ box-sizing: border-box; }
24
  .button-news-n{width:49%; float:right; text-align:right}
25
 
26
  .recent-news-items{clear:both;}
 
 
27
 
28
  .news-col-4{width:25%; float:left; clear:none !important; padding:0 15px;}
29
  .news-col-3{width:33%; float:left; clear:none !important; padding:0 15px;}
@@ -32,7 +34,7 @@ box-sizing: border-box; }
32
 
33
  .grid-news-thumb{float: left; height: 160px;line-height: 0; overflow: hidden; position: relative; width: 100%;}
34
  .grid-news-thumb img{margin: 0 auto;opacity: 1;position: absolute; }
35
-
36
 
37
  .news-col-3 .news-thumb, .news-col-2 .news-thumb, .news-col-4 .news-thumb{margin-bottom:5px;}
38
  .news-col-3 .post-content-text, .news-col-2 .post-content-text, .news-col-4 .post-content-text{width:100%; margin:0px;}p.news-short-content{margin-bottom:5px !important}
24
  .button-news-n{width:49%; float:right; text-align:right}
25
 
26
  .recent-news-items{clear:both;}
27
+ .recent-news-items.no_p h6{margin:5px 0;}
28
+ .recent-news-items p{font-size:13px !important; margin-bottom:10px !important}
29
 
30
  .news-col-4{width:25%; float:left; clear:none !important; padding:0 15px;}
31
  .news-col-3{width:33%; float:left; clear:none !important; padding:0 15px;}
34
 
35
  .grid-news-thumb{float: left; height: 160px;line-height: 0; overflow: hidden; position: relative; width: 100%;}
36
  .grid-news-thumb img{margin: 0 auto;opacity: 1;position: absolute; }
37
+ .news_li h6{clear: none !important; }
38
 
39
  .news-col-3 .news-thumb, .news-col-2 .news-thumb, .news-col-4 .news-thumb{margin-bottom:5px;}
40
  .news-col-3 .post-content-text, .news-col-2 .post-content-text, .news-col-4 .post-content-text{width:100%; margin:0px;}p.news-short-content{margin-bottom:5px !important}
js/jcarousellite.js CHANGED
@@ -1,8 +1,8 @@
1
- /*!
2
- * jCarouselLite - v1.1 - 2014-09-28
3
- * http://www.gmarwaha.com/jquery/jcarousellite/
4
- * Copyright (c) 2014 Ganeshji Marwaha
5
- * Licensed MIT (https://github.com/ganeshmax/jcarousellite/blob/master/LICENSE)
6
- */
7
-
8
- !function(a){a.jCarouselLite={version:"1.1"},a.fn.jCarouselLite=function(b){return b=a.extend({},a.fn.jCarouselLite.options,b||{}),this.each(function(){function c(a){return n||(clearTimeout(A),z=a,b.beforeStart&&b.beforeStart.call(this,i()),b.circular?j(a):k(a),m({start:function(){n=!0},done:function(){b.afterEnd&&b.afterEnd.call(this,i()),b.auto&&h(),n=!1}}),b.circular||l()),!1}function d(){if(n=!1,o=b.vertical?"top":"left",p=b.vertical?"height":"width",q=B.find(">ul"),r=q.find(">li"),x=r.size(),w=x<b.visible?x:b.visible,b.circular){var c=r.slice(x-w).clone(),d=r.slice(0,w).clone();q.prepend(c).append(d),b.start+=w}s=a("li",q),y=s.size(),z=b.start}function e(){B.css("visibility","visible"),s.css({overflow:"hidden","float":b.vertical?"none":"left"}),q.css({margin:"0",padding:"0",position:"relative","list-style":"none","z-index":"1"}),B.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"}),!b.circular&&b.btnPrev&&0==b.start&&a(b.btnPrev).addClass("disabled")}function f(){t=b.vertical?s.outerHeight(!0):s.outerWidth(!0),u=t*y,v=t*w,s.css({width:s.width(),height:s.height()}),q.css(p,u+"px").css(o,-(z*t)),B.css(p,v+"px")}function g(){b.btnPrev&&a(b.btnPrev).click(function(){return c(z-b.scroll)}),b.btnNext&&a(b.btnNext).click(function(){return c(z+b.scroll)}),b.btnGo&&a.each(b.btnGo,function(d,e){a(e).click(function(){return c(b.circular?w+d:d)})}),b.mouseWheel&&B.mousewheel&&B.mousewheel(function(a,d){return c(d>0?z-b.scroll:z+b.scroll)}),b.auto&&h()}function h(){A=setTimeout(function(){c(z+b.scroll)},b.auto)}function i(){return s.slice(z).slice(0,w)}function j(a){var c;a<=b.start-w-1?(c=a+x+b.scroll,q.css(o,-(c*t)+"px"),z=c-b.scroll):a>=y-w+1&&(c=a-x-b.scroll,q.css(o,-(c*t)+"px"),z=c+b.scroll)}function k(a){0>a?z=0:a>y-w&&(z=y-w)}function l(){a(b.btnPrev+","+b.btnNext).removeClass("disabled"),a(z-b.scroll<0&&b.btnPrev||z+b.scroll>y-w&&b.btnNext||[]).addClass("disabled")}function m(c){n=!0,q.animate("left"==o?{left:-(z*t)}:{top:-(z*t)},a.extend({duration:b.speed,easing:b.easing},c))}var n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a(this);d(),e(),f(),g()})},a.fn.jCarouselLite.options={btnPrev:null,btnNext:null,btnGo:null,mouseWheel:!1,auto:null,speed:200,easing:null,vertical:!1,circular:!0,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null}}(jQuery);
1
+ /*!
2
+ * jCarouselLite - v1.1 - 2014-09-28
3
+ * http://www.gmarwaha.com/jquery/jcarousellite/
4
+ * Copyright (c) 2014 Ganeshji Marwaha
5
+ * Licensed MIT (https://github.com/ganeshmax/jcarousellite/blob/master/LICENSE)
6
+ */
7
+
8
+ !function(a){a.jCarouselLite={version:"1.1"},a.fn.jCarouselLite=function(b){return b=a.extend({},a.fn.jCarouselLite.options,b||{}),this.each(function(){function c(a){return n||(clearTimeout(A),z=a,b.beforeStart&&b.beforeStart.call(this,i()),b.circular?j(a):k(a),m({start:function(){n=!0},done:function(){b.afterEnd&&b.afterEnd.call(this,i()),b.auto&&h(),n=!1}}),b.circular||l()),!1}function d(){if(n=!1,o=b.vertical?"top":"left",p=b.vertical?"height":"width",q=B.find(">ul"),r=q.find(">li"),x=r.size(),w=x<b.visible?x:b.visible,b.circular){var c=r.slice(x-w).clone(),d=r.slice(0,w).clone();q.prepend(c).append(d),b.start+=w}s=a("li",q),y=s.size(),z=b.start}function e(){B.css("visibility","visible"),s.css({overflow:"hidden","float":b.vertical?"none":"left"}),q.css({margin:"0",padding:"0",position:"relative","list-style":"none","z-index":"1"}),B.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"}),!b.circular&&b.btnPrev&&0==b.start&&a(b.btnPrev).addClass("disabled")}function f(){t=b.vertical?s.outerHeight(!0):s.outerWidth(!0),u=t*y,v=t*w,s.css({width:s.width(),height:s.height()}),q.css(p,u+"px").css(o,-(z*t)),B.css(p,v+"px")}function g(){b.btnPrev&&a(b.btnPrev).click(function(){return c(z-b.scroll)}),b.btnNext&&a(b.btnNext).click(function(){return c(z+b.scroll)}),b.btnGo&&a.each(b.btnGo,function(d,e){a(e).click(function(){return c(b.circular?w+d:d)})}),b.mouseWheel&&B.mousewheel&&B.mousewheel(function(a,d){return c(d>0?z-b.scroll:z+b.scroll)}),b.auto&&h()}function h(){A=setTimeout(function(){c(z+b.scroll)},b.auto)}function i(){return s.slice(z).slice(0,w)}function j(a){var c;a<=b.start-w-1?(c=a+x+b.scroll,q.css(o,-(c*t)+"px"),z=c-b.scroll):a>=y-w+1&&(c=a-x-b.scroll,q.css(o,-(c*t)+"px"),z=c+b.scroll)}function k(a){0>a?z=0:a>y-w&&(z=y-w)}function l(){a(b.btnPrev+","+b.btnNext).removeClass("disabled"),a(z-b.scroll<0&&b.btnPrev||z+b.scroll>y-w&&b.btnNext||[]).addClass("disabled")}function m(c){n=!0,q.animate("left"==o?{left:-(z*t)}:{top:-(z*t)},a.extend({duration:b.speed,easing:b.easing},c))}var n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a(this);d(),e(),f(),g()})},a.fn.jCarouselLite.options={btnPrev:null,btnNext:null,btnGo:null,mouseWheel:!1,auto:null,speed:200,easing:null,vertical:!1,circular:!0,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null}}(jQuery);
readme.txt CHANGED
@@ -43,6 +43,8 @@ Arts news
43
 
44
  * Comments for the news
45
 
 
 
46
  * Users that are using version 2.1 please paste the shortcode in their News page <code> [sp_news] </code> and If your Permalink link is www.yourdoamin.com/news then plaese change from "news" to other name like "ournews", "latestnews etc" otherwise all your news will go to archive page.
47
 
48
  = Following are News Parameters: =
@@ -59,13 +61,13 @@ This plugin add a News custom post type, News widget, vertical and horizontal
59
 
60
  The plugin adds a News tab to your admin menu, which allows you to enter news items just as you would regular posts.
61
 
62
-
63
  If you are getting any kind of problum with news page means your are not able to see all news items then please remodify your permalinks Structure for example
64
  first select "Default" and save then again select "Custom Structure " and save.
65
 
66
  Finally, the plugin adds a Recent News Items widget and vertical news scrolling widget , which can be placed on any sidebar available in your theme. You can set the title of this list and the number of news items to show.
67
 
68
  = Added New Features : =
 
69
  * Shortcode <code> [sp_news] </code> for news page.
70
  * Category wise News <code> Sports news [sp_news category="category_id"] </code>
71
  * Display News with Grid [sp_news grid="2"]
@@ -84,6 +86,7 @@ Finally, the plugin adds a Recent News Items widget and vertical news scrolling
84
  * News Tags
85
  * 3 News widgets
86
  * CSS and JS file for custmization
 
87
 
88
 
89
  == Installation ==
@@ -122,9 +125,14 @@ Yse <code> [sp_news] </code>.
122
  5. Single News view
123
  6. Widgets
124
  7. Admin setting page
 
125
 
126
  == Changelog ==
127
 
 
 
 
 
128
  = 3.1.1 =
129
  * Solved categories bug
130
 
@@ -167,6 +175,10 @@ Yse <code> [sp_news] </code>.
167
 
168
  == Upgrade Notice ==
169
 
 
 
 
 
170
  = 3.1.1 =
171
  * Solved categories bug
172
 
43
 
44
  * Comments for the news
45
 
46
+ * Added Widget Options like Show News date, Show News Categories, Select News Categories.
47
+
48
  * Users that are using version 2.1 please paste the shortcode in their News page <code> [sp_news] </code> and If your Permalink link is www.yourdoamin.com/news then plaese change from "news" to other name like "ournews", "latestnews etc" otherwise all your news will go to archive page.
49
 
50
  = Following are News Parameters: =
61
 
62
  The plugin adds a News tab to your admin menu, which allows you to enter news items just as you would regular posts.
63
 
 
64
  If you are getting any kind of problum with news page means your are not able to see all news items then please remodify your permalinks Structure for example
65
  first select "Default" and save then again select "Custom Structure " and save.
66
 
67
  Finally, the plugin adds a Recent News Items widget and vertical news scrolling widget , which can be placed on any sidebar available in your theme. You can set the title of this list and the number of news items to show.
68
 
69
  = Added New Features : =
70
+ * Added Widget Options like Show News date, Show News Categories, Select News Categories.
71
  * Shortcode <code> [sp_news] </code> for news page.
72
  * Category wise News <code> Sports news [sp_news category="category_id"] </code>
73
  * Display News with Grid [sp_news grid="2"]
86
  * News Tags
87
  * 3 News widgets
88
  * CSS and JS file for custmization
89
+ * Widget Options like Show date, Show Categories, Select News Categories.
90
 
91
 
92
  == Installation ==
125
  5. Single News view
126
  6. Widgets
127
  7. Admin setting page
128
+ 8. Widgets Options
129
 
130
  == Changelog ==
131
 
132
+ = 3.2 =
133
+
134
+ * Widget Options like Show News date, Show News Categories, Select News Categories.
135
+
136
  = 3.1.1 =
137
  * Solved categories bug
138
 
175
 
176
  == Upgrade Notice ==
177
 
178
+ = 3.2 =
179
+
180
+ * Widget Options like Show News date, Show News Categories, Select News Categories.
181
+
182
  = 3.1.1 =
183
  * Solved categories bug
184
 
sp-news-and-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP News and three widgets(static, scrolling and scrolling with thumbs)
4
  Plugin URL: http://www.wponlinesupport.com/
5
  Description: A simple News and three widgets(static, scrolling and scrolling with thumbs) plugin
6
- Version: 3.1.1
7
  Author: WP Online Support
8
  Author URI: http://www.wponlinesupport.com/
9
  Contributors: WP Online Support
@@ -108,6 +108,21 @@ class SP_News_Widget extends WP_Widget {
108
  ?>
109
  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
110
  <p><label for="<?php echo $this->get_field_id('num_items'); ?>">Number of Items: <input class="widefat" id="<?php echo $this->get_field_id('num_items'); ?>" name="<?php echo $this->get_field_name('num_items'); ?>" type="text" value="<?php echo attribute_escape($num_items); ?>" /></label></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  <?php
112
  }
113
 
@@ -115,6 +130,9 @@ class SP_News_Widget extends WP_Widget {
115
  $instance = $old_instance;
116
  $instance['title'] = $new_instance['title'];
117
  $instance['num_items'] = $new_instance['num_items'];
 
 
 
118
  return $instance;
119
  }
120
  function widget($news_args, $instance) {
@@ -124,7 +142,9 @@ class SP_News_Widget extends WP_Widget {
124
 
125
  $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
126
  $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
127
-
 
 
128
  $postcount = 0;
129
 
130
  echo $before_widget;
@@ -132,7 +152,10 @@ class SP_News_Widget extends WP_Widget {
132
  ?>
133
  <h4 class="widget-title"><?php echo $title ?></h4>
134
  <!--visual-columns-->
135
- <div class="recent-news-items">
 
 
 
136
  <ul>
137
  <?php // setup the query
138
  $news_args = array( 'suppress_filters' => true,
@@ -141,12 +164,31 @@ class SP_News_Widget extends WP_Widget {
141
  'order' => 'DESC'
142
  );
143
 
 
 
 
144
  $cust_loop = new WP_Query($news_args);
 
 
 
145
  if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
 
 
 
 
 
 
 
 
 
 
 
146
  ?>
147
- <li>
148
- <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
149
-
 
 
150
  </li>
151
  <?php endwhile;
152
  endif;
@@ -158,25 +200,19 @@ class SP_News_Widget extends WP_Widget {
158
  echo $after_widget;
159
  }
160
  }
161
-
162
  /* Register the widget */
163
  function sp_news_widget_load_widgets() {
164
  register_widget( 'SP_News_Widget' );
165
  }
166
-
167
  /* Load the widget */
168
  add_action( 'widgets_init', 'sp_news_widget_load_widgets' );
169
-
170
  /* scrolling news */
171
  class SP_News_scrolling_Widget extends WP_Widget {
172
-
173
  function SP_News_scrolling_Widget() {
174
-
175
  $widget_ops = array('classname' => 'SP_News_scrolling_Widget', 'description' => __('Displayed Letest News Items from the News in a sidebar', 'news_cpt') );
176
  $control_ops = array( 'width' => 350, 'height' => 450, 'id_base' => 'sp_news_s_widget' );
177
  $this->WP_Widget( 'sp_news_s_widget', __('Letest News Scrolling Widget', 'news_cpt'), $widget_ops, $control_ops );
178
  }
179
-
180
  function form($instance) {
181
  $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
182
  $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
@@ -184,20 +220,41 @@ class SP_News_scrolling_Widget extends WP_Widget {
184
  ?>
185
  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
186
  <p><label for="<?php echo $this->get_field_id('num_items'); ?>">Number of Items: <input class="widefat" id="<?php echo $this->get_field_id('num_items'); ?>" name="<?php echo $this->get_field_name('num_items'); ?>" type="text" value="<?php echo attribute_escape($num_items); ?>" /></label></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  <?php
188
  }
189
 
190
  function update($new_instance, $old_instance) {
191
  $instance = $old_instance;
192
  $instance['title'] = $new_instance['title'];
193
- $instance['num_items'] = $new_instance['num_items'];
 
 
 
194
  return $instance;
195
  }
196
  function widget($news_args, $instance) {
197
  extract($news_args, EXTR_SKIP);
198
  $current_post_name = get_query_var('name');
199
  $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
200
- $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
 
 
 
201
  $postcount = 0;
202
 
203
  echo $before_widget;
@@ -205,7 +262,10 @@ class SP_News_scrolling_Widget extends WP_Widget {
205
  ?>
206
  <h4 class="widget-title"><?php echo $title ?></h4>
207
  <!--visual-columns-->
208
- <div class="recent-news-items">
 
 
 
209
  <div class="newsticker-jcarousellite">
210
  <ul>
211
  <?php // setup the query
@@ -214,12 +274,31 @@ class SP_News_scrolling_Widget extends WP_Widget {
214
  'post_type' => 'news',
215
  'order' => 'DESC'
216
  );
217
-
 
 
218
  $cust_loop = new WP_Query($news_args);
 
 
 
219
  if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
 
 
 
 
 
 
 
 
 
 
 
220
  ?>
221
- <li >
222
- <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
 
 
 
223
  </li>
224
  <?php endwhile;
225
  endif;
@@ -250,13 +329,28 @@ class SP_News_thmb_Widget extends WP_Widget {
250
  $this->WP_Widget( 'sp_news_sthumb_widget', __('Letest News with thumb Widget', 'news_cpt'), $widget_ops, $control_ops );
251
  }
252
 
253
- function form($instance) {
254
  $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
255
  $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
256
  $num_items = isset($instance['num_items']) ? absint($instance['num_items']) : 5;
257
  ?>
258
  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
259
  <p><label for="<?php echo $this->get_field_id('num_items'); ?>">Number of Items: <input class="widefat" id="<?php echo $this->get_field_id('num_items'); ?>" name="<?php echo $this->get_field_name('num_items'); ?>" type="text" value="<?php echo attribute_escape($num_items); ?>" /></label></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  <?php
261
  }
262
 
@@ -264,6 +358,9 @@ class SP_News_thmb_Widget extends WP_Widget {
264
  $instance = $old_instance;
265
  $instance['title'] = $new_instance['title'];
266
  $instance['num_items'] = $new_instance['num_items'];
 
 
 
267
  return $instance;
268
  }
269
  function widget($news_args, $instance) {
@@ -273,15 +370,18 @@ class SP_News_thmb_Widget extends WP_Widget {
273
 
274
  $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
275
  $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
276
-
 
 
277
  $postcount = 0;
278
-
279
  echo $before_widget;
280
-
281
  ?>
282
  <h4 class="widget-title"><?php echo $title ?></h4>
283
  <!--visual-columns-->
284
- <div class="recent-news-items">
 
 
 
285
  <div class="newstickerthumb-jcarousellite">
286
  <ul>
287
  <?php // setup the query
@@ -290,20 +390,41 @@ class SP_News_thmb_Widget extends WP_Widget {
290
  'post_type' => 'news',
291
  'order' => 'DESC'
292
  );
 
 
 
293
 
294
  $cust_loop = new WP_Query($news_args);
 
 
295
  if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
 
 
 
 
 
 
 
 
 
 
 
296
  ?>
297
- <li>
298
  <div class="news_thumb_left">
299
- <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php
 
 
300
  if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
301
  the_post_thumbnail( array(80,80) );
302
  }
303
  ?> </a></div>
304
  <div class="news_thumb_right">
305
- <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
306
- </div>
 
 
 
307
  </li>
308
  <?php endwhile;
309
  endif;
@@ -372,32 +493,17 @@ function get_news( $atts, $content = null ){
372
  $orderby = 'post_date';
373
  $order = 'DESC';
374
 
375
- if($category)
376
- {
377
  $args = array (
378
  'post_type' => $post_type,
379
  'orderby' => $orderby,
380
  'order' => $order,
381
  'posts_per_page' => $posts_per_page,
382
  'paged' => $paged,
383
- 'tax_query' => array(
384
- array(
385
- 'taxonomy' => 'news-category',
386
- 'field' => 'id',
387
- 'terms' => $cat,
388
- ),
389
- ),
390
  );
391
- }else{
392
- $args = array (
393
- 'post_type' => $post_type,
394
- 'orderby' => $orderby,
395
- 'order' => $order,
396
- 'posts_per_page' => $posts_per_page,
397
- 'paged' => $paged,
398
- );
399
- }
400
- $query = new WP_Query($args);
401
  $post_count = $query->post_count;
402
  $count = 0;
403
  if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
@@ -421,7 +527,8 @@ function get_news( $atts, $content = null ){
421
  <div class="news-thumb">
422
  <?php
423
  // Post thumbnail.
424
- if ( has_post_thumbnail() && $gridcol == '1') { ?>
 
425
  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('url'); ?></a>
426
  <?php } else if($gridcol > '2') { ?>
427
  <div class="grid-news-thumb">
@@ -431,7 +538,7 @@ function get_news( $atts, $content = null ){
431
  <div class="grid-news-thumb">
432
  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a>
433
  </div>
434
- <?php } ?>
435
  </div>
436
  <div class="news-content">
437
  <?php if($gridcol == '1') { ?>
3
  Plugin Name: WP News and three widgets(static, scrolling and scrolling with thumbs)
4
  Plugin URL: http://www.wponlinesupport.com/
5
  Description: A simple News and three widgets(static, scrolling and scrolling with thumbs) plugin
6
+ Version: 3.2
7
  Author: WP Online Support
8
  Author URI: http://www.wponlinesupport.com/
9
  Contributors: WP Online Support
108
  ?>
109
  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
110
  <p><label for="<?php echo $this->get_field_id('num_items'); ?>">Number of Items: <input class="widefat" id="<?php echo $this->get_field_id('num_items'); ?>" name="<?php echo $this->get_field_name('num_items'); ?>" type="text" value="<?php echo attribute_escape($num_items); ?>" /></label></p>
111
+ <p>
112
+ <input id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" type="checkbox"<?php checked( $instance['date'], 1 ); ?> />
113
+ <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Display Date', 'news' ); ?></label>
114
+ </p>
115
+ <p>
116
+ <input id="<?php echo $this->get_field_id( 'show_category' ); ?>" name="<?php echo $this->get_field_name( 'show_category' ); ?>" type="checkbox"<?php checked( $instance['show_category'], 1 ); ?> />
117
+ <label for="<?php echo $this->get_field_id( 'show_category' ); ?>"><?php _e( 'Display Category', 'news' ); ?></label>
118
+ </p>
119
+ <p>
120
+ <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Category:', 'news' ); ?></label>
121
+ <?php
122
+ $dropdown_args = array( 'taxonomy' => 'news-category', 'class' => 'widefat', 'show_option_all' => __( 'All', 'news' ), 'id' => $this->get_field_id( 'category' ), 'name' => $this->get_field_name( 'category' ), 'selected' => $instance['category'] );
123
+ wp_dropdown_categories( $dropdown_args );
124
+ ?>
125
+ </p>
126
  <?php
127
  }
128
 
130
  $instance = $old_instance;
131
  $instance['title'] = $new_instance['title'];
132
  $instance['num_items'] = $new_instance['num_items'];
133
+ $instance['date'] = (bool) esc_attr( $new_instance['date'] );
134
+ $instance['show_category'] = (bool) esc_attr( $new_instance['show_category'] );
135
+ $instance['category'] = intval( $new_instance['category'] );
136
  return $instance;
137
  }
138
  function widget($news_args, $instance) {
142
 
143
  $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
144
  $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
145
+ if ( isset( $instance['date'] ) && ( 1 == $instance['date'] ) ) { $date = "true"; } else { $date = "false"; }
146
+ if ( isset( $instance['show_category'] ) && ( 1 == $instance['show_category'] ) ) { $show_category = "true"; } else { $show_category = "false"; }
147
+ if ( isset( $instance['category'] ) && is_numeric( $instance['category'] ) ) $category = intval( $instance['category'] );
148
  $postcount = 0;
149
 
150
  echo $before_widget;
152
  ?>
153
  <h4 class="widget-title"><?php echo $title ?></h4>
154
  <!--visual-columns-->
155
+ <?php if($date == "false" && $show_category == "false"){
156
+ $no_p = "no_p";
157
+ }?>
158
+ <div class="recent-news-items <?php echo $no_p?>">
159
  <ul>
160
  <?php // setup the query
161
  $news_args = array( 'suppress_filters' => true,
164
  'order' => 'DESC'
165
  );
166
 
167
+ if($category != 0){
168
+ $news_args['tax_query'] = array( array( 'taxonomy' => 'news-category', 'field' => 'id', 'terms' => $category) );
169
+ }
170
  $cust_loop = new WP_Query($news_args);
171
+ $post_count = $cust_loop->post_count;
172
+ $count = 0;
173
+
174
  if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
175
+ $count++;
176
+ $terms = get_the_terms( $post->ID, 'news-category' );
177
+ $news_links = array();
178
+ if($terms){
179
+
180
+ foreach ( $terms as $term ) {
181
+ $term_link = get_term_link( $term );
182
+ $news_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
183
+ }
184
+ }
185
+ $cate_name = join( ", ", $news_links );
186
  ?>
187
+ <li class="news_li">
188
+ <h6> <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6>
189
+ <?php echo ($date == "true")? '<p>'.get_the_date('j, M y') : "" ;?>
190
+ <?php echo ($date == "true" && $show_category == "true" && $cate_name != '') ? " , " : "";?>
191
+ <?php echo ($show_category == 'true' && $cate_name != '') ? $cate_name.'</p>' : ""?>
192
  </li>
193
  <?php endwhile;
194
  endif;
200
  echo $after_widget;
201
  }
202
  }
 
203
  /* Register the widget */
204
  function sp_news_widget_load_widgets() {
205
  register_widget( 'SP_News_Widget' );
206
  }
 
207
  /* Load the widget */
208
  add_action( 'widgets_init', 'sp_news_widget_load_widgets' );
 
209
  /* scrolling news */
210
  class SP_News_scrolling_Widget extends WP_Widget {
 
211
  function SP_News_scrolling_Widget() {
 
212
  $widget_ops = array('classname' => 'SP_News_scrolling_Widget', 'description' => __('Displayed Letest News Items from the News in a sidebar', 'news_cpt') );
213
  $control_ops = array( 'width' => 350, 'height' => 450, 'id_base' => 'sp_news_s_widget' );
214
  $this->WP_Widget( 'sp_news_s_widget', __('Letest News Scrolling Widget', 'news_cpt'), $widget_ops, $control_ops );
215
  }
 
216
  function form($instance) {
217
  $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
218
  $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
220
  ?>
221
  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
222
  <p><label for="<?php echo $this->get_field_id('num_items'); ?>">Number of Items: <input class="widefat" id="<?php echo $this->get_field_id('num_items'); ?>" name="<?php echo $this->get_field_name('num_items'); ?>" type="text" value="<?php echo attribute_escape($num_items); ?>" /></label></p>
223
+ <p>
224
+ <input id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" type="checkbox"<?php checked( $instance['date'], 1 ); ?> />
225
+ <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Display Date', 'news' ); ?></label>
226
+ </p>
227
+ <p>
228
+ <input id="<?php echo $this->get_field_id( 'show_category' ); ?>" name="<?php echo $this->get_field_name( 'show_category' ); ?>" type="checkbox"<?php checked( $instance['show_category'], 1 ); ?> />
229
+ <label for="<?php echo $this->get_field_id( 'show_category' ); ?>"><?php _e( 'Display Category', 'news' ); ?></label>
230
+ </p>
231
+ <p>
232
+ <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Category:', 'news' ); ?></label>
233
+ <?php
234
+ $dropdown_args = array( 'taxonomy' => 'news-category', 'class' => 'widefat', 'show_option_all' => __( 'All', 'news' ), 'id' => $this->get_field_id( 'category' ), 'name' => $this->get_field_name( 'category' ), 'selected' => $instance['category'] );
235
+ wp_dropdown_categories( $dropdown_args );
236
+ ?>
237
+ </p>
238
  <?php
239
  }
240
 
241
  function update($new_instance, $old_instance) {
242
  $instance = $old_instance;
243
  $instance['title'] = $new_instance['title'];
244
+ $instance['num_items'] = $new_instance['num_items'];
245
+ $instance['date'] = (bool) esc_attr( $new_instance['date'] );
246
+ $instance['show_category'] = (bool) esc_attr( $new_instance['show_category'] );
247
+ $instance['category'] = intval( $new_instance['category'] );
248
  return $instance;
249
  }
250
  function widget($news_args, $instance) {
251
  extract($news_args, EXTR_SKIP);
252
  $current_post_name = get_query_var('name');
253
  $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
254
+ $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
255
+ if ( isset( $instance['date'] ) && ( 1 == $instance['date'] ) ) { $date = "true"; } else { $date = "false"; }
256
+ if ( isset( $instance['show_category'] ) && ( 1 == $instance['show_category'] ) ) { $show_category = "true"; } else { $show_category = "false"; }
257
+ if ( isset( $instance['category'] ) && is_numeric( $instance['category'] ) ) $category = intval( $instance['category'] );
258
  $postcount = 0;
259
 
260
  echo $before_widget;
262
  ?>
263
  <h4 class="widget-title"><?php echo $title ?></h4>
264
  <!--visual-columns-->
265
+ <?php if($date == "false" && $show_category == "false"){
266
+ $no_p = "no_p";
267
+ }?>
268
+ <div class="recent-news-items <?php echo $no_p;?>">
269
  <div class="newsticker-jcarousellite">
270
  <ul>
271
  <?php // setup the query
274
  'post_type' => 'news',
275
  'order' => 'DESC'
276
  );
277
+ if($category != 0){
278
+ $news_args['tax_query'] = array( array( 'taxonomy' => 'news-category', 'field' => 'id', 'terms' => $category) );
279
+ }
280
  $cust_loop = new WP_Query($news_args);
281
+ $post_count = $cust_loop->post_count;
282
+ $count = 0;
283
+
284
  if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
285
+ $count++;
286
+ $terms = get_the_terms( $post->ID, 'news-category' );
287
+ $news_links = array();
288
+ if($terms){
289
+
290
+ foreach ( $terms as $term ) {
291
+ $term_link = get_term_link( $term );
292
+ $news_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
293
+ }
294
+ }
295
+ $cate_name = join( ", ", $news_links );
296
  ?>
297
+ <li class="news_li">
298
+ <h6><a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6>
299
+ <?php echo ($date == "true")? '<p>'.get_the_date('j, M y') : "" ;?>
300
+ <?php echo ($date == "true" && $show_category == "true" && $cate_name != '') ? " , " : "";?>
301
+ <?php echo ($show_category == 'true' && $cate_name != '') ? $cate_name.'</p>' : ""?>
302
  </li>
303
  <?php endwhile;
304
  endif;
329
  $this->WP_Widget( 'sp_news_sthumb_widget', __('Letest News with thumb Widget', 'news_cpt'), $widget_ops, $control_ops );
330
  }
331
 
332
+ function form($instance) {
333
  $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
334
  $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
335
  $num_items = isset($instance['num_items']) ? absint($instance['num_items']) : 5;
336
  ?>
337
  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
338
  <p><label for="<?php echo $this->get_field_id('num_items'); ?>">Number of Items: <input class="widefat" id="<?php echo $this->get_field_id('num_items'); ?>" name="<?php echo $this->get_field_name('num_items'); ?>" type="text" value="<?php echo attribute_escape($num_items); ?>" /></label></p>
339
+ <p>
340
+ <input id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" type="checkbox"<?php checked( $instance['date'], 1 ); ?> />
341
+ <label for="<?php echo $this->get_field_id( 'date' ); ?>"><?php _e( 'Display Date', 'news' ); ?></label>
342
+ </p>
343
+ <p>
344
+ <input id="<?php echo $this->get_field_id( 'show_category' ); ?>" name="<?php echo $this->get_field_name( 'show_category' ); ?>" type="checkbox"<?php checked( $instance['show_category'], 1 ); ?> />
345
+ <label for="<?php echo $this->get_field_id( 'show_category' ); ?>"><?php _e( 'Display Category', 'news' ); ?></label>
346
+ </p>
347
+ <p>
348
+ <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Category:', 'news' ); ?></label>
349
+ <?php
350
+ $dropdown_args = array( 'taxonomy' => 'news-category', 'class' => 'widefat', 'show_option_all' => __( 'All', 'news' ), 'id' => $this->get_field_id( 'category' ), 'name' => $this->get_field_name( 'category' ), 'selected' => $instance['category'] );
351
+ wp_dropdown_categories( $dropdown_args );
352
+ ?>
353
+ </p>
354
  <?php
355
  }
356
 
358
  $instance = $old_instance;
359
  $instance['title'] = $new_instance['title'];
360
  $instance['num_items'] = $new_instance['num_items'];
361
+ $instance['date'] = (bool) esc_attr( $new_instance['date'] );
362
+ $instance['show_category'] = (bool) esc_attr( $new_instance['show_category'] );
363
+ $instance['category'] = intval( $new_instance['category'] );
364
  return $instance;
365
  }
366
  function widget($news_args, $instance) {
370
 
371
  $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
372
  $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
373
+ if ( isset( $instance['date'] ) && ( 1 == $instance['date'] ) ) { $date = "true"; } else { $date = "false"; }
374
+ if ( isset( $instance['show_category'] ) && ( 1 == $instance['show_category'] ) ) { $show_category = "true"; } else { $show_category = "false"; }
375
+ if ( isset( $instance['category'] ) && is_numeric( $instance['category'] ) ) $category = intval( $instance['category'] );
376
  $postcount = 0;
 
377
  echo $before_widget;
 
378
  ?>
379
  <h4 class="widget-title"><?php echo $title ?></h4>
380
  <!--visual-columns-->
381
+ <?php if($date == "false" && $show_category == "false"){
382
+ $no_p = "no_p";
383
+ }?>
384
+ <div class="recent-news-items <?php echo $no_p;?>">
385
  <div class="newstickerthumb-jcarousellite">
386
  <ul>
387
  <?php // setup the query
390
  'post_type' => 'news',
391
  'order' => 'DESC'
392
  );
393
+ if($category != 0){
394
+ $news_args['tax_query'] = array( array( 'taxonomy' => 'news-category', 'field' => 'id', 'terms' => $category) );
395
+ }
396
 
397
  $cust_loop = new WP_Query($news_args);
398
+ $post_count = $cust_loop->post_count;
399
+ $count = 0;
400
  if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
401
+ $count++;
402
+ $terms = get_the_terms( $post->ID, 'news-category' );
403
+ $news_links = array();
404
+ if($terms){
405
+
406
+ foreach ( $terms as $term ) {
407
+ $term_link = get_term_link( $term );
408
+ $news_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
409
+ }
410
+ }
411
+ $cate_name = join( ", ", $news_links );
412
  ?>
413
+ <li class="news_li">
414
  <div class="news_thumb_left">
415
+ <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
416
+
417
+ <?php
418
  if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
419
  the_post_thumbnail( array(80,80) );
420
  }
421
  ?> </a></div>
422
  <div class="news_thumb_right">
423
+ <h6><a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h6>
424
+ <?php echo ($date == "true")? '<p>'.get_the_date('j, M y') : "" ;?>
425
+ <?php echo ($date == "true" && $show_category == "true" && $cate_name != '') ? " , " : "";?>
426
+ <?php echo ($show_category == 'true' && $cate_name != '') ? $cate_name.'</p>' : ""?></div>
427
+
428
  </li>
429
  <?php endwhile;
430
  endif;
493
  $orderby = 'post_date';
494
  $order = 'DESC';
495
 
 
 
496
  $args = array (
497
  'post_type' => $post_type,
498
  'orderby' => $orderby,
499
  'order' => $order,
500
  'posts_per_page' => $posts_per_page,
501
  'paged' => $paged,
 
 
 
 
 
 
 
502
  );
503
+ if($cat != ""){
504
+ $args['tax_query'] = array( array( 'taxonomy' => 'news-category', 'field' => 'id', 'terms' => $cat) );
505
+ }
506
+ $query = new WP_Query($args);
 
 
 
 
 
 
507
  $post_count = $query->post_count;
508
  $count = 0;
509
  if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
527
  <div class="news-thumb">
528
  <?php
529
  // Post thumbnail.
530
+ if ( has_post_thumbnail()) {
531
+ if($gridcol == '1'){ ?>
532
  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('url'); ?></a>
533
  <?php } else if($gridcol > '2') { ?>
534
  <div class="grid-news-thumb">
538
  <div class="grid-news-thumb">
539
  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a>
540
  </div>
541
+ <?php } }?>
542
  </div>
543
  <div class="news-content">
544
  <?php if($gridcol == '1') { ?>