Exclude Pages - Version 1.4

Version Description

Download this release

Release Info

Developer simonwheatley
Plugin Icon wp plugin Exclude Pages
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

exclude_pages.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Exclude Pages from Navigation
4
Plugin URI: http://www.simonwheatley.co.uk/wordpress-plugins/exclude-pages/
5
Description: Provides a checkbox on the editing page which you can check to exclude pages from the primary navigation. IMPORTANT NOTE: This will remove the pages from any "consumer" side page listings, which may not be limited to your page navigation listings.
6
- Version: 1.2
7
Author: Simon Wheatley
8
9
Copyright 2007 Simon Wheatley
@@ -32,8 +32,16 @@ define('EP_OPTION_NAME', 'ep_exclude_pages');
32
define('EP_OPTION_SEP', ',');
33
34
// Take the pages array, and return the pages array without the excluded pages
35
function ep_exclude_pages( & $pages )
36
{
37
$excluded_ids = ep_get_excluded_ids();
38
$length = count($pages);
39
// Ensure we catch all descendant pages, so that if a parent
@@ -102,7 +110,7 @@ function ep_get_page( $page_id, & $pages )
102
// returns true if NOT excluded (i.e. included)
103
// returns false is it IS excluded.
104
// (Tricky this upside down flag business.)
105
- function ep_include_this_page()
106
{
107
global $post_ID;
108
// New post? Must be included then.
@@ -151,7 +159,7 @@ function ep_get_excluded_ids()
151
function ep_update_exclusions( $post_ID )
152
{
153
// Bang (!) to reverse the polarity of the boolean, turning include into exclude
154
- $exclude_this_page = ! (bool) $_POST['ep_include_this_page'];
155
// SWTODO: Also check for a hidden var, which confirms that this checkbox was present
156
// If hidden var not present, then default to including the page in the nav (i.e. bomb out here rather
157
// than add the page ID to the list of IDs to exclude)
@@ -186,6 +194,7 @@ function ep_set_option( $name, $value, $description )
186
add_option($name, $value, $description);
187
}
188
189
// Add some HTML for the DBX sidebar control into the edit page page
190
function ep_admin_sidebar()
191
{
@@ -193,12 +202,12 @@ function ep_admin_sidebar()
193
echo ' <fieldset id="excludepagediv" class="dbx-box">';
194
echo ' <h3 class="dbx-handle">'.__('Navigation').'</h3>';
195
echo ' <div class="dbx-content">';
196
- echo ' <label for="ep_include_this_page" class="selectit">';
197
echo ' <input ';
198
echo ' type="checkbox" ';
199
- echo ' name="ep_include_this_page" ';
200
- echo ' id="ep_include_this_page" ';
201
- if ( ep_include_this_page() ) echo 'checked="checked"';
202
echo ' />';
203
echo ' '.__('Include this page in menus').'</label>';
204
echo ' <input type="hidden" name="ep_ctrl_present" value="1" />';
@@ -211,11 +220,42 @@ function ep_admin_sidebar()
211
echo ' </div></fieldset>';
212
}
213
214
// Add some CSS into the HEAD element of the admin area
215
function ep_admin_css()
216
{
217
echo ' <style type="text/css" media="screen">';
218
echo ' div.exclude_alert { font-size: 11px; }';
219
echo ' </style>';
220
}
221
@@ -229,7 +269,8 @@ function ep_hec_show_dbx( $to_show )
229
// HOOK IT UP TO WORDPRESS
230
231
// Add panels into the editing sidebar(s)
232
- add_action('dbx_page_sidebar', 'ep_admin_sidebar');
233
234
// Set the exclusion when the post is saved
235
add_action('save_post', 'ep_update_exclusions');
3
Plugin Name: Exclude Pages from Navigation
4
Plugin URI: http://www.simonwheatley.co.uk/wordpress-plugins/exclude-pages/
5
Description: Provides a checkbox on the editing page which you can check to exclude pages from the primary navigation. IMPORTANT NOTE: This will remove the pages from any "consumer" side page listings, which may not be limited to your page navigation listings.
6
+ Version: 1.4
7
Author: Simon Wheatley
8
9
Copyright 2007 Simon Wheatley
32
define('EP_OPTION_SEP', ',');
33
34
// Take the pages array, and return the pages array without the excluded pages
35
+ // Doesn't do this when in the admin area
36
function ep_exclude_pages( & $pages )
37
{
38
+ // If the URL includes "wp-admin", just return the unaltered list
39
+ // This constant, WP_ADMIN, only came into WP on 2007-12-19 17:56:16 rev 6412, i.e. not something we can rely upon unfortunately.
40
+ // May as well check it though.
41
+ if ( defined( 'WP_ADMIN' ) && WP_ADMIN == true ) return $pages;
42
+ // Fall back to checking the URL... let's hope they haven't got a page called wp-admin (probably not)
43
+ // SWTODO: Actually, you can create a page with an address of wp-admin (which is then inaccessible), I consider this a bug in WordPress (which I may file a report for, and patch, another time).
44
+ if ( strpos( $_SERVER[ 'PHP_SELF' ], 'wp-admin' ) !== false ) return $pages;
45
$excluded_ids = ep_get_excluded_ids();
46
$length = count($pages);
47
// Ensure we catch all descendant pages, so that if a parent
110
// returns true if NOT excluded (i.e. included)
111
// returns false is it IS excluded.
112
// (Tricky this upside down flag business.)
113
+ function ep_this_page_included()
114
{
115
global $post_ID;
116
// New post? Must be included then.
159
function ep_update_exclusions( $post_ID )
160
{
161
// Bang (!) to reverse the polarity of the boolean, turning include into exclude
162
+ $exclude_this_page = ! (bool) $_POST['ep_this_page_included'];
163
// SWTODO: Also check for a hidden var, which confirms that this checkbox was present
164
// If hidden var not present, then default to including the page in the nav (i.e. bomb out here rather
165
// than add the page ID to the list of IDs to exclude)
194
add_option($name, $value, $description);
195
}
196
197
+ // Pre WP2.5
198
// Add some HTML for the DBX sidebar control into the edit page page
199
function ep_admin_sidebar()
200
{
202
echo ' <fieldset id="excludepagediv" class="dbx-box">';
203
echo ' <h3 class="dbx-handle">'.__('Navigation').'</h3>';
204
echo ' <div class="dbx-content">';
205
+ echo ' <label for="ep_this_page_included" class="selectit">';
206
echo ' <input ';
207
echo ' type="checkbox" ';
208
+ echo ' name="ep_this_page_included" ';
209
+ echo ' id="ep_this_page_included" ';
210
+ if ( ep_this_page_included() ) echo 'checked="checked"';
211
echo ' />';
212
echo ' '.__('Include this page in menus').'</label>';
213
echo ' <input type="hidden" name="ep_ctrl_present" value="1" />';
220
echo ' </div></fieldset>';
221
}
222
223
+ // Post WP 2.5
224
+ // Add some HTML below the submit box
225
+ function ep_admin_sidebar_wp25()
226
+ {
227
+ $nearest_excluded_ancestor = ep_nearest_excluded_ancestor();
228
+ echo ' <div id="excludepagediv" class="new-admin-wp25">';
229
+ echo ' <div class="outer"><div class="inner">';
230
+ echo ' <label for="ep_this_page_included" class="selectit">';
231
+ echo ' <input ';
232
+ echo ' type="checkbox" ';
233
+ echo ' name="ep_this_page_included" ';
234
+ echo ' id="ep_this_page_included" ';
235
+ if ( ep_this_page_included() ) echo 'checked="checked"';
236
+ echo ' />';
237
+ echo ' '.__('Include this page in user menus').'</label>';
238
+ echo ' <input type="hidden" name="ep_ctrl_present" value="1" />';
239
+ if ( $nearest_excluded_ancestor !== false ) {
240
+ echo '<div class="exclude_alert"><em>';
241
+ echo __('N.B. An ancestor of this page is excluded, so this page is too. ');
242
+ echo '<a href="page.php?action=edit&amp;post='.$nearest_excluded_ancestor.'"';
243
+ echo ' title="'.__('edit the excluded ancestor').'">'.__('Edit ancestor').'</a>.</em></div>';
244
+ }
245
+ echo ' </div><!-- .inner --></div><!-- .outer -->';
246
+ echo ' </div><!-- #excludepagediv -->';
247
+ }
248
+
249
+
250
// Add some CSS into the HEAD element of the admin area
251
function ep_admin_css()
252
{
253
echo ' <style type="text/css" media="screen">';
254
echo ' div.exclude_alert { font-size: 11px; }';
255
+ echo ' .new-admin-wp25 { font-size: 11px; background-color: #fff; }';
256
+ echo ' .new-admin-wp25 div.inner { padding: 8px 12px; background-color: #EAF3FA; border: 1px solid #EAF3FA; -moz-border-radius: 3px; -khtml-border-bottom-radius: 3px; -webkit-border-bottom-radius: 3px; border-bottom-radius: 3px; }';
257
+ echo ' .new-admin-wp25 div.exclude_alert { padding-top: 5px; }';
258
+ echo ' .new-admin-wp25 div.exclude_alert em { font-style: normal; }';
259
echo ' </style>';
260
}
261
269
// HOOK IT UP TO WORDPRESS
270
271
// Add panels into the editing sidebar(s)
272
+ add_action('dbx_page_sidebar', 'ep_admin_sidebar'); // Pre WP2.5
273
+ add_action('submitpage_box', 'ep_admin_sidebar_wp25'); // Post WP 2.5
274
275
// Set the exclusion when the post is saved
276
add_action('save_post', 'ep_update_exclusions');
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: simonwheatley
3
Donate link: http://www.simonwheatley.co.uk/wordpress-plugins/
4
Tags: get_pages, navigation, menu, exclude pages, hide pages
5
Requires at least: 2.2.3
6
- Tested up to: 2.3.1
7
- Stable tag: 1.3
8
9
This plugin adds a checkbox, “include this page in menus”, uncheck this to exclude pages from the
10
page navigation that users see on your site.
@@ -18,6 +18,11 @@ Any issues: [contact me](http://www.simonwheatley.co.uk/contact-me/).
18
19
== Change Log ==
20
21
= v1.3 2008/01/02 =
22
23
* FIXED: Descendant (e.g. child) pages were only being checked to a depth of 1 generation.
@@ -42,11 +47,11 @@ Pages which are children of excluded pages also do not show up in menu listings.
42
underneath the "include" checkbox allows you to track down which ancestor page is affecting child pages
43
in this way.)
44
45
- == Requests ==
46
47
- I'm simply noting requests here, I've not necessarily looked into how possible any of these are or how much effort they might require.
48
49
- * BUG REPORT: Pages are also excluded from the "Front page displays:" > "Posts page:" admin menu. (Reported by Ed Foley)
50
51
== Installation ==
52
@@ -56,5 +61,10 @@ I'm simply noting requests here, I've not necessarily looked into how possible a
56
57
== Screenshots ==
58
59
- 1. Showing the control on the editing screen to exclude a page from the navigation
60
- 2. Showing the control and warning for a page which is the child of an excluded page
3
Donate link: http://www.simonwheatley.co.uk/wordpress-plugins/
4
Tags: get_pages, navigation, menu, exclude pages, hide pages
5
Requires at least: 2.2.3
6
+ Tested up to: 2.5
7
+ Stable tag: 1.4
8
9
This plugin adds a checkbox, “include this page in menus”, uncheck this to exclude pages from the
10
page navigation that users see on your site.
18
19
== Change Log ==
20
21
+ = v1.4 2008/01/02 =
22
+
23
+ * ENHANCEMENT: Now compatible with WP 2.5
24
+ * FIX: Pages are also excluded from the "Front page displays:" > "Posts page:" admin menu. (Reported by Ed Foley) This plugin now checks if it's within the admin area, and does nothing if it is.
25
+
26
= v1.3 2008/01/02 =
27
28
* FIXED: Descendant (e.g. child) pages were only being checked to a depth of 1 generation.
47
underneath the "include" checkbox allows you to track down which ancestor page is affecting child pages
48
in this way.)
49
50
+ == Requests & Bug Reports ==
51
52
+ I'm simply noting requests & bug reports here, I've not necessarily looked into any of these.
53
54
+ *None!*
55
56
== Installation ==
57
61
62
== Screenshots ==
63
64
+ There appears to be a [bug](http://wordpress.org/support/topic/167316?replies=1) in this plugin site, which is causing screenshots to
65
+ not be updated. This may mean there's not a WordPress 2.5 screenshot below.
66
+
67
+ 1. WP 2.5 - Showing the control on the editing screen to exclude a page from the navigation
68
+ 2. WP 2.5 - Showing the control and warning for a page which is the child of an excluded page
69
+ 3. Pre WP 2.5 - Showing the control on the editing screen to exclude a page from the navigation
70
+ 4. Pre WP 2.5 - Showing the control and warning for a page which is the child of an excluded page
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file