Version Description
Download this release
Release Info
Developer | petervanderdoes |
Plugin | AVH Extended Categories Widgets |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3
- readme.txt +7 -4
- widget_extended_categories.php +180 -125
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Extended Categories Widget ===
|
2 |
-
Contributors: petervanderdoes
|
3 |
Donate link: http://blog.avirtualhome.com/wordpress-plugins/
|
4 |
Tags: extended, categories, widget
|
5 |
Requires at least: 2.3
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Replacement of the category widget to allow for greater customization of the category widget.
|
10 |
|
@@ -18,12 +18,13 @@ Replacement of the category widget to allow for greater customization of the cat
|
|
18 |
* Show categories hierarchical.
|
19 |
* Sort by ID, Name,Count.
|
20 |
* Sort ascending or descending.
|
|
|
21 |
|
22 |
== Installation ==
|
23 |
|
24 |
The Extended Categories Widget can be installed in 3 easy steps:
|
25 |
|
26 |
-
1. Unzip
|
27 |
|
28 |
1. Activate the plugin
|
29 |
|
@@ -39,6 +40,8 @@ I created a support site at http://forums.avirtualhome.com where you can ask que
|
|
39 |
None
|
40 |
|
41 |
== Arbitrary section ==
|
|
|
|
|
42 |
* Version 1.2
|
43 |
* When no category or an empty category is selected the dropdown menu shows Select Category, like the default category widget.
|
44 |
* Version 1.1
|
1 |
=== Extended Categories Widget ===
|
2 |
+
Contributors: petervanderdoes, datafeedr.com
|
3 |
Donate link: http://blog.avirtualhome.com/wordpress-plugins/
|
4 |
Tags: extended, categories, widget
|
5 |
Requires at least: 2.3
|
6 |
+
Tested up to: 2.6
|
7 |
+
Stable tag: 1.3
|
8 |
|
9 |
Replacement of the category widget to allow for greater customization of the category widget.
|
10 |
|
18 |
* Show categories hierarchical.
|
19 |
* Sort by ID, Name,Count.
|
20 |
* Sort ascending or descending.
|
21 |
+
* Select which categories to show. (Requires WordPress 2.5.1 or higher)
|
22 |
|
23 |
== Installation ==
|
24 |
|
25 |
The Extended Categories Widget can be installed in 3 easy steps:
|
26 |
|
27 |
+
1. Unzip the extended-categories-widget archive and put the directory "extended-categories-widget" into your "plugins" folder (wp-content/plugins/).
|
28 |
|
29 |
1. Activate the plugin
|
30 |
|
40 |
None
|
41 |
|
42 |
== Arbitrary section ==
|
43 |
+
* Version 1.3
|
44 |
+
* You can select which categories to show (Requires WordPress 2.5.1 or higher).
|
45 |
* Version 1.2
|
46 |
* When no category or an empty category is selected the dropdown menu shows Select Category, like the default category widget.
|
47 |
* Version 1.1
|
widget_extended_categories.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Extended Category Widget
|
4 |
Plugin URI: http://blog.avirtualhome.com/wordpress-plugins
|
5 |
Description: Replacement of the category widget to allow for greater customization of the category widget.
|
6 |
-
Version: 1.
|
7 |
Author: Peter van der Does
|
8 |
Author URI: http://blog.avirtualhome.com/
|
9 |
|
@@ -25,137 +25,192 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25 |
*/
|
26 |
|
27 |
function widget_extended_categories_init() {
|
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 |
var dropdown = document.getElementById("cat");
|
55 |
function onCatChange() {
|
56 |
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
|
57 |
-
location.href = "<?php
|
|
|
|
|
58 |
}
|
59 |
}
|
60 |
dropdown.onchange = onCatChange;
|
61 |
--></script>
|
62 |
<?php
|
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 |
-
add_action('plugins_loaded', 'widget_extended_categories_init');
|
161 |
?>
|
3 |
Plugin Name: Extended Category Widget
|
4 |
Plugin URI: http://blog.avirtualhome.com/wordpress-plugins
|
5 |
Description: Replacement of the category widget to allow for greater customization of the category widget.
|
6 |
+
Version: 1.3
|
7 |
Author: Peter van der Does
|
8 |
Author URI: http://blog.avirtualhome.com/
|
9 |
|
25 |
*/
|
26 |
|
27 |
function widget_extended_categories_init() {
|
28 |
+
// Widgets exists?
|
29 |
+
if (! function_exists ( 'wp_register_sidebar_widget' ) || ! function_exists ( 'wp_register_widget_control' )) {
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
|
33 |
+
function widget_extended_categories($args) {
|
34 |
+
// Check for version
|
35 |
+
global $wp_version;
|
36 |
+
if ( version_compare($wp_version, '2.5.1', '<') ) {
|
37 |
+
$avh_extcat_canselectcats=false;
|
38 |
+
} else {
|
39 |
+
$avh_extcat_canselectcats=true;
|
40 |
+
}
|
41 |
+
extract ( $args );
|
42 |
+
$options = get_option ( 'widget_extended_categories' );
|
43 |
+
$c = $options ['count'] ? '1' : '0';
|
44 |
+
$h = $options ['hierarchical'] ? '1' : '0';
|
45 |
+
$e = $options ['hide_empty'] ? '1' : '0';
|
46 |
+
$s = $options ['sort_column'] ? $options ['sort_column'] : 'name';
|
47 |
+
$o = $options ['sort_order'] ? $options ['sort_order'] : 'asc';
|
48 |
+
$title = empty ( $options ['title'] ) ? __ ( 'Categories' ) : $options ['title'];
|
49 |
+
$style = empty ( $options ['style'] ) ? 'list' : $options ['style'];
|
50 |
+
if ($avh_extcat_canselectcats) {
|
51 |
+
if ($options ['post_category']) {
|
52 |
+
$post_category = unserialize ( $options ['post_category'] );
|
53 |
+
$included_cats = implode ( ",", $post_category );
|
54 |
+
}
|
55 |
+
$cat_args = array ('include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => __ ( 'Select Category' ) );
|
56 |
+
} else {
|
57 |
+
$cat_args = array ('orderby' => $s, 'order' => $o, 'show_count' => $c, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => __ ( 'Select Category' ) );
|
58 |
+
}
|
59 |
+
echo $before_widget;
|
60 |
+
echo '<!-- AVH Extended Categories | http://blog.avirtualhome.com/wordpress-plugins/ -->';
|
61 |
+
echo $before_title . $title . $after_title;
|
62 |
+
echo '<ul>';
|
63 |
+
|
64 |
+
if ($style == 'list') {
|
65 |
+
wp_list_categories ( $cat_args );
|
66 |
+
} else {
|
67 |
+
wp_dropdown_categories ( $cat_args );
|
68 |
+
?>
|
69 |
+
<script lang='javascript'><!--
|
70 |
var dropdown = document.getElementById("cat");
|
71 |
function onCatChange() {
|
72 |
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
|
73 |
+
location.href = "<?php
|
74 |
+
echo get_option ( 'home' );
|
75 |
+
?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
|
76 |
}
|
77 |
}
|
78 |
dropdown.onchange = onCatChange;
|
79 |
--></script>
|
80 |
<?php
|
81 |
+
}
|
82 |
+
echo '</ul>';
|
83 |
+
echo $after_widget;
|
84 |
+
}
|
85 |
+
|
86 |
+
function widget_extended_categories_control() {
|
87 |
+
// Check for version
|
88 |
+
global $wp_version;
|
89 |
+
if ( version_compare($wp_version, '2.5.1', '<') ) {
|
90 |
+
$avh_extcat_canselectcats=false;
|
91 |
+
} else {
|
92 |
+
$avh_extcat_canselectcats=true;
|
93 |
+
}
|
94 |
+
// Get actual options
|
95 |
+
$options = $newoptions = get_option ( 'widget_extended_categories' );
|
96 |
+
if (! is_array ( $options )) {
|
97 |
+
$options = $newoptions = array ( );
|
98 |
+
}
|
99 |
+
|
100 |
+
// Post to new options array
|
101 |
+
if ($_POST ['categories-submit']) {
|
102 |
+
$newoptions ['title'] = strip_tags ( stripslashes ( $_POST ['categories-title'] ) );
|
103 |
+
$newoptions ['count'] = isset ( $_POST ['categories-count'] );
|
104 |
+
$newoptions ['hierarchical'] = isset ( $_POST ['categories-hierarchical'] );
|
105 |
+
$newoptions ['hide_empty'] = isset ( $_POST ['categories-hide_empty'] );
|
106 |
+
$newoptions ['sort_column'] = strip_tags ( stripslashes ( $_POST ['categories-sort_column'] ) );
|
107 |
+
$newoptions ['sort_order'] = strip_tags ( stripslashes ( $_POST ['categories-sort_order'] ) );
|
108 |
+
$newoptions ['style'] = strip_tags ( stripslashes ( $_POST ['categories-style'] ) );
|
109 |
+
if ($avh_extcat_canselectcats) {
|
110 |
+
if (in_array ( '-1', $_POST ['post_category'], true )) {
|
111 |
+
$newoptions ['post_category'] = false;
|
112 |
+
} else {
|
113 |
+
$newoptions ['post_category'] = serialize ( $_POST ['post_category'] );
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
// Update if new options
|
120 |
+
if ($options != $newoptions) {
|
121 |
+
$options = $newoptions;
|
122 |
+
update_option ( 'widget_extended_categories', $options );
|
123 |
+
}
|
124 |
+
|
125 |
+
// Prepare data for display
|
126 |
+
$title = htmlspecialchars ( $options ['title'], ENT_QUOTES );
|
127 |
+
$count = $options ['count'] ? 'checked="checked"' : '';
|
128 |
+
$hierarchical = $options ['hierarchical'] ? 'checked="checked"' : '';
|
129 |
+
$hide_empty = $options ['hide_empty'] ? 'checked="checked"' : '';
|
130 |
+
$sort_id = ($options ['sort_column'] == 'ID') ? ' SELECTED' : '';
|
131 |
+
$sort_name = ($options ['sort_column'] == 'name') ? ' SELECTED' : '';
|
132 |
+
$sort_count = ($options ['sort_column'] == 'count') ? ' SELECTED' : '';
|
133 |
+
$sort_order_a = ($options ['sort_order'] == 'asc') ? ' SELECTED' : '';
|
134 |
+
$sort_order_d = ($options ['sort_order'] == 'desc') ? ' SELECTED' : '';
|
135 |
+
$style_list = ($options ['style'] == 'list') ? ' SELECTED' : '';
|
136 |
+
$style_drop = ($options ['style'] == 'drop') ? ' SELECTED' : '';
|
137 |
+
if ($avh_extcat_canselectcats) {
|
138 |
+
$selected_cats = ($options ['post_category'] != '') ? unserialize ( $options ['post_category'] ) : false;
|
139 |
+
}
|
140 |
+
?>
|
141 |
+
<div>
|
142 |
+
<label for="categories-title"><?php _e ( 'Title:' ); ?>
|
143 |
+
<input style="width: 250px;" id="categories-title" name="categories-title" type="text" value="<?php echo $title; ?>" />
|
144 |
+
</label>
|
145 |
+
<label for="categories-count" style="line-height: 35px; display: block;">Show post counts <input class="checkbox" type="checkbox" <?php echo $count;
|
146 |
+
?>
|
147 |
+
id="categories-count" name="categories-count" /> </label> <label
|
148 |
+
for="categories-hierarchical"
|
149 |
+
style="line-height: 35px; display: block;">Show hierarchy <input
|
150 |
+
class="checkbox" type="checkbox" <?php
|
151 |
+
echo $hierarchical;
|
152 |
+
?>
|
153 |
+
id="categories-hierarchical" name="categories-hierarchical" /> </label>
|
154 |
+
|
155 |
+
<label for="categories-hide_empty"
|
156 |
+
style="line-height: 35px; display: block;">Hide empty categories <input
|
157 |
+
class="checkbox" type="checkbox" <?php
|
158 |
+
echo $hide_empty;
|
159 |
+
?>
|
160 |
+
id="categories-hide_empty" name="categories-hide_empty" /> </label> <label
|
161 |
+
for="categories-sort_column" style="line-height: 35px; display: block;">Sort
|
162 |
+
by <select id="categories-sort_column" name="categories-sort_column">
|
163 |
+
<option value="ID" <?php
|
164 |
+
echo $sort_id?>>ID</option>
|
165 |
+
<option value="name" <?php
|
166 |
+
echo $sort_name?>>Name</option>
|
167 |
+
<option value="count" <?php
|
168 |
+
echo $sort_count?>>Count</option>
|
169 |
+
</select> </label> <label for="categories-sort_order"
|
170 |
+
style="line-height: 35px; display: block;">Sort order <select
|
171 |
+
id="categories-sort_order" name="categories-sort_order">
|
172 |
+
<option value="asc" <?php
|
173 |
+
echo $sort_order_a?>>Ascending</option>
|
174 |
+
<option value="desc" <?php
|
175 |
+
echo $sort_order_d?>>Descending</option>
|
176 |
+
</select> </label> <label for="categories-style"
|
177 |
+
style="line-height: 35px; display: block;">Display style <select
|
178 |
+
id="categories-style" name="categories-style">
|
179 |
+
<option value='list' <?php
|
180 |
+
echo $style_list;
|
181 |
+
?>>List</option>
|
182 |
+
<option value='drop' <?php
|
183 |
+
echo $style_drop;
|
184 |
+
?>>Drop down</option>
|
185 |
+
</select> </label>
|
186 |
+
<?php
|
187 |
+
if ($avh_extcat_canselectcats) {
|
188 |
+
echo ' <b>Include these categories</b><hr />';
|
189 |
+
echo ' <ul id="categorychecklist" class="list:category categorychecklist form-no-clear" style="list-style-type: none; margin-left: 5px; padding-left: 0px; margin-bottom: 20px;">';
|
190 |
+
echo ' <li id="category--1" class="popular-category">';
|
191 |
+
echo ' <label for="in-category--1" class="selectit">';
|
192 |
+
echo ' <input value="-1" name="post_category[]" id="in-category--1" type="checkbox"';
|
193 |
+
if (!$selected_cats) { echo 'checked'; }
|
194 |
+
echo '> Include All Categories';
|
195 |
+
echo ' </label>';
|
196 |
+
echo ' </li>';
|
197 |
+
wp_category_checklist(0,0,$selected_cats);
|
198 |
+
echo ' </ul>';
|
199 |
+
}
|
200 |
+
?>
|
201 |
+
|
202 |
+
<input type="hidden" id="categories-submit" name="categories-submit"
|
203 |
+
value="1" /></div>
|
204 |
+
<?php
|
205 |
+
}
|
206 |
+
|
207 |
+
function widget_extended_categories_register() {
|
208 |
+
wp_register_sidebar_widget ( 'extended-categories', 'Extended Categories', 'widget_extended_categories' );
|
209 |
+
wp_register_widget_control ( 'extended-categories', 'Extended Categories', 'widget_extended_categories_control', array ('width' => 300, 'height' => 245 ) );
|
210 |
+
}
|
211 |
+
|
212 |
+
// Launch Widgets
|
213 |
+
widget_extended_categories_register ();
|
214 |
}
|
215 |
+
add_action ( 'plugins_loaded', 'widget_extended_categories_init' );
|
216 |
?>
|