Version Description
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Advanced Sidebar Menu |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 2.0
- advanced-sidebar-menu.php +50 -47
- readme.txt +10 -8
advanced-sidebar-menu.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Advanced Sidebar Menu
|
|
4 |
Plugin URI: http://www.vimm.com
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
-
Version: 1.
|
8 |
Author URI: http://www.vimm.com
|
9 |
|
10 |
email: mat@lipeimagination.info
|
@@ -19,18 +19,17 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
19 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
20 |
// this creates the widget form for the dashboard
|
21 |
function form( $instance ) {
|
22 |
-
|
23 |
-
$exclude = esc_attr( $instance[ 'exclude' ] );
|
24 |
-
}
|
25 |
-
else {
|
26 |
-
$exclude = '';
|
27 |
-
}
|
28 |
?>
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
<?php
|
35 |
}
|
36 |
|
@@ -39,7 +38,7 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
39 |
|
40 |
function update( $new_instance, $old_instance ) {
|
41 |
$instance = $old_instance;
|
42 |
-
$instance['
|
43 |
$instance['include_parent'] = strip_tags($new_instance['include_parent']);
|
44 |
return $instance;
|
45 |
}
|
@@ -48,7 +47,12 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
48 |
|
49 |
// This decides the name of the widget
|
50 |
function advanced_sidebar_menu( ) {
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
|
@@ -63,32 +67,18 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
63 |
global $wpdb;
|
64 |
global $p;
|
65 |
global $post;
|
66 |
-
|
67 |
-
if( $instance['exclude'] != '' ){
|
68 |
-
$exclude = explode( ',', $instance['exclude'] );
|
69 |
-
}
|
70 |
-
|
71 |
|
72 |
//makes the custom menu
|
73 |
-
|
|
|
74 |
if($post->ancestors){
|
75 |
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
|
76 |
|
|
|
77 |
while($parent != FALSE){
|
78 |
-
//----------------------------------- make the pages listed in the exludes menu not show ---------------------------------
|
79 |
-
if(isset($exclude)){
|
80 |
-
foreach( $exclude as $e ){
|
81 |
-
if( $parent == $e ){
|
82 |
-
$toggle = 'yes';
|
83 |
-
}
|
84 |
-
}}
|
85 |
-
if( $toggle == 'yes' ){
|
86 |
-
$toggle = '';
|
87 |
-
} else {
|
88 |
-
//--------------------------------------------------------------------------------------------------------------------
|
89 |
$p = $parent;
|
90 |
-
|
91 |
-
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
|
92 |
}
|
93 |
|
94 |
} else {
|
@@ -97,27 +87,40 @@ class advanced_sidebar_menu extends WP_Widget {
|
|
97 |
}
|
98 |
|
99 |
$result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
|
100 |
-
|
101 |
-
if( $instance['
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
//=----------------------------------- makes the link list -----------------------------------------
|
108 |
-
foreach($result as $
|
109 |
-
|
110 |
-
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
echo '</ul>';
|
116 |
-
endif;
|
117 |
|
118 |
|
119 |
}
|
120 |
-
|
|
|
121 |
echo '</ul>';
|
122 |
}
|
123 |
?>
|
4 |
Plugin URI: http://www.vimm.com
|
5 |
Description: Creates dynamic menu based on child/parent relationship.
|
6 |
Author: Mat Lipe
|
7 |
+
Version: 1.4
|
8 |
Author URI: http://www.vimm.com
|
9 |
|
10 |
email: mat@lipeimagination.info
|
19 |
#-----------------------------------------------------------------------------------------------------------------------------------
|
20 |
// this creates the widget form for the dashboard
|
21 |
function form( $instance ) {
|
22 |
+
|
|
|
|
|
|
|
|
|
|
|
23 |
?>
|
24 |
+
|
25 |
+
<p> Include Parent Page <input id="<?php echo $this->get_field_name('include_parent'); ?>"
|
26 |
+
name="<?php echo $this->get_field_name('include_parent'); ?>" type="checkbox" value="checked"
|
27 |
+
<?php echo $instance['include_parent']; ?>/></p>
|
28 |
+
|
29 |
+
|
30 |
+
<p> Include Parent Even With No Children<input id="<?php echo $this->get_field_name('include_childless_parent'); ?>"
|
31 |
+
name="<?php echo $this->get_field_name('include_childless_parent'); ?>" type="checkbox" value="checked"
|
32 |
+
<?php echo $instance['include_childless_parent']; ?>/></p>
|
33 |
<?php
|
34 |
}
|
35 |
|
38 |
|
39 |
function update( $new_instance, $old_instance ) {
|
40 |
$instance = $old_instance;
|
41 |
+
$instance['include_childless_parent'] = strip_tags($new_instance['include_childless_parent']);
|
42 |
$instance['include_parent'] = strip_tags($new_instance['include_parent']);
|
43 |
return $instance;
|
44 |
}
|
47 |
|
48 |
// This decides the name of the widget
|
49 |
function advanced_sidebar_menu( ) {
|
50 |
+
/* Widget settings. */
|
51 |
+
$widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
|
52 |
+
|
53 |
+
|
54 |
+
/* Create the widget. */
|
55 |
+
$this->WP_Widget( 'advanced_sidebar_menu', 'Sidebar Menu', $widget_ops, $control_ops );
|
56 |
}
|
57 |
|
58 |
|
67 |
global $wpdb;
|
68 |
global $p;
|
69 |
global $post;
|
70 |
+
|
|
|
|
|
|
|
|
|
71 |
|
72 |
//makes the custom menu
|
73 |
+
|
74 |
+
#-- if the post has parrents
|
75 |
if($post->ancestors){
|
76 |
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$post->ID );
|
77 |
|
78 |
+
//--- If there is a parent of the post set $p to it and check if there is a parent as well
|
79 |
while($parent != FALSE){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
$p = $parent;
|
81 |
+
$parent = $wpdb->get_var( "SELECT post_parent from wp_posts WHERE ID=".$parent);
|
|
|
82 |
}
|
83 |
|
84 |
} else {
|
87 |
}
|
88 |
|
89 |
$result = $wpdb->get_results( "SELECT ID FROM wp_posts WHERE post_parent = $p AND post_type='page' Order by menu_order" );
|
90 |
+
#---- if there are no children do not display the parent unless it is check to do so
|
91 |
+
if($result != false || $instance['include_childless_parent'] == 'checked' ){
|
92 |
+
|
93 |
+
#-- if the checkbox to include parent is checked
|
94 |
+
if( $instance['include_parent'] == 'checked' ){
|
95 |
+
$parent_toggle = TRUE;
|
96 |
+
|
97 |
+
#-- list the parent page
|
98 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$p);
|
99 |
+
echo '<ul class="child-sidebar-menu">';
|
100 |
+
}
|
101 |
}
|
102 |
|
103 |
//=----------------------------------- makes the link list -----------------------------------------
|
104 |
+
foreach($result as $pID){
|
105 |
+
#--echo the current page from the $result
|
106 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
|
107 |
+
|
108 |
+
#-- if the link that was just listed is the current page we are on
|
109 |
+
if($pID->ID == $post->ID or $pID->ID == $post->post_parent or in_array($pID->ID, $post->ancestors) ){
|
110 |
+
|
111 |
+
#-- Create a new menu with all the children under it
|
112 |
+
echo '<ul class="grandchild-sidebar-menu">';
|
113 |
+
|
114 |
+
wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=3&child_of=".$pID->ID);
|
115 |
|
116 |
+
echo '</ul>';
|
117 |
+
|
118 |
+
}
|
|
|
|
|
119 |
|
120 |
|
121 |
}
|
122 |
+
#-- if the options above echoed the parent and therefore added another ul
|
123 |
+
if( $parent_toggle == TRUE ){
|
124 |
echo '</ul>';
|
125 |
}
|
126 |
?>
|
readme.txt
CHANGED
@@ -4,18 +4,14 @@ Donate link: http://lipeimagination.info/contact/
|
|
4 |
Tags: menus, sidebar menu, heirchy
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.2.1
|
7 |
-
Stable tag: 1.
|
|
|
8 |
|
9 |
== Description ==
|
10 |
|
11 |
Creates a widget that can be dragged into a sidebar which automatically generates a menu based on the parent/child relationship of the pages. When on a top level page it displays a menu of the all of the top level pages and a menu of all of the pages that are children of the current page. Keep the sidebar menu clean and usable.
|
12 |
Has a checkbox for including the top level of pages (good for sites that have 3 or more page levels) and a box to exclude pages and children of excluded page.
|
13 |
|
14 |
-
Creates a widget that can be dragged into a sidebar which automatically generates a menu based on the parent/child relationship of the pages. When on a top level page it displays a menu of the all of the top level pages and a menu of all of the pages that are children of the current page. Keep the sidebar menu clean and usable.
|
15 |
-
Has a checkbox for including the top level of pages (good for sites that have 3 or more page levels) and a box to exclude pages and children of excluded page.
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
== Installation ==
|
21 |
|
@@ -25,7 +21,7 @@ e.g.
|
|
25 |
|
26 |
1. Upload the `advanced-sidbebar-menu` folder to the `/wp-content/plugins/` directory
|
27 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
-
1. Drag the
|
29 |
|
30 |
== Frequently Asked Questions ==
|
31 |
|
@@ -43,11 +39,17 @@ As of version 1.1 this will automatically generate class names for each level fo
|
|
43 |
|
44 |
== Screenshots ==
|
45 |
|
46 |
-
1.
|
47 |
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
= 1.2 =
|
52 |
* Added support for the built in page ordering.
|
53 |
|
4 |
Tags: menus, sidebar menu, heirchy
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.2.1
|
7 |
+
Stable tag: 1.4
|
8 |
+
Version: 1.4
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
Creates a widget that can be dragged into a sidebar which automatically generates a menu based on the parent/child relationship of the pages. When on a top level page it displays a menu of the all of the top level pages and a menu of all of the pages that are children of the current page. Keep the sidebar menu clean and usable.
|
13 |
Has a checkbox for including the top level of pages (good for sites that have 3 or more page levels) and a box to exclude pages and children of excluded page.
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
== Installation ==
|
17 |
|
21 |
|
22 |
1. Upload the `advanced-sidbebar-menu` folder to the `/wp-content/plugins/` directory
|
23 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
24 |
+
1. Drag the Sidebar Menu widget into a sidebar.
|
25 |
|
26 |
== Frequently Asked Questions ==
|
27 |
|
39 |
|
40 |
== Screenshots ==
|
41 |
|
42 |
+
screenshot-1.PNG
|
43 |
|
44 |
|
45 |
== Changelog ==
|
46 |
|
47 |
+
= 1.4 =
|
48 |
+
* Removed Menu from pages with no children
|
49 |
+
* Added a checkbox for including menu on page with no children
|
50 |
+
* Removed ability to exclude items from menu
|
51 |
+
|
52 |
+
|
53 |
= 1.2 =
|
54 |
* Added support for the built in page ordering.
|
55 |
|