Advanced Sidebar Menu - Version 4.2.1

Version Description

Download this release

Release Info

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

Code changes from version 4.2.0 to 4.2.1

Files changed (3) hide show
  1. advanced-sidebar-menu.php +1 -1
  2. readme.txt +1 -1
  3. widgets/page.widget.php +21 -25
advanced-sidebar-menu.php CHANGED
@@ -4,7 +4,7 @@ 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: 4.2.0
8
  Author URI: http://lipeimagination.info
9
  Since: 5.28.13
10
  */
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: 4.2.1
8
  Author URI: http://lipeimagination.info
9
  Since: 5.28.13
10
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.5.1
7
- Stable tag: 4.2.0
8
 
9
  Creates a widget for both page and categories that will display the current page/category and all child pages or categories.
10
 
4
  Tags: menus, sidebar menu, heirchy, category menu, pages menu
5
  Requires at least: 3.1
6
  Tested up to: 3.5.1
7
+ Stable tag: 4.2.1
8
 
9
  Creates a widget for both page and categories that will display the current page/category and all child pages or categories.
10
 
widgets/page.widget.php CHANGED
@@ -5,7 +5,7 @@
5
  * Creates a Widget of parent Child Pages
6
  *
7
  * @author mat lipe
8
- * @since 4.23.13
9
  * @package Advanced Sidebar Menu
10
  *
11
  */
@@ -148,47 +148,42 @@ class advanced_sidebar_menu_page extends WP_Widget {
148
  function widget($args, $instance) {
149
  global $wpdb, $post, $table_prefix;
150
 
151
- //There will be no pages to generate on an archive page
152
- if( is_archive() ) return;
153
-
154
  $asm = new advancedSidebarMenu;
155
 
156
  $asm->instance = $instance;
157
  $asm->args = $args;
 
 
 
158
  extract($args);
159
 
160
  //Filter this one with a 'single' for a custom post type will default to working for pages only
161
  $post_type = apply_filters('advanced_sidebar_menu_post_type', 'page', $args, $instance );
162
-
163
- if( !(is_single() || is_page() ) || (get_post_type() != $post_type) ) return;
164
-
165
-
166
  $asm->post_type = $post_type;
167
-
168
- if( $post_type != 'page' ){
169
- add_filter('page_css_class', array( $asm, 'custom_post_type_css'), 2, 4 );
170
-
171
  }
172
 
173
 
174
-
175
- #-- Create a usable array of the excluded pages
176
- $exclude = explode(',', $instance['exclude']);
177
- $asm->exclude = $exclude;
 
178
 
179
-
180
- #-- if the post has parents
181
  if($post->ancestors){
182
- $top_parent = end( $post->ancestors );
183
  } else {
184
- #--------- If this is the parent ------------------------------------------------
185
- $top_parent = $post->ID;
186
- }
187
-
188
-
189
  //Filter for specifying the top parent
190
  $top_parent = apply_filters('advanced_sidebar_menu_top_parent', $top_parent, $post, $args, $instance );
191
  $asm->top_id = $top_parent;
 
 
 
 
192
 
193
 
194
  //Filter for specifiying the order by
@@ -204,9 +199,10 @@ class advanced_sidebar_menu_page extends WP_Widget {
204
  //for depreciation
205
  $p = $top_parent;
206
  $result = $child_pages = apply_filters( 'advanced_sidebar_menu_child_pages', $child_pages, $post, $args, $instance );
 
207
 
208
  #---- if there are no children do not display the parent unless it is check to do so
209
- if( ($child_pages) || $asm->checked('include_childless_parent') && (!in_array($top_parent, $exclude) ) ){
210
 
211
  $legacy = $asm->checked('legacy_mode' );
212
 
5
  * Creates a Widget of parent Child Pages
6
  *
7
  * @author mat lipe
8
+ * @since 5.28.13
9
  * @package Advanced Sidebar Menu
10
  *
11
  */
148
  function widget($args, $instance) {
149
  global $wpdb, $post, $table_prefix;
150
 
 
 
 
151
  $asm = new advancedSidebarMenu;
152
 
153
  $asm->instance = $instance;
154
  $asm->args = $args;
155
+ $exclude = explode(',', $instance['exclude']);
156
+ $asm->exclude = $exclude;
157
+
158
  extract($args);
159
 
160
  //Filter this one with a 'single' for a custom post type will default to working for pages only
161
  $post_type = apply_filters('advanced_sidebar_menu_post_type', 'page', $args, $instance );
 
 
 
 
162
  $asm->post_type = $post_type;
163
+ if( $asm->post_type != 'page' ){
164
+ add_filter('page_css_class', array( $asm, 'custom_post_type_css'), 2, 4 );
 
 
165
  }
166
 
167
 
168
+
169
+ $proper_single = !(is_single() || is_page() ) || (get_post_type() != $post_type);
170
+ //Filter the single post check if try to display the menu somewhere else like a category page
171
+ if( apply_filters('advanced_sidebar_menu_proper_single', $proper_single, $args, $instance) ) return;
172
+
173
 
174
+ //Get the Top Parent Id
 
175
  if($post->ancestors){
176
+ $top_parent = end( $post->ancestors );
177
  } else {
178
+ $top_parent = $post->ID;
179
+ }
 
 
 
180
  //Filter for specifying the top parent
181
  $top_parent = apply_filters('advanced_sidebar_menu_top_parent', $top_parent, $post, $args, $instance );
182
  $asm->top_id = $top_parent;
183
+
184
+
185
+ //Bail if the parent page does not belong in this menu
186
+ if( get_post_type( $asm->top_id ) != $asm->post_type ) return;
187
 
188
 
189
  //Filter for specifiying the order by
199
  //for depreciation
200
  $p = $top_parent;
201
  $result = $child_pages = apply_filters( 'advanced_sidebar_menu_child_pages', $child_pages, $post, $args, $instance );
202
+
203
 
204
  #---- if there are no children do not display the parent unless it is check to do so
205
+ if( (!empty($child_pages)) || $asm->checked('include_childless_parent') && (!in_array($top_parent, $exclude) ) ){
206
 
207
  $legacy = $asm->checked('legacy_mode' );
208