Version Description
- Add content display option
Download this release
Release Info
Developer | bostondv |
Plugin | Ultimate Posts Widget |
Version | 1.8.1 |
Comparing to | |
See all releases |
Code changes from version 1.7 to 1.8.1
- readme.txt +17 -3
- ultimate-posts-widget.php +689 -611
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Ultimate Posts Widget ===
|
2 |
Contributors: bostondv
|
3 |
Donate link: http://www.pomelodesign.com/donate
|
4 |
-
Tags: widget, recent posts, custom post types, sticky posts, featured image, post thumbnail, excerpts, category
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.6
|
7 |
-
Stable tag: 1.
|
8 |
License: GPL2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -26,11 +26,13 @@ Options:
|
|
26 |
* Display publish time
|
27 |
* Display post author
|
28 |
* Display excerpt
|
|
|
29 |
* Display read more link
|
30 |
* Display featured image
|
31 |
* Display more button link
|
32 |
* Display post categories
|
33 |
* Display post tags
|
|
|
34 |
* Custom widget title link
|
35 |
* Custom read more link text
|
36 |
* Custom excerpt length (in words)
|
@@ -54,6 +56,7 @@ This plugin uses the [TimThumb library](http://www.binarymoon.co.uk/projects/tim
|
|
54 |
* Cache permissions - The cache directory `wp-content/plugins/ultimate-posts-widget/cache` should be set to 777 or if that doesn't work, you may find 755 is ok.
|
55 |
* Image sizes - TimThumb is configured to only work for images smaller than 1500 x 1500. The plugin and automatically selects the "Large" size from Settings > Media, if it is greater than 1500 x 1500 you will need to reduce the size or modify the configuration in `thumb.php` to support larger image sizes.
|
56 |
* Tilde(~) in url - Timthumb has a known issue with this, please use a url without a tilde until a fix is available. [Bug report](https://code.google.com/p/timthumb/issues/detail?id=263)
|
|
|
57 |
|
58 |
Still stuck? See [additional troubleshooting tips](http://www.binarymoon.co.uk/2010/11/timthumb-hints-tips/) from the TimThumb author.
|
59 |
|
@@ -63,6 +66,17 @@ Still stuck? See [additional troubleshooting tips](http://www.binarymoon.co.uk/2
|
|
63 |
|
64 |
== Changelog ==
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
= 1.7 =
|
67 |
|
68 |
* Added show author option
|
1 |
=== Ultimate Posts Widget ===
|
2 |
Contributors: bostondv
|
3 |
Donate link: http://www.pomelodesign.com/donate
|
4 |
+
Tags: widget, recent posts, custom post types, sticky posts, featured image, post thumbnail, excerpts, category, custom fields
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.6.1
|
7 |
+
Stable tag: 1.8.1
|
8 |
License: GPL2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
26 |
* Display publish time
|
27 |
* Display post author
|
28 |
* Display excerpt
|
29 |
+
* Display content
|
30 |
* Display read more link
|
31 |
* Display featured image
|
32 |
* Display more button link
|
33 |
* Display post categories
|
34 |
* Display post tags
|
35 |
+
* Display custom fields
|
36 |
* Custom widget title link
|
37 |
* Custom read more link text
|
38 |
* Custom excerpt length (in words)
|
56 |
* Cache permissions - The cache directory `wp-content/plugins/ultimate-posts-widget/cache` should be set to 777 or if that doesn't work, you may find 755 is ok.
|
57 |
* Image sizes - TimThumb is configured to only work for images smaller than 1500 x 1500. The plugin and automatically selects the "Large" size from Settings > Media, if it is greater than 1500 x 1500 you will need to reduce the size or modify the configuration in `thumb.php` to support larger image sizes.
|
58 |
* Tilde(~) in url - Timthumb has a known issue with this, please use a url without a tilde until a fix is available. [Bug report](https://code.google.com/p/timthumb/issues/detail?id=263)
|
59 |
+
* Thumbnail images only work with WordPress' native post thumbnail / featured image. Many theme use a custom image field for thumbnails, these are not supported.
|
60 |
|
61 |
Still stuck? See [additional troubleshooting tips](http://www.binarymoon.co.uk/2010/11/timthumb-hints-tips/) from the TimThumb author.
|
62 |
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 1.8.1 =
|
70 |
+
|
71 |
+
* Add content display option
|
72 |
+
|
73 |
+
= 1.8 =
|
74 |
+
|
75 |
+
* Add custom field display
|
76 |
+
* Re-organized widget options
|
77 |
+
* Use proper alt tag for image thumbnails
|
78 |
+
* Better title attribute for links
|
79 |
+
|
80 |
= 1.7 =
|
81 |
|
82 |
* Added show author option
|
ultimate-posts-widget.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Ultimate Posts Widget
|
4 |
Plugin URI: http://wordpress.org/plugins/ultimate-posts-widget/
|
5 |
Description: The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
|
6 |
-
Version: 1.
|
7 |
Author: Boston Dell-Vandenberg
|
8 |
Author URI: http://pomelodesign.com
|
9 |
License: GPL2
|
@@ -25,624 +25,702 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25 |
|
26 |
if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
|
630 |
-
|
|
|
|
|
|
|
631 |
|
632 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
|
634 |
-
|
|
|
|
|
635 |
|
636 |
-
|
637 |
|
638 |
-
|
639 |
|
640 |
-
|
641 |
|
642 |
-
|
643 |
|
644 |
-
|
645 |
|
646 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
647 |
|
648 |
}
|
3 |
Plugin Name: Ultimate Posts Widget
|
4 |
Plugin URI: http://wordpress.org/plugins/ultimate-posts-widget/
|
5 |
Description: The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
|
6 |
+
Version: 1.8.1
|
7 |
Author: Boston Dell-Vandenberg
|
8 |
Author URI: http://pomelodesign.com
|
9 |
License: GPL2
|
25 |
|
26 |
if ( !class_exists( 'WP_Widget_Ultimate_Posts' ) ) {
|
27 |
|
28 |
+
class WP_Widget_Ultimate_Posts extends WP_Widget {
|
29 |
+
|
30 |
+
function WP_Widget_Ultimate_Posts() {
|
31 |
+
|
32 |
+
$widget_options = array(
|
33 |
+
'classname' => 'widget_ultimate_posts',
|
34 |
+
'description' => __( 'Displays list of posts with an array of options', 'upw' )
|
35 |
+
);
|
36 |
+
|
37 |
+
$control_options = array();
|
38 |
+
|
39 |
+
$this->WP_Widget(
|
40 |
+
'sticky-posts',
|
41 |
+
__( 'Ultimate Posts', 'upw' ),
|
42 |
+
$widget_options,
|
43 |
+
$control_options
|
44 |
+
);
|
45 |
+
|
46 |
+
$this->alt_option_name = 'widget_ultimate_posts';
|
47 |
+
|
48 |
+
add_action( 'save_post', array( &$this, 'flush_widget_cache' ) );
|
49 |
+
add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) );
|
50 |
+
add_action( 'switch_theme', array( &$this, 'flush_widget_cache' ) );
|
51 |
+
|
52 |
+
load_plugin_textdomain('upw', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
function widget( $args, $instance ) {
|
57 |
+
|
58 |
+
global $post;
|
59 |
+
$current_post_id = $post->ID;
|
60 |
+
|
61 |
+
if( !function_exists('get_image_path') ) {
|
62 |
+
function get_image_path($src) {
|
63 |
+
global $blog_id;
|
64 |
+
if(isset($blog_id) && $blog_id > 0) {
|
65 |
+
$imageParts = explode('/files/' , $src);
|
66 |
+
if(isset($imageParts[1])) {
|
67 |
+
$src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return $src;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
$cache = wp_cache_get( 'widget_ultimate_posts', 'widget' );
|
75 |
+
|
76 |
+
if ( !is_array( $cache ) )
|
77 |
+
$cache = array();
|
78 |
+
|
79 |
+
if ( isset( $cache[$args['widget_id']] ) ) {
|
80 |
+
echo $cache[$args['widget_id']];
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
ob_start();
|
85 |
+
extract( $args );
|
86 |
+
|
87 |
+
$title = apply_filters( 'widget_title', $instance['title'] );
|
88 |
+
$title_link = $instance['title_link'];
|
89 |
+
$number = $instance['number'];
|
90 |
+
$types = ($instance['types'] ? explode(',', $instance['types']) : '');
|
91 |
+
$cats = ($instance['cats'] ? explode(',', $instance['cats']) : '');
|
92 |
+
$atcat = $instance['atcat'] ? true : false;
|
93 |
+
$thumb_w = $instance['thumb_w'];
|
94 |
+
$thumb_h = $instance['thumb_h'];
|
95 |
+
$thumb_crop = $instance['thumb_crop'];
|
96 |
+
$excerpt_length = $instance['excerpt_length'];
|
97 |
+
$excerpt_readmore = $instance['excerpt_readmore'];
|
98 |
+
$sticky = $instance['sticky'];
|
99 |
+
$order = $instance['order'];
|
100 |
+
$orderby = $instance['orderby'];
|
101 |
+
$custom_fields = $instance['custom_fields'];
|
102 |
+
|
103 |
+
// Sticky posts
|
104 |
+
if ($sticky == 'only') {
|
105 |
+
$sticky_query = array( 'post__in' => get_option( 'sticky_posts' ) );
|
106 |
+
} elseif ($sticky == 'hide') {
|
107 |
+
$sticky_query = array( 'post__not_in' => get_option( 'sticky_posts' ) );
|
108 |
+
} else {
|
109 |
+
$sticky_query = null;
|
110 |
+
}
|
111 |
+
|
112 |
+
// If $atcat true and in category
|
113 |
+
if ($atcat && is_category()) {
|
114 |
+
$cats = get_query_var('cat');
|
115 |
+
}
|
116 |
+
|
117 |
+
// If $atcat true and is single post
|
118 |
+
if ($atcat && is_single()) {
|
119 |
+
$cats = '';
|
120 |
+
foreach (get_the_category() as $catt) {
|
121 |
+
$cats .= $catt->cat_ID.' ';
|
122 |
+
}
|
123 |
+
$cats = str_replace(" ", ",", trim($cats));
|
124 |
+
}
|
125 |
+
|
126 |
+
//Excerpt more filter
|
127 |
+
$new_excerpt_more = create_function('$more', 'return "...";');
|
128 |
+
add_filter('excerpt_more', $new_excerpt_more);
|
129 |
+
|
130 |
+
// Excerpt length filter
|
131 |
+
$new_excerpt_length = create_function('$length', "return " . $excerpt_length . ";");
|
132 |
+
if ( $instance["excerpt_length"] > 0 ) add_filter('excerpt_length', $new_excerpt_length);
|
133 |
+
|
134 |
+
echo $before_widget;
|
135 |
+
if ( $title ) {
|
136 |
+
echo $before_title;
|
137 |
+
if ( $title_link ) echo "<a href='$title_link'>";
|
138 |
+
echo $title;
|
139 |
+
if ( $title_link ) echo "</a>";
|
140 |
+
echo $after_title;
|
141 |
+
}
|
142 |
+
|
143 |
+
$args = array(
|
144 |
+
'showposts' => $number,
|
145 |
+
'order' => $order,
|
146 |
+
'orderby' => $orderby,
|
147 |
+
'category__in' => $cats,
|
148 |
+
'post_type' => $types
|
149 |
+
);
|
150 |
+
|
151 |
+
if (!empty($sticky_query)) {
|
152 |
+
$args[key($sticky_query)] = reset($sticky_query);
|
153 |
+
}
|
154 |
+
|
155 |
+
$r = new WP_Query( $args );
|
156 |
+
|
157 |
+
if ( $r->have_posts() ) :
|
158 |
+
|
159 |
+
echo '<ul>';
|
160 |
+
|
161 |
+
while ( $r->have_posts() ) : $r->the_post();
|
162 |
+
|
163 |
+
?>
|
164 |
+
|
165 |
+
<li class="<?php echo ($post->ID == $current_post_id && is_single())?'current-post-item':'' ?>">
|
166 |
+
|
167 |
+
<?php
|
168 |
+
if ( function_exists('the_post_thumbnail') &&
|
169 |
+
current_theme_supports("post-thumbnails") &&
|
170 |
+
$instance["show_thumbnail"] &&
|
171 |
+
has_post_thumbnail() ) :
|
172 |
+
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'large');
|
173 |
+
$thumbnail_alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
|
174 |
+
$plugin_dir = 'ultimate-posts-widget';
|
175 |
+
?>
|
176 |
+
|
177 |
+
<div class="upw-image">
|
178 |
+
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(array('before'=>'Permalink to: ')); ?>">
|
179 |
+
<img src="<?php echo WP_PLUGIN_URL . '/ultimate-posts-widget/thumb.php?src='. get_image_path($thumbnail[0]) .'&h='.$thumb_h.'&w='.$thumb_w.'&zc='.$thumb_crop; ?>" alt="<?php echo $thumbnail_alt; ?>" />
|
180 |
+
</a>
|
181 |
+
</div>
|
182 |
+
|
183 |
+
<?php endif; ?>
|
184 |
+
|
185 |
+
<div class="upw-content">
|
186 |
+
|
187 |
+
<?php if ( get_the_title() && $instance['show_title'] ) : ?>
|
188 |
+
<p class="post-title">
|
189 |
+
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(array('before'=>'Permalink to: ')); ?>">
|
190 |
+
<?php the_title(); ?>
|
191 |
+
</a>
|
192 |
+
</p>
|
193 |
+
<?php endif; ?>
|
194 |
+
|
195 |
+
<?php if ( $instance['show_date'] || $instance['show_time'] ) : ?>
|
196 |
+
<p class="post-date">
|
197 |
+
<?php
|
198 |
+
if ( $instance['show_date'] && $instance['show_time'] ) {
|
199 |
+
the_time(get_option('date_format') . ' ' . get_option('time_format'));
|
200 |
+
} elseif ( $instance['show_date'] && !$instance['show_time'] ) {
|
201 |
+
the_time(get_option('date_format'));
|
202 |
+
} else {
|
203 |
+
the_time(get_option('time_format'));
|
204 |
+
}
|
205 |
+
?>
|
206 |
+
</p>
|
207 |
+
<?php endif; ?>
|
208 |
+
|
209 |
+
<?php if( $instance['show_author'] ) : ?>
|
210 |
+
<p class="post-author">
|
211 |
+
<span class="post-author-label"><?php _e('By', 'upw'); ?>:</span>
|
212 |
+
<?php the_author_posts_link(); ?>
|
213 |
+
</p>
|
214 |
+
<?php endif; ?>
|
215 |
+
|
216 |
+
<?php if ( $instance['show_excerpt'] ) :
|
217 |
+
if ( $instance['show_readmore'] ) : $linkmore = ' <a href="'.get_permalink().'" class="more-link" title="'.the_title_attribute(array('before'=>'Permalink to: ', 'echo'=>false)).'">'.$excerpt_readmore.'</a>'; else: $linkmore =''; endif; ?>
|
218 |
+
<p class="post-excerpt"><?php echo get_the_excerpt() . $linkmore; ?></p>
|
219 |
+
<?php endif; ?>
|
220 |
+
|
221 |
+
<?php if ( $instance['show_content'] ) : ?>
|
222 |
+
<p class="post-content"><?php the_content() ?></p>
|
223 |
+
<?php endif; ?>
|
224 |
+
|
225 |
+
<?php if ( $instance['show_cats'] ) : ?>
|
226 |
+
<p class="post-cats">
|
227 |
+
<span class="post-cats-label"><?php _e('Categories', 'upw'); ?>:</span>
|
228 |
+
<span class="post-cats-list"><?php the_category(', '); ?></span>
|
229 |
+
</p>
|
230 |
+
<?php endif; ?>
|
231 |
+
|
232 |
+
<?php if ( $instance['show_tags'] ) : ?>
|
233 |
+
<p class="post-tags">
|
234 |
+
<span class="post-tags-label"><?php _e('Tags', 'upw'); ?>:</span>
|
235 |
+
<?php the_tags('<span class="post-tags-list">', ', ', '</span>'); ?>
|
236 |
+
</p>
|
237 |
+
<?php endif; ?>
|
238 |
+
|
239 |
+
<?php if ( $custom_fields ) {
|
240 |
+
$custom_field_name = explode(',', $custom_fields);
|
241 |
+
foreach ($custom_field_name as $name) {
|
242 |
+
$name = trim($name);
|
243 |
+
$custom_field_values = get_post_meta($post->ID, $name, true);
|
244 |
+
if ($custom_field_values) {
|
245 |
+
echo '<p class="post-meta post-meta-'.$name.'">';
|
246 |
+
if (!is_array($custom_field_values)) {
|
247 |
+
echo $custom_field_values;
|
248 |
+
} else {
|
249 |
+
$last_value = end($custom_field_values);
|
250 |
+
foreach ($custom_field_values as $value) {
|
251 |
+
echo $value;
|
252 |
+
if ($value != $last_value) echo ', ';
|
253 |
+
}
|
254 |
+
}
|
255 |
+
echo '</p>';
|
256 |
+
}
|
257 |
+
}
|
258 |
+
} ?>
|
259 |
+
|
260 |
+
</div>
|
261 |
+
|
262 |
+
</li>
|
263 |
+
|
264 |
+
<?php
|
265 |
+
endwhile;
|
266 |
+
echo '</ul>';
|
267 |
+
|
268 |
+
if ( $instance['show_morebutton'] ) : ?>
|
269 |
+
<div class="upw-more">
|
270 |
+
<a href="<?php echo $instance['morebutton_url']; ?>" class="button"><?php echo $instance['morebutton_text']; ?></a>
|
271 |
+
</div>
|
272 |
+
<?php endif;
|
273 |
+
|
274 |
+
// Reset the global $the_post as this query will have stomped on it
|
275 |
+
wp_reset_postdata();
|
276 |
+
|
277 |
+
else :
|
278 |
+
|
279 |
+
echo __('No posts found.', 'upw');
|
280 |
+
|
281 |
+
endif;
|
282 |
+
|
283 |
+
echo $after_widget;
|
284 |
+
|
285 |
+
if ($cache) {
|
286 |
+
$cache[$args['widget_id']] = ob_get_flush();
|
287 |
+
}
|
288 |
+
wp_cache_set( 'widget_ultimate_posts', $cache, 'widget' );
|
289 |
+
}
|
290 |
+
|
291 |
+
function update( $new_instance, $old_instance ) {
|
292 |
+
$instance = $old_instance;
|
293 |
+
|
294 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
295 |
+
$instance['title_link'] = strip_tags( $new_instance['title_link'] );
|
296 |
+
$instance['number'] = strip_tags( $new_instance['number'] );
|
297 |
+
$instance['types'] = (isset( $new_instance['types'] )) ? implode(',', (array) $new_instance['types']) : '';
|
298 |
+
$instance['cats'] = (isset( $new_instance['cats'] )) ? implode(',', (array) $new_instance['cats']) : '';
|
299 |
+
$instance['atcat'] = isset( $new_instance['atcat'] );
|
300 |
+
$instance['show_excerpt'] = isset( $new_instance['show_excerpt'] );
|
301 |
+
$instance['show_content'] = isset( $new_instance['show_content'] );
|
302 |
+
$instance['show_thumbnail'] = isset( $new_instance['show_thumbnail'] );
|
303 |
+
$instance['show_date'] = isset( $new_instance['show_date'] );
|
304 |
+
$instance['show_time'] = isset( $new_instance['show_time'] );
|
305 |
+
$instance['show_title'] = isset( $new_instance['show_title'] );
|
306 |
+
$instance['show_author'] = isset( $new_instance['show_author'] );
|
307 |
+
$instance['thumb_w'] = strip_tags( $new_instance['thumb_w'] );
|
308 |
+
$instance['thumb_h'] = strip_tags( $new_instance['thumb_h'] );
|
309 |
+
$instance['thumb_crop'] = $new_instance['thumb_crop'];
|
310 |
+
$instance['show_readmore'] = isset( $new_instance['show_readmore']);
|
311 |
+
$instance['excerpt_length'] = strip_tags( $new_instance['excerpt_length'] );
|
312 |
+
$instance['excerpt_readmore'] = strip_tags( $new_instance['excerpt_readmore'] );
|
313 |
+
$instance['sticky'] = $new_instance['sticky'];
|
314 |
+
$instance['order'] = $new_instance['order'];
|
315 |
+
$instance['orderby'] = $new_instance['orderby'];
|
316 |
+
$instance['show_morebutton'] = isset( $new_instance['show_morebutton'] );
|
317 |
+
$instance['morebutton_url'] = strip_tags( $new_instance['morebutton_url'] );
|
318 |
+
$instance['morebutton_text'] = strip_tags( $new_instance['morebutton_text'] );
|
319 |
+
$instance['show_cats'] = isset( $new_instance['show_cats'] );
|
320 |
+
$instance['show_tags'] = isset( $new_instance['show_tags'] );
|
321 |
+
$instance['custom_fields'] = strip_tags( $new_instance['custom_fields'] );
|
322 |
+
|
323 |
+
$this->flush_widget_cache();
|
324 |
+
|
325 |
+
$alloptions = wp_cache_get( 'alloptions', 'options' );
|
326 |
+
if ( isset( $alloptions['widget_ultimate_posts'] ) )
|
327 |
+
delete_option( 'widget_ultimate_posts' );
|
328 |
+
|
329 |
+
return $instance;
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
function flush_widget_cache() {
|
334 |
+
|
335 |
+
wp_cache_delete( 'widget_ultimate_posts', 'widget' );
|
336 |
+
|
337 |
+
}
|
338 |
+
|
339 |
+
function form( $instance ) {
|
340 |
+
|
341 |
+
// Set default arguments
|
342 |
+
$instance = wp_parse_args( (array) $instance, array(
|
343 |
+
'title' => '',
|
344 |
+
'title_link' => '' ,
|
345 |
+
'number' => '5',
|
346 |
+
'types' => 'post',
|
347 |
+
'cats' => '',
|
348 |
+
'atcat' => false,
|
349 |
+
'thumb_w' => 100,
|
350 |
+
'thumb_h' => 100,
|
351 |
+
'thumb_crop' => 1,
|
352 |
+
'excerpt_length' => 10,
|
353 |
+
'excerpt_readmore' => __('Read more →', 'upw'),
|
354 |
+
'order' => 'DESC',
|
355 |
+
'orderby' => 'date',
|
356 |
+
'morebutton_text' => __('View More Posts', 'upw'),
|
357 |
+
'morebutton_url' => site_url(),
|
358 |
+
'sticky' => 'show',
|
359 |
+
'show_cats' => false,
|
360 |
+
'show_tags' => false,
|
361 |
+
'show_title' => false,
|
362 |
+
'show_date' => false,
|
363 |
+
'show_time' => false,
|
364 |
+
'show_author' => false,
|
365 |
+
'show_excerpt' => false,
|
366 |
+
'show_content' => false,
|
367 |
+
'show_readmore' => false,
|
368 |
+
'show_thumbnail' => false,
|
369 |
+
'custom_fields' => '',
|
370 |
+
'show_morebutton' => false
|
371 |
+
) );
|
372 |
+
|
373 |
+
// Or use the instance
|
374 |
+
$title = strip_tags($instance['title']);
|
375 |
+
$title_link = strip_tags($instance['title_link']);
|
376 |
+
$number = strip_tags($instance['number']);
|
377 |
+
$types = $instance['types'];
|
378 |
+
$cats = $instance['cats'];
|
379 |
+
$atcat = $instance['atcat'];
|
380 |
+
$thumb_w = strip_tags($instance['thumb_w']);
|
381 |
+
$thumb_h = strip_tags($instance['thumb_h']);
|
382 |
+
$thumb_crop = strip_tags($instance['thumb_crop']);
|
383 |
+
$excerpt_length = strip_tags($instance['excerpt_length']);
|
384 |
+
$excerpt_readmore = strip_tags($instance['excerpt_readmore']);
|
385 |
+
$order = $instance['order'];
|
386 |
+
$orderby = $instance['orderby'];
|
387 |
+
$morebutton_text = strip_tags($instance['morebutton_text']);
|
388 |
+
$morebutton_url = strip_tags($instance['morebutton_url']);
|
389 |
+
$sticky = $instance['sticky'];
|
390 |
+
$show_cats = $instance['show_cats'];
|
391 |
+
$show_tags = $instance['show_tags'];
|
392 |
+
$show_title = $instance['show_title'];
|
393 |
+
$show_date = $instance['show_date'];
|
394 |
+
$show_time = $instance['show_time'];
|
395 |
+
$show_author = $instance['show_author'];
|
396 |
+
$show_excerpt = $instance['show_excerpt'];
|
397 |
+
$show_content = $instance['show_content'];
|
398 |
+
$show_readmore = $instance['show_readmore'];
|
399 |
+
$show_thumbnail = $instance['show_thumbnail'];
|
400 |
+
$show_morebutton = $instance['show_morebutton'];
|
401 |
+
$custom_fields = strip_tags($instance['custom_fields']);
|
402 |
+
|
403 |
+
//Let's turn $types and $cats into an array
|
404 |
+
$types = explode(',', $types);
|
405 |
+
$cats = explode(',', $cats);
|
406 |
+
|
407 |
+
//Count number of post types for select box sizing
|
408 |
+
$cpt_types = get_post_types( array( 'public' => true ), 'names' );
|
409 |
+
foreach ($cpt_types as $cpt ) {
|
410 |
+
$cpt_ar[] = $cpt;
|
411 |
+
}
|
412 |
+
$n = count($cpt_ar);
|
413 |
+
if($n > 10) { $n = 10; }
|
414 |
+
|
415 |
+
//Count number of categories for select box sizing
|
416 |
+
$cat_list = get_categories( 'hide_empty=0' );
|
417 |
+
foreach ($cat_list as $cat ) {
|
418 |
+
$cat_ar[] = $cat;
|
419 |
+
}
|
420 |
+
$c = count($cat_ar);
|
421 |
+
if($c > 10) { $c = 10; }
|
422 |
+
|
423 |
+
?>
|
424 |
+
|
425 |
+
<style>
|
426 |
+
.upw-divider {
|
427 |
+
border: 0;
|
428 |
+
border-top: 1px solid #DFDFDF;
|
429 |
+
}
|
430 |
+
</style>
|
431 |
+
|
432 |
+
<p>
|
433 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'upw' ); ?>:</label>
|
434 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
|
435 |
+
</p>
|
436 |
+
|
437 |
+
<p>
|
438 |
+
<label for="<?php echo $this->get_field_id( 'title_link' ); ?>"><?php _e( 'Title URL', 'upw' ); ?>:</label>
|
439 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title_link' ); ?>" name="<?php echo $this->get_field_name( 'title_link' ); ?>" type="text" value="<?php echo $title_link; ?>" />
|
440 |
+
</p>
|
441 |
+
|
442 |
+
<p>
|
443 |
+
<label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts', 'upw' ); ?>:</label>
|
444 |
+
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="2" />
|
445 |
+
</p>
|
446 |
+
|
447 |
+
<p>
|
448 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_morebutton'); ?>" name="<?php echo $this->get_field_name('show_morebutton'); ?>" <?php checked( (bool) $show_morebutton, true ); ?> />
|
449 |
+
<label for="<?php echo $this->get_field_id('show_morebutton'); ?>"> <?php _e('Show more button', 'upw'); ?></label>
|
450 |
+
</p>
|
451 |
+
|
452 |
+
<p>
|
453 |
+
<label for="<?php echo $this->get_field_id('morebutton_text'); ?>"><?php _e( 'More button text', 'upw' ); ?>:</label>
|
454 |
+
<input class="widefat" type="text" id="<?php echo $this->get_field_id('morebutton_text'); ?>" name="<?php echo $this->get_field_name('morebutton_text'); ?>" value="<?php echo $morebutton_text; ?>" />
|
455 |
+
</p>
|
456 |
+
|
457 |
+
<p>
|
458 |
+
<label for="<?php echo $this->get_field_id('morebutton_url'); ?>"><?php _e( 'More button URL', 'upw' ); ?>:</label>
|
459 |
+
<input class="widefat" type="text" id="<?php echo $this->get_field_id('morebutton_url'); ?>" name="<?php echo $this->get_field_name('morebutton_url'); ?>" value="<?php echo $morebutton_url; ?>" />
|
460 |
+
</p>
|
461 |
+
|
462 |
+
<hr class="upw-divider">
|
463 |
+
|
464 |
+
<h4>Post Display</h4>
|
465 |
+
|
466 |
+
<p>
|
467 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_title' ); ?>" name="<?php echo $this->get_field_name( 'show_title' ); ?>" type="checkbox" <?php checked( (bool) $show_title, true ); ?> />
|
468 |
+
<label for="<?php echo $this->get_field_id( 'show_title' ); ?>"><?php _e( 'Show title', 'upw' ); ?></label>
|
469 |
+
</p>
|
470 |
+
|
471 |
+
<p>
|
472 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" type="checkbox" <?php checked( (bool) $show_date, true ); ?> />
|
473 |
+
<label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Show published date', 'upw' ); ?></label>
|
474 |
+
</p>
|
475 |
+
|
476 |
+
<p>
|
477 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_time' ); ?>" name="<?php echo $this->get_field_name( 'show_time' ); ?>" type="checkbox" <?php checked( (bool) $show_time, true ); ?> />
|
478 |
+
<label for="<?php echo $this->get_field_id( 'show_time' ); ?>"><?php _e( 'Show published time', 'upw' ); ?></label>
|
479 |
+
</p>
|
480 |
+
|
481 |
+
<p>
|
482 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_author' ); ?>" name="<?php echo $this->get_field_name( 'show_author' ); ?>" type="checkbox" <?php checked( (bool) $show_author, true ); ?> />
|
483 |
+
<label for="<?php echo $this->get_field_id( 'show_author' ); ?>"><?php _e( 'Show post author', 'upw' ); ?></label>
|
484 |
+
</p>
|
485 |
+
|
486 |
+
<p>
|
487 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_excerpt' ); ?>" name="<?php echo $this->get_field_name( 'show_excerpt' ); ?>" type="checkbox" <?php checked( (bool) $show_excerpt, true ); ?> />
|
488 |
+
<label for="<?php echo $this->get_field_id( 'show_excerpt' ); ?>"><?php _e( 'Show excerpt', 'upw' ); ?></label>
|
489 |
+
</p>
|
490 |
+
|
491 |
+
<p>
|
492 |
+
<label for="<?php echo $this->get_field_id('excerpt_length'); ?>"><?php _e( 'Excerpt length (in words)', 'upw' ); ?>:</label>
|
493 |
+
<input style="text-align: center;" type="text" id="<?php echo $this->get_field_id('excerpt_length'); ?>" name="<?php echo $this->get_field_name('excerpt_length'); ?>" value="<?php echo $excerpt_length; ?>" size="3" />
|
494 |
+
</p>
|
495 |
+
|
496 |
+
<p>
|
497 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_content' ); ?>" name="<?php echo $this->get_field_name( 'show_content' ); ?>" type="checkbox" <?php checked( (bool) $show_content, true ); ?> />
|
498 |
+
<label for="<?php echo $this->get_field_id( 'show_content' ); ?>"><?php _e( 'Show content', 'upw' ); ?></label>
|
499 |
+
</p>
|
500 |
+
|
501 |
+
<p>
|
502 |
+
<label for="<?php echo $this->get_field_id('show_readmore'); ?>">
|
503 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_readmore'); ?>" name="<?php echo $this->get_field_name('show_readmore'); ?>"<?php checked( (bool) $show_readmore, true ); ?> />
|
504 |
+
<?php _e( 'Show read more link', 'upw' ); ?>
|
505 |
+
</label>
|
506 |
+
</p>
|
507 |
+
|
508 |
+
<p>
|
509 |
+
<label for="<?php echo $this->get_field_id('excerpt_readmore'); ?>"><?php _e( 'Read more text', 'upw' ); ?>:</label>
|
510 |
+
<input class="widefat" type="text" id="<?php echo $this->get_field_id('excerpt_readmore'); ?>" name="<?php echo $this->get_field_name('excerpt_readmore'); ?>" value="<?php echo $excerpt_readmore; ?>" />
|
511 |
+
</p>
|
512 |
+
|
513 |
+
<?php if ( function_exists('the_post_thumbnail') && current_theme_supports( 'post-thumbnails' ) ) : ?>
|
514 |
+
|
515 |
+
<p>
|
516 |
+
<input class="checkbox" id="<?php echo $this->get_field_id( 'show_thumbnail' ); ?>" name="<?php echo $this->get_field_name( 'show_thumbnail' ); ?>" type="checkbox" <?php checked( (bool) $show_thumbnail, true ); ?> />
|
517 |
+
<label for="<?php echo $this->get_field_id( 'show_thumbnail' ); ?>"><?php _e( 'Show thumbnail', 'upw' ); ?></label>
|
518 |
+
</p>
|
519 |
+
|
520 |
+
<p>
|
521 |
+
<label><?php _e('Thumbnail size', 'upw'); ?>:</label>
|
522 |
+
<br />
|
523 |
+
<label for="<?php echo $this->get_field_id('thumb_w'); ?>">
|
524 |
+
<?php _e('W', 'upw'); ?>: <input class="widefat" style="width:40%;" type="text" id="<?php echo $this->get_field_id('thumb_w'); ?>" name="<?php echo $this->get_field_name('thumb_w'); ?>" value="<?php echo $thumb_w; ?>" />
|
525 |
+
</label>
|
526 |
+
<label for="<?php echo $this->get_field_id('thumb_h'); ?>">
|
527 |
+
<?php _e('H', 'upw'); ?>: <input class="widefat" style="width:40%;" type="text" id="<?php echo $this->get_field_id('thumb_h'); ?>" name="<?php echo $this->get_field_name('thumb_h'); ?>" value="<?php echo $thumb_h; ?>" />
|
528 |
+
</label>
|
529 |
+
</p>
|
530 |
+
|
531 |
+
<p>
|
532 |
+
<label><?php _e('Crop mode', 'upw'); ?>:</label>
|
533 |
+
<br />
|
534 |
+
<select id="<?php echo $this->get_field_id('thumb_crop'); ?>" name="<?php echo $this->get_field_name('thumb_crop'); ?>">
|
535 |
+
<option value="1"<?php if($thumb_crop == 1) echo ' selected'; ?>><?php _e('Scale & Crop to Fit', 'upw'); ?></option>
|
536 |
+
<option value="0"<?php if($thumb_crop == 0) echo ' selected'; ?>><?php _e('Stretch to Fit', 'upw'); ?></option>
|
537 |
+
<option value="2"<?php if($thumb_crop == 2) echo ' selected'; ?>><?php _e('Proportional Scale', 'upw'); ?></option>
|
538 |
+
<option value="3"<?php if($thumb_crop == 3) echo ' selected'; ?>><?php _e('Proportional Scale No Borders', 'upw'); ?></option>
|
539 |
+
</select>
|
540 |
+
</p>
|
541 |
+
|
542 |
+
<?php endif; ?>
|
543 |
+
|
544 |
+
<p>
|
545 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_cats'); ?>" name="<?php echo $this->get_field_name('show_cats'); ?>" <?php checked( (bool) $show_cats, true ); ?> />
|
546 |
+
<label for="<?php echo $this->get_field_id('show_cats'); ?>"> <?php _e('Show post categories', 'upw'); ?></label>
|
547 |
+
</p>
|
548 |
+
|
549 |
+
<p>
|
550 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('show_tags'); ?>" name="<?php echo $this->get_field_name('show_tags'); ?>" <?php checked( (bool) $show_tags, true ); ?> />
|
551 |
+
<label for="<?php echo $this->get_field_id('show_tags'); ?>"> <?php _e('Show post tags', 'upw'); ?></label>
|
552 |
+
</p>
|
553 |
+
|
554 |
+
<p>
|
555 |
+
<label for="<?php echo $this->get_field_id( 'custom_fields' ); ?>"><?php _e( 'Show Custom Fields (comma separated)', 'upw' ); ?>:</label>
|
556 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'custom_fields' ); ?>" name="<?php echo $this->get_field_name( 'custom_fields' ); ?>" type="text" value="<?php echo $custom_fields; ?>" />
|
557 |
+
</p>
|
558 |
+
|
559 |
+
<hr class="upw-divider">
|
560 |
+
|
561 |
+
<h4>Filters</h4>
|
562 |
+
|
563 |
+
<p>
|
564 |
+
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('atcat'); ?>" name="<?php echo $this->get_field_name('atcat'); ?>" <?php checked( (bool) $atcat, true ); ?> />
|
565 |
+
<label for="<?php echo $this->get_field_id('atcat'); ?>"> <?php _e('Show posts only from current category', 'upw');?></label>
|
566 |
+
</p>
|
567 |
+
|
568 |
+
<p>
|
569 |
+
<label for="<?php echo $this->get_field_id('cats'); ?>"><?php _e( 'Categories', 'upw' ); ?>:</label>
|
570 |
+
<select name="<?php echo $this->get_field_name('cats'); ?>[]" id="<?php echo $this->get_field_id('cats'); ?>" class="widefat" style="height: auto;" size="<?php echo $c ?>" multiple>
|
571 |
+
<?php
|
572 |
+
$categories = get_categories( 'hide_empty=0' );
|
573 |
+
foreach ($categories as $category ) { ?>
|
574 |
+
<option value="<?php echo $category->term_id; ?>" <?php if( in_array($category->term_id, $cats)) { echo 'selected="selected"'; } ?>><?php echo $category->cat_name;?></option>
|
575 |
+
<?php } ?>
|
576 |
+
</select>
|
577 |
+
</p>
|
578 |
+
|
579 |
+
<p>
|
580 |
+
<label for="<?php echo $this->get_field_id('types'); ?>"><?php _e( 'Post types', 'upw' ); ?>:</label>
|
581 |
+
<select name="<?php echo $this->get_field_name('types'); ?>[]" id="<?php echo $this->get_field_id('types'); ?>" class="widefat" style="height: auto;" size="<?php echo $n ?>" multiple>
|
582 |
+
<?php
|
583 |
+
$args = array( 'public' => true );
|
584 |
+
$post_types = get_post_types( $args, 'names' );
|
585 |
+
foreach ($post_types as $post_type ) { ?>
|
586 |
+
<option value="<?php echo $post_type; ?>" <?php if( in_array($post_type, $types)) { echo 'selected="selected"'; } ?>><?php echo $post_type;?></option>
|
587 |
+
<?php } ?>
|
588 |
+
</select>
|
589 |
+
</p>
|
590 |
+
|
591 |
+
<p>
|
592 |
+
<label for="<?php echo $this->get_field_id('sticky'); ?>"><?php _e( 'Sticky posts', 'upw' ); ?>:</label>
|
593 |
+
<select name="<?php echo $this->get_field_name('sticky'); ?>" id="<?php echo $this->get_field_id('sticky'); ?>" class="widefat">
|
594 |
+
<option value="show"<?php if( $sticky === 'show') echo ' selected'; ?>><?php _e('Show All Posts', 'upw'); ?></option>
|
595 |
+
<option value="hide"<?php if( $sticky == 'hide') echo ' selected'; ?>><?php _e('Hide Sticky Posts', 'upw'); ?></option>
|
596 |
+
<option value="only"<?php if( $sticky == 'only') echo ' selected'; ?>><?php _e('Show Only Sticky Posts', 'upw'); ?></option>
|
597 |
+
</select>
|
598 |
+
</p>
|
599 |
+
|
600 |
+
<hr class="upw-divider">
|
601 |
+
|
602 |
+
<h4>Order</h4>
|
603 |
+
|
604 |
+
<p>
|
605 |
+
<select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
|
606 |
+
<option value="date"<?php if( $orderby == 'date') echo ' selected'; ?>><?php _e('Published Date', 'upw'); ?></option>
|
607 |
+
<option value="title"<?php if( $orderby == 'title') echo ' selected'; ?>><?php _e('Title', 'upw'); ?></option>
|
608 |
+
<option value="comment_count"<?php if( $orderby == 'comment_count') echo ' selected'; ?>><?php _e('Comment Count', 'upw'); ?></option>
|
609 |
+
<option value="rand"<?php if( $orderby == 'rand') echo ' selected'; ?>><?php _e('Random'); ?></option>
|
610 |
+
</select>
|
611 |
+
</p>
|
612 |
+
|
613 |
+
<p>
|
614 |
+
<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('order'); ?>" class="widefat">
|
615 |
+
<option value="DESC"<?php if( $order == 'DESC') echo ' selected'; ?>><?php _e('Descending', 'upw'); ?></option>
|
616 |
+
<option value="ASC"<?php if( $order == 'ASC') echo ' selected'; ?>><?php _e('Ascending', 'upw'); ?></option>
|
617 |
+
</select>
|
618 |
+
</p>
|
619 |
+
|
620 |
+
<p class="credits"><small><?php _e('Developed by', 'upw'); ?> <a href="http://pomelodesign.com">Pomelo Design</a></small></p>
|
621 |
+
|
622 |
+
<?php if ( $instance ) { ?>
|
623 |
+
|
624 |
+
<script>
|
625 |
+
|
626 |
+
jQuery(document).ready(function($){
|
627 |
+
|
628 |
+
var show_excerpt = $("#<?php echo $this->get_field_id( 'show_excerpt' ); ?>");
|
629 |
+
var show_readmore = $("#<?php echo $this->get_field_id( 'show_readmore' ); ?>");
|
630 |
+
var show_thumbnail = $("#<?php echo $this->get_field_id( 'show_thumbnail' ); ?>");
|
631 |
+
var excerpt_length = $("#<?php echo $this->get_field_id( 'excerpt_length' ); ?>").parents('p');
|
632 |
+
var excerpt_readmore = $("#<?php echo $this->get_field_id( 'excerpt_readmore' ); ?>").parents('p');
|
633 |
+
var thumb_w = $("#<?php echo $this->get_field_id( 'thumb_w' ); ?>").parents('p');
|
634 |
+
var thumb_crop = $("#<?php echo $this->get_field_id( 'thumb_crop' ); ?>").parents('p');
|
635 |
+
var show_morebutton = $("#<?php echo $this->get_field_id( 'show_morebutton' ); ?>");
|
636 |
+
var morebutton_text = $("#<?php echo $this->get_field_id( 'morebutton_text' ); ?>").parents('p');
|
637 |
+
var morebutton_url = $("#<?php echo $this->get_field_id( 'morebutton_url' ); ?>").parents('p');
|
638 |
+
|
639 |
+
<?php
|
640 |
+
// Use PHP to determine if not checked and hide if so
|
641 |
+
// jQuery method was acting up
|
642 |
+
if ( !$show_excerpt ) {
|
643 |
+
echo 'excerpt_length.hide();';
|
644 |
+
}
|
645 |
+
if ( !$show_readmore ) {
|
646 |
+
echo 'excerpt_readmore.hide();';
|
647 |
+
}
|
648 |
+
if ( !$show_thumbnail ) {
|
649 |
+
echo 'thumb_w.hide();';
|
650 |
+
echo 'thumb_crop.hide();';
|
651 |
+
}
|
652 |
+
if ( !$show_morebutton ) {
|
653 |
+
echo 'morebutton_text.hide();';
|
654 |
+
echo 'morebutton_url.hide();';
|
655 |
+
}
|
656 |
+
?>
|
657 |
+
|
658 |
+
// Toggle excerpt length on click
|
659 |
+
show_excerpt.click(function(){
|
660 |
+
|
661 |
+
if ( $(this).is(":checked") ) {
|
662 |
+
excerpt_length.show("fast");
|
663 |
+
} else {
|
664 |
+
excerpt_length.hide("fast");
|
665 |
+
}
|
666 |
+
|
667 |
+
});
|
668 |
+
|
669 |
+
// Toggle excerpt length on click
|
670 |
+
show_readmore.click(function(){
|
671 |
+
|
672 |
+
if ( $(this).is(":checked") ) {
|
673 |
+
excerpt_readmore.show("fast");
|
674 |
+
} else {
|
675 |
+
excerpt_readmore.hide("fast");
|
676 |
+
}
|
677 |
+
|
678 |
+
});
|
679 |
+
|
680 |
+
// Toggle excerpt length on click
|
681 |
+
show_thumbnail.click(function(){
|
682 |
+
|
683 |
+
if ( $(this).is(":checked") ) {
|
684 |
+
thumb_w.show("fast");
|
685 |
+
thumb_crop.show("fast");
|
686 |
+
} else {
|
687 |
+
thumb_w.hide("fast");
|
688 |
+
thumb_crop.hide("fast");
|
689 |
+
}
|
690 |
|
691 |
+
});
|
692 |
+
|
693 |
+
// Toggle more button on click
|
694 |
+
show_morebutton.click(function(){
|
695 |
|
696 |
+
if ( $(this).is(":checked") ) {
|
697 |
+
morebutton_text.show("fast");
|
698 |
+
morebutton_url.show("fast");
|
699 |
+
} else {
|
700 |
+
morebutton_text.hide("fast");
|
701 |
+
morebutton_url.hide("fast");
|
702 |
+
}
|
703 |
|
704 |
+
});
|
705 |
+
|
706 |
+
});
|
707 |
|
708 |
+
</script>
|
709 |
|
710 |
+
<?php
|
711 |
|
712 |
+
}
|
713 |
|
714 |
+
}
|
715 |
|
716 |
+
}
|
717 |
|
718 |
+
function init_WP_Widget_Ultimate_Posts() {
|
719 |
+
|
720 |
+
register_widget( 'WP_Widget_Ultimate_Posts' );
|
721 |
+
|
722 |
+
}
|
723 |
+
|
724 |
+
add_action( 'widgets_init', 'init_WP_Widget_Ultimate_Posts' );
|
725 |
|
726 |
}
|