Version Description
- Fixed function name collisions with "Exclude Pages" plugin. The plugin is fully functional now.
Download this release
Release Info
Developer | mattsay |
Plugin | Dropdown Menu Widget |
Version | 1.3.3 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.3.3
- readme.txt +5 -1
- shailan.DropDownMenu.php +3 -3
- exclude_pages.php → simon-exclude-pages.php +62 -61
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://shailan.com/donate
|
|
4 |
Tags: css, dropdown, menu, widget, pages, categories
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.9.1
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
This widget adds a beatiful vertical/horizontal CSS only dropdown menu of pages OR categories of your blog.
|
10 |
|
@@ -44,9 +44,13 @@ You can submit errors and bugs using the [online form](http://shailan.com/contac
|
|
44 |
1. Shiny Black menu theme
|
45 |
1. WP-Default menu theme
|
46 |
1. Dropdown menu settings page
|
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
50 |
= 1.3.2 =
|
51 |
* Bundled with "Exclude Pages" plugin by [Simon Wheatley](http://simonwheatley.co.uk/wordpress/). You can now easily exclude pages from the navigation. Just uncheck the the "Include page in menus" checkbox on the page edit screen. See [screenshots](http://wordpress.org/extend/plugins/dropdown-menu-widget/screenshots/) for more information.
|
52 |
|
4 |
Tags: css, dropdown, menu, widget, pages, categories
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.9.1
|
7 |
+
Stable tag: 1.3.3
|
8 |
|
9 |
This widget adds a beatiful vertical/horizontal CSS only dropdown menu of pages OR categories of your blog.
|
10 |
|
44 |
1. Shiny Black menu theme
|
45 |
1. WP-Default menu theme
|
46 |
1. Dropdown menu settings page
|
47 |
+
1. New exclude pages metabox
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
= 1.3.3 =
|
52 |
+
* Fixed function name collisions with "Exclude Pages" plugin. The plugin is fully functional now.
|
53 |
+
|
54 |
= 1.3.2 =
|
55 |
* Bundled with "Exclude Pages" plugin by [Simon Wheatley](http://simonwheatley.co.uk/wordpress/). You can now easily exclude pages from the navigation. Just uncheck the the "Include page in menus" checkbox on the page edit screen. See [screenshots](http://wordpress.org/extend/plugins/dropdown-menu-widget/screenshots/) for more information.
|
56 |
|
shailan.DropDownMenu.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
Plugin Name: Shailan Dropdown Menu Widget
|
4 |
Plugin URI: http://shailan.com/wordpress/plugins/dropdown-menu
|
5 |
Description: A multi widget to generate drop-down menus from your pages and categories. This widget is best used in <a href="http://shailan.com">Shailan.com</a> themes. You can find more widgets, plugins and themes at <a href="http://shailan.com">shailan.com</a>.
|
6 |
-
Version: 1.3.
|
7 |
Author: Matt Say
|
8 |
Author URI: http://shailan.com
|
9 |
Text Domain: shailan-dropdown-menu
|
10 |
*/
|
11 |
|
12 |
-
define('SHAILAN_DM_VERSION','1.3.
|
13 |
define('SHAILAN_DM_TITLE', 'Dropdown Menu');
|
14 |
define('SHAILAN_DM_FOLDER', 'dropdown-menu-widget');
|
15 |
|
@@ -348,7 +348,7 @@ load_plugin_textdomain( 'shailan-dropdown-menu', 'wp-content/plugins/' . $plugin
|
|
348 |
// add admin menu
|
349 |
add_action('admin_menu', array('shailan_DropdownWidget', 'adminMenu'));
|
350 |
|
351 |
-
include_once('
|
352 |
include('shailan-page-walker.php'); // Load custom page walker
|
353 |
include('shailan-category-walker.php'); // Load custom category walker
|
354 |
|
3 |
Plugin Name: Shailan Dropdown Menu Widget
|
4 |
Plugin URI: http://shailan.com/wordpress/plugins/dropdown-menu
|
5 |
Description: A multi widget to generate drop-down menus from your pages and categories. This widget is best used in <a href="http://shailan.com">Shailan.com</a> themes. You can find more widgets, plugins and themes at <a href="http://shailan.com">shailan.com</a>.
|
6 |
+
Version: 1.3.3
|
7 |
Author: Matt Say
|
8 |
Author URI: http://shailan.com
|
9 |
Text Domain: shailan-dropdown-menu
|
10 |
*/
|
11 |
|
12 |
+
define('SHAILAN_DM_VERSION','1.3.3');
|
13 |
define('SHAILAN_DM_TITLE', 'Dropdown Menu');
|
14 |
define('SHAILAN_DM_FOLDER', 'dropdown-menu-widget');
|
15 |
|
348 |
// add admin menu
|
349 |
add_action('admin_menu', array('shailan_DropdownWidget', 'adminMenu'));
|
350 |
|
351 |
+
include_once('simon-exclude-pages.php');
|
352 |
include('shailan-page-walker.php'); // Load custom page walker
|
353 |
include('shailan-category-walker.php'); // Load custom category walker
|
354 |
|
exclude_pages.php → simon-exclude-pages.php
RENAMED
@@ -29,16 +29,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29 |
*/
|
30 |
|
31 |
// Full filesystem path to this dir
|
32 |
-
define('
|
33 |
|
34 |
// Option name for exclusion data
|
35 |
-
define('
|
36 |
// Separator for the string of IDs stored in the option value
|
37 |
-
define('
|
38 |
|
39 |
// Take the pages array, and return the pages array without the excluded pages
|
40 |
// Doesn't do this when in the admin area
|
41 |
-
function
|
42 |
{
|
43 |
// If the URL includes "wp-admin", just return the unaltered list
|
44 |
// 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.
|
@@ -46,16 +46,16 @@ function ep_exclude_pages( $pages )
|
|
46 |
// Also check the URL... let's hope they haven't got a page called wp-admin (probably not)
|
47 |
// 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).
|
48 |
$bail_out = ( ( defined( 'WP_ADMIN' ) && WP_ADMIN == true ) || ( strpos( $_SERVER[ 'PHP_SELF' ], 'wp-admin' ) !== false ) );
|
49 |
-
$bail_out = apply_filters( '
|
50 |
if ( $bail_out ) return $pages;
|
51 |
-
$excluded_ids =
|
52 |
$length = count($pages);
|
53 |
// Ensure we catch all descendant pages, so that if a parent
|
54 |
// is hidden, it's children are too.
|
55 |
for ( $i=0; $i<$length; $i++ ) {
|
56 |
$page = & $pages[$i];
|
57 |
// If one of the ancestor pages is excluded, add it to our exclude array
|
58 |
-
if (
|
59 |
// Can't actually delete the pages at the moment,
|
60 |
// it'll screw with our recursive search.
|
61 |
// For the moment, just tag the ID onto our excluded IDs
|
@@ -86,9 +86,9 @@ function ep_exclude_pages( $pages )
|
|
86 |
|
87 |
// Recurse down an ancestor chain, checking if one is excluded
|
88 |
// Returns the ID of the "nearest" excluded ancestor
|
89 |
-
function
|
90 |
{
|
91 |
-
$parent = &
|
92 |
// Is it excluded?
|
93 |
if ( in_array( $parent->ID, $excluded_ids ) ) {
|
94 |
return $parent->ID;
|
@@ -96,11 +96,11 @@ function ep_ancestor_excluded( & $page, & $excluded_ids, & $pages )
|
|
96 |
// Is it the homepage?
|
97 |
if ( $parent->ID == 0 ) return false;
|
98 |
// Otherwise we have another ancestor to check
|
99 |
-
return
|
100 |
}
|
101 |
|
102 |
// Return the portion of the $pages array which refers to the ID passed as $page_id
|
103 |
-
function
|
104 |
{
|
105 |
// PHP 5 would be much nicer here, we could use foreach by reference, ah well.
|
106 |
$length = count($pages);
|
@@ -117,12 +117,12 @@ function ep_get_page( $page_id, & $pages )
|
|
117 |
// returns true if NOT excluded (i.e. included)
|
118 |
// returns false is it IS excluded.
|
119 |
// (Tricky this upside down flag business.)
|
120 |
-
function
|
121 |
{
|
122 |
global $post_ID;
|
123 |
// New post? Must be included then.
|
124 |
if ( ! $post_ID ) return true;
|
125 |
-
$excluded_ids =
|
126 |
// If there's no exclusion array, we can return true
|
127 |
if ( empty($excluded_ids) ) return true;
|
128 |
// Check if our page is in the exclusion array
|
@@ -134,27 +134,27 @@ function ep_this_page_included()
|
|
134 |
// Check the ancestors for the page we're editing (defined by
|
135 |
// global $post_ID var), return the ID if the nearest one which
|
136 |
// is excluded (if any);
|
137 |
-
function
|
138 |
{
|
139 |
global $post_ID, $wpdb;
|
140 |
// New post? No problem.
|
141 |
if ( ! $post_ID ) return false;
|
142 |
-
$excluded_ids =
|
143 |
// Manually get all the pages, to avoid our own filter.
|
144 |
$sql = "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'";
|
145 |
$pages = $wpdb->get_results( $sql );
|
146 |
// Start recursively checking the ancestors
|
147 |
-
$parent =
|
148 |
-
return
|
149 |
}
|
150 |
|
151 |
-
function
|
152 |
{
|
153 |
-
$exclude_ids_str = get_option(
|
154 |
// No excluded IDs? Return an empty array
|
155 |
if ( empty($exclude_ids_str) ) return array();
|
156 |
// Otherwise, explode the separated string into an array, and return that
|
157 |
-
return explode(
|
158 |
}
|
159 |
|
160 |
// This function gets all the exclusions out of the options
|
@@ -163,17 +163,17 @@ function ep_get_excluded_ids()
|
|
163 |
// don't want to have to retrieve meta for every page in order to
|
164 |
// determine if it's to be excluded. Storing all the exclusions in
|
165 |
// one row seems more sensible.
|
166 |
-
function
|
167 |
{
|
168 |
// Bang (!) to reverse the polarity of the boolean, turning include into exclude
|
169 |
-
$exclude_this_page = ! (bool) $_POST['
|
170 |
// SWTODO: Also check for a hidden var, which confirms that this checkbox was present
|
171 |
// If hidden var not present, then default to including the page in the nav (i.e. bomb out here rather
|
172 |
// than add the page ID to the list of IDs to exclude)
|
173 |
-
$ctrl_present = (bool) @ $_POST['
|
174 |
if ( ! $ctrl_present ) return;
|
175 |
|
176 |
-
$excluded_ids =
|
177 |
// If we need to EXCLUDE the page from the navigation...
|
178 |
if ( $exclude_this_page ) {
|
179 |
// Add the post ID to the array of excluded IDs
|
@@ -188,12 +188,12 @@ function ep_update_exclusions( $post_ID )
|
|
188 |
// Delete any index found
|
189 |
if ( $index !== false ) unset( $excluded_ids[$index] );
|
190 |
}
|
191 |
-
$excluded_ids_str = implode(
|
192 |
-
|
193 |
}
|
194 |
|
195 |
// Take an option, delete it if it exists, then add it.
|
196 |
-
function
|
197 |
{
|
198 |
// Delete option
|
199 |
delete_option($name);
|
@@ -203,21 +203,21 @@ function ep_set_option( $name, $value, $description )
|
|
203 |
|
204 |
// Pre WP2.5
|
205 |
// Add some HTML for the DBX sidebar control into the edit page page
|
206 |
-
function
|
207 |
{
|
208 |
-
$nearest_excluded_ancestor =
|
209 |
echo ' <fieldset id="excludepagediv" class="dbx-box">';
|
210 |
echo ' <h3 class="dbx-handle">'.__('Navigation').'</h3>';
|
211 |
echo ' <div class="dbx-content">';
|
212 |
-
echo ' <label for="
|
213 |
echo ' <input ';
|
214 |
echo ' type="checkbox" ';
|
215 |
-
echo ' name="
|
216 |
-
echo ' id="
|
217 |
-
if (
|
218 |
echo ' />';
|
219 |
echo ' '.__('Include this page in menus').'</label>';
|
220 |
-
echo ' <input type="hidden" name="
|
221 |
if ( $nearest_excluded_ancestor !== false ) {
|
222 |
echo '<div class="exclude_alert">';
|
223 |
echo __('An ancestor of this page is excluded, so this page is too. ');
|
@@ -229,20 +229,20 @@ function ep_admin_sidebar()
|
|
229 |
|
230 |
// Post WP 2.5
|
231 |
// Add some HTML below the submit box
|
232 |
-
function
|
233 |
{
|
234 |
-
$nearest_excluded_ancestor =
|
235 |
echo ' <div id="excludepagediv" class="new-admin-wp25">';
|
236 |
echo ' <div class="outer"><div class="inner">';
|
237 |
-
echo ' <label for="
|
238 |
echo ' <input ';
|
239 |
echo ' type="checkbox" ';
|
240 |
-
echo ' name="
|
241 |
-
echo ' id="
|
242 |
-
if (
|
243 |
echo ' />';
|
244 |
echo ' '.__('Include this page in user menus').'</label>';
|
245 |
-
echo ' <input type="hidden" name="
|
246 |
if ( $nearest_excluded_ancestor !== false ) {
|
247 |
echo '<div class="exclude_alert"><em>';
|
248 |
echo __('N.B. An ancestor of this page is excluded, so this page is too. ');
|
@@ -254,21 +254,21 @@ function ep_admin_sidebar_wp25()
|
|
254 |
}
|
255 |
|
256 |
// Add some CSS into the HEAD element of the admin area
|
257 |
-
function
|
258 |
{
|
259 |
echo ' <style type="text/css" media="screen">';
|
260 |
echo ' div.exclude_alert { font-size: 11px; }';
|
261 |
echo ' .new-admin-wp25 { font-size: 11px; background-color: #fff; }';
|
262 |
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; }';
|
263 |
-
echo ' #
|
264 |
-
echo ' #
|
265 |
echo ' .new-admin-wp25 div.exclude_alert { padding-top: 5px; }';
|
266 |
echo ' .new-admin-wp25 div.exclude_alert em { font-style: normal; }';
|
267 |
echo ' </style>';
|
268 |
}
|
269 |
|
270 |
// Add our ctrl to the list of controls which AREN'T hidden
|
271 |
-
function
|
272 |
{
|
273 |
array_push( $to_show, 'excludepagediv' );
|
274 |
return $to_show;
|
@@ -276,55 +276,56 @@ function ep_hec_show_dbx( $to_show )
|
|
276 |
|
277 |
// PAUSE & RESUME FUNCTIONS
|
278 |
|
279 |
-
function
|
280 |
{
|
281 |
-
remove_filter('get_pages','
|
282 |
}
|
283 |
|
284 |
-
function
|
285 |
{
|
286 |
-
add_filter('get_pages','
|
287 |
}
|
288 |
|
289 |
// INIT FUNCTIONS
|
290 |
|
291 |
-
function
|
292 |
{
|
293 |
// Call this function on the get_pages filter
|
294 |
// (get_pages filter appears to only be called on the "consumer" side of WP,
|
295 |
// the admin side must use another function to get the pages. So we're safe to
|
296 |
// remove these pages every time.)
|
297 |
-
add_filter('get_pages','
|
298 |
}
|
299 |
|
300 |
-
function
|
301 |
{
|
302 |
// Add panels into the editing sidebar(s)
|
303 |
global $wp_version;
|
304 |
if ( version_compare( $wp_version, '2.7-beta', '>=' ) ) {
|
305 |
-
add_meta_box('
|
306 |
} else {
|
307 |
-
add_action('dbx_page_sidebar', '
|
308 |
-
add_action('submitpage_box', '
|
309 |
}
|
310 |
|
311 |
// Set the exclusion when the post is saved
|
312 |
-
add_action('save_post', '
|
313 |
|
314 |
// Add some CSS to the admin header
|
315 |
-
add_action('admin_head', '
|
316 |
|
317 |
// Call this function on our very own hec_show_dbx filter
|
318 |
// This filter is harmless to add, even if we don't have the
|
319 |
// Hide Editor Clutter plugin installed as it's using a custom filter
|
320 |
// which won't be called except by the HEC plugin.
|
321 |
// Uncomment to show the control by default
|
322 |
-
// add_filter('hec_show_dbx','
|
323 |
}
|
324 |
|
325 |
// HOOK IT UP TO WORDPRESS
|
326 |
-
|
327 |
-
add_action( 'init', '
|
328 |
-
add_action( 'admin_init', '
|
|
|
329 |
|
330 |
?>
|
29 |
*/
|
30 |
|
31 |
// Full filesystem path to this dir
|
32 |
+
define('sdep_PLUGIN_DIR', dirname(__FILE__));
|
33 |
|
34 |
// Option name for exclusion data
|
35 |
+
define('sdep_OPTION_NAME', 'ep_exclude_pages');
|
36 |
// Separator for the string of IDs stored in the option value
|
37 |
+
define('sdep_OPTION_SEP', ',');
|
38 |
|
39 |
// Take the pages array, and return the pages array without the excluded pages
|
40 |
// Doesn't do this when in the admin area
|
41 |
+
function sdep_exclude_pages( $pages )
|
42 |
{
|
43 |
// If the URL includes "wp-admin", just return the unaltered list
|
44 |
// 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.
|
46 |
// Also check the URL... let's hope they haven't got a page called wp-admin (probably not)
|
47 |
// 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).
|
48 |
$bail_out = ( ( defined( 'WP_ADMIN' ) && WP_ADMIN == true ) || ( strpos( $_SERVER[ 'PHP_SELF' ], 'wp-admin' ) !== false ) );
|
49 |
+
$bail_out = apply_filters( 'sdep_admin_bail_out', $bail_out );
|
50 |
if ( $bail_out ) return $pages;
|
51 |
+
$excluded_ids = sdep_get_excluded_ids();
|
52 |
$length = count($pages);
|
53 |
// Ensure we catch all descendant pages, so that if a parent
|
54 |
// is hidden, it's children are too.
|
55 |
for ( $i=0; $i<$length; $i++ ) {
|
56 |
$page = & $pages[$i];
|
57 |
// If one of the ancestor pages is excluded, add it to our exclude array
|
58 |
+
if ( sdep_ancestor_excluded( $page, $excluded_ids, $pages ) ) {
|
59 |
// Can't actually delete the pages at the moment,
|
60 |
// it'll screw with our recursive search.
|
61 |
// For the moment, just tag the ID onto our excluded IDs
|
86 |
|
87 |
// Recurse down an ancestor chain, checking if one is excluded
|
88 |
// Returns the ID of the "nearest" excluded ancestor
|
89 |
+
function sdep_ancestor_excluded( & $page, & $excluded_ids, & $pages )
|
90 |
{
|
91 |
+
$parent = & sdep_get_page( $page->post_parent, $pages );
|
92 |
// Is it excluded?
|
93 |
if ( in_array( $parent->ID, $excluded_ids ) ) {
|
94 |
return $parent->ID;
|
96 |
// Is it the homepage?
|
97 |
if ( $parent->ID == 0 ) return false;
|
98 |
// Otherwise we have another ancestor to check
|
99 |
+
return sdep_ancestor_excluded( $parent, $excluded_ids, $pages );
|
100 |
}
|
101 |
|
102 |
// Return the portion of the $pages array which refers to the ID passed as $page_id
|
103 |
+
function sdep_get_page( $page_id, & $pages )
|
104 |
{
|
105 |
// PHP 5 would be much nicer here, we could use foreach by reference, ah well.
|
106 |
$length = count($pages);
|
117 |
// returns true if NOT excluded (i.e. included)
|
118 |
// returns false is it IS excluded.
|
119 |
// (Tricky this upside down flag business.)
|
120 |
+
function sdep_this_page_included()
|
121 |
{
|
122 |
global $post_ID;
|
123 |
// New post? Must be included then.
|
124 |
if ( ! $post_ID ) return true;
|
125 |
+
$excluded_ids = sdep_get_excluded_ids();
|
126 |
// If there's no exclusion array, we can return true
|
127 |
if ( empty($excluded_ids) ) return true;
|
128 |
// Check if our page is in the exclusion array
|
134 |
// Check the ancestors for the page we're editing (defined by
|
135 |
// global $post_ID var), return the ID if the nearest one which
|
136 |
// is excluded (if any);
|
137 |
+
function sdep_nearest_excluded_ancestor()
|
138 |
{
|
139 |
global $post_ID, $wpdb;
|
140 |
// New post? No problem.
|
141 |
if ( ! $post_ID ) return false;
|
142 |
+
$excluded_ids = sdep_get_excluded_ids();
|
143 |
// Manually get all the pages, to avoid our own filter.
|
144 |
$sql = "SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'";
|
145 |
$pages = $wpdb->get_results( $sql );
|
146 |
// Start recursively checking the ancestors
|
147 |
+
$parent = sdep_get_page( $post_ID, $pages );
|
148 |
+
return sdep_ancestor_excluded( $parent, $excluded_ids, $pages );
|
149 |
}
|
150 |
|
151 |
+
function sdep_get_excluded_ids()
|
152 |
{
|
153 |
+
$exclude_ids_str = get_option( sdep_OPTION_NAME );
|
154 |
// No excluded IDs? Return an empty array
|
155 |
if ( empty($exclude_ids_str) ) return array();
|
156 |
// Otherwise, explode the separated string into an array, and return that
|
157 |
+
return explode( sdep_OPTION_SEP, $exclude_ids_str );
|
158 |
}
|
159 |
|
160 |
// This function gets all the exclusions out of the options
|
163 |
// don't want to have to retrieve meta for every page in order to
|
164 |
// determine if it's to be excluded. Storing all the exclusions in
|
165 |
// one row seems more sensible.
|
166 |
+
function sdep_update_exclusions( $post_ID )
|
167 |
{
|
168 |
// Bang (!) to reverse the polarity of the boolean, turning include into exclude
|
169 |
+
$exclude_this_page = ! (bool) $_POST['sdep_this_page_included'];
|
170 |
// SWTODO: Also check for a hidden var, which confirms that this checkbox was present
|
171 |
// If hidden var not present, then default to including the page in the nav (i.e. bomb out here rather
|
172 |
// than add the page ID to the list of IDs to exclude)
|
173 |
+
$ctrl_present = (bool) @ $_POST['sdep_ctrl_present'];
|
174 |
if ( ! $ctrl_present ) return;
|
175 |
|
176 |
+
$excluded_ids = sdep_get_excluded_ids();
|
177 |
// If we need to EXCLUDE the page from the navigation...
|
178 |
if ( $exclude_this_page ) {
|
179 |
// Add the post ID to the array of excluded IDs
|
188 |
// Delete any index found
|
189 |
if ( $index !== false ) unset( $excluded_ids[$index] );
|
190 |
}
|
191 |
+
$excluded_ids_str = implode( sdep_OPTION_SEP, $excluded_ids );
|
192 |
+
sdep_set_option( sdep_OPTION_NAME, $excluded_ids_str, "Comma separated list of post and page IDs to exclude when returning pages from the get_pages function." );
|
193 |
}
|
194 |
|
195 |
// Take an option, delete it if it exists, then add it.
|
196 |
+
function sdep_set_option( $name, $value, $description )
|
197 |
{
|
198 |
// Delete option
|
199 |
delete_option($name);
|
203 |
|
204 |
// Pre WP2.5
|
205 |
// Add some HTML for the DBX sidebar control into the edit page page
|
206 |
+
function sdep_admin_sidebar()
|
207 |
{
|
208 |
+
$nearest_excluded_ancestor = sdep_nearest_excluded_ancestor();
|
209 |
echo ' <fieldset id="excludepagediv" class="dbx-box">';
|
210 |
echo ' <h3 class="dbx-handle">'.__('Navigation').'</h3>';
|
211 |
echo ' <div class="dbx-content">';
|
212 |
+
echo ' <label for="sdep_this_page_included" class="selectit">';
|
213 |
echo ' <input ';
|
214 |
echo ' type="checkbox" ';
|
215 |
+
echo ' name="sdep_this_page_included" ';
|
216 |
+
echo ' id="sdep_this_page_included" ';
|
217 |
+
if ( sdep_this_page_included() ) echo 'checked="checked"';
|
218 |
echo ' />';
|
219 |
echo ' '.__('Include this page in menus').'</label>';
|
220 |
+
echo ' <input type="hidden" name="sdep_ctrl_present" value="1" />';
|
221 |
if ( $nearest_excluded_ancestor !== false ) {
|
222 |
echo '<div class="exclude_alert">';
|
223 |
echo __('An ancestor of this page is excluded, so this page is too. ');
|
229 |
|
230 |
// Post WP 2.5
|
231 |
// Add some HTML below the submit box
|
232 |
+
function sdep_admin_sidebar_wp25()
|
233 |
{
|
234 |
+
$nearest_excluded_ancestor = sdep_nearest_excluded_ancestor();
|
235 |
echo ' <div id="excludepagediv" class="new-admin-wp25">';
|
236 |
echo ' <div class="outer"><div class="inner">';
|
237 |
+
echo ' <label for="sdep_this_page_included" class="selectit">';
|
238 |
echo ' <input ';
|
239 |
echo ' type="checkbox" ';
|
240 |
+
echo ' name="sdep_this_page_included" ';
|
241 |
+
echo ' id="sdep_this_page_included" ';
|
242 |
+
if ( sdep_this_page_included() ) echo 'checked="checked"';
|
243 |
echo ' />';
|
244 |
echo ' '.__('Include this page in user menus').'</label>';
|
245 |
+
echo ' <input type="hidden" name="sdep_ctrl_present" value="1" />';
|
246 |
if ( $nearest_excluded_ancestor !== false ) {
|
247 |
echo '<div class="exclude_alert"><em>';
|
248 |
echo __('N.B. An ancestor of this page is excluded, so this page is too. ');
|
254 |
}
|
255 |
|
256 |
// Add some CSS into the HEAD element of the admin area
|
257 |
+
function sdep_admin_css()
|
258 |
{
|
259 |
echo ' <style type="text/css" media="screen">';
|
260 |
echo ' div.exclude_alert { font-size: 11px; }';
|
261 |
echo ' .new-admin-wp25 { font-size: 11px; background-color: #fff; }';
|
262 |
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; }';
|
263 |
+
echo ' #sdep_admin_meta_box div.inner { padding: inherit; background-color: transparent; border: none; }';
|
264 |
+
echo ' #sdep_admin_meta_box div.inner label { background-color: none; }';
|
265 |
echo ' .new-admin-wp25 div.exclude_alert { padding-top: 5px; }';
|
266 |
echo ' .new-admin-wp25 div.exclude_alert em { font-style: normal; }';
|
267 |
echo ' </style>';
|
268 |
}
|
269 |
|
270 |
// Add our ctrl to the list of controls which AREN'T hidden
|
271 |
+
function sdep_hec_show_dbx( $to_show )
|
272 |
{
|
273 |
array_push( $to_show, 'excludepagediv' );
|
274 |
return $to_show;
|
276 |
|
277 |
// PAUSE & RESUME FUNCTIONS
|
278 |
|
279 |
+
function sd_pause_exclude_pages()
|
280 |
{
|
281 |
+
remove_filter('get_pages','sdep_exclude_pages');
|
282 |
}
|
283 |
|
284 |
+
function sd_resume_exclude_pages()
|
285 |
{
|
286 |
+
add_filter('get_pages','sdep_exclude_pages');
|
287 |
}
|
288 |
|
289 |
// INIT FUNCTIONS
|
290 |
|
291 |
+
function sdep_init()
|
292 |
{
|
293 |
// Call this function on the get_pages filter
|
294 |
// (get_pages filter appears to only be called on the "consumer" side of WP,
|
295 |
// the admin side must use another function to get the pages. So we're safe to
|
296 |
// remove these pages every time.)
|
297 |
+
add_filter('get_pages','sdep_exclude_pages');
|
298 |
}
|
299 |
|
300 |
+
function sdep_admin_init()
|
301 |
{
|
302 |
// Add panels into the editing sidebar(s)
|
303 |
global $wp_version;
|
304 |
if ( version_compare( $wp_version, '2.7-beta', '>=' ) ) {
|
305 |
+
add_meta_box('sdep_admin_meta_box', __('Exclude Pages'), 'sdep_admin_sidebar_wp25', 'page', 'side', 'low');
|
306 |
} else {
|
307 |
+
add_action('dbx_page_sidebar', 'sdep_admin_sidebar'); // Pre WP2.5
|
308 |
+
add_action('submitpage_box', 'sdep_admin_sidebar_wp25'); // Post WP 2.5, pre WP 2.7
|
309 |
}
|
310 |
|
311 |
// Set the exclusion when the post is saved
|
312 |
+
add_action('save_post', 'sdep_update_exclusions');
|
313 |
|
314 |
// Add some CSS to the admin header
|
315 |
+
add_action('admin_head', 'sdep_admin_css');
|
316 |
|
317 |
// Call this function on our very own hec_show_dbx filter
|
318 |
// This filter is harmless to add, even if we don't have the
|
319 |
// Hide Editor Clutter plugin installed as it's using a custom filter
|
320 |
// which won't be called except by the HEC plugin.
|
321 |
// Uncomment to show the control by default
|
322 |
+
// add_filter('hec_show_dbx','sdep_hec_show_dbx');
|
323 |
}
|
324 |
|
325 |
// HOOK IT UP TO WORDPRESS
|
326 |
+
if(!function_exists('sdep_exclude_pages')){
|
327 |
+
add_action( 'init', 'sdep_init' );
|
328 |
+
add_action( 'admin_init', 'sdep_admin_init' );
|
329 |
+
};
|
330 |
|
331 |
?>
|