forked from tiptoppress/category-posts-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcat-posts.php
593 lines (542 loc) · 23.2 KB
/
cat-posts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
<?php
/*
Plugin Name: Category Posts Widget
Plugin URI: http://mkrdip.me/category-posts-widget
Description: Adds a widget that shows the most recent posts from a single category.
Author: Mrinal Kanti Roy
Version: 4.1.5
Author URI: http://mkrdip.me
*/
// Don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
/*
Check if CSS needs to be enqueued by traversing all active widgets on the page
and checking if they all have disabled CSS.
Return: false if CSS should not be enqueued, true if it should
*/
function category_posts_should_enqueue($id_base,$class) {
global $wp_registered_widgets;
$ret = false;
$sidebars_widgets = wp_get_sidebars_widgets();
if ( is_array($sidebars_widgets) ) {
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) {
continue;
}
if ( is_array($widgets) ) {
foreach ( $widgets as $widget ) {
$widget_base = _get_widget_id_base($widget);
if ( $widget_base == $id_base ) {
$widgetclass = new $class();
$allsettings = $widgetclass->get_settings();
$settings = $allsettings[str_replace($widget_base.'-','',$widget)];
if (!isset($settings['disable_css'])) // checks if css disable is not set
$ret = true;
}
}
}
}
}
return $ret;
}
/**
* Register our styles
*
* @return void
*/
add_action( 'wp_enqueue_scripts', 'category_posts_widget_styles' );
function category_posts_widget_styles() {
$enqueue = category_posts_should_enqueue('category-posts','CategoryPosts');
if ($enqueue) {
wp_register_style( 'category-posts', plugins_url( 'category-posts/cat-posts.css' ) );
wp_enqueue_style( 'category-posts' );
}
}
/**
* Load plugin textdomain.
*
*/
add_action( 'admin_init', 'category_posts_load_textdomain' );
function category_posts_load_textdomain() {
load_plugin_textdomain( 'categoryposts', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
/**
* Add styles for widget sections
*
*/
add_action( 'admin_print_styles-widgets.php', 'category_posts_admin_styles' );
function category_posts_admin_styles() {
?>
<style>
.category-widget-cont h4 {
padding: 12px 15px;
cursor: pointer;
margin: 5px 0;
border: 1px solid #E5E5E5;
}
.category-widget-cont h4:first-child {
margin-top: 10px;
}
.category-widget-cont h4:last-of-type {
margin-bottom: 10px;
}
.category-widget-cont h4:after {
float:right;
font-family: "dashicons";
content: '\f140';
-ms-transform: translate(-1px,1px);
-webkit-transform: translate(-1px,1px);
-moz-transform: translate(-1px,1px);
transform: translate(-1px,1px);
-ms-transition: all 600ms;
-webkit-transition: all 600ms;
-moz-transition: all 600ms;
transition: all 600ms;
}
.category-widget-cont h4.open:after {
-ms-transition: all 600ms;
-webkit-transition: all 600ms;
-moz-transition: all 600ms;
transition: all 600ms;
-ms-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);
}
.category-widget-cont div {
display:none;
overflow: hidden;
}
.category-widget-cont div.open {
display:block;
}
</style>
<?php
}
/**
* Add JS to control open and close the widget section
*
*/
add_action( 'admin_enqueue_scripts', 'category_posts_admin_scripts', 100 );
function category_posts_admin_scripts() {
// widget script
wp_register_script( 'category-posts-admin-js', plugins_url( 'category-posts/js/admin/category-posts-widget.js' ),array('jquery'),'4.1.2',true );
wp_enqueue_script( 'category-posts-admin-js' );
}
/**
* Category Posts Widget Class
*
* Shows the single category posts with some configurable options
*/
class CategoryPosts extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'cat-post-widget', 'description' => __('List single category posts','categoryposts'));
parent::__construct('category-posts', __('Category Posts','categoryposts'), $widget_ops);
}
// Displays category posts widget on blog.
function widget($args, $instance) {
extract( $args );
// If not title, use the name of the category.
if( !$instance["title"] ) {
$category_info = get_category($instance["cat"]);
$instance["title"] = $category_info->name;
}
$valid_sort_orders = array('date', 'title', 'comment_count', 'rand');
if ( in_array($instance['sort_by'], $valid_sort_orders) ) {
$sort_by = $instance['sort_by'];
$sort_order = (bool) isset( $instance['asc_sort_order'] ) ? 'ASC' : 'DESC';
} else {
// by default, display latest first
$sort_by = 'date';
$sort_order = 'DESC';
}
// Exclude current post
$current_post_id = get_the_ID();
$exclude_current_post = (isset( $instance['exclude_current_post'] ) && $instance['exclude_current_post'] != -1) ? $current_post_id : "";
// Get array of post info.
$args = array(
'showposts' => $instance["num"],
'cat' => $instance["cat"],
'post__not_in' => array( $exclude_current_post ),
'orderby' => $sort_by,
'order' => $sort_order
);
if( isset( $instance['hideNoThumb'] ) ) {
$args = array_merge( $args, array( 'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS' )
)
)
);
}
$cat_posts = new WP_Query( $args );
if ( !isset ( $instance["hide_if_empty"] ) || $cat_posts->have_posts() ) {
// Excerpt length filter
$new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
if ( $instance["excerpt_length"] > 0 )
add_filter('excerpt_length', $new_excerpt_length);
// Excerpt more link filter
function new_excerpt_more($more) {
global $post, $new_excerpt_more_text;
return ' <a class="cat-post-excerpt-more" href="'. get_permalink($post->ID) . '">' . $new_excerpt_more_text . '</a>';
}
if( isset($instance["excerpt_more_text"]) && ltrim($instance["excerpt_more_text"]) != '' )
{
global $new_excerpt_more_text;
$new_excerpt_more_text = $instance["excerpt_more_text"];
add_filter('excerpt_more', 'new_excerpt_more');
}
echo $before_widget;
// Widget title
if( !isset ( $instance["hide_title"] ) ) {
echo $before_title;
if( isset ( $instance["title_link"] ) ) {
echo '<a href="' . get_category_link($instance["cat"]) . '">' . apply_filters( 'widget_title', $instance["title"] ) . '</a>';
} else {
echo apply_filters( 'widget_title', $instance["title"] );
}
echo $after_title;
}
// Post list
echo "<ul>\n";
while ( $cat_posts->have_posts() )
{
$cat_posts->the_post(); ?>
<li <?php if( !isset( $instance['disable_css'] ) ) {
if ( is_single(get_the_title() )) {
echo "class='cat-post-item cat-post-current'";
} else {
echo "class='cat-post-item'";
}
} ?> >
<?php
if( isset( $instance["thumbTop"] ) ) :
if ( current_theme_supports("post-thumbnails") &&
isset( $instance["thumb"] ) &&
has_post_thumbnail() ) : ?>
<a <?php if( !isset( $instance['disable_css'] )) {
if( isset($instance['thumb_hover'] )) {
echo "class=\"cat-post-thumbnail cat-post-" . $instance['thumb_hover'] . "\"";
} else {
echo "class=\"cat-post-thumbnail\"";
}
} ?>
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail( array($instance['thumb_w'],$instance['thumb_h'])); ?>
</a>
<?php endif;
endif; ?>
<a class="post-title <?php if( !isset( $instance['disable_css'] ) ) { echo " cat-post-title"; } ?>"
href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
</a>
<?php if ( isset( $instance['date'] ) ) : ?>
<?php if ( isset( $instance['date_format'] ) && strlen( trim( $instance['date_format'] ) ) > 0 ) { $date_format = $instance['date_format']; } else { $date_format = "j M Y"; } ?>
<p class="post-date <?php if( !isset( $instance['disable_css'] ) ) { echo "cat-post-date"; } ?>">
<?php if( isset ( $instance["date_link"] ) ) { ?> <a href="<?php the_permalink(); ?>"><?php } ?>
<?php the_time($date_format); ?>
<?php if( isset ( $instance["date_link"] ) ) { echo "</a>"; } ?>
</p>
<?php endif;
if( !isset( $instance["thumbTop"] ) ) :
if ( current_theme_supports("post-thumbnails") &&
isset( $instance["thumb"] ) &&
has_post_thumbnail() ) : ?>
<a <?php if( !isset( $instance['disable_css'] )) {
if( isset($instance['thumb_hover'] )) {
echo "class=\"cat-post-thumbnail cat-post-" . $instance['thumb_hover'] . "\"";
} else {
echo "class=\"cat-post-thumbnail\"";
}
} ?>
href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail( array($instance['thumb_w'],$instance['thumb_h'])); ?>
</a>
<?php endif;
endif;
if ( isset( $instance['excerpt'] ) ) :
the_excerpt();
endif;
if ( isset( $instance['comment_num'] ) ) : ?>
<p class="comment-num <?php if( !isset( $instance['disable_css'] ) ) { echo "cat-post-comment-num"; } ?>">
(<?php comments_number(); ?>)
</p>
<?php endif;
if ( isset( $instance['author'] ) ) : ?>
<p class="post-author <?php if( !isset( $instance['disable_css'] ) ) { echo "cat-post-author"; } ?>">
<?php the_author_posts_link(); ?>
</p>
<?php endif; ?>
</li>
<?php
}
echo "</ul>\n";
// Footer link to category page
if( isset ( $instance["footer_link"] ) && $instance["footer_link"] ) {
echo "<a";
if( !isset( $instance['disable_css'] ) ) { echo " class=\"cat-post-footer-link\""; }
echo " href=\"" . get_category_link($instance["cat"]) . "\">" . $instance["footer_link"] . "</a>";
}
echo $after_widget;
remove_filter('excerpt_length', $new_excerpt_length);
wp_reset_postdata();
} // END if
} // END function
/**
* Update the options
*
* @param array $new_instance
* @param array $old_instance
* @return array
*/
function update($new_instance, $old_instance) {
return $new_instance;
}
/**
* The widget configuration form back end.
*
* @param array $instance
* @return void
*/
function form($instance) {
$instance = wp_parse_args( ( array ) $instance, array(
'title' => '',
'hide_title' => '',
'cat' => '',
'num' => '',
'sort_by' => '',
'asc_sort_order' => '',
'exclude_current_post' => '',
'title_link' => '',
'footer_link' => '',
'excerpt' => '',
'excerpt_length' => '',
'excerpt_more_text' => '',
'comment_num' => '',
'author' => '',
'date' => '',
'date_link' => '',
'date_format' => '',
'thumb' => '',
'thumbTop' => '',
'hideNoThumb' => '',
'thumb_w' => '',
'thumb_h' => '',
'thumb_hover' => '',
'disable_css' => '',
'hide_if_empty' => ''
) );
$title = $instance['title'];
$hide_title = $instance['hide_title'];
$cat = $instance['cat'];
$num = $instance['num'];
$sort_by = $instance['sort_by'];
$asc_sort_order = $instance['asc_sort_order'];
$exclude_current_post = $instance['exclude_current_post'];
$title_link = $instance['title_link'];
$footer_link = $instance['footer_link'];
$excerpt = $instance['excerpt'];
$excerpt_length = $instance['excerpt_length'];
$excerpt_more_text = $instance['excerpt_more_text'];
$comment_num = $instance['comment_num'];
$author = $instance['author'];
$date = $instance['date'];
$date_link = $instance['date_link'];
$date_format = $instance['date_format'];
$thumb = $instance['thumb'];
$thumbTop = $instance['thumbTop'];
$hideNoThumb = $instance['hideNoThumb'];
$thumb_w = $instance['thumb_w'];
$thumb_h = $instance['thumb_h'];
$thumb_hover = $instance['thumb_hover'];
$disable_css = $instance['disable_css'];
$hide_if_empty = $instance['hide_if_empty'];
?>
<div class="category-widget-cont">
<h4 class="open"><?php _e('Filter','categoryposts');?></h4>
<div class="open">
<p>
<label>
<?php _e( 'Category','categoryposts' ); ?>:
<?php wp_dropdown_categories( array( 'hide_empty'=> 0, 'name' => $this->get_field_name("cat"), 'selected' => $instance["cat"] ) ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("num"); ?>">
<?php _e('Number of posts to show','categoryposts'); ?>:
<input style="text-align: center; width: 30%;" id="<?php echo $this->get_field_id("num"); ?>" name="<?php echo $this->get_field_name("num"); ?>" type="number" min="0" value="<?php echo absint($instance["num"]); ?>" />
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("sort_by"); ?>">
<?php _e('Sort by','categoryposts'); ?>:
<select id="<?php echo $this->get_field_id("sort_by"); ?>" name="<?php echo $this->get_field_name("sort_by"); ?>">
<option value="date"<?php selected( $instance["sort_by"], "date" ); ?>><?php _e('Date','categoryposts')?></option>
<option value="title"<?php selected( $instance["sort_by"], "title" ); ?>><?php _e('Title','categoryposts')?></option>
<option value="comment_count"<?php selected( $instance["sort_by"], "comment_count" ); ?>><?php _e('Number of comments','categoryposts')?></option>
<option value="rand"<?php selected( $instance["sort_by"], "rand" ); ?>><?php _e('Random','categoryposts')?></option>
</select>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("asc_sort_order"); ?>">
<input type="checkbox" class="checkbox"
id="<?php echo $this->get_field_id("asc_sort_order"); ?>"
name="<?php echo $this->get_field_name("asc_sort_order"); ?>"
<?php checked( (bool) $instance["asc_sort_order"], true ); ?> />
<?php _e( 'Reverse sort order (ascending)','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("exclude_current_post"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("exclude_current_post"); ?>" name="<?php echo $this->get_field_name("exclude_current_post"); ?>"<?php checked( (bool) $instance["exclude_current_post"], true ); ?> />
<?php _e( 'Exclude current post','categoryposts' ); ?>
</label>
</p>
</div>
<h4><?php _e('Title','categoryposts')?></h4>
<div>
<p>
<label for="<?php echo $this->get_field_id("title"); ?>">
<?php _e( 'Title','categoryposts' ); ?>:
<input class="widefat" style="width:80%;" id="<?php echo $this->get_field_id("title"); ?>" name="<?php echo $this->get_field_name("title"); ?>" type="text" value="<?php echo esc_attr($instance["title"]); ?>" />
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("title_link"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("title_link"); ?>" name="<?php echo $this->get_field_name("title_link"); ?>"<?php checked( (bool) $instance["title_link"], true ); ?> />
<?php _e( 'Make widget title link','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("hide_title"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("hide_title"); ?>" name="<?php echo $this->get_field_name("hide_title"); ?>"<?php checked( (bool) $instance["hide_title"], true ); ?> />
<?php _e( 'Hide title','categoryposts' ); ?>
</label>
</p>
</div>
<?php if ( current_theme_supports("post-thumbnails") ) : ?>
<h4><?php _e('Thumbnails','categoryposts')?></h4>
<div>
<p>
<label for="<?php echo $this->get_field_id("thumb"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("thumb"); ?>" name="<?php echo $this->get_field_name("thumb"); ?>"<?php checked( (bool) $instance["thumb"], true ); ?> />
<?php _e( 'Show post thumbnail','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("hideNoThumb"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("hideNoThumb"); ?>" name="<?php echo $this->get_field_name("hideNoThumb"); ?>"<?php checked( (bool) $instance["hideNoThumb"], true ); ?> />
<?php _e( 'Hide posts which have no thumbnail','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("thumbTop"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("thumbTop"); ?>" name="<?php echo $this->get_field_name("thumbTop"); ?>"<?php checked( (bool) $instance["thumbTop"], true ); ?> />
<?php _e( 'Thumbnail to top','categoryposts' ); ?>
</label>
</p>
<p>
<label>
<?php _e('Thumbnail dimensions (in pixels)','categoryposts'); ?>:<br />
<label for="<?php echo $this->get_field_id("thumb_w"); ?>">
<?php _e('Width:','categoryposts')?> <input class="widefat" style="width:30%;" type="number" min="1" id="<?php echo $this->get_field_id("thumb_w"); ?>" name="<?php echo $this->get_field_name("thumb_w"); ?>" value="<?php echo $instance["thumb_w"]; ?>" />
</label>
<label for="<?php echo $this->get_field_id("thumb_h"); ?>">
<?php _e('Height:','categoryposts')?> <input class="widefat" style="width:30%;" type="number" min="1" id="<?php echo $this->get_field_id("thumb_h"); ?>" name="<?php echo $this->get_field_name("thumb_h"); ?>" value="<?php echo $instance["thumb_h"]; ?>" />
</label>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("thumb_hover"); ?>">
<?php _e( 'Mouse hover effect:','categorypostspro' ); ?>
</label>
<select id="<?php echo $this->get_field_id("thumb_hover"); ?>" name="<?php echo $this->get_field_name("thumb_hover"); ?>">
<option value="none" <?php selected($thumb_hover, 'none')?>><?php _e( 'None', 'categorypostspro' ); ?></option>
<option value="dark" <?php selected($thumb_hover, 'dark')?>><?php _e( 'Dark', 'categorypostspro' ); ?></option>
<option value="white" <?php selected($thumb_hover, 'white')?>><?php _e( 'White', 'categorypostspro' ); ?></option>
<option value="scale" <?php selected($thumb_hover, 'scale')?>><?php _e( 'Scale', 'categorypostspro' ); ?></option>
</select>
</p>
</div>
<?php endif; ?>
<h4><?php _e('Post details','categoryposts')?></h4>
<div>
<p>
<label for="<?php echo $this->get_field_id("excerpt"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("excerpt"); ?>" name="<?php echo $this->get_field_name("excerpt"); ?>"<?php checked( (bool) $instance["excerpt"], true ); ?> />
<?php _e( 'Show post excerpt','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("excerpt_length"); ?>">
<?php _e( 'Excerpt length (in words):','categoryposts' ); ?>
</label>
<input style="text-align: center; width:30%;" type="number" min="0" id="<?php echo $this->get_field_id("excerpt_length"); ?>" name="<?php echo $this->get_field_name("excerpt_length"); ?>" value="<?php echo $instance["excerpt_length"]; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("excerpt_more_text"); ?>">
<?php _e( 'Excerpt \'more\' text:','categoryposts' ); ?>
</label>
<input class="widefat" style="width:55%;" placeholder="<?php _e('... more','categoryposts')?>" id="<?php echo $this->get_field_id("excerpt_more_text"); ?>" name="<?php echo $this->get_field_name("excerpt_more_text"); ?>" type="text" value="<?php echo $instance["excerpt_more_text"]; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("date"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date"); ?>" name="<?php echo $this->get_field_name("date"); ?>"<?php checked( (bool) $instance["date"], true ); ?> />
<?php _e( 'Show post date','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date_format"); ?>">
<?php _e( 'Date format:','categoryposts' ); ?>
</label>
<input class="text" placeholder="j M Y" id="<?php echo $this->get_field_id("date_format"); ?>" name="<?php echo $this->get_field_name("date_format"); ?>" type="text" value="<?php echo esc_attr($instance["date_format"]); ?>" size="8" />
</p>
<p>
<label for="<?php echo $this->get_field_id("date_link"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date_link"); ?>" name="<?php echo $this->get_field_name("date_link"); ?>"<?php checked( (bool) $instance["date_link"], true ); ?> />
<?php _e( 'Make widget date link','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num"); ?>" name="<?php echo $this->get_field_name("comment_num"); ?>"<?php checked( (bool) $instance["comment_num"], true ); ?> />
<?php _e( 'Show number of comments','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("author"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("author"); ?>" name="<?php echo $this->get_field_name("author"); ?>"<?php checked( (bool) $instance["author"], true ); ?> />
<?php _e( 'Show post author','categoryposts' ); ?>
</label>
</p>
</div>
<h4><?php _e('Footer','categoryposts')?></h4>
<div>
<p>
<label for="<?php echo $this->get_field_id("footer_link"); ?>">
<?php _e( 'Footer link text','categoryposts' ); ?>:
<input class="widefat" style="width:60%;" placeholder="<?php _e('... more by this topic','categoryposts')?>" id="<?php echo $this->get_field_id("footer_link"); ?>" name="<?php echo $this->get_field_name("footer_link"); ?>" type="text" value="<?php echo esc_attr($instance["footer_link"]); ?>" />
</label>
</p>
</div>
<h4><?php _e('General styling','categoryposts')?></h4>
<div>
<p>
<label for="<?php echo $this->get_field_id("disable_css"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("disable_css"); ?>" name="<?php echo $this->get_field_name("disable_css"); ?>"<?php checked( (bool) $instance["disable_css"], true ); ?> />
<?php _e( 'Disable widget CSS','categoryposts' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("hide_if_empty"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("hide_if_empty"); ?>" name="<?php echo $this->get_field_name("hide_if_empty"); ?>"<?php checked( (bool) $instance["hide_if_empty"], true ); ?> />
<?php _e( 'Hide if empty','categoryposts' ); ?>
</label>
</p>
</div>
</div>
<?php
}
}
add_action( 'widgets_init', create_function('', 'return register_widget("CategoryPosts");') );