WP News and Scrolling Widgets - Version 2.1

Version Description

  • Scroll main page news
  • Setting page for enable or disable main page news scrolling
  • Setting page for main news page vertical and horizontal news scrolling
Download this release

Release Info

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

Version 2.1

css/stylenews.css ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .sp-news .archive-header{padding:0 0 10px 0; margin:0 0 10px 0; border:0px;}
2
+ .news img{padding:5px; background:#f8f8f8; border:1px solid #f1f1f1;}
3
+ .sp-news .archive-header h1{font-size:22px; text-transform:capitalize; line-height:25px;}
4
+ .sp-news h2{padding:0 0 10px 0; font-size:16px;}
5
+ .sp-news h2 a{text-decoration:none;}
6
+ .sp-news .date{display:block; background:url(../images/Calendar-Empty-icon.png) 0 50% no-repeat; padding:5px 0 5px 20px;}
7
+ .sp-news .news{clear:both; padding-bottom:20px;}
8
+ .sp-news .back{display:block; padding:10px 0;}
9
+
10
+ .SP_News_Widget h4{font-size:22px; text-transform:capitalize; padding-bottom:5px;}
11
+ .SP_News_Widget ul li{padding:5px 0 5px 20px; border-bottom:1px solid #ddd; background:url(../images/Calendar-Empty-icon.png) 0 8px no-repeat; list-style:none !important;}
12
+ .SP_News_Widget ul li a{text-decoration:none; display:block;}
13
+
14
+
15
+ .SP_News_scrolling_Widget h4, .SP_News_thmb_Widget h4{font-size:22px; text-transform:capitalize; padding-bottom:5px;}
16
+ .SP_News_scrolling_Widget ul li{padding:5px 0 5px 20px; border-bottom:1px solid #ddd; background:url(../images/Calendar-Empty-icon.png) 0 8px no-repeat;}
17
+ .SP_News_scrolling_Widget ul li a{text-decoration:none; display:block;}
18
+
19
+ .SP_News_thmb_Widget li{list-style:none !important; padding:5px 0 5px 0px; border-bottom:1px solid #ddd; float:left; width:100%;}
20
+ .news_thumb_left{float:left;}
21
+ .news_thumb_left img{padding:5px; background:#f8f8f8; border:1px solid #f1f1f1; }
22
+ .news_thumb_right{float:left; margin-left:8px; }
23
+
24
+ .newsticker-jcarousellite, .newstickerthumb-jcarousellite { width:100% !important; }
25
+ .newsticker-jcarousellite ul li{ list-style:none; display:block; }
26
+ .sp-news{overflow:hidden; clear:both !important;}
27
+
images/Calendar-Empty-icon.png ADDED
Binary file
images/Thumbs.db ADDED
Binary file
images/back.png ADDED
Binary file
images/forword.png ADDED
Binary file
images/newspaper-add-icon.png ADDED
Binary file
images/play.png ADDED
Binary file
images/stop.png ADDED
Binary file
js/jcarousellite.js ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.
3
+ * @requires jQuery v1.2 or above
4
+ *
5
+ * http://gmarwaha.com/jquery/jcarousellite/
6
+ *
7
+ * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
8
+ * Dual licensed under the MIT and GPL licenses:
9
+ * http://www.opensource.org/licenses/mit-license.php
10
+ * http://www.gnu.org/licenses/gpl.html
11
+ *
12
+ * Version: 1.0.1
13
+ * Note: Requires jquery 1.2 or above from version 1.0.1
14
+ */
15
+
16
+ /**
17
+ * Creates a carousel-style navigation widget for images/any-content from a simple HTML markup.
18
+ *
19
+ * The HTML markup that is used to build the carousel can be as simple as...
20
+ *
21
+ * <div class="carousel">
22
+ * <ul>
23
+ * <li><img src="image/1.jpg" alt="1"></li>
24
+ * <li><img src="image/2.jpg" alt="2"></li>
25
+ * <li><img src="image/3.jpg" alt="3"></li>
26
+ * </ul>
27
+ * </div>
28
+ *
29
+ * As you can see, this snippet is nothing but a simple div containing an unordered list of images.
30
+ * You don't need any special "class" attribute, or a special "css" file for this plugin.
31
+ * I am using a class attribute just for the sake of explanation here.
32
+ *
33
+ * To navigate the elements of the carousel, you need some kind of navigation buttons.
34
+ * For example, you will need a "previous" button to go backward, and a "next" button to go forward.
35
+ * This need not be part of the carousel "div" itself. It can be any element in your page.
36
+ * Lets assume that the following elements in your document can be used as next, and prev buttons...
37
+ *
38
+ * <button class="prev">&lt;&lt;</button>
39
+ * <button class="next">&gt;&gt;</button>
40
+ *
41
+ * Now, all you need to do is call the carousel component on the div element that represents it, and pass in the
42
+ * navigation buttons as options.
43
+ *
44
+ * $(".carousel").jCarouselLite({
45
+ * btnNext: ".next",
46
+ * btnPrev: ".prev"
47
+ * });
48
+ *
49
+ * That's it, you would have now converted your raw div, into a magnificient carousel.
50
+ *
51
+ * There are quite a few other options that you can use to customize it though.
52
+ * Each will be explained with an example below.
53
+ *
54
+ * @param an options object - You can specify all the options shown below as an options object param.
55
+ *
56
+ * @option btnPrev, btnNext : string - no defaults
57
+ * @example
58
+ * $(".carousel").jCarouselLite({
59
+ * btnNext: ".next",
60
+ * btnPrev: ".prev"
61
+ * });
62
+ * @desc Creates a basic carousel. Clicking "btnPrev" navigates backwards and "btnNext" navigates forward.
63
+ *
64
+ * @option btnGo - array - no defaults
65
+ * @example
66
+ * $(".carousel").jCarouselLite({
67
+ * btnNext: ".next",
68
+ * btnPrev: ".prev",
69
+ * btnGo: [".0", ".1", ".2"]
70
+ * });
71
+ * @desc If you don't want next and previous buttons for navigation, instead you prefer custom navigation based on
72
+ * the item number within the carousel, you can use this option. Just supply an array of selectors for each element
73
+ * in the carousel. The index of the array represents the index of the element. What i mean is, if the
74
+ * first element in the array is ".0", it means that when the element represented by ".0" is clicked, the carousel
75
+ * will slide to the first element and so on and so forth. This feature is very powerful. For example, i made a tabbed
76
+ * interface out of it by making my navigation elements styled like tabs in css. As the carousel is capable of holding
77
+ * any content, not just images, you can have a very simple tabbed navigation in minutes without using any other plugin.
78
+ * The best part is that, the tab will "slide" based on the provided effect. :-)
79
+ *
80
+ * @option mouseWheel : boolean - default is false
81
+ * @example
82
+ * $(".carousel").jCarouselLite({
83
+ * mouseWheel: true
84
+ * });
85
+ * @desc The carousel can also be navigated using the mouse wheel interface of a scroll mouse instead of using buttons.
86
+ * To get this feature working, you have to do 2 things. First, you have to include the mouse-wheel plugin from brandon.
87
+ * Second, you will have to set the option "mouseWheel" to true. That's it, now you will be able to navigate your carousel
88
+ * using the mouse wheel. Using buttons and mouseWheel or not mutually exclusive. You can still have buttons for navigation
89
+ * as well. They complement each other. To use both together, just supply the options required for both as shown below.
90
+ * @example
91
+ * $(".carousel").jCarouselLite({
92
+ * btnNext: ".next",
93
+ * btnPrev: ".prev",
94
+ * mouseWheel: true
95
+ * });
96
+ *
97
+ * @option auto : number - default is null, meaning autoscroll is disabled by default
98
+ * @example
99
+ * $(".carousel").jCarouselLite({
100
+ * auto: 800,
101
+ * speed: 500
102
+ * });
103
+ * @desc You can make your carousel auto-navigate itself by specfying a millisecond value in this option.
104
+ * The value you specify is the amount of time between 2 slides. The default is null, and that disables auto scrolling.
105
+ * Specify this value and magically your carousel will start auto scrolling.
106
+ *
107
+ * @option speed : number - 200 is default
108
+ * @example
109
+ * $(".carousel").jCarouselLite({
110
+ * btnNext: ".next",
111
+ * btnPrev: ".prev",
112
+ * speed: 800
113
+ * });
114
+ * @desc Specifying a speed will slow-down or speed-up the sliding speed of your carousel. Try it out with
115
+ * different speeds like 800, 600, 1500 etc. Providing 0, will remove the slide effect.
116
+ *
117
+ * @option easing : string - no easing effects by default.
118
+ * @example
119
+ * $(".carousel").jCarouselLite({
120
+ * btnNext: ".next",
121
+ * btnPrev: ".prev",
122
+ * easing: "bounceout"
123
+ * });
124
+ * @desc You can specify any easing effect. Note: You need easing plugin for that. Once specified,
125
+ * the carousel will slide based on the provided easing effect.
126
+ *
127
+ * @option vertical : boolean - default is false
128
+ * @example
129
+ * $(".carousel").jCarouselLite({
130
+ * btnNext: ".next",
131
+ * btnPrev: ".prev",
132
+ * vertical: true
133
+ * });
134
+ * @desc Determines the direction of the carousel. true, means the carousel will display vertically. The next and
135
+ * prev buttons will slide the items vertically as well. The default is false, which means that the carousel will
136
+ * display horizontally. The next and prev items will slide the items from left-right in this case.
137
+ *
138
+ * @option circular : boolean - default is true
139
+ * @example
140
+ * $(".carousel").jCarouselLite({
141
+ * btnNext: ".next",
142
+ * btnPrev: ".prev",
143
+ * circular: false
144
+ * });
145
+ * @desc Setting it to true enables circular navigation. This means, if you click "next" after you reach the last
146
+ * element, you will automatically slide to the first element and vice versa. If you set circular to false, then
147
+ * if you click on the "next" button after you reach the last element, you will stay in the last element itself
148
+ * and similarly for "previous" button and first element.
149
+ *
150
+ * @option visible : number - default is 3
151
+ * @example
152
+ * $(".carousel").jCarouselLite({
153
+ * btnNext: ".next",
154
+ * btnPrev: ".prev",
155
+ * visible: 4
156
+ * });
157
+ * @desc This specifies the number of items visible at all times within the carousel. The default is 3.
158
+ * You are even free to experiment with real numbers. Eg: "3.5" will have 3 items fully visible and the
159
+ * last item half visible. This gives you the effect of showing the user that there are more images to the right.
160
+ *
161
+ * @option start : number - default is 0
162
+ * @example
163
+ * $(".carousel").jCarouselLite({
164
+ * btnNext: ".next",
165
+ * btnPrev: ".prev",
166
+ * start: 2
167
+ * });
168
+ * @desc You can specify from which item the carousel should start. Remember, the first item in the carousel
169
+ * has a start of 0, and so on.
170
+ *
171
+ * @option scrool : number - default is 1
172
+ * @example
173
+ * $(".carousel").jCarouselLite({
174
+ * btnNext: ".next",
175
+ * btnPrev: ".prev",
176
+ * scroll: 2
177
+ * });
178
+ * @desc The number of items that should scroll/slide when you click the next/prev navigation buttons. By
179
+ * default, only one item is scrolled, but you may set it to any number. Eg: setting it to "2" will scroll
180
+ * 2 items when you click the next or previous buttons.
181
+ *
182
+ * @option beforeStart, afterEnd : function - callbacks
183
+ * @example
184
+ * $(".carousel").jCarouselLite({
185
+ * btnNext: ".next",
186
+ * btnPrev: ".prev",
187
+ * beforeStart: function(a) {
188
+ * alert("Before animation starts:" + a);
189
+ * },
190
+ * afterEnd: function(a) {
191
+ * alert("After animation ends:" + a);
192
+ * }
193
+ * });
194
+ * @desc If you wanted to do some logic in your page before the slide starts and after the slide ends, you can
195
+ * register these 2 callbacks. The functions will be passed an argument that represents an array of elements that
196
+ * are visible at the time of callback.
197
+ *
198
+ *
199
+ * @cat Plugins/Image Gallery
200
+ * @author Ganeshji Marwaha/ganeshread@gmail.com
201
+ */
202
+
203
+ (function($) { // Compliant with jquery.noConflict()
204
+ $.fn.jCarouselLite = function(o) {
205
+ o = $.extend({
206
+ btnPrev: null,
207
+ btnNext: null,
208
+ btnGo: null,
209
+ mouseWheel: false,
210
+ auto: null,
211
+ hoverPause: false,
212
+
213
+ speed: 200,
214
+ easing: null,
215
+
216
+ vertical: false,
217
+ circular: true,
218
+ visible: 3,
219
+ start: 0,
220
+ scroll: 1,
221
+
222
+ beforeStart: null,
223
+ afterEnd: null
224
+ }, o || {});
225
+
226
+ return this.each(function() { // Returns the element collection. Chainable.
227
+
228
+ var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
229
+ var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
230
+
231
+ if(o.circular) {
232
+ ul.prepend(tLi.slice(tl-v+1).clone())
233
+ .append(tLi.slice(0,o.scroll).clone());
234
+ o.start += v-1;
235
+ }
236
+
237
+ var li = $("li", ul), itemLength = li.size(), curr = o.start;
238
+ div.css("visibility", "visible");
239
+
240
+ li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});
241
+ ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
242
+ div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});
243
+
244
+ var liSize = o.vertical ? height(li) : width(li); // Full li size(incl margin)-Used for animation
245
+ var ulSize = liSize * itemLength; // size of full ul(total length, not just for the visible items)
246
+ var divSize = liSize * v; // size of entire div(total length for just the visible items)
247
+
248
+ li.css({width: li.width(), height: li.height()});
249
+ ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
250
+
251
+ div.css(sizeCss, divSize+"px"); // Width of the DIV. length of visible images
252
+
253
+ if(o.btnPrev) {
254
+ $(o.btnPrev).click(function() {
255
+ return go(curr-o.scroll);
256
+ });
257
+ if(o.hoverPause) {
258
+ $(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});
259
+ }
260
+ }
261
+
262
+
263
+ if(o.btnNext) {
264
+ $(o.btnNext).click(function() {
265
+ return go(curr+o.scroll);
266
+ });
267
+ if(o.hoverPause) {
268
+ $(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});
269
+ }
270
+ }
271
+
272
+ if(o.btnGo)
273
+ $.each(o.btnGo, function(i, val) {
274
+ $(val).click(function() {
275
+ return go(o.circular ? o.visible+i : i);
276
+ });
277
+ });
278
+
279
+ if(o.mouseWheel && div.mousewheel)
280
+ div.mousewheel(function(e, d) {
281
+ return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
282
+ });
283
+
284
+ var autoInterval;
285
+
286
+ function startAuto() {
287
+ stopAuto();
288
+ autoInterval = setInterval(function() {
289
+ go(curr+o.scroll);
290
+ }, o.auto+o.speed);
291
+ };
292
+
293
+ function stopAuto() {
294
+ clearInterval(autoInterval);
295
+ };
296
+
297
+ if(o.auto) {
298
+ if(o.hoverPause) {
299
+ div.hover(function(){stopAuto();}, function(){startAuto();});
300
+ }
301
+ startAuto();
302
+ };
303
+
304
+ function vis() {
305
+ return li.slice(curr).slice(0,v);
306
+ };
307
+
308
+ function go(to) {
309
+ if(!running) {
310
+
311
+ if(o.beforeStart)
312
+ o.beforeStart.call(this, vis());
313
+
314
+ if(o.circular) { // If circular we are in first or last, then goto the other end
315
+ if(to<0) { // If before range, then go around
316
+ ul.css(animCss, -( (curr + tl) * liSize)+"px");
317
+ curr = to + tl;
318
+ } else if(to>itemLength-v) { // If beyond range, then come around
319
+ ul.css(animCss, -( (curr - tl) * liSize ) + "px" );
320
+ curr = to - tl;
321
+ } else curr = to;
322
+ } else { // If non-circular and to points to first or last, we just return.
323
+ if(to<0 || to>itemLength-v) return;
324
+ else curr = to;
325
+ } // If neither overrides it, the curr will still be "to" and we can proceed.
326
+
327
+ running = true;
328
+
329
+ ul.animate(
330
+ animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
331
+ function() {
332
+ if(o.afterEnd)
333
+ o.afterEnd.call(this, vis());
334
+ running = false;
335
+ }
336
+ );
337
+ // Disable buttons when the carousel reaches the last/first, and enable when not
338
+ if(!o.circular) {
339
+ $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
340
+ $( (curr-o.scroll<0 && o.btnPrev)
341
+ ||
342
+ (curr+o.scroll > itemLength-v && o.btnNext)
343
+ ||
344
+ []
345
+ ).addClass("disabled");
346
+ }
347
+
348
+ }
349
+ return false;
350
+ };
351
+ });
352
+ };
353
+
354
+ function css(el, prop) {
355
+ return parseInt($.css(el[0], prop)) || 0;
356
+ };
357
+ function width(el) {
358
+ return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
359
+ };
360
+ function height(el) {
361
+ return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
362
+ };
363
+
364
+ })(jQuery);
readme.txt ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === SP News and Scrolling Widgets ===
2
+ Contributors: SP Technolab, anoopranawat
3
+ Tags: wordpress news plugin, main news page scrolling , wordpress vertical news plugin widget, wordpress horizontal news plugin widget , Free scrolling news wordpress plugin, Free scrolling news widget wordpress plugin, WordPress set post or page as news, WordPress dynamic news, news, latest news, custom post type, cpt, widget, vertical news scrolling widget, news widget
4
+ Requires at least: 3.1
5
+ Tested up to: 3.8
6
+ Author URI: http://www.sptechnolab.com
7
+ Stable tag: trunk
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ A quick, easy way to add an News custom post type, News widget, vertical and horizontal scrolling news widget to Wordpress.
12
+
13
+ == Description ==
14
+
15
+ Every CMS site needs a news section. SP News allows you add, manage and display news, date archives, widget, vertical and horizontal news scrolling widget.
16
+
17
+ <code>Important Note :
18
+ *Now you can also scroll main page news section. A Setting page also added.
19
+ *By default scrolling is enabled in the main news page. If you want static news then please go to "setting > News Widget Settings" and make "Main page news scrolling" false </code>
20
+
21
+ View [screenshots](http://wordpress.org/plugins/sp-news-and-widget/screenshots/) for additional information.
22
+
23
+ This plugin add a News custom post type, News widget, vertical and horizontal news scrolling widget( With setting page 'setting -> News Widget Setting') to your Wordpress site.
24
+
25
+ The plugin adds a News tab to your admin menu, which allows you to enter news items just as you would regular posts.
26
+
27
+ Your all news items will appear at '/news', and single news items will appear at '/news/<permalink>'.
28
+
29
+ Default Single news and All News templates for news items are also provided. One stylesheet is also provided with these templates so that you can design it as per your layout.
30
+
31
+ If you are getting any kind of problum with "/news" link means your are not able to see all news items then please remodify your permalinks Structure for example
32
+ first select "Default" and save then again select "Custom Structure " and save.
33
+
34
+ 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.
35
+
36
+ = Added New Features : =
37
+ * Scroll main page news
38
+ * Setting page for enable or disable main page news scrolling
39
+ * Setting page for main news page vertical and horizontal news scrolling
40
+
41
+ = Features include: =
42
+ * Just create a news page with link name "news"
43
+ * Vertical and horizontal (Also added thumbnail option) news widget with setting page
44
+ * Setting page
45
+ * Easy to configure
46
+ * Smoothly integrates into any theme
47
+ * Yearly, Monthly and Daily archives
48
+ * News Categories
49
+ * News Tags
50
+ * 3 News widgets
51
+ * CSS and JS file for custmization
52
+
53
+
54
+ == Installation ==
55
+
56
+ 1. Upload the 'sp-news-and-widget' folder to the '/wp-content/plugins/' directory.
57
+ 1. Activate the SP News plugin through the 'Plugins' menu in WordPress.
58
+ 1. Add and manage news items on your site by clicking on the 'News' tab that appears in your admin menu.
59
+ 1. Create a page with the name of News OR Latest News BUT Link name should be '/news'
60
+ 1. (Optional) Add and configure the News Items widget, vertical and horizontal news scrolling widget for one or more your sidebars.
61
+ 1. Go to admin 'Setting page -> News Widget Setting' and enter your settings for vertical and horizontal news scrolling widgets eg Scrolling Direction, Number of news items, delay etc.
62
+
63
+ == Frequently Asked Questions ==
64
+
65
+ = What news templates are available? =
66
+
67
+ There is one templates named 'single-news.php' which controls the display of each individual news item on a page. There is also a template named 'all-news.php' which controls the display of the list of all news items.
68
+
69
+ = Can I filter the list of news items by date? + =
70
+
71
+ Yes. Just as you can display a list of your regular posts by year, month, or day, you can display news items for a particular year (/news/2013/), month (/news/2013/04/), or day (/news/2013/04/20/).
72
+
73
+ = Do I need to update my permalinks after I activate this plugin? =
74
+
75
+ No, not usually. But if you are geting "/news" page OR 404 error on single news then please update your permalinks to Custom Structure.
76
+
77
+ = Are there shortcodes for news items? =
78
+
79
+ No, you just need to create a page with "News". Thats it
80
+
81
+ == Screenshots ==
82
+
83
+ 1. Main page news scrolling
84
+ 2. A complate view with comments
85
+ 3. Admin all News items view
86
+ 4. Add new news
87
+ 5. Single News view
88
+ 6. Widgets
89
+ 7. Admin setting page
90
+
91
+ == Changelog ==
92
+
93
+ = 2.1 =
94
+ * Scroll main page news
95
+ * Setting page for enable or disable main page news scrolling
96
+ * Setting page for main news page vertical and horizontal news scrolling
97
+
98
+ = 2.0 =
99
+ * Added Vertical and horizontal news scrolling widget with setting page
100
+ * New UI designs
101
+ * Admin setting page
102
+
103
+ = 1.0 =
104
+ * Initial release
105
+ * Adds custom post type for News item
106
+ * Adds all and single page templates for news
107
+ * Adds Letest news widget
108
+ * Adds Vertical news scrolling widget
109
+
110
+
111
+
112
+ == Upgrade Notice ==
113
+
114
+ = 2.1 =
115
+ Scroll main page news
116
+ Setting page for enable or disable main page news scrolling
117
+ Setting page for main news page vertical and horizontal news scrolling
118
+
119
+ = 2.0 =
120
+ Added Vertical and horizontal news scrolling widget with setting page
121
+
122
+ = 1.0 =
123
+ Initial release
124
+
125
+
sp-news-and-widget.php ADDED
@@ -0,0 +1,608 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: SP News and three widgets(static, scrolling and scrolling with thumbs)
4
+ Plugin URL: http://sptechnolab.com
5
+ Description: A simple News and three widgets(static, scrolling and scrolling with thumbs) plugin
6
+ Version: 2.1
7
+ Author: SP Technolab
8
+ Author URI: http://www.sptechnolab.com
9
+ Contributors: SP Technolab
10
+ */
11
+ /*
12
+ * Register CPT sp_News
13
+ *
14
+ */
15
+ // Initialization function
16
+ add_action('init', 'sp_cpt_news_init');
17
+ function sp_cpt_news_init() {
18
+ // Create new News custom post type
19
+ $news_labels = array(
20
+ 'name' => _x('News', 'post type general name'),
21
+ 'singular_name' => _x('News', 'post type singular name'),
22
+ 'add_new' => _x('Add News Item', 'news'),
23
+ 'add_new_item' => __('Add New News Item'),
24
+ 'edit_item' => __('Edit News Item'),
25
+ 'new_item' => __('New News Item'),
26
+ 'view_item' => __('View News Item'),
27
+ 'search_items' => __('Search News Items'),
28
+ 'not_found' => __('No News Items found'),
29
+ 'not_found_in_trash' => __('No News Items found in Trash'),
30
+ '_builtin' => false,
31
+ 'parent_item_colon' => '',
32
+ 'menu_name' => 'News'
33
+ );
34
+ $news_args = array(
35
+ 'labels' => $news_labels,
36
+ 'public' => true,
37
+ 'publicly_queryable' => true,
38
+ 'exclude_from_search' => false,
39
+ 'show_ui' => true,
40
+ 'show_in_menu' => true,
41
+ 'query_var' => true,
42
+ 'rewrite' => array(
43
+ 'slug' => 'news',
44
+ 'with_front' => false
45
+ ),
46
+ 'capability_type' => 'post',
47
+ 'has_archive' => true,
48
+ 'hierarchical' => false,
49
+ 'menu_position' => 8,
50
+ 'menu_icon' => plugins_url( 'images/newspaper-add-icon.png', __FILE__ ),
51
+ 'supports' => array('title','editor','thumbnail','excerpt'),
52
+ 'taxonomies' => array('category', 'post_tag')
53
+ );
54
+ register_post_type('news',$news_args);
55
+ }
56
+
57
+ function my_rewrite_flush() {
58
+ sp_cpt_news_init();
59
+ flush_rewrite_rules();
60
+ }
61
+ register_activation_hook( __FILE__, 'my_rewrite_flush' );
62
+
63
+ class SP_News_Widget extends WP_Widget {
64
+
65
+ function SP_News_Widget() {
66
+
67
+ $widget_ops = array('classname' => 'SP_News_Widget', 'description' => __('Displayed Letest News Items from the News in a sidebar', 'news_cpt') );
68
+ $control_ops = array( 'width' => 350, 'height' => 450, 'id_base' => 'sp_news_widget' );
69
+ $this->WP_Widget( 'sp_news_widget', __('Letest News Widget', 'news_cpt'), $widget_ops, $control_ops );
70
+ }
71
+
72
+ function form($instance) {
73
+ $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
74
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
75
+ $num_items = isset($instance['num_items']) ? absint($instance['num_items']) : 5;
76
+ ?>
77
+ <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>
78
+ <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>
79
+ <?php
80
+ }
81
+
82
+ function update($new_instance, $old_instance) {
83
+ $instance = $old_instance;
84
+ $instance['title'] = $new_instance['title'];
85
+ $instance['num_items'] = $new_instance['num_items'];
86
+ return $instance;
87
+ }
88
+ function widget($news_args, $instance) {
89
+ extract($news_args, EXTR_SKIP);
90
+
91
+ $current_post_name = get_query_var('name');
92
+
93
+ $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
94
+ $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
95
+
96
+ $postcount = 0;
97
+
98
+ echo $before_widget;
99
+
100
+ ?>
101
+ <h4 class="sp_new_title"><?php echo $title ?></h4>
102
+ <!--visual-columns-->
103
+ <div class="recent-news-items">
104
+ <ul>
105
+ <?php // setup the query
106
+ $news_args = array( 'suppress_filters' => true,
107
+ 'posts_per_page' => $num_items,
108
+ 'post_type' => 'news',
109
+ 'order' => 'DESC'
110
+ );
111
+
112
+ $cust_loop = new WP_Query($news_args);
113
+ if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
114
+ ?>
115
+ <li>
116
+ <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
117
+
118
+ </li>
119
+ <?php endwhile;
120
+ endif;
121
+ wp_reset_query(); ?>
122
+
123
+ </ul>
124
+ </div>
125
+ <?php
126
+ echo $after_widget;
127
+ }
128
+ }
129
+
130
+ /* Register the widget */
131
+ function sp_news_widget_load_widgets() {
132
+ register_widget( 'SP_News_Widget' );
133
+ }
134
+
135
+ /* Load the widget */
136
+ add_action( 'widgets_init', 'sp_news_widget_load_widgets' );
137
+
138
+ /* scrolling news */
139
+ class SP_News_scrolling_Widget extends WP_Widget {
140
+
141
+ function SP_News_scrolling_Widget() {
142
+
143
+ $widget_ops = array('classname' => 'SP_News_scrolling_Widget', 'description' => __('Displayed Letest News Items from the News in a sidebar', 'news_cpt') );
144
+ $control_ops = array( 'width' => 350, 'height' => 450, 'id_base' => 'sp_news_s_widget' );
145
+ $this->WP_Widget( 'sp_news_s_widget', __('Letest News Scrolling Widget', 'news_cpt'), $widget_ops, $control_ops );
146
+ }
147
+
148
+ function form($instance) {
149
+ $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
150
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
151
+ ?>
152
+ <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>
153
+
154
+ <?php
155
+ }
156
+
157
+ function update($new_instance, $old_instance) {
158
+ $instance = $old_instance;
159
+ $instance['title'] = $new_instance['title'];
160
+ return $instance;
161
+ }
162
+ function widget($news_args, $instance) {
163
+ extract($news_args, EXTR_SKIP);
164
+ $current_post_name = get_query_var('name');
165
+ $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
166
+
167
+ $postcount = 0;
168
+
169
+ echo $before_widget;
170
+
171
+ ?>
172
+ <h4 class="sp_new_title"><?php echo $title ?></h4>
173
+ <!--visual-columns-->
174
+ <div class="recent-news-items">
175
+ <div class="newsticker-jcarousellite">
176
+ <ul>
177
+ <?php // setup the query
178
+ $news_args = array( 'suppress_filters' => true,
179
+
180
+ 'post_type' => 'news',
181
+ 'order' => 'DESC'
182
+ );
183
+
184
+ $cust_loop = new WP_Query($news_args);
185
+ if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
186
+ ?>
187
+ <li >
188
+
189
+ <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
190
+
191
+ </li>
192
+ <?php endwhile;
193
+ endif;
194
+ wp_reset_query(); ?>
195
+
196
+ </ul>
197
+ </div>
198
+ </div>
199
+ <?php
200
+ echo $after_widget;
201
+ }
202
+ }
203
+
204
+ /* Register the widget */
205
+ function sp_news_scroll_widget_load_widgets() {
206
+ register_widget( 'SP_News_scrolling_Widget' );
207
+ }
208
+
209
+ /* Load the widget */
210
+ add_action( 'widgets_init', 'sp_news_scroll_widget_load_widgets' );
211
+
212
+ /* news with thumb */
213
+ class SP_News_thmb_Widget extends WP_Widget {
214
+
215
+ function SP_News_thmb_Widget() {
216
+
217
+ $widget_ops = array('classname' => 'SP_News_thmb_Widget', 'description' => __('Displayed Letest News Items from the News in a sidebar with thumbnails', 'news_cpt') );
218
+ $control_ops = array( 'width' => 350, 'height' => 450, 'id_base' => 'sp_news_sthumb_widget' );
219
+ $this->WP_Widget( 'sp_news_sthumb_widget', __('Letest News with thumb Widget', 'news_cpt'), $widget_ops, $control_ops );
220
+ }
221
+
222
+ function form($instance) {
223
+ $instance = wp_parse_args((array) $instance, array( 'title' => '' ));
224
+ $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
225
+ $num_items = isset($instance['num_items']) ? absint($instance['num_items']) : 5;
226
+ ?>
227
+ <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>
228
+ <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>
229
+ <?php
230
+ }
231
+
232
+ function update($new_instance, $old_instance) {
233
+ $instance = $old_instance;
234
+ $instance['title'] = $new_instance['title'];
235
+ $instance['num_items'] = $new_instance['num_items'];
236
+ return $instance;
237
+ }
238
+ function widget($news_args, $instance) {
239
+ extract($news_args, EXTR_SKIP);
240
+
241
+ $current_post_name = get_query_var('name');
242
+
243
+ $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
244
+ $num_items = empty($instance['num_items']) ? '5' : apply_filters('widget_title', $instance['num_items']);
245
+
246
+ $postcount = 0;
247
+
248
+ echo $before_widget;
249
+
250
+ ?>
251
+ <h4 class="sp_new_title"><?php echo $title ?></h4>
252
+ <!--visual-columns-->
253
+ <div class="recent-news-items">
254
+ <div class="newstickerthumb-jcarousellite">
255
+ <ul>
256
+ <?php // setup the query
257
+ $news_args = array( 'suppress_filters' => true,
258
+ 'posts_per_page' => $num_items,
259
+ 'post_type' => 'news',
260
+ 'order' => 'DESC'
261
+ );
262
+
263
+ $cust_loop = new WP_Query($news_args);
264
+ if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
265
+ ?>
266
+ <li>
267
+ <div class="news_thumb_left">
268
+ <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php
269
+ if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
270
+ the_post_thumbnail( array(80,80) );
271
+ }
272
+ ?> </a></div>
273
+ <div class="news_thumb_right">
274
+ <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
275
+ </div>
276
+ </li>
277
+ <?php endwhile;
278
+ endif;
279
+ wp_reset_query(); ?>
280
+
281
+ </ul>
282
+ </div> </div>
283
+ <?php
284
+ echo $after_widget;
285
+ }
286
+ }
287
+ /* Register the widget */
288
+ function sp_news_thumb_widget_load_widgets() {
289
+ register_widget( 'SP_News_thmb_Widget' );
290
+ }
291
+
292
+ /* Load the widget */
293
+ add_action( 'widgets_init', 'sp_news_thumb_widget_load_widgets' );
294
+
295
+ function get_news_template( $template_path ) {
296
+
297
+ if ( get_post_type() == 'news' ) {
298
+ if ( is_single() ) {
299
+
300
+ if ( $theme_file = locate_template( array ( 'single-news.php' ) ) ) {
301
+ $template_path = $theme_file;
302
+ } else {
303
+ $template_path = plugin_dir_path( __FILE__ ) . '/views/single-news.php';
304
+ }
305
+ } elseif ( is_archive() ) {
306
+ if ( $theme_file = locate_template( array ( 'all-news.php' ) ) ) {
307
+ $template_path = $theme_file;
308
+ } else {
309
+ $template_path = plugin_dir_path( __FILE__ ) . '/views/all-news.php';
310
+ }
311
+ }
312
+
313
+ }
314
+
315
+ return $template_path;
316
+ }
317
+ wp_register_style( 'cssnews', plugin_dir_url( __FILE__ ) . 'css/stylenews.css' );
318
+ wp_register_script( 'vticker', plugin_dir_url( __FILE__ ) . 'js/jcarousellite.js', array( 'jquery' ) );
319
+
320
+ wp_enqueue_style( 'cssnews' );
321
+ wp_enqueue_script( 'vticker' );
322
+ function mynewsscript() {
323
+ $option = 'NewsWidget_option';
324
+ $newsscrollingoptionadmin = get_option( $option, $default );
325
+ $customscrollpost = $newsscrollingoptionadmin['news_width'];
326
+ $customscrollpostheight = $newsscrollingoptionadmin['news_height'];
327
+ $customscrollpostdelay = $newsscrollingoptionadmin['news_delay'];
328
+ $customscrollpostspeed = $newsscrollingoptionadmin['news_speed'];
329
+
330
+ $news_mainpage_direction = $newsscrollingoptionadmin['news_mainpage_direction'];
331
+
332
+ if ($customscrollpost == 0 )
333
+ {
334
+ $vtrue = 'true';
335
+ } else { $vtrue = 'false';
336
+ }
337
+ if ($customscrollpostheight == '' )
338
+ {
339
+ $vvisible = 3;
340
+ } else { $vvisible = $customscrollpostheight;
341
+ }
342
+ if ($customscrollpostdelay == '' )
343
+ {
344
+ $vdelay = 500;
345
+ } else { $vdelay = $customscrollpostdelay;
346
+ }
347
+ if ($customscrollpostspeed == '' )
348
+ {
349
+ $vspeed = 2000;
350
+ } else { $vspeed = $customscrollpostspeed;
351
+ }
352
+ if ($news_mainpage_direction == '' || $news_mainpage_direction == 0 )
353
+ {
354
+ $vtruenews = 'true';
355
+ } else { $vtruenews = 'false';
356
+ }
357
+ ?>
358
+ <script type="text/javascript">
359
+
360
+ jQuery(function() {
361
+ jQuery(".newsticker-jcarousellite").jCarouselLite({
362
+ vertical: <?php echo $vtrue; ?>,
363
+ hoverPause:true,
364
+ visible: <?php echo $vvisible; ?>,
365
+ auto: <?php echo $vdelay; ?>,
366
+ speed:<?php echo $vspeed; ?>,
367
+ });
368
+ jQuery(".newstickerthumb-jcarousellite").jCarouselLite({
369
+ vertical: <?php echo $vtrue; ?>,
370
+ hoverPause:true,
371
+ visible: <?php echo $vvisible; ?>,
372
+ auto: <?php echo $vdelay; ?>,
373
+ speed:<?php echo $vspeed; ?>,
374
+ });
375
+ jQuery(".newstickerthumbmain-jcarousellite").jCarouselLite({
376
+ vertical: <?php echo $vtruenews; ?>,
377
+ hoverPause:true,
378
+ visible: <?php echo $vvisible; ?>,
379
+ auto: <?php echo $vdelay; ?>,
380
+ speed:<?php echo $vspeed; ?>,
381
+ });
382
+ });
383
+ </script>
384
+ <?php
385
+ }
386
+ add_action('wp_head', 'mynewsscript');
387
+ add_filter( 'template_include', 'get_news_template' ) ;
388
+
389
+ class SP_News_setting
390
+ {
391
+ /**
392
+ * Holds the values to be used in the fields callbacks
393
+ */
394
+ private $options;
395
+
396
+ /**
397
+ * Start up
398
+ */
399
+ public function __construct()
400
+ {
401
+ add_action( 'admin_menu', array( $this, 'add_news_page' ) );
402
+ add_action( 'admin_init', array( $this, 'page_init_news' ) );
403
+ }
404
+
405
+ /**
406
+ * Add options page
407
+ */
408
+ public function add_news_page()
409
+ {
410
+ // This page will be under "Settings"
411
+ add_options_page(
412
+ 'Settings Admin',
413
+ 'News Widget Settings',
414
+ 'manage_options',
415
+ 'news-setting-admin',
416
+ array( $this, 'create_newsadmin_page' )
417
+ );
418
+ }
419
+
420
+ /**
421
+ * Options page callback
422
+ */
423
+ public function create_newsadmin_page()
424
+ {
425
+ // Set class property
426
+ $this->options = get_option( 'NewsWidget_option' );
427
+ ?>
428
+ <div class="wrap">
429
+ <?php screen_icon(); ?>
430
+ <h2>Scrolling News Widget Setting</h2>
431
+ <form method="post" action="options.php">
432
+ <?php
433
+ // This prints out all hidden setting fields
434
+ settings_fields( 'news_option_group' );
435
+ do_settings_sections( 'news-setting-admin' );
436
+ submit_button();
437
+ ?>
438
+ </form>
439
+ </div>
440
+ <?php
441
+ }
442
+
443
+ /**
444
+ * Register and add settings
445
+ */
446
+ public function page_init_news()
447
+ {
448
+ register_setting(
449
+ 'news_option_group', // Option group
450
+ 'NewsWidget_option', // Option name
451
+ array( $this, 'sanitize' ) // Sanitize
452
+ );
453
+
454
+ add_settings_section(
455
+ 'setting_section_id', // ID
456
+ 'Scorlling News Widget Settings', // Title
457
+ array( $this, 'print_section_info' ), // Callback
458
+ 'news-setting-admin' // Page
459
+ );
460
+
461
+ add_settings_field(
462
+ 'news_width', // ID
463
+ 'Scrolling Direction (Vertical OR Horizontal) ', // Title
464
+ array( $this, 'news_width_callback' ), // Callback
465
+ 'news-setting-admin', // Page
466
+ 'setting_section_id' // Section
467
+ );
468
+
469
+ add_settings_field(
470
+ 'news_height',
471
+ 'Number of news items',
472
+ array( $this, 'news_height_callback' ),
473
+ 'news-setting-admin',
474
+ 'setting_section_id'
475
+ );
476
+ add_settings_field(
477
+ 'news_delay', // ID
478
+ 'Enter delay ', // Title
479
+ array( $this, 'news_delay_callback' ), // Callback
480
+ 'news-setting-admin', // Page
481
+ 'setting_section_id' // Section
482
+ );
483
+
484
+ add_settings_field(
485
+ 'news_speed',
486
+ 'Enter speed',
487
+ array( $this, 'news_speed_callback' ),
488
+ 'news-setting-admin',
489
+ 'setting_section_id'
490
+ );
491
+ add_settings_field(
492
+ 'news_mainpage',
493
+ 'Main page news scrolling',
494
+ array( $this, 'news_mainpage_callback' ),
495
+ 'news-setting-admin',
496
+ 'setting_section_id'
497
+ );
498
+ add_settings_field(
499
+ 'news_mainpage_direction',
500
+ 'Main page news scrolling direction (Vertical OR Horizontal)',
501
+ array( $this, 'news_mainpage_direction' ),
502
+ 'news-setting-admin',
503
+ 'setting_section_id'
504
+ );
505
+ }
506
+
507
+ /**
508
+ * Sanitize each setting field as needed
509
+ *
510
+ * @param array $input Contains all settings fields as array keys
511
+ */
512
+ public function sanitize( $input )
513
+ {
514
+ $new_input = array();
515
+ if( isset( $input['news_width'] ) )
516
+ $new_input['news_width'] = absint( $input['news_width'] );
517
+
518
+ if( isset( $input['news_height'] ) )
519
+ $new_input['news_height'] = sanitize_text_field( $input['news_height'] );
520
+
521
+ if( isset( $input['news_delay'] ) )
522
+ $new_input['news_delay'] = sanitize_text_field( $input['news_delay'] );
523
+
524
+ if( isset( $input['news_speed'] ) )
525
+ $new_input['news_speed'] = sanitize_text_field( $input['news_speed'] );
526
+
527
+ if( isset( $input['news_mainpage'] ) )
528
+ $new_input['news_mainpage'] = sanitize_text_field( $input['news_mainpage'] );
529
+ if( isset( $input['news_mainpage_direction'] ) )
530
+ $new_input['news_mainpage_direction'] = sanitize_text_field( $input['news_mainpage_direction'] );
531
+
532
+ return $new_input;
533
+ }
534
+
535
+ /**
536
+ * Print the Section text
537
+ */
538
+ public function print_section_info()
539
+ {
540
+ print 'Enter your settings below:';
541
+ }
542
+
543
+ /**
544
+ * Get the settings option array and print one of its values
545
+ */
546
+ public function news_width_callback()
547
+ {
548
+ printf(
549
+ '<input type="text" id="news_width" name="NewsWidget_option[news_width]" value="%s" />',
550
+ isset( $this->options['news_width'] ) ? esc_attr( $this->options['news_width']) : ''
551
+ );
552
+ printf(' Enter "0" for <b>Vertical Scrolling</b> and "1" for <b>Horizontal Scrolling</b>');
553
+ }
554
+
555
+ /**
556
+ * Get the settings option array and print one of its values
557
+ */
558
+ public function news_height_callback()
559
+ {
560
+ printf(
561
+ '<input type="text" id="news_height" name="NewsWidget_option[news_height]" value="%s" />',
562
+ isset( $this->options['news_height'] ) ? esc_attr( $this->options['news_height']) : ''
563
+ );
564
+ printf(' ie 1, 2, 3, 4 etc');
565
+ }
566
+ public function news_delay_callback()
567
+ {
568
+ printf(
569
+ '<input type="text" id="news_delay" name="NewsWidget_option[news_delay]" value="%s" />',
570
+ isset( $this->options['news_delay'] ) ? esc_attr( $this->options['news_delay']) : ''
571
+ );
572
+ printf(' ie 500, 1000 milliseconds delay');
573
+ }
574
+
575
+ /**
576
+ * Get the settings option array and print one of its values
577
+ */
578
+ public function news_speed_callback()
579
+ {
580
+ printf(
581
+ '<input type="text" id="news_speed" name="NewsWidget_option[news_speed]" value="%s" />',
582
+ isset( $this->options['news_speed'] ) ? esc_attr( $this->options['news_speed']) : ''
583
+ );
584
+ printf(' ie 500, 1000 milliseconds speed');
585
+ }
586
+
587
+ public function news_mainpage_callback()
588
+ {
589
+ printf(
590
+ '<input type="text" id="news_mainpage" name="NewsWidget_option[news_mainpage]" value="%s" />',
591
+ isset( $this->options['news_mainpage'] ) ? esc_attr( $this->options['news_mainpage']) : ''
592
+ );
593
+ printf(' Enter "0" for <b>True</b> and "1" for <b>False</b>');
594
+ }
595
+
596
+ public function news_mainpage_direction()
597
+ {
598
+ printf(
599
+ '<input type="text" id="news_mainpage_direction" name="NewsWidget_option[news_mainpage_direction]" value="%s" />',
600
+ isset( $this->options['news_mainpage_direction'] ) ? esc_attr( $this->options['news_mainpage_direction']) : ''
601
+ );
602
+ printf(' Enter "0" for <b>Vertical Scrolling</b> and "1" for <b>Horizontal Scrolling</b>');
603
+ }
604
+ }
605
+
606
+ if( is_admin() )
607
+ $my_newssettings_page = new SP_News_setting();
608
+ ?>
views/all-news.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /*Template Name: All News * * You can customize this view changeing the class name OR id name * */ get_header(); ?>
2
+ <div id="primary" class="site-content">
3
+ <div id="content" role="main" class="sp-news widecolumn">
4
+ <div class="archive-header">
5
+ <h1 class="archive-title">
6
+ <?php if ( is_day() ) : printf( __( 'Daily News Archives: %s' ), '<span>' . get_the_date() . '</span>' ); elseif ( is_month() ) : printf( __( 'Monthly News Archives: %s' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' ); elseif ( is_year() ) : printf( __( 'Yearly News Archives: %s' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' ); else : _e( 'News' ); endif; ?>
7
+ </h1>
8
+ </div>
9
+ <?php
10
+ $option = 'NewsWidget_option';
11
+ $newsscrollingoptionadmin = get_option( $option, $default );
12
+ $news_mainpage = $newsscrollingoptionadmin['news_mainpage'];
13
+ if ($news_mainpage == '' || $news_mainpage == 0 )
14
+ {
15
+
16
+ ?>
17
+ <!-- .archive-header -->
18
+ <div class="newstickerthumbmain-jcarousellite">
19
+ <ul>
20
+ <?php } ?>
21
+ <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
22
+ <?php if ($news_mainpage == '' || $news_mainpage == 0 )
23
+ {
24
+
25
+ ?>
26
+ <li>
27
+ <?php } ?>
28
+ <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
29
+ <h2>
30
+ <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
31
+ <?php the_title(); ?>
32
+ </a>
33
+ </h2>
34
+ <div class="post-info">
35
+ <span class="date published time" title="<?php the_time('c') ?>">
36
+ <?php the_time( 'F j, Y') ?>
37
+ </span>
38
+ </div>
39
+ <div class="entry-content">
40
+ <?php if ( function_exists( 'has_post_thumbnail') && has_post_thumbnail() ) { the_post_thumbnail( 'thumbnail'); } ?>
41
+ <div class="summary">
42
+ <?php the_excerpt(); ?>
43
+ <a class="moretag" href="<?php the_permalink() ?>">Read More..</a>
44
+ </div>
45
+ </div>
46
+ <?php edit_post_link(__( 'Edit'), '<span class="edit-link">', '</span>'); ?>
47
+ </div>
48
+ <!-- post -->
49
+ <?php if ($news_mainpage == '' || $news_mainpage == 0 )
50
+ {
51
+
52
+ ?>
53
+ </li>
54
+ <?php } ?>
55
+ <?php endwhile; ?>
56
+ <?php if ($news_mainpage == '' || $news_mainpage == 0 )
57
+ {
58
+
59
+ ?>
60
+ </ul>
61
+ </div>
62
+ <?php } ?>
63
+ <div class="navigation">
64
+ <div class="alignleft">
65
+ <?php next_posts_link( 'Previous entries') ?>
66
+ </div>
67
+ <div class="alignright">
68
+ <?php previous_posts_link( 'Next entries') ?>
69
+ </div>
70
+ </div>
71
+ <?php else: ?>
72
+ <p>There are no news items to display.</p>
73
+ <?php endif; ?>
74
+ </div>
75
+ <!-- #content -->
76
+ </div>
77
+ <!--#primary-->
78
+ <?php get_sidebar(); ?>
79
+ <?php get_footer(); ?>
views/single-news.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*Template Name: Single News
3
+ *
4
+ *You can customize this view changeing the class name OR id name.
5
+ *
6
+ */
7
+
8
+ get_header();
9
+ ?>
10
+
11
+ <div id="primary" class="site-content">
12
+ <div id="content" role="main" class="sp-news widecolumn">
13
+
14
+
15
+
16
+ <?php if( have_posts() ) : ?><?php while( have_posts() ) : the_post(); ?>
17
+
18
+ <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
19
+ <div class="entry-header">
20
+ <h1 class="entry-title"><?php the_title(); ?></h1>
21
+ <div class="entry-meta post-info">
22
+ <span class="date published time" title="<?php the_time('c') ?>"><?php the_time('F j, Y') ?></span>
23
+ </div> <!-- .entry-meata .post-info -->
24
+ </div> <!-- .entry-header -->
25
+ <div class="entry-content">
26
+ <?php
27
+ if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
28
+ the_post_thumbnail();
29
+ } ?>
30
+ <div class="summary"><?php the_content(); ?></div>
31
+ </div> <!-- .entry-content -->
32
+
33
+ <?php edit_post_link(__('Edit'), '<span class="edit-link">', '</span>'); ?>
34
+ </div> <!-- post -->
35
+
36
+ <div class="navigation">
37
+ <?php previous_post_link('&laquo; %link') ?> <?php next_post_link(' %link >') ?>
38
+ </div>
39
+
40
+ <?php endwhile; ?>
41
+
42
+ <?php else: ?>
43
+
44
+ <p>There are no news items to display.</p>
45
+
46
+ <?php endif; ?>
47
+ <span class="back"><a href="/news/"><?php _e('&laquo; Back to News'); ?></a></span>
48
+ </div><!-- #content -->
49
+
50
+ </div><!--#primary-->
51
+
52
+ <?php get_sidebar(); ?>
53
+
54
+ <?php get_footer(); ?>