Title
Include Parent Page: />
Include Parent Even With No Children: />
Use Built in Styling: />
Pages to Exclude, Comma Separated:
Always Display Child Pages: />
'; } #------------------------------------------------------------------------------------------------------------------------------ // this allows more than one instance function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['include_childless_parent'] = strip_tags($new_instance['include_childless_parent']); $instance['include_parent'] = strip_tags($new_instance['include_parent']); $instance['exclude'] = strip_tags($new_instance['exclude']); $instance['display_all'] = strip_tags($new_instance['display_all']); $instance['levels'] = strip_tags($new_instance['levels']); $instance['css'] = strip_tags($new_instance['css']); $instance['title'] = strip_tags($new_instance['title']); return $instance; } #------------------------------------------------------------------------------------------------------------------------- // This decides the name of the widget function advanced_sidebar_menu_page( ) { /* Widget settings. */ $widget_ops = array( 'classname' => 'advanced-sidebar-menu', 'description' => 'Creates a menu of all the pages using the child/parent relationship' ); $control_ops = array( 'width' => 290 ); /* Create the widget. */ $this->WP_Widget( 'advanced_sidebar_menu', 'Advanced Sidebar Pages Menu', $widget_ops, $control_ops); } #--------------------------------------------------------------------------------------------------------------------------- /** * Outputs the page list * @see WP_Widget::widget() * @uses for custom post types send the type to the filter titled 'advanced_sidebar_menu_post_type' * @since 10.10.12 */ function widget($args, $instance) { $single_type = 'page'; //default use is for pages global $asm; //Filter this one with a 'single' for a custom post type will default to working for pages only $post_type = apply_filters('advanced_sidebar_menu_post_type', 'page' ); if( $post_type != 'page' ){ $single_type = 'single'; add_filter('page_css_class', array( $asm, 'custom_post_type_css'), 2, 4 ); } if( call_user_func('is_'.$single_type) ){ extract($args); global $wpdb, $post, $table_prefix, $asm; #-- Create a usable array of the excluded pages $exclude = explode(',', $instance['exclude']); #-- if the post has parents if($post->ancestors){ $top_parent = end( $post->ancestors ); } else { #--------- If this is the parent ------------------------------------------------ $top_parent = $post->ID; } /** * Must be done this way to prevent doubling up of pages */ $child_pages = $wpdb->get_results( "SELECT ID FROM ".$table_prefix."posts WHERE post_parent = $top_parent AND post_status='publish' Order by menu_order" ); //for depreciation $p = $top_parent; $result = $child_pages; #---- if there are no children do not display the parent unless it is check to do so if( ($child_pages) || (($instance['include_childless_parent'] == 'checked') && (!in_array($top_parent, $exclude)) ) ){ if( $instance['css'] == 'checked' ){ echo ''; } //Start the menu echo $before_widget; $asm->set_widget_vars( $instance, $top_parent, $exclude ); #-- Bring in the view require( $asm->file_hyercy( 'page_list.php' ) ); echo $after_widget; } } } #== /widget() } #== /Clas