Version Description
- February 24, 2011 Addressed a bug in UCE that didnt handle multiple excluded categories correctly.
Download this release
Release Info
Developer | planetmike |
Plugin | Ultimate Category Excluder |
Version | 0.6 |
Comparing to | |
See all releases |
Version 0.6
- readme.txt +45 -0
- ultimate-category-excluder.php +129 -0
readme.txt
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Ultimate Category Excluder ===
|
2 |
+
Contributors: planetmike
|
3 |
+
Donate link: http://www.planetmike.com/donations/
|
4 |
+
Tags: category, categories, exclude, visible, hidden, hide
|
5 |
+
Requires at least: 3.1
|
6 |
+
Tested up to: 3.1
|
7 |
+
Stable tag: 0.6
|
8 |
+
|
9 |
+
Ultimate Category Excluder allows you to quickly and easily exclude categories from your front page, archives, and feeds.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Ultimate Category Excluder (UCE – unfortunately the same abbreviation as unsolicited commercial email) is a WordPress plugin that allows you to quickly and easily exclude categories from your front page, archives, and feeds. Just select which categories you want to be excluded, and UCE does all the work for you!
|
14 |
+
|
15 |
+
|
16 |
+
== Installation ==
|
17 |
+
|
18 |
+
1. Download Ultimate Category Excluder.
|
19 |
+
2. Unzip the ultimate-category-excluder.zip file.
|
20 |
+
3. Activate the plugin on your plugins page.
|
21 |
+
4. You can edit the options by going under “Options” and then “Category Exclusion.”
|
22 |
+
5. (Optional) I suggest you subscribe to my <a href="http://www.planetmike.com/feed/">RSS feed</a> so you can stay informed about any updates to Ultimate Category Excluder.
|
23 |
+
|
24 |
+
== Changelog ==
|
25 |
+
|
26 |
+
= 0.6 =
|
27 |
+
* February 24, 2011 – Addressed a bug in UCE that didn’t handle multiple excluded categories correctly.
|
28 |
+
|
29 |
+
= 0.5 =
|
30 |
+
* February 24, 2011 – Addressed a bug in WP 3.1.
|
31 |
+
|
32 |
+
= 0.4 =
|
33 |
+
* October 10, 2009 – A user pointed out a bug when trying to filter down categories in the edit posts admin area. I believe I’ve fixed this, but let me know if you still have trouble.
|
34 |
+
|
35 |
+
= 0.3 =
|
36 |
+
* June 20, 2009 – James Revillini pointed out a few fairly obvious bugs. I’ve incorporated his changes into the software.
|
37 |
+
|
38 |
+
= 0.21 Beta =
|
39 |
+
* January 10, 2008 – Initial release, fixed file name bug, dashes vs. underscores
|
40 |
+
|
41 |
+
= 0.2 Beta =
|
42 |
+
* December 13, 2007 – Initial release, tweaked to refer to PlanetMike.com, no functionality changed
|
43 |
+
|
44 |
+
= 0.1 Beta =
|
45 |
+
* February 14, 2007 – Initial release
|
ultimate-category-excluder.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Ultimate Category Excluder
|
4 |
+
Plugin URI: http://www.planetmike.com/plugins/ultimate-category-excluder/
|
5 |
+
Description: Easily exclude categories from your front page, feeds, and archives.
|
6 |
+
Author: Michael Clark
|
7 |
+
Version: 0.6
|
8 |
+
Author URI: http://www.planetmike.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
add_action('admin_menu', 'ksuce_admin_menu');
|
12 |
+
add_filter('pre_get_posts','ksuce_exclude_categories');
|
13 |
+
|
14 |
+
function ksuce_admin_menu() {
|
15 |
+
add_options_page( 'Ultimate Category Excluder Options', 'Category Exclusion', 9, basename(__FILE__), 'ksuce_options_page');
|
16 |
+
}
|
17 |
+
|
18 |
+
function ksuce_options_page() {
|
19 |
+
if( $_POST[ 'ksuce' ] ) {
|
20 |
+
$message = ksuce_process();
|
21 |
+
}
|
22 |
+
$options = ksuce_get_options();
|
23 |
+
?>
|
24 |
+
<div class="wrap">
|
25 |
+
<h2>Ultimate Category Excluder Options</h2>
|
26 |
+
<?php echo $message ?>
|
27 |
+
<p>Use this page to select the categories you wish to exclude and where you would like to exclude them from.</p>
|
28 |
+
<form action="options-general.php?page=ultimate-category-excluder.php" method="post">
|
29 |
+
<table class="widefat">
|
30 |
+
<thead>
|
31 |
+
<tr>
|
32 |
+
<th scope="col">Category</th>
|
33 |
+
<th scope="col">Exclude from Main Page?</th>
|
34 |
+
<th scope="col">Exclude from Feeds?</th>
|
35 |
+
<th scope="col">Exclude from Archives?</th>
|
36 |
+
</tr>
|
37 |
+
</thead>
|
38 |
+
<tbody id="the-list">
|
39 |
+
<?php
|
40 |
+
//print_r( get_categories() );
|
41 |
+
$cats = get_categories();
|
42 |
+
$alt = 0;
|
43 |
+
foreach( $cats as $cat ) {
|
44 |
+
?>
|
45 |
+
<tr<?php if ( $alt == 1 ) { echo ' class="alternate"'; $alt = 0; } else { $alt = 1; } ?>>
|
46 |
+
<th scope="row"><?php echo $cat->cat_name; //. ' (' . $cat->cat_ID . ')'; ?></th>
|
47 |
+
<td>
|
48 |
+
<input type="checkbox" name="exclude_main[]" value="-<?php echo $cat->cat_ID ?>" <?php if ( in_array( '-' . $cat->cat_ID, $options['exclude_main'] ) ) { echo 'checked="true" '; } ?>/>
|
49 |
+
</td>
|
50 |
+
<td><input type="checkbox" name="exclude_feed[]" value="-<?php echo $cat->cat_ID ?>" <?php if ( in_array( '-' . $cat->cat_ID, $options['exclude_feed'] ) ) { echo 'checked="true" '; } ?>/></td>
|
51 |
+
<td><input type="checkbox" name="exclude_archives[]" value="-<?php echo $cat->cat_ID ?>" <?php if ( in_array( '-' . $cat->cat_ID, $options['exclude_archives'] ) ) { echo 'checked="true" '; } ?>/></td>
|
52 |
+
</tr>
|
53 |
+
<?php
|
54 |
+
}
|
55 |
+
?>
|
56 |
+
</table>
|
57 |
+
<p class="submit"><input type="submit" value="Update" /></p>
|
58 |
+
<input type="hidden" name="ksuce" value="true" />
|
59 |
+
</form>
|
60 |
+
</div><?php
|
61 |
+
}
|
62 |
+
|
63 |
+
function ksuce_process() {
|
64 |
+
//echo '<pre>'; print_r( $_POST );
|
65 |
+
if( !$_POST[ 'exclude_main' ] ) {
|
66 |
+
$_POST[ 'exclude_main' ] = array();
|
67 |
+
}
|
68 |
+
if( !$_POST[ 'exclude_feed' ] ) {
|
69 |
+
$_POST[ 'exclude_feed' ] = array();
|
70 |
+
}
|
71 |
+
if( !$_POST[ 'exclude_archives' ] ) {
|
72 |
+
$_POST[ 'exclude_archives' ] = array();
|
73 |
+
}
|
74 |
+
$options['exclude_main'] = $_POST[ 'exclude_main' ];
|
75 |
+
$options['exclude_feed'] = $_POST[ 'exclude_feed' ];
|
76 |
+
$options['exclude_archives'] = $_POST[ 'exclude_archives' ];
|
77 |
+
update_option('ksuceExcludes', $options);
|
78 |
+
|
79 |
+
$message = "<div class='updated'><p>Excludes successfully updated</p></div>";
|
80 |
+
return $message;
|
81 |
+
}
|
82 |
+
|
83 |
+
function ksuce_get_options(){
|
84 |
+
$defaults = array();
|
85 |
+
$defaults['exclude_main'] = array();
|
86 |
+
$defaults['exclude_feed'] = array();
|
87 |
+
$defaults['exclude_archives'] = array();
|
88 |
+
|
89 |
+
$options = get_option('ksuceExcludes');
|
90 |
+
if (!is_array($options)){
|
91 |
+
$options = $defaults;
|
92 |
+
update_option('ksuceExcludes', $options);
|
93 |
+
}
|
94 |
+
|
95 |
+
return $options;
|
96 |
+
}
|
97 |
+
|
98 |
+
function ksuce_exclude_categories($query) {
|
99 |
+
$options = ksuce_get_options();
|
100 |
+
if ($query->is_home) {
|
101 |
+
$mbccount=0;
|
102 |
+
foreach ($options[ 'exclude_main' ] as $value) {
|
103 |
+
$array2[$mbccount] = $value;
|
104 |
+
$mbccount++;
|
105 |
+
}
|
106 |
+
$query->set('category__not_in', $array2);
|
107 |
+
}
|
108 |
+
if ($query->is_feed) {
|
109 |
+
$mbccount=0;
|
110 |
+
foreach ($options[ 'exclude_feed' ] as $value) {
|
111 |
+
$array2[$mbccount] = $value;
|
112 |
+
$mbccount++;
|
113 |
+
}
|
114 |
+
$query->set('category__not_in', $array2);
|
115 |
+
}
|
116 |
+
if ($query->is_archive) {
|
117 |
+
if (!is_admin()) {
|
118 |
+
$mbccount=0;
|
119 |
+
foreach ($options[ 'exclude_archives' ] as $value) {
|
120 |
+
$array2[$mbccount] = $value;
|
121 |
+
$mbccount++;
|
122 |
+
}
|
123 |
+
$query->set('category__not_in', $array2);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
return $query;
|
128 |
+
}
|
129 |
+
?>
|