Category Posts Widget - Version 1.2.1

Version Description

Download this release

Release Info

Developer ZephyrWest
Plugin Icon 128x128 Category Posts Widget
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2 to 1.2.1

Files changed (2) hide show
  1. cat-posts.php +16 -3
  2. readme.txt +3 -2
cat-posts.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Category Posts Widget
4
  Plugin URI: http://jameslao.com/
5
  Description: Adds a widget that can display a specified number of posts from a single category. Can also set how many widgets to show.
6
  Author: James Lao
7
- Version: 1.2
8
  Author URI: http://jameslao.com/
9
  */
10
 
@@ -13,6 +13,7 @@ function nk_cat_posts_widget($args, $number = 1) {
13
  extract($args);
14
  $options = get_option('widget_cat_posts');
15
  $catID = empty($options[$number]['cat']) ? 1 : $options[$number]['cat'];
 
16
 
17
  // If not title, use the name of the category.
18
  if( empty($options[$number]['title']) ) {
@@ -25,7 +26,15 @@ function nk_cat_posts_widget($args, $number = 1) {
25
  $num = $options[$number]['num'] > 15 ? 15 : $options[$number]['num'];
26
 
27
  echo $before_widget;
28
- echo $before_title . $title . $after_title;
 
 
 
 
 
 
 
 
29
  echo '<ul>';
30
  nk_cat_posts($catID, $num);
31
  echo '</ul>';
@@ -39,6 +48,7 @@ function nk_cat_posts_widget_control($number) {
39
  $newoptions[$number]['title'] = strip_tags(stripslashes($_POST["cat-posts-title-" . $number]));
40
  $newoptions[$number]['cat'] = $_POST["show-cat-id-" . $number];
41
  $newoptions[$number]['num'] = is_numeric($_POST["cat-posts-num-" . $number]) && $_POST["cat-posts-num-" . $number]!=0 ? $_POST["cat-posts-num-" . $number] : 5;
 
42
  }
43
  if ( $options != $newoptions ) {
44
  $options = $newoptions;
@@ -50,6 +60,9 @@ function nk_cat_posts_widget_control($number) {
50
  wp_dropdown_categories(array('name'=>'show-cat-id-' . $number, 'selected'=>$options[$number]['cat']));
51
  echo '</label></p>';
52
  echo '<p><label for="cat-posts-num-' . $number . '">Number of posts to show: <input size="3" id="cat-posts-num-' . $number . '" name="cat-posts-num-' . $number . '" type="text" value="' . $options[$number]['num'] . '" /></label> (max 15)</p>';
 
 
 
53
  }
54
 
55
  // Displays the dialog to set how many widgets.
@@ -91,7 +104,7 @@ function nk_cat_posts_widget_register() {
91
  $num_of_widgets = $options['num_of_widgets'];
92
  if ( $num_of_widgets < 1 ) $num_of_widgets = 1;
93
  if ( $num_of_widgets > 20 ) $num_of_widgets = 20;
94
- $dims = array('width' => 300, 'height' => 150);
95
  $class = array('classname' => 'widget_cat_posts');
96
  for ($i = 1; $i <= 20; $i++) {
97
  $name = sprintf('Category Posts %d', $i);
4
  Plugin URI: http://jameslao.com/
5
  Description: Adds a widget that can display a specified number of posts from a single category. Can also set how many widgets to show.
6
  Author: James Lao
7
+ Version: 1.2.1
8
  Author URI: http://jameslao.com/
9
  */
10
 
13
  extract($args);
14
  $options = get_option('widget_cat_posts');
15
  $catID = empty($options[$number]['cat']) ? 1 : $options[$number]['cat'];
16
+ $titleLink = empty($options[$number]['titleLink']) ? FALSE : $options[$number]['titleLink'];
17
 
18
  // If not title, use the name of the category.
19
  if( empty($options[$number]['title']) ) {
26
  $num = $options[$number]['num'] > 15 ? 15 : $options[$number]['num'];
27
 
28
  echo $before_widget;
29
+ echo $before_title;
30
+
31
+ if( $titleLink ) {
32
+ echo '<a href="' . get_category_link($catID) . '">' . $title . '</a>';
33
+ } else {
34
+ echo $title;
35
+ }
36
+
37
+ echo $after_title;
38
  echo '<ul>';
39
  nk_cat_posts($catID, $num);
40
  echo '</ul>';
48
  $newoptions[$number]['title'] = strip_tags(stripslashes($_POST["cat-posts-title-" . $number]));
49
  $newoptions[$number]['cat'] = $_POST["show-cat-id-" . $number];
50
  $newoptions[$number]['num'] = is_numeric($_POST["cat-posts-num-" . $number]) && $_POST["cat-posts-num-" . $number]!=0 ? $_POST["cat-posts-num-" . $number] : 5;
51
+ $newoptions[$number]['titleLink'] = $_POST["cat-posts-title-link-" . $number] ? TRUE : FALSE;
52
  }
53
  if ( $options != $newoptions ) {
54
  $options = $newoptions;
60
  wp_dropdown_categories(array('name'=>'show-cat-id-' . $number, 'selected'=>$options[$number]['cat']));
61
  echo '</label></p>';
62
  echo '<p><label for="cat-posts-num-' . $number . '">Number of posts to show: <input size="3" id="cat-posts-num-' . $number . '" name="cat-posts-num-' . $number . '" type="text" value="' . $options[$number]['num'] . '" /></label> (max 15)</p>';
63
+
64
+ echo '<p><label for="cat-posts-title-link-' . $number . '">Link widget title to category page? <input name="cat-posts-title-link-' . $number . '" type="checkbox"';
65
+ echo $options[$number]['titleLink'] ? ' checked="checked"></label></p>' : '></label></p>';
66
  }
67
 
68
  // Displays the dialog to set how many widgets.
104
  $num_of_widgets = $options['num_of_widgets'];
105
  if ( $num_of_widgets < 1 ) $num_of_widgets = 1;
106
  if ( $num_of_widgets > 20 ) $num_of_widgets = 20;
107
+ $dims = array('width' => 300, 'height' => 160);
108
  $class = array('classname' => 'widget_cat_posts');
109
  for ($i = 1; $i <= 20; $i++) {
110
  $name = sprintf('Category Posts %d', $i);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: James Lao
3
  Donate link: http://jameslao.com/
4
  Tags: category, posts, widget
5
  Requires at least: 2.2
6
- Tested up to: 2.3
7
- Stable tag: 1.2
8
 
9
  Adds a widget that shows the most recent posts in a single category. You can specify how many posts to show and from which category as well as how many widgets to show.
10
 
@@ -17,6 +17,7 @@ Features:
17
  * Specify how many posts to show
18
  * Set which category the posts should come form
19
  * Designate how many of the widgets you need
 
20
 
21
  == Installation ==
22
 
3
  Donate link: http://jameslao.com/
4
  Tags: category, posts, widget
5
  Requires at least: 2.2
6
+ Tested up to: 2.3.2
7
+ Stable tag: 1.2.1
8
 
9
  Adds a widget that shows the most recent posts in a single category. You can specify how many posts to show and from which category as well as how many widgets to show.
10
 
17
  * Specify how many posts to show
18
  * Set which category the posts should come form
19
  * Designate how many of the widgets you need
20
+ * Specify whether to make to the widget title a link to the category page
21
 
22
  == Installation ==
23