Version Description
- Added Vertical and horizontal news scrolling widget with setting page
- New UI designs
- Admin setting page
Download this release
Release Info
Developer | anoopranawat |
Plugin | WP News and Scrolling Widgets |
Version | 2.0 |
Comparing to | |
See all releases |
Version 2.0
- css/stylenews.css +27 -0
- images/Calendar-Empty-icon.png +0 -0
- images/Thumbs.db +0 -0
- images/back.png +0 -0
- images/forword.png +0 -0
- images/newspaper-add-icon.png +0 -0
- images/play.png +0 -0
- images/stop.png +0 -0
- js/jcarousellite.js +364 -0
- readme.txt +105 -0
- sp-news-and-widget.php +558 -0
- views/all-news.php +64 -0
- views/single-news.php +54 -0
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{ 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"><<</button>
|
39 |
+
* <button class="next">>></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,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== SP News and Scrolling Widgets ===
|
2 |
+
Contributors: SP Technolab
|
3 |
+
Tags: wordpress news plugin, 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.7
|
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 |
+
View [screenshots](http://wordpress.org/plugins/sp-news-and-widget/screenshots/) for additional information.
|
18 |
+
|
19 |
+
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.
|
20 |
+
|
21 |
+
The plugin adds a News tab to your admin menu, which allows you to enter news items just as you would regular posts.
|
22 |
+
|
23 |
+
Your all news items will appear at '/news', and single news items will appear at '/news/<permalink>'.
|
24 |
+
|
25 |
+
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.
|
26 |
+
|
27 |
+
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
|
28 |
+
first select "Default" and save then again select "Custom Structure " and save.
|
29 |
+
|
30 |
+
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.
|
31 |
+
|
32 |
+
= New Features include: =
|
33 |
+
* Just create a news page with link name "news"
|
34 |
+
* Vertical and horizontal (Also added thumbnail option) news widget with setting page
|
35 |
+
* Setting page
|
36 |
+
* Easy to configure
|
37 |
+
* Smoothly integrates into any theme
|
38 |
+
* Yearly, Monthly and Daily archives
|
39 |
+
* News Categories
|
40 |
+
* News Tags
|
41 |
+
* 3 News widgets
|
42 |
+
* CSS and JS file for custmization
|
43 |
+
|
44 |
+
|
45 |
+
== Installation ==
|
46 |
+
|
47 |
+
1. Upload the 'sp-news-and-widget' folder to the '/wp-content/plugins/' directory.
|
48 |
+
1. Activate the SP News plugin through the 'Plugins' menu in WordPress.
|
49 |
+
1. Add and manage news items on your site by clicking on the 'News' tab that appears in your admin menu.
|
50 |
+
1. Create a page with the name of News OR Latest News BUT Link name should be '/news'
|
51 |
+
1. (Optional) Add and configure the News Items widget, vertical and horizontal news scrolling widget for one or more your sidebars.
|
52 |
+
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.
|
53 |
+
|
54 |
+
== Frequently Asked Questions ==
|
55 |
+
|
56 |
+
= What news templates are available? =
|
57 |
+
|
58 |
+
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.
|
59 |
+
|
60 |
+
= Can I filter the list of news items by date? + =
|
61 |
+
|
62 |
+
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/).
|
63 |
+
|
64 |
+
= Do I need to update my permalinks after I activate this plugin? =
|
65 |
+
|
66 |
+
No, not usually. But if you are geting "/news" page OR 404 error on single news then please update your permalinks to Custom Structure.
|
67 |
+
|
68 |
+
= Are there shortcodes for news items? =
|
69 |
+
|
70 |
+
No, you just need to create a page with "News". Thats it
|
71 |
+
|
72 |
+
== Screenshots ==
|
73 |
+
|
74 |
+
1. A complate view with comments
|
75 |
+
2. Admin all News items view
|
76 |
+
3. Add new news
|
77 |
+
4. Single News view
|
78 |
+
5. Widgets
|
79 |
+
6. Admin setting page
|
80 |
+
|
81 |
+
== Changelog ==
|
82 |
+
|
83 |
+
= 2.0 =
|
84 |
+
* Added Vertical and horizontal news scrolling widget with setting page
|
85 |
+
* New UI designs
|
86 |
+
* Admin setting page
|
87 |
+
|
88 |
+
= 1.0 =
|
89 |
+
* Initial release
|
90 |
+
* Adds custom post type for News item
|
91 |
+
* Adds all and single page templates for news
|
92 |
+
* Adds Letest news widget
|
93 |
+
* Adds Vertical news scrolling widget
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
== Upgrade Notice ==
|
98 |
+
|
99 |
+
= 2.0 =
|
100 |
+
Added Vertical and horizontal news scrolling widget with setting page
|
101 |
+
|
102 |
+
= 1.0 =
|
103 |
+
Initial release
|
104 |
+
|
105 |
+
|
sp-news-and-widget.php
ADDED
@@ -0,0 +1,558 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.0
|
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 |
+
if ($customscrollpost == 0 )
|
331 |
+
{
|
332 |
+
$vtrue = 'true';
|
333 |
+
} else { $vtrue = 'false';
|
334 |
+
}
|
335 |
+
if ($customscrollpostheight == '' )
|
336 |
+
{
|
337 |
+
$vvisible = 3;
|
338 |
+
} else { $vvisible = $customscrollpostheight;
|
339 |
+
}
|
340 |
+
if ($customscrollpostdelay == '' )
|
341 |
+
{
|
342 |
+
$vdelay = 500;
|
343 |
+
} else { $vdelay = $customscrollpostdelay;
|
344 |
+
}
|
345 |
+
if ($customscrollpostspeed == '' )
|
346 |
+
{
|
347 |
+
$vspeed = 2000;
|
348 |
+
} else { $vspeed = $customscrollpostspeed;
|
349 |
+
}
|
350 |
+
|
351 |
+
?>
|
352 |
+
<script type="text/javascript">
|
353 |
+
|
354 |
+
jQuery(function() {
|
355 |
+
jQuery(".newsticker-jcarousellite").jCarouselLite({
|
356 |
+
vertical: <?php echo $vtrue; ?>,
|
357 |
+
hoverPause:true,
|
358 |
+
visible: <?php echo $vvisible; ?>,
|
359 |
+
auto: <?php echo $vdelay; ?>,
|
360 |
+
speed:<?php echo $vspeed; ?>,
|
361 |
+
});
|
362 |
+
jQuery(".newstickerthumb-jcarousellite").jCarouselLite({
|
363 |
+
vertical: <?php echo $vtrue; ?>,
|
364 |
+
hoverPause:true,
|
365 |
+
visible: <?php echo $vvisible; ?>,
|
366 |
+
auto: <?php echo $vdelay; ?>,
|
367 |
+
speed:<?php echo $vspeed; ?>,
|
368 |
+
});
|
369 |
+
});
|
370 |
+
</script>
|
371 |
+
<?php
|
372 |
+
}
|
373 |
+
add_action('wp_head', 'mynewsscript');
|
374 |
+
add_filter( 'template_include', 'get_news_template' ) ;
|
375 |
+
|
376 |
+
class SP_News_setting
|
377 |
+
{
|
378 |
+
/**
|
379 |
+
* Holds the values to be used in the fields callbacks
|
380 |
+
*/
|
381 |
+
private $options;
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Start up
|
385 |
+
*/
|
386 |
+
public function __construct()
|
387 |
+
{
|
388 |
+
add_action( 'admin_menu', array( $this, 'add_news_page' ) );
|
389 |
+
add_action( 'admin_init', array( $this, 'page_init_news' ) );
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Add options page
|
394 |
+
*/
|
395 |
+
public function add_news_page()
|
396 |
+
{
|
397 |
+
// This page will be under "Settings"
|
398 |
+
add_options_page(
|
399 |
+
'Settings Admin',
|
400 |
+
'News Widget Settings',
|
401 |
+
'manage_options',
|
402 |
+
'news-setting-admin',
|
403 |
+
array( $this, 'create_newsadmin_page' )
|
404 |
+
);
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Options page callback
|
409 |
+
*/
|
410 |
+
public function create_newsadmin_page()
|
411 |
+
{
|
412 |
+
// Set class property
|
413 |
+
$this->options = get_option( 'NewsWidget_option' );
|
414 |
+
?>
|
415 |
+
<div class="wrap">
|
416 |
+
<?php screen_icon(); ?>
|
417 |
+
<h2>Scrolling News Widget Setting</h2>
|
418 |
+
<form method="post" action="options.php">
|
419 |
+
<?php
|
420 |
+
// This prints out all hidden setting fields
|
421 |
+
settings_fields( 'news_option_group' );
|
422 |
+
do_settings_sections( 'news-setting-admin' );
|
423 |
+
submit_button();
|
424 |
+
?>
|
425 |
+
</form>
|
426 |
+
</div>
|
427 |
+
<?php
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Register and add settings
|
432 |
+
*/
|
433 |
+
public function page_init_news()
|
434 |
+
{
|
435 |
+
register_setting(
|
436 |
+
'news_option_group', // Option group
|
437 |
+
'NewsWidget_option', // Option name
|
438 |
+
array( $this, 'sanitize' ) // Sanitize
|
439 |
+
);
|
440 |
+
|
441 |
+
add_settings_section(
|
442 |
+
'setting_section_id', // ID
|
443 |
+
'Scorlling News Widget Settings', // Title
|
444 |
+
array( $this, 'print_section_info' ), // Callback
|
445 |
+
'news-setting-admin' // Page
|
446 |
+
);
|
447 |
+
|
448 |
+
add_settings_field(
|
449 |
+
'news_width', // ID
|
450 |
+
'Scrolling Direction (Vertical OR Horizontal) ', // Title
|
451 |
+
array( $this, 'news_width_callback' ), // Callback
|
452 |
+
'news-setting-admin', // Page
|
453 |
+
'setting_section_id' // Section
|
454 |
+
);
|
455 |
+
|
456 |
+
add_settings_field(
|
457 |
+
'news_height',
|
458 |
+
'Number of news items',
|
459 |
+
array( $this, 'news_height_callback' ),
|
460 |
+
'news-setting-admin',
|
461 |
+
'setting_section_id'
|
462 |
+
);
|
463 |
+
add_settings_field(
|
464 |
+
'news_delay', // ID
|
465 |
+
'Enter delay ', // Title
|
466 |
+
array( $this, 'news_delay_callback' ), // Callback
|
467 |
+
'news-setting-admin', // Page
|
468 |
+
'setting_section_id' // Section
|
469 |
+
);
|
470 |
+
|
471 |
+
add_settings_field(
|
472 |
+
'news_speed',
|
473 |
+
'Enter speed',
|
474 |
+
array( $this, 'news_speed_callback' ),
|
475 |
+
'news-setting-admin',
|
476 |
+
'setting_section_id'
|
477 |
+
);
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Sanitize each setting field as needed
|
482 |
+
*
|
483 |
+
* @param array $input Contains all settings fields as array keys
|
484 |
+
*/
|
485 |
+
public function sanitize( $input )
|
486 |
+
{
|
487 |
+
$new_input = array();
|
488 |
+
if( isset( $input['news_width'] ) )
|
489 |
+
$new_input['news_width'] = absint( $input['news_width'] );
|
490 |
+
|
491 |
+
if( isset( $input['news_height'] ) )
|
492 |
+
$new_input['news_height'] = sanitize_text_field( $input['news_height'] );
|
493 |
+
|
494 |
+
if( isset( $input['news_delay'] ) )
|
495 |
+
$new_input['news_delay'] = sanitize_text_field( $input['news_delay'] );
|
496 |
+
|
497 |
+
if( isset( $input['news_speed'] ) )
|
498 |
+
$new_input['news_speed'] = sanitize_text_field( $input['news_speed'] );
|
499 |
+
|
500 |
+
return $new_input;
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Print the Section text
|
505 |
+
*/
|
506 |
+
public function print_section_info()
|
507 |
+
{
|
508 |
+
print 'Enter your settings below:';
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Get the settings option array and print one of its values
|
513 |
+
*/
|
514 |
+
public function news_width_callback()
|
515 |
+
{
|
516 |
+
printf(
|
517 |
+
'<input type="text" id="news_width" name="NewsWidget_option[news_width]" value="%s" />',
|
518 |
+
isset( $this->options['news_width'] ) ? esc_attr( $this->options['news_width']) : ''
|
519 |
+
);
|
520 |
+
printf(' Enter "0" for <b>Vertical Scrolling</b> and "1" for <b>Horizontal Scrolling</b>');
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Get the settings option array and print one of its values
|
525 |
+
*/
|
526 |
+
public function news_height_callback()
|
527 |
+
{
|
528 |
+
printf(
|
529 |
+
'<input type="text" id="news_height" name="NewsWidget_option[news_height]" value="%s" />',
|
530 |
+
isset( $this->options['news_height'] ) ? esc_attr( $this->options['news_height']) : ''
|
531 |
+
);
|
532 |
+
printf(' ie 1, 2, 3, 4 etc');
|
533 |
+
}
|
534 |
+
public function news_delay_callback()
|
535 |
+
{
|
536 |
+
printf(
|
537 |
+
'<input type="text" id="news_delay" name="NewsWidget_option[news_delay]" value="%s" />',
|
538 |
+
isset( $this->options['news_delay'] ) ? esc_attr( $this->options['news_delay']) : ''
|
539 |
+
);
|
540 |
+
printf(' ie 500, 1000 milliseconds delay');
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Get the settings option array and print one of its values
|
545 |
+
*/
|
546 |
+
public function news_speed_callback()
|
547 |
+
{
|
548 |
+
printf(
|
549 |
+
'<input type="text" id="news_speed" name="NewsWidget_option[news_speed]" value="%s" />',
|
550 |
+
isset( $this->options['news_speed'] ) ? esc_attr( $this->options['news_speed']) : ''
|
551 |
+
);
|
552 |
+
printf(' ie 500, 1000 milliseconds speed');
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
if( is_admin() )
|
557 |
+
$my_newssettings_page = new SP_News_setting();
|
558 |
+
?>
|
views/all-news.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*Template Name: All 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 |
+
<div class="archive-header">
|
15 |
+
<h1 class="archive-title"><?php
|
16 |
+
if ( is_day() ) :
|
17 |
+
printf( __( 'Daily News Archives: %s' ), '<span>' . get_the_date() . '</span>' );
|
18 |
+
elseif ( is_month() ) :
|
19 |
+
printf( __( 'Monthly News Archives: %s' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' );
|
20 |
+
elseif ( is_year() ) :
|
21 |
+
printf( __( 'Yearly News Archives: %s' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' );
|
22 |
+
else :
|
23 |
+
_e( 'News' );
|
24 |
+
endif;
|
25 |
+
?></h1>
|
26 |
+
</div> <!-- .archive-header -->
|
27 |
+
|
28 |
+
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
|
29 |
+
|
30 |
+
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
31 |
+
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
|
32 |
+
<div class="post-info">
|
33 |
+
<span class="date published time" title="<?php the_time('c') ?>"><?php the_time('F j, Y') ?></span>
|
34 |
+
</div>
|
35 |
+
<div class="entry-content">
|
36 |
+
<?php
|
37 |
+
if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
|
38 |
+
the_post_thumbnail('thumbnail');
|
39 |
+
}
|
40 |
+
?>
|
41 |
+
<div class="summary"><?php the_excerpt(); ?> <a class="moretag" href="<?php the_permalink() ?>"> Read More..</a></div>
|
42 |
+
</div>
|
43 |
+
<?php edit_post_link(__('Edit'), '<span class="edit-link">', '</span>'); ?>
|
44 |
+
</div><!-- post -->
|
45 |
+
|
46 |
+
<?php endwhile; ?>
|
47 |
+
|
48 |
+
<div class="navigation">
|
49 |
+
<div class="alignleft"><?php next_posts_link('Previous entries') ?></div>
|
50 |
+
<div class="alignright"><?php previous_posts_link('Next entries') ?></div>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<?php else: ?>
|
54 |
+
|
55 |
+
<p>There are no news items to display.</p>
|
56 |
+
|
57 |
+
<?php endif; ?>
|
58 |
+
|
59 |
+
</div><!-- #content -->
|
60 |
+
|
61 |
+
</div><!--#primary-->
|
62 |
+
|
63 |
+
<?php get_sidebar(); ?>
|
64 |
+
<?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('« %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('« Back to News'); ?></a></span>
|
48 |
+
</div><!-- #content -->
|
49 |
+
|
50 |
+
</div><!--#primary-->
|
51 |
+
|
52 |
+
<?php get_sidebar(); ?>
|
53 |
+
|
54 |
+
<?php get_footer(); ?>
|