Advanced Sidebar Menu - Version 3.4.5

Version Description

Download this release

Release Info

Developer Mat Lipe
Plugin Icon 128x128 Advanced Sidebar Menu
Version 3.4.5
Comparing to
See all releases

Code changes from version 3.3.1 to 3.4.5

advanced-sidebar-menu.php CHANGED
@@ -4,9 +4,9 @@ Plugin Name: Advanced Sidebar Menu
4
  Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
5
  Description: Creates dynamic menu based on child/parent relationship.
6
  Author: Mat Lipe
7
- Version: 3.3.1
8
  Author URI: http://lipeimagination.info
9
- Since: 7/16/12
10
  Email: mat@lipeimagination.info
11
  */
12
 
4
  Plugin URI: http://lipeimagination.info/wordpress/advanced-sidebar-menu/
5
  Description: Creates dynamic menu based on child/parent relationship.
6
  Author: Mat Lipe
7
+ Version: 3.4.5
8
  Author URI: http://lipeimagination.info
9
+ Since: 10.10.12
10
  Email: mat@lipeimagination.info
11
  */
12
 
functions.php CHANGED
@@ -4,7 +4,7 @@
4
  /**
5
  * These Functions are Specific to the Advanced Sidebar Menu
6
  * @author Mat Lipe
7
- * @since 7/16/12
8
  */
9
 
10
 
@@ -12,6 +12,30 @@
12
  class advanced_sidebar_menu_functions{
13
  protected $bad = array(); //for 3.3 version
14
  protected $bad_file = ''; //for 3.3 version
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
 
17
  /**
@@ -132,11 +156,11 @@ function notice_3_3( ){
132
  *
133
  * Returns and array of all the children of a page
134
  * @param int $pID the id of the page
135
- * @since 7/19/12
136
  */
137
  function page_children( $pID ){
138
  global $wpdb, $table_prefix;
139
- return $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID." AND post_type='page' AND post_status='publish'" );
140
 
141
  }
142
 
4
  /**
5
  * These Functions are Specific to the Advanced Sidebar Menu
6
  * @author Mat Lipe
7
+ * @since 10.10.12
8
  */
9
 
10
 
