Version Description
Download this release
Release Info
Developer | petervanderdoes |
Plugin | AVH Extended Categories Widgets |
Version | 1.2 |
Comparing to | |
See all releases |
Version 1.2
- readme.txt +47 -0
- widget_extended_categories.php +161 -0
readme.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.5
|
7 |
+
Stable tag: 1.2
|
8 |
+
|
9 |
+
Replacement of the category widget to allow for greater customization of the category widget.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Replacement of the category widget to allow for greater customization of the category widget. The following options have been implemented:
|
14 |
+
|
15 |
+
* Display as List or Dropdown
|
16 |
+
* Show number of posts (Count) after the category
|
17 |
+
* Hide empty categories
|
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 "Extended Categories" archive and put the directory "extended-categories" into your "plugins" folder (wp-content/plugins/).
|
27 |
+
|
28 |
+
1. Activate the plugin
|
29 |
+
|
30 |
+
1. Go to the Presentation->Widgets page and drag the widget into the sidebar of your choice. Configuration of the widget is done like all other widgets.
|
31 |
+
|
32 |
+
|
33 |
+
== Frequently Asked Questions ==
|
34 |
+
|
35 |
+
= What about support? =
|
36 |
+
I created a support site at http://forums.avirtualhome.com where you can ask questions or request features.
|
37 |
+
|
38 |
+
== Screenshots ==
|
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
|
45 |
+
* Dropdown menu didn't work. Page wasn't refreshed with selected category.
|
46 |
+
* Version 1.0
|
47 |
+
* Initial version
|
widget_extended_categories.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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.2
|
7 |
+
Author: Peter van der Does
|
8 |
+
Author URI: http://blog.avirtualhome.com/
|
9 |
+
|
10 |
+
Copyright 2008 Peter van der Does (email : peter@avirtualhome.com)
|
11 |
+
|
12 |
+
This program is free software; you can redistribute it and/or modify
|
13 |
+
it under the terms of the GNU General Public License as published by
|
14 |
+
the Free Software Foundation; either version 2 of the License, or
|
15 |
+
(at your option) any later version.
|
16 |
+
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
|
22 |
+
You should have received a copy of the GNU General Public License
|
23 |
+
along with this program; if not, write to the Free Software
|
24 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
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 |
+
extract($args);
|
35 |
+
$options = get_option('widget_extended_categories');
|
36 |
+
$c = $options['count'] ? '1' : '0';
|
37 |
+
$h = $options['hierarchical'] ? '1' : '0';
|
38 |
+
$e = $options['hide_empty'] ? '1' : '0';
|
39 |
+
$s = $options['sort_column'] ? $options['sort_column'] : 'name';
|
40 |
+
$o = $options['sort_order'] ? $options['sort_order'] : 'asc';
|
41 |
+
$title = empty($options['title']) ? __('Categories') : $options['title'];
|
42 |
+
$style = empty($options['style']) ? 'list' : $options['style'];
|
43 |
+
$cat_args = array('orderby' => $s, 'order' => $o, 'show_count' => $c, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => __('Select Category'));
|
44 |
+
|
45 |
+
echo $before_widget;
|
46 |
+
echo $before_title . $title . $after_title; ?>
|
47 |
+
<ul>
|
48 |
+
<?php
|
49 |
+
if ($style == 'list') {
|
50 |
+
wp_list_categories($cat_args);
|
51 |
+
} else {
|
52 |
+
wp_dropdown_categories($cat_args); ?>
|
53 |
+
<script lang='javascript'><!--
|
54 |
+
var dropdown = document.getElementById("cat");
|
55 |
+
function onCatChange() {
|
56 |
+
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
|
57 |
+
location.href = "<?php echo get_option('home'); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
dropdown.onchange = onCatChange;
|
61 |
+
--></script>
|
62 |
+
<?php
|
63 |
+
|
64 |
+
}
|
65 |
+
?>
|
66 |
+
</ul>
|
67 |
+
<?php echo $after_widget; ?>
|
68 |
+
<?php
|
69 |
+
}
|
70 |
+
|
71 |
+
function widget_extended_categories_control() {
|
72 |
+
// Get actual options
|
73 |
+
$options = $newoptions = get_option('widget_extended_categories');
|
74 |
+
if ( !is_array($options) ) {
|
75 |
+
$options = $newoptions = array ();
|
76 |
+
}
|
77 |
+
|
78 |
+
// Post to new options array
|
79 |
+
if ( $_POST['categories-submit'] ) {
|
80 |
+
$newoptions['title'] = strip_tags(stripslashes($_POST['categories-title']));
|
81 |
+
$newoptions['count'] = isset($_POST['categories-count']);
|
82 |
+
$newoptions['hierarchical'] = isset($_POST['categories-hierarchical']);
|
83 |
+
$newoptions['hide_empty'] = isset($_POST['categories-hide_empty']);
|
84 |
+
$newoptions['sort_column'] = strip_tags(stripslashes($_POST['categories-sort_column']));
|
85 |
+
$newoptions['sort_order'] = strip_tags(stripslashes($_POST['categories-sort_order']));
|
86 |
+
$newoptions['style'] = strip_tags(stripslashes($_POST['categories-style']));
|
87 |
+
}
|
88 |
+
|
89 |
+
// Update if new options
|
90 |
+
if ( $options != $newoptions ) {
|
91 |
+
$options = $newoptions;
|
92 |
+
update_option('widget_extended_categories', $options);
|
93 |
+
}
|
94 |
+
|
95 |
+
// Prepare data for display
|
96 |
+
$title = htmlspecialchars($options['title'], ENT_QUOTES);
|
97 |
+
$count = $options['count'] ? 'checked="checked"' : '';
|
98 |
+
$hierarchical = $options['hierarchical'] ? 'checked="checked"' : '';
|
99 |
+
$hide_empty = $options['hide_empty'] ? 'checked="checked"' : '';
|
100 |
+
$sort_id = ($options['sort_column'] == 'ID') ? ' SELECTED' : '';
|
101 |
+
$sort_name = ($options['sort_column'] == 'name') ? ' SELECTED' : '';
|
102 |
+
$sort_count = ($options['sort_column'] == 'count') ? ' SELECTED' : '';
|
103 |
+
$sort_order_a = ($options['sort_order'] == 'asc') ? ' SELECTED' : '';
|
104 |
+
$sort_order_d = ($options['sort_order'] == 'desc') ? ' SELECTED' : '';
|
105 |
+
$style_list = ($options['style'] == 'list') ? ' SELECTED' : '';
|
106 |
+
$style_drop = ($options['style'] == 'drop') ? ' SELECTED' : '';
|
107 |
+
?>
|
108 |
+
<div>
|
109 |
+
<label for="categories-title"><?php _e('Title:'); ?>
|
110 |
+
<input style="width: 250px;" id="categories-title" name="categories-title" type="text" value="<?php echo $title; ?>" />
|
111 |
+
</label>
|
112 |
+
|
113 |
+
<label for="categories-count" style="line-height: 35px; display: block;">Show post counts
|
114 |
+
<input class="checkbox" type="checkbox" <?php echo $count; ?> id="categories-count" name="categories-count" />
|
115 |
+
</label>
|
116 |
+
|
117 |
+
<label for="categories-hierarchical" style="line-height: 35px; display: block;">Show hierarchy
|
118 |
+
<input class="checkbox" type="checkbox" <?php echo $hierarchical; ?> id="categories-hierarchical" name="categories-hierarchical" />
|
119 |
+
</label>
|
120 |
+
|
121 |
+
<label for="categories-hide_empty" style="line-height: 35px; display: block;">Hide empty categories
|
122 |
+
<input class="checkbox" type="checkbox" <?php echo $hide_empty; ?> id="categories-hide_empty" name="categories-hide_empty" />
|
123 |
+
</label>
|
124 |
+
|
125 |
+
<label for="categories-sort_column" style="line-height: 35px; display: block;">Sort by
|
126 |
+
<select id="categories-sort_column" name="categories-sort_column">
|
127 |
+
<option value="ID" <?php echo $sort_id ?>>ID</option>
|
128 |
+
<option value="name" <?php echo $sort_name ?>>Name</option>
|
129 |
+
<option value="count" <?php echo $sort_count ?>>Count</option>
|
130 |
+
</select>
|
131 |
+
</label>
|
132 |
+
|
133 |
+
<label for="categories-sort_order" style="line-height: 35px; display: block;">Sort order
|
134 |
+
<select id="categories-sort_order" name="categories-sort_order">
|
135 |
+
<option value="asc" <?php echo $sort_order_a ?>>Ascending</option>
|
136 |
+
<option value="desc" <?php echo $sort_order_d ?>>Descending</option>
|
137 |
+
</select>
|
138 |
+
</label>
|
139 |
+
|
140 |
+
<label for="categories-style" style="line-height: 35px; display: block;">Display style
|
141 |
+
<select id="categories-style" name="categories-style">
|
142 |
+
<option value='list' <?php echo $style_list; ?>>List</option>
|
143 |
+
<option value='drop' <?php echo $style_drop; ?>>Drop down</option>
|
144 |
+
</select>
|
145 |
+
</label>
|
146 |
+
|
147 |
+
<input type="hidden" id="categories-submit" name="categories-submit" value="1" />
|
148 |
+
</div>
|
149 |
+
<?php
|
150 |
+
}
|
151 |
+
|
152 |
+
function widget_extended_categories_register() {
|
153 |
+
wp_register_sidebar_widget('extended-categories', 'Extended Categories', 'widget_extended_categories');
|
154 |
+
wp_register_widget_control('extended-categories', 'Extended Categories', 'widget_extended_categories_control',array('width' => 300, 'height' => 245));
|
155 |
+
}
|
156 |
+
|
157 |
+
// Launch Widgets
|
158 |
+
widget_extended_categories_register();
|
159 |
+
}
|
160 |
+
add_action('plugins_loaded', 'widget_extended_categories_init');
|
161 |
+
?>
|