12
  class advanced_sidebar_menu_functions{
13
  protected $bad = array(); //for 3.3 version
14
  protected $bad_file = ''; //for 3.3 version
15
+
16
+
17
+
18
+ /**
19
+ * Adds the class for current page item etc to the page list when using a custom post type
20
+ * @param array $css the currrent css classes
21
+ * @param obj $this_menu_item the page being checked
22
+ * @return array
23
+ * @since 10.10.12
24
+ */
25
+ function custom_post_type_css($css, $this_menu_item){
26
+ global $post;
27
+ if ( isset($post->ancestors) && in_array($this_menu_item->ID, (array)$post->ancestors) ){
28
+ $css[] = 'current_page_ancestor';
29
+ }
30
+ if ( $this_menu_item->ID == $post->ID ){
31
+ $css[] = 'current_page_item';
32
+
33
+ } elseif ($this_menu_item->ID == $post->post_parent ){
34
+ $css[] = 'current_page_parent';
35
+ }
36
+ return $css;
37
+ }
38
+
39
 
40
 
41
  /**
156
  *
157
  * Returns and array of all the children of a page
158
  * @param int $pID the id of the page
159
+ * @since 10.5.12
160
  */
161
  function page_children( $pID ){
162
  global $wpdb, $table_prefix;
163
+ return $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = ".$pID." AND post_status='publish'" );
164
 
165
  }
166
 
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
4
  Tags: menus, sidebar menu, heirchy, category menu, pages menu
5
  Requires at least: 3.1
6
  Tested up to: 3.4.2
7
- Stable tag: 3.3.1
8
- Version: 3.3.0
9
 
10
  == Description ==
11
 
@@ -85,6 +85,10 @@ You may want to use something like margins to set the levels apart.
85
 
86
 
87
  == Changelog ==
 
 
 
 
88
  = 3.3.1 =
89
  * Added unlimited number of levels displayed once on the grandchild level of pages
90
 
4
  Tags: menus, sidebar menu, heirchy, category menu, pages menu
5
  Requires at least: 3.1
6
  Tested up to: 3.4.2
7
+ Stable tag: 3.4.5
8
+ Version: 3.4.5
9
 
10
  == Description ==
11
 
85
 
86
 
87
  == Changelog ==
88
+
89
+ = 3.4.0 =
90
+ * Added filter support for custom post types
91
+
92
  = 3.3.1 =
93
  * Added unlimited number of levels displayed once on the grandchild level of pages
94
 
views/page_list.php CHANGED
@@ -5,7 +5,7 @@
5
  /**
6
  * The Ouput of tad Advanced Sidebar Page Widget
7
  * @author Mat Lipe
8
- * @since 7/16/12
9
  *
10
  *
11
  * @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
@@ -18,7 +18,7 @@ $asm->title();
18
  #-- list the parent page if chosen
19
  if( $asm->include_parent() ){
20
  echo '<ul class="parent-sidebar-menu" >';
21
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$top_parent);
22
  }
23
 
24
 
@@ -29,7 +29,7 @@ if( $child_pages ){
29
  #-- If they want all the pages displayed always
30
  if( $asm->display_all() ){
31
 
32
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&child_of=".$top_parent."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
33
  } else {
34
 
35
  #-- Display children of current page's parent only
@@ -38,7 +38,7 @@ if( $child_pages ){
38
  #-- If the page is not in the excluded ones
39
  if( $asm->exclude( $pID->ID) ){
40
  #--echo the current page from the $result
41
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
42
  }
43
 
44
  #-- if the link that was just listed is the current page we are on
@@ -49,7 +49,7 @@ if( $child_pages ){
49
  if( $grandkids ){
50
  #-- Create a new menu with all the children under it
51
  echo '<ul class="grandchild-sidebar-menu">';
52
- wp_list_pages("sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&child_of=".$pID->ID);
53
 
54
  echo '</ul>';
55
  }
5
  /**
6
  * The Ouput of tad Advanced Sidebar Page Widget
7
  * @author Mat Lipe
8
+ * @since 10.05.12
9
  *
10
  *
11
  * @uses to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu
18
  #-- list the parent page if chosen
19
  if( $asm->include_parent() ){
20
  echo '<ul class="parent-sidebar-menu" >';
21
+ wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&depth=1&include=".$top_parent);
22
  }
23
 
24
 
29
  #-- If they want all the pages displayed always
30
  if( $asm->display_all() ){
31
 
32
+ wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&child_of=".$top_parent."&depth=".$instance['levels']."&exclude=".$instance['exclude']);
33
  } else {
34
 
35
  #-- Display children of current page's parent only
38
  #-- If the page is not in the excluded ones
39
  if( $asm->exclude( $pID->ID) ){
40
  #--echo the current page from the $result
41
+ wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&depth=1&include=".$pID->ID);
42
  }
43
 
44
  #-- if the link that was just listed is the current page we are on
49
  if( $grandkids ){
50
  #-- Create a new menu with all the children under it
51
  echo '<ul class="grandchild-sidebar-menu">';
52
+ wp_list_pages("post_type=".$post_type."&sort_column=menu_order&title_li=&echo=1&exclude=".$instance['exclude']."&child_of=".$pID->ID);
53
 
54
  echo '</ul>';
55
  }
widgets/category.widget.php CHANGED
@@ -117,7 +117,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
117
  // This decides the name of the widget
118
  function advanced_sidebar_menu_category( ) {
119
  /* Widget settings. */
120
- $widget_ops = array( 'classname' => , 'description' => 'Creates a menu of all the Categories using the child/parent relationship' );
121
  $control_ops = array( 'width' => 290 );
122
  /* Create the widget. */
123
  $this->WP_Widget( 'advanced_sidebar_menu_category', 'Advanced Sidebar Categories Menu', $widget_ops, $control_ops );
@@ -126,9 +126,14 @@ class advanced_sidebar_menu_category extends WP_Widget {
126
 
127
  #---------------------------------------------------------------------------------------------------------------------------
128
 
129
- // adds the output to the widget area on the page
 
 
 
 
130
  function widget($args, $instance) {
131
  global $asm;
 
132
  #-- Create a usable array of the excluded pages
133
  $exclude = explode(',', $instance['exclude']);
134
  $cat_ids = $already_top = array();
@@ -198,8 +203,8 @@ class advanced_sidebar_menu_category extends WP_Widget {
198
  //Creates a new widget for each category the single page has if the options are selected to do so
199
  if( !$asm_once || ($instance['new_widget'] == 'widget') ){
200
 
201
- echo '<div id="'.$args['widget_id']. $count .'" class="advanced-sidebar-menu widget advanced-sidebar-category">
202
- <div class="widget-wrap">';
203
 
204
  $count++; // To change the id of the widget if there are multiple
205
  $asm_once = true; //There has been a div
@@ -218,8 +223,7 @@ class advanced_sidebar_menu_category extends WP_Widget {
218
 
219
  if( $close ){
220
  //End the Widget Area
221
- echo '</div>
222
- </div><!-- END #advanced-sidebar-cat-menu -->';
223
  }
224
 
225
 
117
  // This decides the name of the widget
118
  function advanced_sidebar_menu_category( ) {
119
  /* Widget settings. */
120
+ $widget_ops = array( 'classname' => 'advanced-sidebar-menu advanced-sidebar-category', 'description' => 'Creates a menu of all the Categories using the child/parent relationship' );
121
  $control_ops = array( 'width' => 290 );
122
  /* Create the widget. */
123
  $this->WP_Widget( 'advanced_sidebar_menu_category', 'Advanced Sidebar Categories Menu', $widget_ops, $control_ops );
126
 
127
  #---------------------------------------------------------------------------------------------------------------------------
128
 
129
+ /**
130
+ * Outputs the categories widget to the page
131
+ * @since 10.5.12
132
+ *
133
+ */
134
  function widget($args, $instance) {
135
  global $asm;
136
+ extract( $args);
137
  #-- Create a usable array of the excluded pages
138
  $exclude = explode(',', $instance['exclude']);
139
  $cat_ids = $already_top = array();
203
  //Creates a new widget for each category the single page has if the options are selected to do so
204
  if( !$asm_once || ($instance['new_widget'] == 'widget') ){
205
 
206
+ //Start the menu
207
+ echo $before_widget;
208
 
209
  $count++; // To change the id of the widget if there are multiple
210
  $asm_once = true; //There has been a div
223
 
224
  if( $close ){
225
  //End the Widget Area
226
+ echo $after_widget;
 
227
  }
228
 
229
 
widgets/page.widget.php CHANGED
@@ -5,7 +5,7 @@
5
  * Creates a Widget of parent Child Pages
6
  *
7
  * @author mat lipe
8
- * @since 7/16/12
9
  * @package Advanced Sidebar Menu
10
  *
11
  */
@@ -84,7 +84,7 @@ class advanced_sidebar_menu_page extends WP_Widget {
84
  // This decides the name of the widget
85
  function advanced_sidebar_menu_page( ) {
86
  /* Widget settings. */
87
- $widget_ops = array( 'classname' => 'sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
88
  $control_ops = array( 'width' => 290 );
89
 
90
  /* Create the widget. */
@@ -94,10 +94,29 @@ class advanced_sidebar_menu_page extends WP_Widget {
94
 
95
  #---------------------------------------------------------------------------------------------------------------------------
96
 
97
- // adds the output to the widget area on the page
 
 
 
 
 
98
  function widget($args, $instance) {
99
-
100
- if( is_page() ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  global $wpdb, $post, $table_prefix, $asm;
103
 
@@ -111,11 +130,11 @@ class advanced_sidebar_menu_page extends WP_Widget {
111
  #--------- If this is the parent ------------------------------------------------
112
  $top_parent = $post->ID;
113
  }
114
-
115
  /**
116
  * Must be done this way to prevent doubling up of pages
117
  */
118
- $child_pages = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $top_parent AND post_type='page' AND post_status='publish' Order by menu_order" );
119
 
120
  //for depreciation
121
  $p = $top_parent;
@@ -131,12 +150,11 @@ class advanced_sidebar_menu_page extends WP_Widget {
131
  }
132
 
133
  //Start the menu
134
- echo '<div id="'.$args['widget_id'].'" class="advanced-sidebar-menu widget advanced-sidebar-page">
135
- <div class="widget-wrap">';
136
  $asm->set_widget_vars( $instance, $top_parent, $exclude );
137
  #-- Bring in the view
138
  require( $asm->file_hyercy( 'page_list.php' ) );
139
- echo '</div></div><!-- end #'.$args['widget_id'].' -->';
140
  }
141
  }
142
  } #== /widget()
5
  * Creates a Widget of parent Child Pages
6
  *
7
  * @author mat lipe
8
+ * @since 10.10.12
9
  * @package Advanced Sidebar Menu
10
  *
11
  */
84
  // This decides the name of the widget
85
  function advanced_sidebar_menu_page( ) {
86
  /* Widget settings. */
87
+ $widget_ops = array( 'classname' => 'advanced-sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' );
88
  $control_ops = array( 'width' => 290 );
89
 
90
  /* Create the widget. */
94
 
95
  #---------------------------------------------------------------------------------------------------------------------------
96
 
97
+ /**
98
+ * Outputs the page list
99
+ * @see WP_Widget::widget()
100
+ * @uses for custom post types send the type to the filter titled 'advanced_sidebar_menu_post_type'
101
+ * @since 10.10.12
102
+ */
103
  function widget($args, $instance) {
104
+ $single_type = 'page'; //default use is for pages
105
+ global $asm;
106
+
107
+ //Filter this one with a 'single' for a custom post type will default to working for pages only
108
+ $post_type = apply_filters('advanced_sidebar_menu_post_type', 'page' );
109
+
110
+
111
+ if( $post_type != 'page' ){
112
+ $single_type = 'single';
113
+ add_filter('page_css_class', array( $asm, 'custom_post_type_css'), 2, 4 );
114
+
115
+ }
116
+
117
+ if( call_user_func('is_'.$single_type) ){
118
+
119
+ extract($args);
120
 
121
  global $wpdb, $post, $table_prefix, $asm;
122
 
130
  #--------- If this is the parent ------------------------------------------------
131
  $top_parent = $post->ID;
132
  }
133
+
134
  /**
135
  * Must be done this way to prevent doubling up of pages
136
  */
137
+ $child_pages = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $top_parent AND post_status='publish' Order by menu_order" );
138
 
139
  //for depreciation
140
  $p = $top_parent;
150
  }
151
 
152
  //Start the menu
153
+ echo $before_widget;
 
154
  $asm->set_widget_vars( $instance, $top_parent, $exclude );
155
  #-- Bring in the view
156
  require( $asm->file_hyercy( 'page_list.php' ) );
157
+ echo $after_widget;
158
  }
159
  }
160
  } #== /widget()