Advanced Sidebar Menu - Version 6.4.1

Version Description

Download this release

Release Info

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

Code changes from version 6.1.0 to 6.4.1

advanced-sidebar-menu.php CHANGED
@@ -4,12 +4,12 @@ Plugin Name: Advanced Sidebar Menu
4
  Plugin URI: https://matlipe.com/advanced-sidebar-menu/
5
  Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
6
  Author: Mat Lipe
7
- Version: 6.1.0
8
  Author URI: https://matlipe.com
9
  Text Domain: advanced-sidebar-menu
10
  */
11
 
12
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '6.1.0' );
13
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
14
 
15
  if( !function_exists( 'advanced_sidebar_menu_load' ) ){
@@ -18,18 +18,18 @@ if( !function_exists( 'advanced_sidebar_menu_load' ) ){
18
  require( ADVANCED_SIDEBAR_DIR . 'src/widgets/advanced_sidebar_menu_category.php' );
19
  require( ADVANCED_SIDEBAR_DIR . 'src/widgets/advanced_sidebar_menu_page.php' );
20
 
21
- //main src
22
- require( ADVANCED_SIDEBAR_DIR . 'deprecated/Advanced_Sidebar_Menu_Menu_Deprecated.php' );
23
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu.php' );
24
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Menu.php' );
25
- require( ADVANCED_SIDEBAR_DIR . 'deprecated/advancedSidebarMenu.php' );
26
 
27
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Page_Walker.php' );
28
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_List_Pages.php' );
29
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Cache.php' );
30
 
 
 
31
  Advanced_Sidebar_Menu::init();
32
  Advanced_Sidebar_Menu_Cache::init();
 
33
  }
34
 
35
  add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
@@ -60,15 +60,17 @@ function advanced_sidebar_menu_pro_notice(){
60
  }
61
  ?>
62
  <fieldset style="border: 1px solid black; border-radius: 10px; padding: 10px;">
63
- <legend style="font-size: 14px; font-weight: bold;"><?php _e( 'Want More Options', 'advanced-sidebar-menu' ); ?>
64
- ?
65
  </legend>
66
  <p>
67
- <strong><big>
68
- <a target="blank" href="http://matlipe.com/product/advanced-sidebar-menu-pro/"><?php _e( 'Go Pro', 'advanced-sidebar-menu' ); ?>
69
- !
 
70
  </a>
71
- </big></strong>
 
72
  <p>
73
  </fieldset>
74
  <?php
4
  Plugin URI: https://matlipe.com/advanced-sidebar-menu/
5
  Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
6
  Author: Mat Lipe
7
+ Version: 6.4.1
8
  Author URI: https://matlipe.com
9
  Text Domain: advanced-sidebar-menu
10
  */
11
 
12
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '6.4.1' );
13
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
14
 
15
  if( !function_exists( 'advanced_sidebar_menu_load' ) ){
18
  require( ADVANCED_SIDEBAR_DIR . 'src/widgets/advanced_sidebar_menu_category.php' );
19
  require( ADVANCED_SIDEBAR_DIR . 'src/widgets/advanced_sidebar_menu_page.php' );
20
 
 
 
21
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu.php' );
22
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Menu.php' );
 
23
 
24
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Page_Walker.php' );
25
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_List_Pages.php' );
26
  require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Cache.php' );
27
 
28
+ require( ADVANCED_SIDEBAR_DIR . 'src/Advanced_Sidebar_Menu_Debug.php' );
29
+
30
  Advanced_Sidebar_Menu::init();
31
  Advanced_Sidebar_Menu_Cache::init();
32
+ Advanced_Sidebar_Menu_Debug::init();
33
  }
34
 
35
  add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
60
  }
61
  ?>
62
  <fieldset style="border: 1px solid black; border-radius: 10px; padding: 10px;">
63
+ <legend style="font-size: 14px; font-weight: bold;">
64
+ <?php _e( 'Want More Options', 'advanced-sidebar-menu' ); ?>?
65
  </legend>
66
  <p>
67
+ <strong>
68
+ <big>
69
+ <a target="blank" href="http://matlipe.com/product/advanced-sidebar-menu-pro/">
70
+ <?php _e( 'Go Pro', 'advanced-sidebar-menu' ); ?>!
71
  </a>
72
+ </big>
73
+ </strong>
74
  <p>
75
  </fieldset>
76
  <?php
composer.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "lipemat/advanced-sidebar-menu",
3
+ "description": "Menu widget generator for wordpress",
4
+ "type": "wordpress-plugin",
5
+ "license": "GPL",
6
+ "authors": [
7
+ {
8
+ "name": "lipemat",
9
+ "email": "mat@matlipe.com"
10
+ }
11
+ ],
12
+ "minimum-stability": "dev",
13
+ "require": {}
14
+ }
deprecated/Advanced_Sidebar_Menu_Menu_Deprecated.php DELETED
@@ -1,159 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Advanced_Sidebar_Menu_Deprecated
5
- *
6
- * For backward compatibility on template overrides only
7
- *
8
- * @see
9
- */
10
- abstract class Advanced_Sidebar_Menu_Menu_Deprecated {
11
-
12
- /**
13
- * @deprecated 6.0.0
14
- */
15
- static function file_hyercy( $file, $legacy = false ) {
16
- if( $theme_file = locate_template( array( 'advanced-sidebar-menu/' . $file ) ) ){
17
- $file = $theme_file;
18
- } else {
19
- $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file;
20
- }
21
-
22
- return apply_filters( 'advanced_sidebar_menu_view_file', $file, $legacy );
23
-
24
- }
25
-
26
- /**
27
- * @see add_has_children_class
28
- * @deprecated
29
- */
30
- function hasChildrenClass( $classes, $page ) {
31
- return $this->add_has_children_class( $classes, $page );
32
- }
33
-
34
-
35
- /**
36
- * @see has_children
37
- * @deprecated
38
- */
39
- function hasChildren( $post_id ){
40
- return $this->has_children( $post_id );
41
- }
42
-
43
-
44
- /**
45
- * @see is_excluded
46
- * @deprecated
47
- */
48
- function exclude( $id ) {
49
- return $this->is_excluded( $id );
50
- }
51
-
52
-
53
- /**
54
- * @deprecated 5.0.0
55
- */
56
- function page_children( $pID ) {
57
- global $wpdb, $table_prefix;
58
-
59
- _deprecated_function( 'Advanced_Sidebar_Menu_Menu::page_children', "5.0.0", 'Advanced_Sidebar_Menu_Menu::hasChildren' );
60
-
61
- return $wpdb->get_results( "SELECT ID FROM " . $table_prefix . "posts WHERE post_parent = " . $pID . " AND post_type = $this->post_type AND post_status='publish' ORDER By " . $this->order_by );
62
-
63
- }
64
-
65
-
66
- /**
67
- * @deprecated 5.0.0
68
- */
69
- function page_ancestor( $pID ) {
70
- global $post;
71
- if( is_numeric( $pID ) ){
72
- $pID = get_post( $pID );
73
- }
74
-
75
- if( $pID->ID == $post->ID or $pID->ID == $post->post_parent or @in_array( $pID->ID, $post->ancestors ) ){
76
- $return = true;
77
- } else {
78
- $return = false;
79
- }
80
-
81
- return apply_filters( 'advanced_sidebar_menu_page_ancestor', $return, $pID, $this );
82
- }
83
-
84
-
85
-
86
- /**
87
- * @deprecated 5.0.0
88
- */
89
- function grandChildLegacyMode( $pID ) {
90
- #-- if the link that was just listed is the current page we are on
91
- if( !$this->page_ancestor( $pID ) ){
92
- return;
93
- }
94
-
95
- //Get the children of this page
96
- $grandkids = $this->page_children( $pID );
97
- if( $grandkids ){
98
- #-- Create a new menu with all the children under it
99
- $content .= '<ul class="grandchild-sidebar-menu">';
100
- $content .= wp_list_pages( "post_type=" . $this->post_type . "&sort_column=$this->order_by&title_li=&echo=0&exclude=" . $this->instance[ 'exclude' ] . "&child_of=" . $pID->ID );
101
-
102
- $content .= '</ul>';
103
- }
104
-
105
- return $content;
106
- }
107
-
108
-
109
- /**
110
- * @deprecated 5.0.0
111
- */
112
- function displayGrandChildMenu( $page ) {
113
- static $count = 0;
114
- $count++;
115
-
116
- //If the page sent is not a child of the current page
117
- if( !$this->page_ancestor( $page ) ){
118
- return;
119
- }
120
-
121
- //if there are no children of the current page bail
122
- if( !$children = $this->page_children( $page->ID ) ){
123
- return;
124
- }
125
-
126
-
127
- $content = sprintf( '<ul class="grandchild-sidebar-menu level-%s children">', $count );
128
- foreach( $children as $child ){
129
-
130
- //If this page should be excluded bail
131
- if( in_array( $child->ID, $this->exclude ) ){
132
- continue;
133
- }
134
-
135
- $args = array(
136
- 'post_type' => $this->post_type,
137
- 'sort_column' => $this->order_by,
138
- 'title_li' => '',
139
- 'echo' => 0,
140
- 'depth' => 1,
141
- 'include' => $child->ID
142
- );
143
-
144
- $content .= $this->openListItem( wp_list_pages( $args ) );
145
-
146
- //If this newly outputed child is a direct parent of the current page
147
- if( $this->page_ancestor( $child ) ){
148
- $content .= $this->displayGrandChildMenu( $child );
149
- }
150
-
151
- $content .= '</li>';
152
-
153
- }
154
- $content .= '</ul>';
155
-
156
- return $content;
157
-
158
- }
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deprecated/advancedSidebarMenu.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- /**
3
- * @deprecated 6.0.0
4
- *
5
- */
6
- class advancedSidebarMenu extends Advanced_Sidebar_Menu_Menu{
7
-
8
- }
 
 
 
 
 
 
 
 
languages/advanced-sidebar-menu.pot CHANGED
@@ -1,127 +1,128 @@
1
- #, fuzzy
2
- msgid ""
3
- msgstr ""
4
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
- "Project-Id-Version: Advanced Sidebar Menu\n"
6
- "POT-Creation-Date: 2016-05-03 10:55-0400\n"
7
- "PO-Revision-Date: 2016-05-03 10:55-0400\n"
8
- "Last-Translator: \n"
9
- "Language-Team: \n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.7\n"
14
- "X-Poedit-Basepath: ..\n"
15
- "X-Poedit-WPHeader: advanced-sidebar-menu.php\n"
16
- "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
- "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
- "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
- "X-Poedit-SearchPath-0: .\n"
21
- "X-Poedit-SearchPathExcluded-0: *.js\n"
22
-
23
- #: advanced-sidebar-menu.php:65
24
- msgid "Want More Options"
25
- msgstr ""
26
-
27
- #: advanced-sidebar-menu.php:70
28
- msgid "Go Pro"
29
- msgstr ""
30
-
31
- #: src/widgets/advanced_sidebar_menu_category.php:35
32
- msgid ""
33
- "Creates a menu of all the categories using the child/parent relationship"
34
- msgstr ""
35
-
36
- #: src/widgets/advanced_sidebar_menu_category.php:39
37
- msgid "Advanced Sidebar Categories Menu"
38
- msgstr ""
39
-
40
- #: src/widgets/advanced_sidebar_menu_category.php:57
41
- #: src/widgets/advanced_sidebar_menu_page.php:59
42
- msgid "Title"
43
- msgstr ""
44
-
45
- #: src/widgets/advanced_sidebar_menu_category.php:64
46
- msgid "Include Parent Category"
47
- msgstr ""
48
-
49
- #: src/widgets/advanced_sidebar_menu_category.php:71
50
- #: src/widgets/advanced_sidebar_menu_page.php:72
51
- msgid "Include Parent Even With No Children"
52
- msgstr ""
53
-
54
- #: src/widgets/advanced_sidebar_menu_category.php:77
55
- msgid "Use this plugins styling"
56
- msgstr ""
57
-
58
- #: src/widgets/advanced_sidebar_menu_category.php:83
59
- msgid "Display Categories on Single Posts"
60
- msgstr ""
61
-
62
- #: src/widgets/advanced_sidebar_menu_category.php:96
63
- msgid "Display Each Single Post's Category"
64
- msgstr ""
65
-
66
- #: src/widgets/advanced_sidebar_menu_category.php:113
67
- msgid "Categories to Exclude, Comma Separated"
68
- msgstr ""
69
-
70
- #: src/widgets/advanced_sidebar_menu_category.php:118
71
- msgid "Always Display Child Categories"
72
- msgstr ""
73
-
74
- #: src/widgets/advanced_sidebar_menu_category.php:131
75
- #: src/widgets/advanced_sidebar_menu_page.php:121
76
- msgid "Levels to Display"
77
- msgstr ""
78
-
79
- #: src/widgets/advanced_sidebar_menu_page.php:33
80
- msgid "Creates a menu of all the pages using the child/parent relationship"
81
- msgstr ""
82
-
83
- #: src/widgets/advanced_sidebar_menu_page.php:40
84
- msgid "Advanced Sidebar Pages Menu"
85
- msgstr ""
86
-
87
- #: src/widgets/advanced_sidebar_menu_page.php:65
88
- msgid "Include Parent Page"
89
- msgstr ""
90
-
91
- #: src/widgets/advanced_sidebar_menu_page.php:78
92
- msgid "Order By"
93
- msgstr ""
94
-
95
- #: src/widgets/advanced_sidebar_menu_page.php:97
96
- msgid "Use this Plugin's Styling"
97
- msgstr ""
98
-
99
- #: src/widgets/advanced_sidebar_menu_page.php:103
100
- msgid "Pages to Exclude (ids), Comma Separated"
101
- msgstr ""
102
-
103
- #: src/widgets/advanced_sidebar_menu_page.php:108
104
- msgid "Always Display Child Pages"
105
- msgstr ""
106
-
107
- #. Plugin Name of the plugin/theme
108
- msgid "Advanced Sidebar Menu"
109
- msgstr ""
110
-
111
- #. Plugin URI of the plugin/theme
112
- msgid "https://matlipe.com/advanced-sidebar-menu/"
113
- msgstr ""
114
-
115
- #. Description of the plugin/theme
116
- msgid ""
117
- "Creates dynamic menus based on parent/child relationship of your pages or "
118
- "categories."
119
- msgstr ""
120
-
121
- #. Author of the plugin/theme
122
- msgid "Mat Lipe"
123
- msgstr ""
124
-
125
- #. Author URI of the plugin/theme
126
- msgid "https://matlipe.com"
127
- msgstr ""
 
1
+ #, fuzzy
2
+ msgid ""
3
+ msgstr ""
4
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
+ "Project-Id-Version: Advanced Sidebar Menu\n"
6
+ "POT-Creation-Date: 2017-04-12 16:44-0400\n"
7
+ "PO-Revision-Date: 2017-04-12 16:44-0400\n"
8
+ "Last-Translator: \n"
9
+ "Language-Team: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.0.1\n"
14
+ "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-Flags-xgettext: --add-comments=translators:\n"
16
+ "X-Poedit-WPHeader: advanced-sidebar-menu.php\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
19
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
20
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
21
+ "X-Poedit-SearchPath-0: .\n"
22
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
23
+
24
+ #: advanced-sidebar-menu.php:61
25
+ msgid "Want More Options"
26
+ msgstr ""
27
+
28
+ #: advanced-sidebar-menu.php:67
29
+ msgid "Go Pro"
30
+ msgstr ""
31
+
32
+ #: src/widgets/advanced_sidebar_menu_category.php:33
33
+ msgid ""
34
+ "Creates a menu of all the categories using the child/parent relationship"
35
+ msgstr ""
36
+
37
+ #: src/widgets/advanced_sidebar_menu_category.php:37
38
+ msgid "Advanced Sidebar Categories Menu"
39
+ msgstr ""
40
+
41
+ #: src/widgets/advanced_sidebar_menu_category.php:55
42
+ #: src/widgets/advanced_sidebar_menu_page.php:59
43
+ msgid "Title"
44
+ msgstr ""
45
+
46
+ #: src/widgets/advanced_sidebar_menu_category.php:62
47
+ msgid "Include Parent Category"
48
+ msgstr ""
49
+
50
+ #: src/widgets/advanced_sidebar_menu_category.php:69
51
+ #: src/widgets/advanced_sidebar_menu_page.php:72
52
+ msgid "Include Parent Even With No Children"
53
+ msgstr ""
54
+
55
+ #: src/widgets/advanced_sidebar_menu_category.php:75
56
+ msgid "Use this plugins styling"
57
+ msgstr ""
58
+
59
+ #: src/widgets/advanced_sidebar_menu_category.php:81
60
+ msgid "Display Categories on Single Posts"
61
+ msgstr ""
62
+
63
+ #: src/widgets/advanced_sidebar_menu_category.php:94
64
+ msgid "Display Each Single Post's Category"
65
+ msgstr ""
66
+
67
+ #: src/widgets/advanced_sidebar_menu_category.php:111
68
+ msgid "Categories to Exclude, Comma Separated"
69
+ msgstr ""
70
+
71
+ #: src/widgets/advanced_sidebar_menu_category.php:116
72
+ msgid "Always Display Child Categories"
73
+ msgstr ""
74
+
75
+ #: src/widgets/advanced_sidebar_menu_category.php:129
76
+ #: src/widgets/advanced_sidebar_menu_page.php:121
77
+ msgid "Levels to Display"
78
+ msgstr ""
79
+
80
+ #: src/widgets/advanced_sidebar_menu_page.php:33
81
+ msgid "Creates a menu of all the pages using the child/parent relationship"
82
+ msgstr ""
83
+
84
+ #: src/widgets/advanced_sidebar_menu_page.php:40
85
+ msgid "Advanced Sidebar Pages Menu"
86
+ msgstr ""
87
+
88
+ #: src/widgets/advanced_sidebar_menu_page.php:65
89
+ msgid "Include Parent Page"
90
+ msgstr ""
91
+
92
+ #: src/widgets/advanced_sidebar_menu_page.php:78
93
+ msgid "Order By"
94
+ msgstr ""
95
+
96
+ #: src/widgets/advanced_sidebar_menu_page.php:97
97
+ msgid "Use this Plugin's Styling"
98
+ msgstr ""
99
+
100
+ #: src/widgets/advanced_sidebar_menu_page.php:103
101
+ msgid "Pages to Exclude (ids), Comma Separated"
102
+ msgstr ""
103
+
104
+ #: src/widgets/advanced_sidebar_menu_page.php:108
105
+ msgid "Always Display Child Pages"
106
+ msgstr ""
107
+
108
+ #. Plugin Name of the plugin/theme
109
+ msgid "Advanced Sidebar Menu"
110
+ msgstr ""
111
+
112
+ #. Plugin URI of the plugin/theme
113
+ msgid "https://matlipe.com/advanced-sidebar-menu/"
114
+ msgstr ""
115
+
116
+ #. Description of the plugin/theme
117
+ msgid ""
118
+ "Creates dynamic menus based on parent/child relationship of your pages or "
119
+ "categories."
120
+ msgstr ""
121
+
122
+ #. Author of the plugin/theme
123
+ msgid "Mat Lipe"
124
+ msgstr ""
125
+
126
+ #. Author URI of the plugin/theme
127
+ msgid "https://matlipe.com"
128
+ msgstr ""
readme.txt CHANGED
@@ -3,9 +3,9 @@
3
  Contributors: Mat Lipe
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40matlipe%2ecom&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
5
  Tags: menus, sidebar menu, hierarchy, category menu, pages menu
6
- Requires at least: 4.2.0
7
- Tested up to: 4.5.1
8
- Stable tag: 6.1.0
9
 
10
  == Description ==
11
 
@@ -25,9 +25,8 @@ Keeps the menu clean and usable. Only related items display so you don't have to
25
  <li>Include the highest level parent page</li>
26
  <li>Include the highest level parent page even with no Children</li>
27
  <li>Order Pages By (date, title, page order)</li>
28
- <li>Use built in styling (very plain styling currently but plans for more advanced in near future versions)</li>
29
  <li>Exclude pages</li>
30
- <li>Legacy Mode - For those who like the way it was pre version 4.0</li>
31
  <li>Always display child Pages</li>
32
  <li>Number of levels of child pages to display</li>
33
  </ol>
@@ -37,7 +36,7 @@ Keeps the menu clean and usable. Only related items display so you don't have to
37
  <li>Add a title to the widget</li>
38
  <li>Include Parent Category</li>
39
  <li>Include Parent Even with no Children</li>
40
- <li>Use Built in Styling</li>
41
  <li>Display Categories on Single Posts</li>
42
  <li>To display each Single Posts Category in a new widget or in same list</li>
43
  <li>Exclude Categories</li>
@@ -83,10 +82,6 @@ Developer docs may be found here:
83
  The .pot file may be found in the plugins' languages folder. Use the 'advanced-sidebar-menu' text domain.
84
 
85
 
86
- = Version 4.0+ is not displaying the same as previous version of the plugin. How do I bring this back? =
87
-
88
- You will find a checkbox in the widget options for Legacy Mode.
89
-
90
  = How do I change the styling of the current page? =
91
 
92
  You may add css to your theme's style.css to change the way the menu looks
@@ -110,28 +105,31 @@ There is a checkbox in the widget options as of version 3.2 that will display th
110
  = How do you edit the output or built in css? =
111
 
112
  Create a folder in your child theme named "advanced-sidebar-menu" copy any of the files from the "views" folder into
113
- the folder you just created. You may edit the files at will to change the output or css?
114
  You must have the option checked to use the built in CSS (in the widget) to be able to edit the css file in this way.
115
- The Others will work always.
116
 
117
 
118
  = Does the menu change for each page you are on? =
119
 
120
- Yes. Based on whatever parents and children pages you are on, the menu will change automatically.
121
 
122
  = How does this work with styling the page? =
123
 
124
- As of version 1.1 this will automatically generate class names for each level for menu system.
125
  You can add classes to your theme's style.css file to style it accordingly.
126
  You may want to use something like margins to set the levels apart.
127
 
 
 
 
 
128
 
129
- = What if I want functionality which is not built in? =
130
-
131
- I do offer premium services for building custom add-ons for additional functionality. Otherwise you are welcome to alter the code in any way or build your own add-ons. keep in mind, if you edit the code directly, it will break on update. The best way to customize is using the built in filters or template overrides. If you have a cool add-on you have developed, let me know, I may want to publish your work.
132
 
 
 
133
 
134
- == Changelog ==
135
  = 6.1.0 =
136
  * Improve page list view
137
  * Add advanced_sidebar_menu_list_pages_args filter
3
  Contributors: Mat Lipe
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40matlipe%2ecom&lc=US&item_name=Advanced%20Sidebar%20Menu&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
5
  Tags: menus, sidebar menu, hierarchy, category menu, pages menu
6
+ Requires at least: 4.6.0
7
+ Tested up to: 4.8.2
8
+ Stable tag: 6.4.1
9
 
10
  == Description ==
11
 
25
  <li>Include the highest level parent page</li>
26
  <li>Include the highest level parent page even with no Children</li>
27
  <li>Order Pages By (date, title, page order)</li>
28
+ <li>Use built in styling (very plain styling, for more advanced styling <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/">Go Pro!</a>)</li>
29
  <li>Exclude pages</li>
 
30
  <li>Always display child Pages</li>
31
  <li>Number of levels of child pages to display</li>
32
  </ol>
36
  <li>Add a title to the widget</li>
37
  <li>Include Parent Category</li>
38
  <li>Include Parent Even with no Children</li>
39
+ <li>Use built in styling (very plain styling, for more advanced styling <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/">Go Pro!</a>)</li>
40
  <li>Display Categories on Single Posts</li>
41
  <li>To display each Single Posts Category in a new widget or in same list</li>
42
  <li>Exclude Categories</li>
82
  The .pot file may be found in the plugins' languages folder. Use the 'advanced-sidebar-menu' text domain.
83
 
84
 
 
 
 
 
85
  = How do I change the styling of the current page? =
86
 
87
  You may add css to your theme's style.css to change the way the menu looks
105
  = How do you edit the output or built in css? =
106
 
107
  Create a folder in your child theme named "advanced-sidebar-menu" copy any of the files from the "views" folder into
108
+ the folder you just created. You may edit the files at will to change the output or css.
109
  You must have the option checked to use the built in CSS (in the widget) to be able to edit the css file in this way.
 
110
 
111
 
112
  = Does the menu change for each page you are on? =
113
 
114
+ Yes. Based on whatever page you are on, the menu will change automatically to display the current parents and children.
115
 
116
  = How does this work with styling the page? =
117
 
118
+ This will automatically generate class names for each level for menu system.
119
  You can add classes to your theme's style.css file to style it accordingly.
120
  You may want to use something like margins to set the levels apart.
121
 
122
+ == Changelog ==
123
+ = 6.4.0 =
124
+ * Code improvements
125
+ * Performance improvements via shared child retrieval
126
 
127
+ = 6.3.0
128
+ * Improve category class handling for pro version accordion support
 
129
 
130
+ = 6.2.0 =
131
+ * Improve sorting of categories
132
 
 
133
  = 6.1.0 =
134
  * Improve page list view
135
  * Add advanced_sidebar_menu_list_pages_args filter
resources/js/advanced-sidebar-menu.js CHANGED
@@ -1,24 +1,23 @@
1
-
2
-
3
- //This will change the style display to block
4
- //For the element that is sent to it
5
- //Use the id or inline tags for this
6
- function asm_reveal_element( this_element_id ){
7
-
8
- //If the toggle has already been clicked to show
9
- //This will hide it
10
- if( document.getElementById( this_element_id ).style.display == 'none' ){
11
- document.getElementById( this_element_id ).style.display = 'block';
12
- //If the toggle has already been clicked to hide
13
- //This will show it
14
- } else {
15
- document.getElementById( this_element_id ).style.display = 'none';
16
- }
17
-
18
- }
19
-
20
-
21
-
22
-
23
-
24
-
1
+ /**
2
+ * Change the style display to block
3
+ * For the element that is sent to it
4
+ * Use the id or inline tags for this
5
+ *
6
+ **/
7
+ function asm_reveal_element( this_element_id ){
8
+ //If the toggle has already been clicked to show
9
+ //This will hide it
10
+ if( document.getElementById( this_element_id ).style.display === 'none' ){
11
+ document.getElementById( this_element_id ).style.display = 'block';
12
+ //If the toggle has already been clicked to hide
13
+ //This will show it
14
+ } else {
15
+ document.getElementById( this_element_id ).style.display = 'none';
16
+ }
17
+ }
18
+
19
+
20
+
21
+
22
+
23
+
 
src/Advanced_Sidebar_Menu.php CHANGED
@@ -1,88 +1,88 @@
1
- <?php
2
-
3
-
4
- /**
5
- * Advanced_Sidebar_Menu
6
- *
7
- * @author Mat Lipe
8
- * @since 6.0.0
9
- *
10
- */
11
- class Advanced_Sidebar_Menu {
12
-
13
- private function hooks(){
14
- add_action( 'widgets_init', array( $this, 'register_widgets' ) );
15
- }
16
-
17
-
18
- public function register_widgets(){
19
- register_widget( "advanced_sidebar_menu_page" );
20
- register_widget( "advanced_sidebar_menu_category" );
21
-
22
- }
23
-
24
-
25
- /**
26
- * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
27
- * or this plugins views folder if one does not exist
28
- *
29
- * @since 6.0.0
30
- *
31
- * @param string $file_name
32
- *
33
- * @return string
34
- */
35
- public function get_template_part( $file_name ){
36
- $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
37
- if( false == $file ){
38
- $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
39
- }
40
-
41
- //backward compatibility
42
- $file = apply_filters( 'advanced_sidebar_menu_view_file', $file, false );
43
-
44
- $_filter_args = array(
45
- $file,
46
- $file_name,
47
- $this,
48
- );
49
-
50
- $file = apply_filters_ref_array( 'advanced_sidebar_menu_template_part', $_filter_args );
51
-
52
- return $file;
53
- }
54
-
55
- //********** SINGLETON FUNCTIONS **********/
56
-
57
- /**
58
- * Instance of this class for use as singleton
59
- */
60
- private static $instance;
61
-
62
-
63
- /**
64
- * Create the instance of the class
65
- *
66
- * @static
67
- * @return void
68
- */
69
- public static function init(){
70
- self::get_instance()->hooks();
71
- }
72
-
73
-
74
- /**
75
- * Get (and instantiate, if necessary) the instance of the
76
- * class
77
- *
78
- * @static
79
- * @return self
80
- */
81
- public static function get_instance(){
82
- if( !is_a( self::$instance, __CLASS__ ) ){
83
- self::$instance = new self();
84
- }
85
-
86
- return self::$instance;
87
- }
88
  }
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu
6
+ *
7
+ * @author Mat Lipe
8
+ * @since 6.0.0
9
+ *
10
+ */
11
+ class Advanced_Sidebar_Menu {
12
+
13
+ private function hooks(){
14
+ add_action( 'widgets_init', array( $this, 'register_widgets' ) );
15
+ }
16
+
17
+
18
+ public function register_widgets(){
19
+ register_widget( "advanced_sidebar_menu_page" );
20
+ register_widget( "advanced_sidebar_menu_category" );
21
+
22
+ }
23
+
24
+
25
+ /**
26
+ * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
27
+ * or this plugins views folder if one does not exist
28
+ *
29
+ * @since 6.0.0
30
+ *
31
+ * @param string $file_name
32
+ *
33
+ * @return string
34
+ */
35
+ public function get_template_part( $file_name ){
36
+ $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
37
+ if( false == $file ){
38
+ $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
39
+ }
40
+
41
+ //backward compatibility
42
+ $file = apply_filters( 'advanced_sidebar_menu_view_file', $file, false );
43
+
44
+ $_filter_args = array(
45
+ $file,
46
+ $file_name,
47
+ $this,
48
+ );
49
+
50
+ $file = apply_filters_ref_array( 'advanced_sidebar_menu_template_part', $_filter_args );
51
+
52
+ return $file;
53
+ }
54
+
55
+ //********** SINGLETON FUNCTIONS **********/
56
+
57
+ /**
58
+ * Instance of this class for use as singleton
59
+ */
60
+ private static $instance;
61
+
62
+
63
+ /**
64
+ * Create the instance of the class
65
+ *
66
+ * @static
67
+ * @return void
68
+ */
69
+ public static function init(){
70
+ self::get_instance()->hooks();
71
+ }
72
+
73
+
74
+ /**
75
+ * Get (and instantiate, if necessary) the instance of the
76
+ * class
77
+ *
78
+ * @static
79
+ * @return self
80
+ */
81
+ public static function get_instance(){
82
+ if( !is_a( self::$instance, __CLASS__ ) ){
83
+ self::$instance = new self();
84
+ }
85
+
86
+ return self::$instance;
87
+ }
88
  }
src/Advanced_Sidebar_Menu_Cache.php CHANGED
@@ -1,122 +1,122 @@
1
- <?php
2
-
3
-
4
- /**
5
- * Advanced_Sidebar_Menu_Cache
6
- *
7
- * @author Mat Lipe
8
- * @since 12/19/2015
9
- *
10
- */
11
- class Advanced_Sidebar_Menu_Cache {
12
- const CACHE_GROUP = 'advanced-sidebar-menu';
13
- const CHILD_PAGES_KEY = 'child-pages';
14
-
15
- private function __construct(){
16
- $this->hooks();
17
- }
18
-
19
-
20
- private function hooks(){
21
- add_action( 'save_post', array( $this, 'clear_cache_group' ) );
22
- }
23
-
24
-
25
- /**
26
- * Clear all of items in this cache group
27
- *
28
- * @return void
29
- */
30
- public function clear_cache_group(){
31
- wp_cache_delete( self::CHILD_PAGES_KEY, self::CACHE_GROUP );
32
- }
33
-
34
-
35
- /**
36
- * Retrieve a posts child pages from the cache
37
- * If no exist in the cache will return false
38
- *
39
- * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
40
- *
41
- * @return array|false
42
- */
43
- public function get_child_pages( $class ){
44
- $key = $this->get_key_from_asm( $class );
45
- $all_child_pages = (array)wp_cache_get( self::CHILD_PAGES_KEY, self::CACHE_GROUP );
46
- if( isset( $all_child_pages[ $key ] ) ){
47
- return $all_child_pages[ $key ];
48
- } else {
49
- return false;
50
- }
51
- }
52
-
53
-
54
- /**
55
- * Add a post and its children to the cache
56
- * Uses a global key for all posts so this appends to an array
57
- *
58
- * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
59
- * @param array $child_pages
60
- *
61
- * @return void
62
- */
63
- public function add_child_pages( $class, $child_pages ){
64
- $key = $this->get_key_from_asm( $class );
65
- $all_child_pages = (array)wp_cache_get( self::CHILD_PAGES_KEY, self::CACHE_GROUP );
66
- $all_child_pages[ $key ] = $child_pages;
67
- wp_cache_set( self::CHILD_PAGES_KEY, $all_child_pages, self::CACHE_GROUP );
68
- }
69
-
70
-
71
- /**
72
- * There are many possibilities for properties
73
- * set to the object used for generations.
74
- * To guarantee we have a unique id for the cache
75
- * we serialize the whole object and hash it
76
- *
77
- *
78
- * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
79
- *
80
- * @return string
81
- */
82
- private function get_key_from_asm( $class ){
83
- $string = serialize( $class );
84
- $hash = md5( $string );
85
- return $hash;
86
- }
87
-
88
-
89
- //********** SINGLETON FUNCTIONS **********/
90
-
91
- /**
92
- * Instance of this class for use as singleton
93
- */
94
- private static $instance;
95
-
96
-
97
- /**
98
- * Create the instance of the class
99
- *
100
- * @static
101
- * @return void
102
- */
103
- public static function init(){
104
- self::$instance = self::get_instance();
105
- }
106
-
107
-
108
- /**
109
- * Get (and instantiate, if necessary) the instance of the
110
- * class
111
- *
112
- * @static
113
- * @return self
114
- */
115
- public static function get_instance(){
116
- if( !is_a( self::$instance, __CLASS__ ) ){
117
- self::$instance = new self();
118
- }
119
-
120
- return self::$instance;
121
- }
122
  }
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu_Cache
6
+ *
7
+ * @author Mat Lipe
8
+ * @since 12/19/2015
9
+ *
10
+ */
11
+ class Advanced_Sidebar_Menu_Cache {
12
+ const CACHE_GROUP = 'advanced-sidebar-menu';
13
+ const CHILD_PAGES_KEY = 'child-pages';
14
+
15
+ private function __construct(){
16
+ $this->hooks();
17
+ }
18
+
19
+
20
+ private function hooks(){
21
+ add_action( 'save_post', array( $this, 'clear_cache_group' ) );
22
+ }
23
+
24
+
25
+ /**
26
+ * Clear all of items in this cache group
27
+ *
28
+ * @return void
29
+ */
30
+ public function clear_cache_group(){
31
+ wp_cache_delete( self::CHILD_PAGES_KEY, self::CACHE_GROUP );
32
+ }
33
+
34
+
35
+ /**
36
+ * Retrieve a posts child pages from the cache
37
+ * If no exist in the cache will return false
38
+ *
39
+ * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
40
+ *
41
+ * @return array|false
42
+ */
43
+ public function get_child_pages( $class ){
44
+ $key = $this->get_key_from_asm( $class );
45
+ $all_child_pages = (array)wp_cache_get( self::CHILD_PAGES_KEY, self::CACHE_GROUP );
46
+ if( isset( $all_child_pages[ $key ] ) ){
47
+ return $all_child_pages[ $key ];
48
+ } else {
49
+ return false;
50
+ }
51
+ }
52
+
53
+
54
+ /**
55
+ * Add a post and its children to the cache
56
+ * Uses a global key for all posts so this appends to an array
57
+ *
58
+ * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
59
+ * @param array $child_pages
60
+ *
61
+ * @return void
62
+ */
63
+ public function add_child_pages( $class, $child_pages ){
64
+ $key = $this->get_key_from_asm( $class );
65
+ $all_child_pages = (array)wp_cache_get( self::CHILD_PAGES_KEY, self::CACHE_GROUP );
66
+ $all_child_pages[ $key ] = $child_pages;
67
+ wp_cache_set( self::CHILD_PAGES_KEY, $all_child_pages, self::CACHE_GROUP );
68
+ }
69
+
70
+
71
+ /**
72
+ * There are many possibilities for properties
73
+ * set to the object used for generations.
74
+ * To guarantee we have a unique id for the cache
75
+ * we serialize the whole object and hash it
76
+ *
77
+ *
78
+ * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
79
+ *
80
+ * @return string
81
+ */
82
+ private function get_key_from_asm( $class ){
83
+ $string = serialize( $class );
84
+ $hash = md5( $string );
85
+ return $hash;
86
+ }
87
+
88
+
89
+ //********** SINGLETON FUNCTIONS **********/
90
+
91
+ /**
92
+ * Instance of this class for use as singleton
93
+ */
94
+ private static $instance;
95
+
96
+
97
+ /**
98
+ * Create the instance of the class
99
+ *
100
+ * @static
101
+ * @return void
102
+ */
103
+ public static function init(){
104
+ self::$instance = self::get_instance();
105
+ }
106
+
107
+
108
+ /**
109
+ * Get (and instantiate, if necessary) the instance of the
110
+ * class
111
+ *
112
+ * @static
113
+ * @return self
114
+ */
115
+ public static function get_instance(){
116
+ if( !is_a( self::$instance, __CLASS__ ) ){
117
+ self::$instance = new self();
118
+ }
119
+
120
+ return self::$instance;
121
+ }
122
  }
src/Advanced_Sidebar_Menu_Debug.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu_Debug
6
+ *
7
+ * @author Mat Lipe
8
+ * @since 6.3.1
9
+ *
10
+ */
11
+ class Advanced_Sidebar_Menu_Debug {
12
+ const DEBUG_PARAM = 'asm_debug';
13
+
14
+ private function hook() {
15
+ if( !empty( $_REQUEST[ self::DEBUG_PARAM ] ) ){
16
+ add_action( 'advanced_sidebar_menu_widget_pre_render', array( $this, 'print_instance' ), 1, 2 );
17
+ }
18
+ }
19
+
20
+
21
+ /**
22
+ *
23
+ * @param Advanced_Sidebar_Menu_Menu $asm
24
+ * @param \advanced_sidebar_menu_page $widget
25
+ *
26
+ * @return void
27
+ */
28
+ public function print_instance( $asm, $widget ){
29
+ ?>
30
+ <script class="<?= self::DEBUG_PARAM; ?>">
31
+ var <?= self::DEBUG_PARAM; ?> = window.<?= self::DEBUG_PARAM; ?> || {};
32
+ <?= self::DEBUG_PARAM; ?>['version'] = '<?= ADVANCED_SIDEBAR_BASIC_VERSION; ?>';
33
+ <?= self::DEBUG_PARAM; ?>['<?= $widget->id; ?>'] = <?= json_encode( $asm->instance ); ?>;
34
+ </script>
35
+ <?php
36
+ }
37
+
38
+ //********** SINGLETON **********/
39
+
40
+
41
+ /**
42
+ * Instance of this class for use as singleton
43
+ */
44
+ private static $instance;
45
+
46
+
47
+ /**
48
+ * Create the instance of the class
49
+ *
50
+ * @static
51
+ * @return void
52
+ */
53
+ public static function init() {
54
+ self::instance()->hook();
55
+ }
56
+
57
+
58
+ /**
59
+ * Get (and instantiate, if necessary) the instance of the
60
+ * class
61
+ *
62
+ * @static
63
+ * @return self
64
+ */
65
+ public static function instance() {
66
+ if( !is_a( self::$instance, __CLASS__ ) ){
67
+ self::$instance = new self();
68
+ }
69
+
70
+ return self::$instance;
71
+ }
72
+ }
src/Advanced_Sidebar_Menu_List_Pages.php CHANGED
@@ -1,314 +1,393 @@
1
- <?php
2
-
3
- /**
4
- * Advanced_Sidebar_Menu_List_Pages
5
- *
6
- * Parse and build the child and grandchild menus
7
- * Create the opening and closing <ul class="child-sidebar-menu">
8
- * in the view and this will fill in the guts.
9
- *
10
- * Send the args ( similar to wp_list_pages ) to the constructor and then
11
- * display by calling list_pages()
12
- *
13
- * @package Advanced Sidebar Menu
14
- *
15
- * @author Mat Lipe <mat@matlipe.com>
16
- *
17
- * @since 5.0.0
18
- *
19
- */
20
- class Advanced_Sidebar_Menu_List_Pages{
21
-
22
- /**
23
- * output
24
- *
25
- * The page list
26
- *
27
- * @var string
28
- */
29
- public $output = '';
30
-
31
- /**
32
- * current_page
33
- *
34
- * Used when walking the list
35
- *
36
- * @var WP_Post
37
- */
38
- private $current_page = NULL;
39
-
40
- /**
41
- * current_page_id
42
- *
43
- * Holds id of current page. Separate from current_page because
44
- * current_page could be empty if something custom going on
45
- *
46
- * @var int
47
- */
48
- private $current_page_id = 0;
49
-
50
- /**
51
- * top_parent_id
52
- *
53
- * Id of current page unless filtered when whatever set during
54
- * widgetcreation
55
- *
56
- * @var int
57
- */
58
- private $top_parent_id = 0;
59
-
60
- /**
61
- * args
62
- *
63
- * Passed during construct given to walker and used for queries
64
- *
65
- * @var array
66
- */
67
- private $args = array();
68
-
69
-
70
- /**
71
- * level
72
- *
73
- * Level of grandchild pages we are on
74
- *
75
- * @var int
76
- */
77
- private $level = 0;
78
-
79
- /**
80
- * Used exclusively for caching
81
- * Holds the value of the latest parent we
82
- * retrieve children for
83
- *
84
- * @var int
85
- */
86
- private $current_children_parent = 0;
87
-
88
-
89
- /**
90
- * Constructor
91
- *
92
- * Used in the view
93
- *
94
- * @param int $parent_id - $asm->top_id
95
- * @param Advanced_Sidebar_Menu_Menu $class
96
- */
97
- public function __construct( $parent_id, $class ){
98
-
99
- $this->top_parent_id = $parent_id;
100
-
101
- $args = array(
102
- 'post_type' => $class->post_type,
103
- 'sort_column' => $class->order_by,
104
- 'exclude' => $class->exclude,
105
- 'levels' => $class->levels
106
- );
107
-
108
- $this->parse_args( $args );
109
-
110
- }
111
-
112
-
113
- /**
114
- * Return the list of args that have been populated by this class
115
- *
116
- * @return array
117
- */
118
- public function get_args(){
119
- return $this->args;
120
- }
121
-
122
-
123
- /**
124
- * __toString
125
- *
126
- * Magic method to allow using a simple echo to get output
127
- *
128
- * @return string
129
- */
130
- public function __toString(){
131
- return $this->output;
132
- }
133
-
134
-
135
-
136
- /**
137
- *
138
- * Do any adjustments to class args here
139
- *
140
- * @param array $args
141
- *
142
- * @return void
143
- */
144
- private function parse_args( $args ){
145
- $defaults = array(
146
- 'depth' => 1,
147
- 'exclude' => '',
148
- 'echo' => 0,
149
- 'sort_order' => 'ASC',
150
- 'sort_column' => 'menu_order, post_title',
151
- 'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
152
- 'hierarchical' => 0,
153
- 'link_before' => '',
154
- 'link_after' => '',
155
- 'title_li' => '',
156
- 'levels' => 100
157
- );
158
-
159
- $args = wp_parse_args( $args, $defaults );
160
-
161
- // sanitize, mostly to keep spaces out
162
- if( is_string( $args[ 'exclude' ] ) ){
163
- $args[ 'exclude' ] = explode( ',', $args[ 'exclude' ] );
164
- }
165
- $args[ 'exclude' ] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args[ 'exclude' ] ) ) );
166
-
167
- if ( is_page() || is_singular() ) {
168
- $this->current_page = get_queried_object();
169
- $this->current_page_id = $this->current_page->ID;
170
- }
171
-
172
- $this->args = apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
173
-
174
- }
175
-
176
-
177
- /**
178
- * list_pages
179
- *
180
- * List the pages very similar to wp_list_pages
181
- *
182
- * @return string|void
183
- */
184
- public function list_pages() {
185
-
186
- $pages = $this->get_child_pages( $this->top_parent_id );
187
-
188
- foreach( $pages as $page ){
189
-
190
- $this->output .= walk_page_tree( array( $page ), 1, $this->current_page_id, $this->args );
191
-
192
- $this->output .= $this->list_grandchild_pages( $page->ID );
193
-
194
- $this->output .= "</li>\n";
195
-
196
- }
197
-
198
- $this->output = apply_filters( 'wp_list_pages', $this->output, $this->args );
199
-
200
- if( $this->args[ 'echo' ] ){
201
- echo $this->output;
202
- } else {
203
- return $this->output;
204
- }
205
- }
206
-
207
-
208
- /**
209
- * list_grandchild_pages
210
- *
211
- * List as many levels as exist within the grandchild-sidebar-menu ul
212
- *
213
- * @param int $parent_page_id
214
- *
215
- * @return string
216
- */
217
- private function list_grandchild_pages( $parent_page_id ){
218
- if( !$this->current_page_ancestor( $parent_page_id ) ){
219
- return '';
220
- }
221
-
222
- if( !$pages = $this->get_child_pages( $parent_page_id ) ){
223
- return '';
224
- }
225
-
226
- if( $this->level == $this->args[ 'levels' ] ){
227
- return '';
228
- }
229
-
230
- $this->level++;
231
-
232
- $content = sprintf( '<ul class="grandchild-sidebar-menu level-%s children">', $this->level );
233
- $inside = '';
234
-
235
- foreach( $pages as $page ){
236
- $inside .= walk_page_tree( array( $page ), 1, $this->current_page_id, $this->args );
237
- $inside .= $this->list_grandchild_pages( $page->ID );
238
- $inside .= "</li>\n";
239
-
240
- }
241
-
242
- if( '' == $inside ){
243
- return '';
244
- }
245
-
246
-
247
- return $content . $inside . "</ul>\n";
248
- }
249
-
250
-
251
- /**
252
- * page_children
253
- *
254
- * Retrieve the child pages of specific page_id
255
- *
256
- * @param $parent_page_id
257
- *
258
- * @return array
259
- */
260
- public function get_child_pages( $parent_page_id ) {
261
- $this->current_children_parent = $parent_page_id;
262
-
263
- $cache = Advanced_Sidebar_Menu_Cache::get_instance();
264
- $child_pages = $cache->get_child_pages( $this );
265
- if( $child_pages === false ){
266
- $args = $this->args;
267
- $args[ 'parent' ] = $this->current_children_parent;
268
- $child_pages = get_pages( $args );
269
-
270
- $cache->add_child_pages( $this, $child_pages );
271
- }
272
-
273
- return $child_pages;
274
-
275
- }
276
-
277
-
278
- /**
279
- * current_page_ancestor
280
- *
281
- * Is the current page and ancestor of the specified page?
282
- *
283
- * @param $page_id
284
- *
285
- * @return bool
286
- */
287
- private function current_page_ancestor( $page_id ) {
288
- $return = false;
289
- if( !empty( $this->current_page_id ) ){
290
- if( $page_id == $this->current_page_id ){
291
- $return = true;
292
- } elseif( $this->current_page->post_parent == $page_id ) {
293
- $return = true;
294
- } else {
295
- if( !empty( $this->current_page->ancestors ) ){
296
- if( in_array( $page_id, $this->current_page->ancestors ) ){
297
- $return = true;
298
- }
299
- }
300
- }
301
- }
302
-
303
- $return = apply_filters(
304
- 'advanced_sidebar_menu_page_ancestor',
305
- $return,
306
- $this->current_page_id,
307
- $this
308
- );
309
-
310
- return $return;
311
- }
312
-
313
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }
1
+ <?php
2
+
3
+ /**
4
+ * Advanced_Sidebar_Menu_List_Pages
5
+ *
6
+ * Parse and build the child and grandchild menus
7
+ * Create the opening and closing <ul class="child-sidebar-menu">
8
+ * in the view and this will fill in the guts.
9
+ *
10
+ * Send the args ( similar to wp_list_pages ) to the constructor and then
11
+ * display by calling list_pages()
12
+ *
13
+ * @package Advanced Sidebar Menu
14
+ *
15
+ * @author Mat Lipe <mat@matlipe.com>
16
+ *
17
+ * @since 5.0.0
18
+ *
19
+ */
20
+ class Advanced_Sidebar_Menu_List_Pages{
21
+
22
+ /**
23
+ * output
24
+ *
25
+ * The page list
26
+ *
27
+ * @var string
28
+ */
29
+ public $output = '';
30
+
31
+ /**
32
+ * current_page
33
+ *
34
+ * Used when walking the list
35
+ *
36
+ * @var WP_Post
37
+ */
38
+ protected $current_page;
39
+
40
+ /**
41
+ * current_page_id
42
+ *
43
+ * Holds id of current page. Separate from current_page because
44
+ * current_page could be empty if something custom going on
45
+ *
46
+ * @var int
47
+ */
48
+ protected $current_page_id = 0;
49
+
50
+ /**
51
+ * top_parent_id
52
+ *
53
+ * Id of current page unless filtered when whatever set during
54
+ * widgetcreation
55
+ *
56
+ * @var int
57
+ */
58
+ public $top_parent_id;
59
+
60
+ /**
61
+ * args
62
+ *
63
+ * Passed during construct given to walker and used for queries
64
+ *
65
+ * @var array
66
+ */
67
+ private $args = array();
68
+
69
+
70
+ /**
71
+ * level
72
+ *
73
+ * Level of grandchild pages we are on
74
+ *
75
+ * @var int
76
+ */
77
+ private $level = 0;
78
+
79
+ /**
80
+ * Used exclusively for caching
81
+ * Holds the value of the latest parent we
82
+ * retrieve children for
83
+ *
84
+ * @var int
85
+ */
86
+ private $current_children_parent = 0;
87
+
88
+ /**
89
+ * menu
90
+ *
91
+ * @var \Advanced_Sidebar_Menu_Menu
92
+ */
93
+ protected $menu;
94
+
95
+
96
+ /**
97
+ * Constructor
98
+ *
99
+ * Used in the view
100
+ *
101
+ * @param int $parent_id - $asm->top_id
102
+ * @param Advanced_Sidebar_Menu_Menu $asm
103
+ * @param WP_Post $current_page;
104
+ */
105
+ public function __construct( $parent_id, \Advanced_Sidebar_Menu_Menu $asm, $current_page ){
106
+ $this->menu = $asm;
107
+ $this->top_parent_id = $parent_id;
108
+ $this->current_page = $current_page;
109
+ if( null !== $current_page ){
110
+ $this->current_page_id = $current_page->ID;
111
+ }
112
+
113
+ $args = array(
114
+ 'post_type' => $asm->post_type,
115
+ 'orderby' => $asm->order_by,
116
+ 'order' => $asm->order,
117
+ 'exclude' => $asm->exclude,
118
+ 'levels' => $asm->levels,
119
+ );
120
+
121
+ $this->parse_args( $args );
122
+ $this->hooks();
123
+
124
+ }
125
+
126
+
127
+ /**
128
+ * Hooks should only hook once
129
+ *
130
+ * @return void
131
+ */
132
+ protected function hooks() {
133
+ static $been_hooked;
134
+ if( null === $been_hooked ){
135
+ $been_hooked = true;
136
+ add_filter( 'page_css_class', array( $this, 'add_list_item_classes' ), 2, 2 );
137
+ }
138
+
139
+ }
140
+
141
+
142
+ /**
143
+ * Add the custom classes to the list items
144
+ *
145
+ *
146
+ * @param array $classes
147
+ * @param \WP_Post $post
148
+ *
149
+ * @return array
150
+ */
151
+ public function add_list_item_classes( $classes, \WP_Post $post ) {
152
+ if( $post->ID === $this->top_parent_id ){
153
+ $children = $this->get_child_pages( $post->ID, true );
154
+ } else {
155
+ $children = $this->get_child_pages( $post->ID );
156
+ }
157
+ if( !empty( $children ) ){
158
+ $classes[] = 'has_children';
159
+ }
160
+
161
+ //below is only for custom post types
162
+ if( $this->current_page->post_type !== 'page' ){
163
+ if( isset( $post->ancestors ) && in_array( $this->current_page->ID, (array) $post->ancestors, true ) ){
164
+ $classes[] = 'current_page_ancestor';
165
+ } elseif( $this->current_page->ID === $post->post_parent ) {
166
+ $classes[] = 'current_page_parent';
167
+ }
168
+ }
169
+
170
+ return $classes;
171
+ }
172
+
173
+
174
+ /**
175
+ * Return the list of args that have been populated by this class
176
+ *
177
+ * @return array
178
+ */
179
+ public function get_args(){
180
+ return $this->args;
181
+ }
182
+
183
+
184
+ /**
185
+ * __toString
186
+ *
187
+ * Magic method to allow using a simple echo to get output
188
+ *
189
+ * @return string
190
+ */
191
+ public function __toString(){
192
+ return $this->output;
193
+ }
194
+
195
+
196
+
197
+ /**
198
+ *
199
+ * Do any adjustments to class args here
200
+ *
201
+ * @param array $args
202
+ *
203
+ * @return void
204
+ */
205
+ private function parse_args( $args ){
206
+ $defaults = array(
207
+ 'exclude' => '',
208
+ 'echo' => 0,
209
+ 'order' => 'ASC',
210
+ 'orderby' => 'menu_order, post_title',
211
+ 'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
212
+ 'link_before' => '',
213
+ 'link_after' => '',
214
+ 'title_li' => '',
215
+ 'levels' => 100,
216
+ 'item_spacing' => 'preserve',
217
+ 'nopaging' => true,
218
+ );
219
+
220
+ $args = wp_parse_args( $args, $defaults );
221
+
222
+ // sanitize, mostly to keep spaces out
223
+ if( is_string( $args[ 'exclude' ] ) ){
224
+ $args[ 'exclude' ] = explode( ',', $args[ 'exclude' ] );
225
+ }
226
+ $args[ 'exclude' ] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args[ 'exclude' ] ) ) );
227
+
228
+ $this->args = apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
229
+
230
+ }
231
+
232
+
233
+ /**
234
+ * list_pages
235
+ *
236
+ * List the pages very similar to wp_list_pages
237
+ *
238
+ * @return string
239
+ */
240
+ public function list_pages() {
241
+
242
+ $pages = $this->get_child_pages( $this->top_parent_id, true );
243
+
244
+ foreach( $pages as $page ){
245
+
246
+ $this->output .= walk_page_tree( array( $page ), 1, $this->current_page_id, $this->args );
247
+
248
+ $this->output .= $this->list_grandchild_pages( $page->ID );
249
+
250
+ $this->output .= '</li>' . "\n";
251
+
252
+ }
253
+
254
+ $this->output = apply_filters( 'wp_list_pages', $this->output, $this->args );
255
+
256
+ if( !$this->args[ 'echo' ] ){
257
+ return $this->output;
258
+ }
259
+
260
+ echo $this->output;
261
+ }
262
+
263
+
264
+ /**
265
+ * list_grandchild_pages
266
+ *
267
+ * List as many levels as exist within the grandchild-sidebar-menu ul
268
+ *
269
+ * @param int $parent_page_id
270
+ *
271
+ * @return string
272
+ */
273
+ private function list_grandchild_pages( $parent_page_id ){
274
+ if( !$this->current_page_ancestor( $parent_page_id ) ){
275
+ return '';
276
+ }
277
+
278
+ if( !$pages = $this->get_child_pages( $parent_page_id ) ){
279
+ return '';
280
+ }
281
+
282
+ if( $this->level === (int)$this->args[ 'levels' ] ){
283
+ return '';
284
+ }
285
+
286
+ $this->level++;
287
+
288
+ $content = sprintf( '<ul class="grandchild-sidebar-menu level-%s children">', $this->level );
289
+ $inside = '';
290
+
291
+ foreach( $pages as $page ){
292
+ $inside .= walk_page_tree( array( $page ), 1, $this->current_page_id, $this->args );
293
+ $inside .= $this->list_grandchild_pages( $page->ID );
294
+ $inside .= "</li>\n";
295
+
296
+ }
297
+
298
+ if( '' === $inside ){
299
+ return '';
300
+ }
301
+
302
+
303
+ return $content . $inside . "</ul>\n";
304
+ }
305
+
306
+
307
+ /**
308
+ * page_children
309
+ *
310
+ * Retrieve the child pages of specific page_id
311
+ *
312
+ * @param int $parent_page_id
313
+ * @param bool $is_first_level
314
+ *
315
+ * @return array
316
+ */
317
+ public function get_child_pages( $parent_page_id, $is_first_level = false ) {
318
+ $this->current_children_parent = $parent_page_id;
319
+
320
+ $cache = Advanced_Sidebar_Menu_Cache::get_instance();
321
+ $child_pages = $cache->get_child_pages( $this );
322
+ if( $child_pages === false ){
323
+ $args = $this->args;
324
+ $args[ 'post_parent' ] = $parent_page_id;
325
+ $args[ 'fields' ] = 'ids';
326
+
327
+ $child_pages = get_posts( $args );
328
+ $cache->add_child_pages( $this, $child_pages );
329
+ }
330
+
331
+ $child_pages = array_map( 'get_post', (array)$child_pages );
332
+
333
+ //we only filter the first level with this filter for backward pro compatibility
334
+ if( $is_first_level ){
335
+ $child_pages = apply_filters( 'advanced_sidebar_menu_child_pages', $child_pages, $this->current_page, $this->menu->instance, $this->menu->args, $this->menu );
336
+ }
337
+
338
+ return $child_pages;
339
+
340
+ }
341
+
342
+
343
+ /**
344
+ * current_page_ancestor
345
+ *
346
+ * Is the current page and ancestor of the specified page?
347
+ *
348
+ * @param $page_id
349
+ *
350
+ * @return bool
351
+ */
352
+ private function current_page_ancestor( $page_id ) {
353
+ $return = false;
354
+ if( !empty( $this->current_page_id ) ){
355
+ if( (int)$page_id === $this->current_page_id ){
356
+ $return = true;
357
+ } elseif( $this->current_page->post_parent === (int)$page_id ) {
358
+ $return = true;
359
+ } elseif( !empty( $this->current_page->ancestors ) && in_array( (int)$page_id, $this->current_page->ancestors, true ) ) {
360
+ $return = true;
361
+ }
362
+ }
363
+
364
+ $return = apply_filters(
365
+ 'advanced_sidebar_menu_page_ancestor',
366
+ $return,
367
+ $this->current_page_id,
368
+ $this
369
+ );
370
+
371
+ return $return;
372
+ }
373
+
374
+
375
+ /**
376
+ *
377
+ * @param \Advanced_Sidebar_Menu_Menu $menu
378
+ * @param \WP_Post|null $current_page;
379
+ *
380
+ * @static
381
+ *
382
+ * @return \Advanced_Sidebar_Menu_List_Pages
383
+ */
384
+ public static function factory( Advanced_Sidebar_Menu_Menu $menu, $current_page = null ){
385
+ if( null === $current_page ){
386
+ if ( is_page() || is_singular() ) {
387
+ $current_page = get_queried_object();
388
+ }
389
+ }
390
+ return new self( $menu->top_id, $menu, $current_page );
391
+ }
392
+
393
  }
src/Advanced_Sidebar_Menu_Menu.php CHANGED
@@ -1,307 +1,287 @@
1
- <?php
2
- /**
3
- * Advanced_Sidebar_Menu_Menu
4
- *
5
- * These Functions are Specific to the Advanced Sidebar Menu
6
- *
7
- * @author Mat Lipe <mat@matlipe.com>
8
- *
9
- * @package Advanced Sidebar Menu
10
- */
11
- class Advanced_Sidebar_Menu_Menu extends Advanced_Sidebar_Menu_Menu_Deprecated {
12
-
13
- var $instance; //The widget instance
14
- var $top_id; //Either the top cat or page
15
- var $exclude = array();
16
- var $ancestors; //For the category ancestors
17
- var $count = 1; //Count for grandchild levels
18
- var $order_by;
19
- var $taxonomy; //For filters to override the taxonomy
20
- var $current_term; //Current category or taxonomy
21
-
22
- /**
23
- * args
24
- *
25
- * Widget Args
26
- *
27
- * @var array
28
- */
29
- public $args = array();
30
-
31
- /**
32
- * post_type
33
- *
34
- * @var string
35
- */
36
- public $post_type = 'page';
37
-
38
- public $levels = 100;
39
-
40
-
41
- /**
42
- * Check is a post has children
43
- *
44
- * @param int $post_id
45
- *
46
- * @return bool
47
- */
48
- function has_children( $post_id ){
49
- $args = array(
50
- 'post_parent' => $post_id,
51
- 'fields' => 'ids',
52
- 'post_type' => get_post_type( $post_id ),
53
- 'post_status' => 'publish',
54
- 'numberposts' => 1,
55
- );
56
-
57
- $children = get_children( $args );
58
-
59
- return !empty( $children );
60
- }
61
-
62
-
63
- /**
64
- * Checks if a widgets checkbox is checked.
65
- * * this one is special and does a double check
66
- *
67
- * @since 4.1.3
68
- *
69
- * @param string $name - name of checkbox
70
- */
71
- function checked( $name ) {
72
- if( isset( $this->instance[ $name ] ) && $this->instance[ $name ] == 'checked' ){
73
- return true;
74
- }
75
-
76
- return false;
77
-
78
- }
79
-
80
-
81
- /**
82
- * Used by a uasort to sort taxonomy arrays by term order
83
- *
84
- * @since 4.3.0
85
- */
86
- function sortTerms( $a, $b ) {
87
- if( !isset( $a->{$this->order_by} ) || !isset( $b->{$this->order_by} ) ){
88
- return 0;
89
- }
90
-
91
- return $a->{$this->order_by} > $b->{$this->order_by};
92
-
93
- }
94
-
95
-
96
- /**
97
- * Retrieves the Highest level Category Id
98
- *
99
- * @since 6.6.13
100
- *
101
- * @param int $catId - id of cat looking for top parent of
102
- *
103
- * @return int
104
- */
105
- function getTopCat( $catId ) {
106
- $cat_ancestors = array();
107
- $cat_ancestors[ ] = $catId;
108
-
109
- do {
110
- $catId = get_term( $catId, $this->taxonomy );
111
- $catId = $catId->parent;
112
- $cat_ancestors[ ] = $catId;
113
- } while( $catId );
114
-
115
- //Reverse the array to start at the last
116
- $this->ancestors = array_reverse( $cat_ancestors );
117
-
118
- //forget the [0] because the parent of top parent is always 0
119
- return $this->ancestors[ 1 ];
120
-
121
- }
122
-
123
-
124
- /**
125
- * Removes the closing </li> tag from a list item to allow for child menus inside of it
126
- *
127
- * @param string $item - an <li></li> item
128
- *
129
- * @return string|bool
130
- * @since 4.7.13
131
- */
132
- function openListItem( $item = false ) {
133
- if( !$item ){
134
- return false;
135
- }
136
-
137
- return substr( trim( $item ), 0, -5 );
138
- }
139
-
140
-
141
- /**
142
- * Adds the class for any menu item with children
143
- *
144
- * @param array $classes the current css classes
145
- * @param \WP_Post $page the page being checked
146
- *
147
- * @return array
148
- */
149
- public function add_has_children_class( $classes, $page ) {
150
- if( $this->has_children( $page->ID ) ){
151
- $classes[] = 'has_children';
152
- }
153
-
154
- return $classes;
155
- }
156
-
157
-
158
- /**
159
- * Adds the class for current page item etc to the page list when using a custom post type
160
- *
161
- * @param array $classes the current css classes
162
- * @param \WP_Post $this_menu_item the page being checked
163
- *
164
- * @return array
165
- */
166
- function custom_post_type_css( $classes, $this_menu_item ) {
167
- global $post;
168
- if( isset( $post->ancestors ) && in_array( $this_menu_item->ID, (array)$post->ancestors ) ){
169
- $classes[ ] = 'current_page_ancestor';
170
- }
171
- if( $this_menu_item->ID == $post->ID ){
172
- $classes[ ] = 'current_page_item';
173
-
174
- } elseif( $this_menu_item->ID == $post->post_parent ) {
175
- $classes[ ] = 'current_page_parent';
176
- }
177
-
178
- return $classes;
179
- }
180
-
181
-
182
- /**
183
- *
184
- * IF this is a top level category
185
- *
186
- * @param \WP_Term $cat the cat object
187
- *
188
- * @since 6.13.13
189
- */
190
- function first_level_category( $cat ) {
191
-
192
- if( !in_array( $cat->term_id, $this->exclude ) && $cat->parent == $this->top_id ){
193
- $return = true;
194
- } else {
195
- $return = false;
196
- }
197
-
198
- return apply_filters( 'advanced_sidebar_menu_first_level_category', $return, $cat, $this );
199
-
200
- }
201
-
202
-
203
- /**
204
- * If the cat is a second level cat
205
- *
206
- * @param \WP_Term $cat the cat
207
- *
208
- * @since 6.13.13
209
- */
210
- function second_level_cat( $cat ) {
211
-
212
- //if this is the current cat or a parent of the current cat
213
- if( $cat->term_id == $this->current_term || in_array( $cat->term_id, $this->ancestors ) ){
214
- $all_children = get_terms( $this->taxonomy, array( 'child_of' => $cat->term_id, 'fields' => 'ids' ) );
215
- if( !empty( $all_children ) ){
216
- $return = true;
217
- } else {
218
- $return = false;
219
- }
220
-
221
- } else {
222
- $return = false;
223
- }
224
-
225
- return apply_filters( 'advanced_sidebar_menu_second_level_category', $return, $cat, $this );
226
-
227
-
228
- }
229
-
230
-
231
- /**
232
- * Determines if all the children should be included
233
- *
234
- * @since 6.26.13
235
- * @return bool
236
- */
237
- function display_all() {
238
- return $this->checked( 'display_all' );
239
- }
240
-
241
-
242
- /**
243
- * Determines if the parent page or cat should be included
244
- *
245
- * @since 6.26.13
246
- * @return bool
247
- */
248
- function include_parent() {
249
- if( !$this->checked( 'include_parent' ) ){
250
- return false;
251
- }
252
-
253
- if( ( !in_array( $this->top_id, $this->exclude ) ) ){
254
- return true;
255
- }
256
-
257
- return false;
258
- }
259
-
260
-
261
- /**
262
- * Echos the title of the widget to the page
263
- *
264
- * @since 6.26.13
265
- */
266
- function title() {
267
- if( isset( $this->instance[ 'title' ] ) && ( $this->instance[ 'title' ] != '' ) ){
268
- $title = apply_filters( 'widget_title', $this->instance[ 'title' ], $this->args, $this->instance );
269
- $title = apply_filters( 'advanced_sidebar_menu_widget_title', $title, $this->args, $this->instance, $this );
270
-
271
- echo $this->args[ 'before_title' ] . $title . $this->args[ 'after_title' ];
272
- }
273
-
274
- }
275
-
276
-
277
- /**
278
- * Retrieve the excluded items' ids
279
- *
280
- * @return array
281
- */
282
- public function get_excluded_ids(){
283
- $excluded = $this->exclude;
284
- $excluded = array_filter( $excluded );
285
- $excluded = array_map( 'intval', $excluded );
286
- return $excluded;
287
- }
288
-
289
-
290
- /**
291
- *
292
- * Checks is this id is excluded or not
293
- *
294
- * @param int $id
295
- *
296
- * @return bool
297
- */
298
- public function is_excluded( $id ) {
299
- if( !in_array( $id, $this->exclude ) ){
300
- return true;
301
- } else {
302
- return false;
303
- }
304
- }
305
-
306
- } //End class
307
-
1
+ <?php
2
+ /**
3
+ * Advanced_Sidebar_Menu_Menu
4
+ *
5
+ * These Functions are Specific to the Advanced Sidebar Menu
6
+ *
7
+ * @author Mat Lipe <mat@matlipe.com>
8
+ *
9
+ * @package Advanced Sidebar Menu
10
+ */
11
+ class Advanced_Sidebar_Menu_Menu {
12
+
13
+ public $instance; //The widget instance
14
+ public $top_id; //Either the top cat or page
15
+ public $exclude = array();
16
+ public $ancestors; //For the category ancestors
17
+ public $count = 1; //Count for grandchild levels
18
+ public $order_by = null;
19
+ public $order = 'ASC';
20
+ public $taxonomy; //For filters to override the taxonomy
21
+ public $current_term; //Current category or taxonomy
22
+
23
+ /**
24
+ * args
25
+ *
26
+ * Widget Args
27
+ *
28
+ * @var array
29
+ */
30
+ public $args = array();
31
+
32
+ /**
33
+ * post_type
34
+ *
35
+ * @var string
36
+ */
37
+ public $post_type = 'page';
38
+
39
+ public $levels = 100;
40
+
41
+ /**
42
+ * list_pages
43
+ *
44
+ * @var \Advanced_Sidebar_Menu_List_Pages
45
+ */
46
+ protected $list_pages;
47
+
48
+
49
+ /**
50
+ * The instance arguments from the current widget
51
+ *
52
+ * @return []
53
+ */
54
+ public function get_widget_instance(){
55
+ return $this->instance;
56
+ }
57
+
58
+
59
+ /**
60
+ * Checks if a widgets checkbox is checked.
61
+ * * this one is special and does a double check
62
+ *
63
+ * @since 4.1.3
64
+ *
65
+ * @param string $name - name of checkbox
66
+ *
67
+ * @return bool
68
+ */
69
+ public function checked( $name ) {
70
+ return isset( $this->instance[ $name ] ) && $this->instance[ $name ] === 'checked';
71
+ }
72
+
73
+
74
+ /**
75
+ * Retrieves the Highest level Category Id
76
+ *
77
+ * @since 6.6.13
78
+ *
79
+ * @param int $catId - id of cat looking for top parent of
80
+ *
81
+ * @return int
82
+ */
83
+ function getTopCat( $catId ) {
84
+ $cat_ancestors = array();
85
+ $cat_ancestors[ ] = $catId;
86
+
87
+ do {
88
+ $catId = get_term( $catId, $this->taxonomy );
89
+ $catId = $catId->parent;
90
+ $cat_ancestors[ ] = $catId;
91
+ } while( $catId );
92
+
93
+ //Reverse the array to start at the last
94
+ $this->ancestors = array_reverse( $cat_ancestors );
95
+
96
+ //forget the [0] because the parent of top parent is always 0
97
+ return $this->ancestors[ 1 ];
98
+
99
+ }
100
+
101
+
102
+ /**
103
+ * Removes the closing </li> tag from a list item to allow for child menus inside of it
104
+ *
105
+ * @param string|bool $item - an <li></li> item
106
+ *
107
+ * @return string|bool
108
+ * @since 4.7.13
109
+ */
110
+ function openListItem( $item = false ) {
111
+ if( !$item ){
112
+ return false;
113
+ }
114
+
115
+ return substr( trim( $item ), 0, -5 );
116
+ }
117
+
118
+
119
+ /**
120
+ * If a category has children add the has_children class
121
+ *
122
+ * @param [] $classes
123
+ * @param \WP_Term $category
124
+ *
125
+ * @return array
126
+ */
127
+ public function add_has_children_category_class( $classes, $category ) {
128
+ $children = get_terms( $category->taxonomy, array(
129
+ 'parent' => $category->term_id,
130
+ 'hide_empty' => false,
131
+ 'number' => 1,
132
+ ) );
133
+ if( !empty( $children ) ){
134
+ $classes[] = 'has_children';
135
+ }
136
+
137
+ return $classes;
138
+ }
139
+
140
+
141
+ /**
142
+ *
143
+ * IF this is a top level category
144
+ *
145
+ * @param \WP_Term $cat the cat object
146
+ *
147
+ * @return bool
148
+ */
149
+ function first_level_category( $cat ) {
150
+
151
+ if( !in_array( $cat->term_id, $this->exclude ) && $cat->parent == $this->top_id ){
152
+ $return = true;
153
+ } else {
154
+ $return = false;
155
+ }
156
+
157
+ return apply_filters( 'advanced_sidebar_menu_first_level_category', $return, $cat, $this );
158
+
159
+ }
160
+
161
+
162
+ /**
163
+ * If the cat is a second level cat
164
+ *
165
+ * @param \WP_Term $cat the cat
166
+ *
167
+ * @return bool
168
+ */
169
+ function second_level_cat( $cat ) {
170
+
171
+ //if this is the current cat or a parent of the current cat
172
+ if( $cat->term_id == $this->current_term || in_array( $cat->term_id, $this->ancestors ) ){
173
+ $all_children = get_terms( $this->taxonomy, array( 'child_of' => $cat->term_id, 'fields' => 'ids' ) );
174
+ if( !empty( $all_children ) ){
175
+ $return = true;
176
+ } else {
177
+ $return = false;
178
+ }
179
+
180
+ } else {
181
+ $return = false;
182
+ }
183
+
184
+ return apply_filters( 'advanced_sidebar_menu_second_level_category', $return, $cat, $this );
185
+
186
+
187
+ }
188
+
189
+
190
+ /**
191
+ * Determines if all the children should be included
192
+ *
193
+ * @since 6.26.13
194
+ * @return bool
195
+ */
196
+ function display_all() {
197
+ return $this->checked( 'display_all' );
198
+ }
199
+
200
+
201
+ /**
202
+ * Determines if the parent page or cat should be included
203
+ *
204
+ * @since 6.26.13
205
+ * @return bool
206
+ */
207
+ function include_parent() {
208
+ if( !$this->checked( 'include_parent' ) ){
209
+ return false;
210
+ }
211
+
212
+ if( ( !in_array( $this->top_id, $this->exclude ) ) ){
213
+ return true;
214
+ }
215
+
216
+ return false;
217
+ }
218
+
219
+
220
+ /**
221
+ * Echos the title of the widget to the page
222
+ *
223
+ * @since 6.26.13
224
+ */
225
+ function title() {
226
+ if( isset( $this->instance[ 'title' ] ) && ( $this->instance[ 'title' ] != '' ) ){
227
+ $title = apply_filters( 'widget_title', $this->instance[ 'title' ], $this->args, $this->instance );
228
+ $title = apply_filters( 'advanced_sidebar_menu_widget_title', $title, $this->args, $this->instance, $this );
229
+
230
+ echo $this->args[ 'before_title' ] . $title . $this->args[ 'after_title' ];
231
+ }
232
+
233
+ }
234
+
235
+
236
+ /**
237
+ * Retrieve the excluded items' ids
238
+ *
239
+ * @return array
240
+ */
241
+ public function get_excluded_ids(){
242
+ $excluded = $this->exclude;
243
+ $excluded = array_filter( $excluded );
244
+ $excluded = array_map( 'intval', $excluded );
245
+ return $excluded;
246
+ }
247
+
248
+
249
+ /**
250
+ *
251
+ * Checks is this id is excluded or not
252
+ *
253
+ * @param int $id
254
+ *
255
+ * @return bool
256
+ */
257
+ public function is_excluded( $id ) {
258
+ if( !in_array( $id, $this->exclude ) ){
259
+ return true;
260
+ } else {
261
+ return false;
262
+ }
263
+ }
264
+
265
+ /*** static ***********/
266
+ /**
267
+ * current
268
+ *
269
+ * @static
270
+ * @var Advanced_Sidebar_Menu_Menu
271
+ */
272
+ private static $current;
273
+
274
+
275
+ public static function factory( array $instance, array $args ){
276
+ self::$current = new self();
277
+ self::$current->instance = $instance;
278
+ self::$current->args = $args;
279
+
280
+ return self::$current;
281
+ }
282
+
283
+
284
+ public static function get_current(){
285
+ return self::$current;
286
+ }
287
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Advanced_Sidebar_Menu_Page_Walker.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
-
4
- class Advanced_Sidebar_Menu_Page_Walker extends Walker_Page{
5
-
6
- function end_el( &$output, $page, $depth = 0, $args = array() ){
7
- /** Do Nothing */
8
- }
9
-
10
  }
1
+ <?php
2
+
3
+
4
+ class Advanced_Sidebar_Menu_Page_Walker extends Walker_Page{
5
+
6
+ function end_el( &$output, $page, $depth = 0, $args = array() ){
7
+ /** Do Nothing */
8
+ }
9
+
10
  }
src/widgets/advanced_sidebar_menu_category.php CHANGED
@@ -1,329 +1,318 @@
1
- <?php
2
-
3
-
4
- /**
5
- * Creates a Widget of parent Child Categories
6
- *
7
- * @author mat lipe
8
- * @since 1.7.14
9
- * @package Advanced Sidebar Menu
10
- *
11
- * @todo Clean this bad boy up. Still rookie code from years ago
12
- *
13
- *
14
- */
15
- class advanced_sidebar_menu_category extends WP_Widget {
16
-
17
- private $defaults = array(
18
- 'title' => '',
19
- 'include_parent' => false,
20
- 'include_childless_parent' => false,
21
- 'css' => false,
22
- 'single' => false,
23
- 'new_widget' => 'widget',
24
- 'exclude' => '',
25
- 'display_all' => false,
26
- 'levels' => 1,
27
- 'order' => 'DESC',
28
- );
29
-
30
-
31
- function __construct(){
32
-
33
- $widget_ops = array(
34
- 'classname' => 'advanced-sidebar-menu advanced-sidebar-category',
35
- 'description' => __( 'Creates a menu of all the categories using the child/parent relationship', 'advanced-sidebar-menu' ),
36
- );
37
- $control_ops = array( 'width' => 290 );
38
-
39
- parent::__construct( 'advanced_sidebar_menu_category', __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
40
- }
41
-
42
-
43
- /**
44
- * Creates a form for the Widget Options
45
- *
46
- * @since 1.7.14
47
- *
48
- * @param array $instance
49
- *
50
- * @actions do_action('advanced_sidebar_menu_category_widget_form', $instance );
51
- */
52
- function form( $instance ){
53
-
54
- $instance = wp_parse_args( $instance, $this->defaults );
55
-
56
- ?>
57
- <p> <?php _e( 'Title', 'advanced-sidebar-menu' ); ?>
58
- <br>
59
- <input id="<?php echo $this->get_field_name( 'title' ); ?>"
60
- name="<?php echo $this->get_field_name( 'title' ); ?>" class="widefat" type="text" value="<?php echo $instance[ 'title' ]; ?>"/>
61
- </p>
62
-
63
-
64
- <p> <?php _e( 'Include Parent Category', 'advanced-sidebar-menu' ); ?>
65
- <input id="<?php echo $this->get_field_name( 'include_parent' ); ?>"
66
- name="<?php echo $this->get_field_name( 'include_parent' ); ?>" type="checkbox" value="checked"
67
- <?php echo $instance[ 'include_parent' ]; ?>/>
68
- </p>
69
-
70
-
71
- <p> <?php _e( 'Include Parent Even With No Children', 'advanced-sidebar-menu' ); ?>
72
- <input id="<?php echo $this->get_field_name( 'include_childless_parent' ); ?>"
73
- name="<?php echo $this->get_field_name( 'include_childless_parent' ); ?>" type="checkbox" value="checked"
74
- <?php echo $instance[ 'include_childless_parent' ]; ?>/>
75
- </p>
76
-
77
- <p> <?php _e( 'Use this plugins styling', 'advanced-sidebar-menu' ); ?>
78
- <input id="<?php echo $this->get_field_name( 'css' ); ?>"
79
- name="<?php echo $this->get_field_name( 'css' ); ?>" type="checkbox" value="checked"
80
- <?php echo $instance[ 'css' ]; ?>/>
81
- </p>
82
-
83
- <p> <?php _e( 'Display Categories on Single Posts', 'advanced-sidebar-menu' ); ?>
84
- <input id="<?php echo $this->get_field_name( 'single' ); ?>"
85
- name="<?php echo $this->get_field_name( 'single' ); ?>" type="checkbox" value="checked"
86
- onclick="javascript:asm_reveal_element( 'new-widget-<?php echo $this->get_field_name( 'new_widget' ); ?>' )"
87
- <?php echo $instance[ 'single' ]; ?>/>
88
- </p>
89
-
90
- <span id="new-widget-<?php echo $this->get_field_name( 'new_widget' ); ?>" style="<?php
91
- if( $instance[ 'single' ] == 'checked' ){
92
- echo 'display:block';
93
- } else {
94
- echo 'display:none';
95
- } ?>">
96
- <p><?php _e( "Display Each Single Post's Category", 'advanced-sidebar-menu' ); ?>
97
- <select id="<?php echo $this->get_field_name( 'new_widget' ); ?>"
98
- name="<?php echo $this->get_field_name( 'new_widget' ); ?>">
99
- <?php
100
- if( $instance[ 'new_widget' ] == 'widget' ){
101
- echo '<option value="widget" selected> In a new widget </option>';
102
- echo '<option value="list"> In another list in the same widget </option>';
103
- } else {
104
- echo '<option value="widget"> In a new widget </option>';
105
- echo '<option value="list" selected> In another list in the same widget </option>';
106
- }
107
-
108
- ?></select>
109
- </p>
110
- </span>
111
-
112
-
113
- <p> <?php _e( "Categories to Exclude, Comma Separated", 'advanced-sidebar-menu' ); ?>:
114
- <input id="<?php echo $this->get_field_name( 'exclude' ); ?>"
115
- name="<?php echo $this->get_field_name( 'exclude' ); ?>" type="text" class="widefat" value="<?php echo $instance[ 'exclude' ]; ?>"/>
116
- </p>
117
-
118
- <p> <?php _e( "Always Display Child Categories", 'advanced-sidebar-menu' ); ?>
119
- <input id="<?php echo $this->get_field_name( 'display_all' ); ?>"
120
- name="<?php echo $this->get_field_name( 'display_all' ); ?>" type="checkbox" value="checked"
121
- onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name( 'levels' ); ?>' )"
122
- <?php echo $instance[ 'display_all' ]; ?>/>
123
- </p>
124
-
125
- <span id="levels-<?php echo $this->get_field_name( 'levels' ); ?>" style="<?php
126
- if( $instance[ 'display_all' ] == 'checked' ){
127
- echo 'display:block';
128
- } else {
129
- echo 'display:none';
130
- } ?>">
131
- <p> <?php _e( "Levels to Display", 'advanced-sidebar-menu' ); ?>
132
- <select id="<?php echo $this->get_field_name( 'levels' ); ?>"
133
- name="<?php echo $this->get_field_name( 'levels' ); ?>">
134
- <?php
135
- for( $i = 1; $i < 6; $i ++ ){
136
- if( $i == $instance[ 'levels' ] ){
137
- echo '<option value="' . $i . '" selected>' . $i . '</option>';
138
- } else {
139
- echo '<option value="' . $i . '">' . $i . '</option>';
140
- }
141
- }
142
- echo '</select></p></span>';
143
-
144
- do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this );
145
-
146
- do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
147
-
148
- }
149
-
150
-
151
- /**
152
- * Updates the widget data
153
- *
154
- * @filter - $newInstance = apply_filters('advanced_sidebar_menu_category_widget_update', $newInstance,
155
- * $oldInstance );
156
- * @since 5.19.13
157
- */
158
- function update( $newInstance, $oldInstance ){
159
- $newInstance[ 'exclude' ] = strip_tags( $newInstance[ 'exclude' ] );
160
- $newInstance = apply_filters( 'advanced_sidebar_menu_category_widget_update', $newInstance, $oldInstance );
161
-
162
- return $newInstance;
163
- }
164
-
165
-
166
-
167
-
168
- #---------------------------------------------------------------------------------------------------------------------------
169
-
170
- /**
171
- * Outputs the categories widget to the page
172
- *
173
- * @since 11.15.13
174
- * @uses loads the views/category_list.php
175
- *
176
- * @filters apply_filters('advanced_sidebar_menu_category_widget_output', $content, $args, $instance );
177
- * apply_filters('advanced_sidebar_menu_taxonomy', 'post', $args, $instance );
178
- * apply_filters('advanced_sidebar_menu_proper_single', $asm->checked('single'), $args, $instance)
179
- * apply_filters( 'advanced_sidebar_menu_category_ids', $cat_ids, $args, $instance )
180
- *
181
- */
182
- function widget( $args, $instance ){
183
-
184
- $instance = wp_parse_args( $instance, $this->defaults );
185
-
186
- if( is_single() && !isset( $instance[ 'single' ] ) ){
187
- return;
188
- }
189
- $asm = new Advanced_Sidebar_Menu_Menu;
190
- $asm->instance = $instance;
191
- $asm->args = $args;
192
-
193
- //Had to display twice for backward compat - because originaly not set to anything
194
- $asm->order_by = apply_filters( 'advanced_sidebar_menu_category_orderby', null, $args, $instance );
195
-
196
- do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
197
-
198
-
199
- $cat_ids = $already_top = array();
200
- $asm_once = false; //keeps track of how many widgets this created
201
-
202
- $exclude = explode( ',', $instance[ 'exclude' ] );
203
- $asm->exclude = $exclude;
204
-
205
- $asm->taxonomy = apply_filters( 'advanced_sidebar_menu_taxonomy', 'category', $args, $instance );
206
-
207
- extract( $args );
208
-
209
- //If on a single page create an array of each category and create a list for each
210
- if( is_single() ){
211
- if( !apply_filters( 'advanced_sidebar_menu_proper_single', $asm->checked( 'single' ), $args, $instance ) ){
212
- return;
213
- }
214
- global $post;
215
- $category_array = wp_get_object_terms( $post->ID, $asm->taxonomy );
216
-
217
- //Sort by a field like term order for other plugins
218
- $asm->order_by = apply_filters( 'advanced_sidebar_menu_category_orderby', 'name', $args, $instance );
219
-
220
- uasort( $category_array, array( $asm, 'sortTerms' ) );
221
-
222
- foreach( $category_array as $id => $cat ){
223
- $cat_ids[] = $cat->term_id;
224
- }
225
-
226
- //IF on a category page get the id of the category
227
- } elseif( is_tax() || is_category() ) {
228
-
229
- $asm->current_term = get_queried_object()->term_id;
230
- $cat_ids[] = get_queried_object()->term_id;
231
- }
232
-
233
- $cat_ids = apply_filters( 'advanced_sidebar_menu_category_ids', $cat_ids, $args, $instance );
234
-
235
- if( empty( $cat_ids ) ){
236
- return;
237
- }
238
-
239
- //Go through each category there will be only one if this is a category page mulitple possible if this is single
240
- foreach( $cat_ids as $cat_id ){
241
-
242
- //Get the top category id
243
- $asm->top_id = $asm->getTopCat( $cat_id );
244
-
245
- //Keeps track or already used top levels so this won't double up
246
- if( in_array( $asm->top_id, $already_top ) ){
247
- continue;
248
- }
249
-
250
- $already_top[] = $asm->top_id;
251
-
252
- //Check for children
253
- $all_categories = $all = array_filter(
254
- get_terms(
255
- $asm->taxonomy, array(
256
- 'child_of' => $asm->top_id,
257
- 'orderby' => $asm->order_by,
258
- 'order' => $instance[ 'order' ],
259
- )
260
- )
261
- );
262
-
263
- //For Backwards Compatibility
264
- foreach( $all_categories as $tc ){
265
- $tc->cat_ID = $tc->term_id;
266
- }
267
-
268
- //If there are no children and not displaying childless parent - bail
269
- if( empty( $all_categories ) && !( $asm->checked( 'include_childless_parent' ) ) ){
270
- continue;
271
- }
272
- //If there are no children and the parent is excluded bail
273
- if( empty( $all_categories ) && in_array( $asm->top_id, $exclude ) ){
274
- continue;
275
- }
276
-
277
- //Creates a new widget for each category the single page has if the options are selected to do so
278
- //Also starts the first widget
279
- if( !$asm_once || ( $instance[ 'new_widget' ] == 'widget' ) ){
280
-
281
- //Start the menu
282
- echo $before_widget;
283
- if( !$asm_once ){
284
- //must remain in the loop instead of the template because we only want it to display once
285
- $asm->title();
286
-
287
- if( $asm->checked( 'css' ) ){
288
- echo '<style type="text/css">';
289
- include( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'sidebar-menu.css' ) );
290
- echo '</style>';
291
- }
292
-
293
- $asm_once = true; //There has been a div
294
- $close = true; //The div should be closed at the end
295
-
296
- if( $instance[ 'new_widget' ] == 'list' ){
297
- $close = false; //If this is a list leave it open for now
298
- }
299
- }
300
- }
301
-
302
- //for deprecation
303
- $top_cat = $asm->top_id;
304
- $cat_ancestors = $asm->ancestors;
305
-
306
- //Bring in the view
307
- require( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'category_list.php' ) );
308
-
309
- echo apply_filters( 'advanced_sidebar_menu_category_widget_output', $content, $args, $instance );
310
-
311
- if( $close ){
312
- //End the Widget Area
313
- echo $after_widget;
314
- echo '<!-- First $after_widget -->';
315
- }
316
-
317
- } //End of each cat loop
318
-
319
- //IF we were waiting for all the individual lists to complete
320
- if( !$close && $asm_once ){
321
- //End the Widget Area
322
- echo $after_widget;
323
- echo '<!-- Second $after_widget -->';
324
-
325
- }
326
-
327
- } #== /widget()
328
-
329
- } #== /Clas
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Creates a Widget of parent Child Categories
6
+ *
7
+ * @author mat lipe
8
+ * @since 1.7.14
9
+ * @package Advanced Sidebar Menu
10
+ *
11
+ *
12
+ */
13
+ class advanced_sidebar_menu_category extends WP_Widget {
14
+
15
+ private $defaults = array(
16
+ 'title' => '',
17
+ 'include_parent' => false,
18
+ 'include_childless_parent' => false,
19
+ 'css' => false,
20
+ 'single' => false,
21
+ 'new_widget' => 'widget',
22
+ 'exclude' => '',
23
+ 'display_all' => false,
24
+ 'levels' => 1,
25
+ 'order' => 'DESC',
26
+ );
27
+
28
+
29
+ function __construct(){
30
+
31
+ $widget_ops = array(
32
+ 'classname' => 'advanced-sidebar-menu advanced-sidebar-category',
33
+ 'description' => __( 'Creates a menu of all the categories using the child/parent relationship', 'advanced-sidebar-menu' ),
34
+ );
35
+ $control_ops = array( 'width' => 290 );
36
+
37
+ parent::__construct( 'advanced_sidebar_menu_category', __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
38
+ }
39
+
40
+
41
+ /**
42
+ * Creates a form for the Widget Options
43
+ *
44
+ * @since 1.7.14
45
+ *
46
+ * @param array $instance
47
+ *
48
+ * @actions do_action('advanced_sidebar_menu_category_widget_form', $instance );
49
+ */
50
+ function form( $instance ){
51
+
52
+ $instance = wp_parse_args( $instance, $this->defaults );
53
+
54
+ ?>
55
+ <p> <?php _e( 'Title', 'advanced-sidebar-menu' ); ?>
56
+ <br>
57
+ <input id="<?php echo $this->get_field_name( 'title' ); ?>"
58
+ name="<?php echo $this->get_field_name( 'title' ); ?>" class="widefat" type="text" value="<?php echo $instance[ 'title' ]; ?>"/>
59
+ </p>
60
+
61
+
62
+ <p> <?php _e( 'Include Parent Category', 'advanced-sidebar-menu' ); ?>
63
+ <input id="<?php echo $this->get_field_name( 'include_parent' ); ?>"
64
+ name="<?php echo $this->get_field_name( 'include_parent' ); ?>" type="checkbox" value="checked"
65
+ <?php echo $instance[ 'include_parent' ]; ?>/>
66
+ </p>
67
+
68
+
69
+ <p> <?php _e( 'Include Parent Even With No Children', 'advanced-sidebar-menu' ); ?>
70
+ <input id="<?php echo $this->get_field_name( 'include_childless_parent' ); ?>"
71
+ name="<?php echo $this->get_field_name( 'include_childless_parent' ); ?>" type="checkbox" value="checked"
72
+ <?php echo $instance[ 'include_childless_parent' ]; ?>/>
73
+ </p>
74
+
75
+ <p> <?php _e( 'Use this plugins styling', 'advanced-sidebar-menu' ); ?>
76
+ <input id="<?php echo $this->get_field_name( 'css' ); ?>"
77
+ name="<?php echo $this->get_field_name( 'css' ); ?>" type="checkbox" value="checked"
78
+ <?php echo $instance[ 'css' ]; ?>/>
79
+ </p>
80
+
81
+ <p> <?php _e( 'Display Categories on Single Posts', 'advanced-sidebar-menu' ); ?>
82
+ <input id="<?php echo $this->get_field_name( 'single' ); ?>"
83
+ name="<?php echo $this->get_field_name( 'single' ); ?>" type="checkbox" value="checked"
84
+ onclick="javascript:asm_reveal_element( 'new-widget-<?php echo $this->get_field_name( 'new_widget' ); ?>' )"
85
+ <?php echo $instance[ 'single' ]; ?>/>
86
+ </p>
87
+
88
+ <span id="new-widget-<?php echo $this->get_field_name( 'new_widget' ); ?>" style="<?php
89
+ if( $instance[ 'single' ] == 'checked' ){
90
+ echo 'display:block';
91
+ } else {
92
+ echo 'display:none';
93
+ } ?>">
94
+ <p><?php _e( "Display Each Single Post's Category", 'advanced-sidebar-menu' ); ?>
95
+ <select id="<?php echo $this->get_field_name( 'new_widget' ); ?>"
96
+ name="<?php echo $this->get_field_name( 'new_widget' ); ?>">
97
+ <?php
98
+ if( $instance[ 'new_widget' ] == 'widget' ){
99
+ echo '<option value="widget" selected> In a new widget </option>';
100
+ echo '<option value="list"> In another list in the same widget </option>';
101
+ } else {
102
+ echo '<option value="widget"> In a new widget </option>';
103
+ echo '<option value="list" selected> In another list in the same widget </option>';
104
+ }
105
+
106
+ ?></select>
107
+ </p>
108
+ </span>
109
+
110
+
111
+ <p> <?php _e( "Categories to Exclude, Comma Separated", 'advanced-sidebar-menu' ); ?>:
112
+ <input id="<?php echo $this->get_field_name( 'exclude' ); ?>"
113
+ name="<?php echo $this->get_field_name( 'exclude' ); ?>" type="text" class="widefat" value="<?php echo $instance[ 'exclude' ]; ?>"/>
114
+ </p>
115
+
116
+ <p> <?php _e( "Always Display Child Categories", 'advanced-sidebar-menu' ); ?>
117
+ <input id="<?php echo $this->get_field_name( 'display_all' ); ?>"
118
+ name="<?php echo $this->get_field_name( 'display_all' ); ?>" type="checkbox" value="checked"
119
+ onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_name( 'levels' ); ?>' )"
120
+ <?php echo $instance[ 'display_all' ]; ?>/>
121
+ </p>
122
+
123
+ <span id="levels-<?php echo $this->get_field_name( 'levels' ); ?>" style="<?php
124
+ if( $instance[ 'display_all' ] == 'checked' ){
125
+ echo 'display:block';
126
+ } else {
127
+ echo 'display:none';
128
+ } ?>">
129
+ <p> <?php _e( "Levels to Display", 'advanced-sidebar-menu' ); ?>
130
+ <select id="<?php echo $this->get_field_name( 'levels' ); ?>"
131
+ name="<?php echo $this->get_field_name( 'levels' ); ?>">
132
+ <?php
133
+ for( $i = 1; $i < 6; $i ++ ){
134
+ if( $i == $instance[ 'levels' ] ){
135
+ echo '<option value="' . $i . '" selected>' . $i . '</option>';
136
+ } else {
137
+ echo '<option value="' . $i . '">' . $i . '</option>';
138
+ }
139
+ }
140
+ echo '</select></p></span>';
141
+
142
+ do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this );
143
+
144
+ do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
145
+
146
+ }
147
+
148
+
149
+ /**
150
+ * Updates the widget data
151
+ *
152
+ * @filter - $newInstance = apply_filters('advanced_sidebar_menu_category_widget_update', $newInstance,
153
+ * $oldInstance );
154
+ * @since 5.19.13
155
+ */
156
+ function update( $newInstance, $oldInstance ){
157
+ $newInstance[ 'exclude' ] = strip_tags( $newInstance[ 'exclude' ] );
158
+ $newInstance = apply_filters( 'advanced_sidebar_menu_category_widget_update', $newInstance, $oldInstance );
159
+
160
+ return $newInstance;
161
+ }
162
+
163
+
164
+
165
+
166
+ #---------------------------------------------------------------------------------------------------------------------------
167
+
168
+ /**
169
+ * Outputs the categories widget to the page
170
+ *
171
+ * @since 11.15.13
172
+ * @uses loads the views/category_list.php
173
+ *
174
+ * @filters apply_filters('advanced_sidebar_menu_category_widget_output', $content, $args, $instance );
175
+ * apply_filters('advanced_sidebar_menu_taxonomy', 'post', $args, $instance );
176
+ * apply_filters('advanced_sidebar_menu_proper_single', $asm->checked('single'), $args, $instance)
177
+ * apply_filters( 'advanced_sidebar_menu_category_ids', $cat_ids, $args, $instance )
178
+ *
179
+ * @todo Clean up filters to match structure of page widget and use apply_filters_ref_array()
180
+ * update web docs when doing so
181
+ * Keep backward compat filters in place
182
+ *
183
+ */
184
+ function widget( $args, $instance ){
185
+ $instance = wp_parse_args( $instance, $this->defaults );
186
+ if( is_single() && !isset( $instance[ 'single' ] ) ){
187
+ return;
188
+ }
189
+
190
+ $asm = Advanced_Sidebar_Menu_Menu::factory( $instance, $args );
191
+ $cat_ids = $already_top = array();
192
+ $asm_once = false; //keeps track of how many widgets this created
193
+ $close = false;
194
+
195
+ do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
196
+
197
+ $asm->order_by = apply_filters( 'advanced_sidebar_menu_category_orderby', 'name', $args, $instance );
198
+ $asm->order = apply_filters( 'advanced_sidebar_menu_category_order', $asm->order, $args, $instance );
199
+ $asm->exclude = apply_filters( 'advanced_sidebar_menu_excluded_categories', explode( ',', $instance[ 'exclude' ] ), $args, $instance, $asm );
200
+ $asm->taxonomy = apply_filters( 'advanced_sidebar_menu_taxonomy', 'category', $args, $instance, $asm );
201
+
202
+ add_filter( 'category_css_class', array( $asm, 'add_has_children_category_class' ), 2, 2 );
203
+
204
+
205
+
206
+ //If on a single page create an array of each category and create a list for each
207
+ if( is_single() ){
208
+ if( !apply_filters( 'advanced_sidebar_menu_proper_single', $asm->checked( 'single' ), $args, $instance, $asm ) ){
209
+ return;
210
+ }
211
+ $cat_ids = wp_get_object_terms( get_the_ID(), $asm->taxonomy, array( 'fields' => 'ids' ) );
212
+
213
+ //IF on a category page get the id of the category
214
+ } elseif( is_tax() || is_category() ) {
215
+ $asm->current_term = get_queried_object()->term_id;
216
+ $cat_ids[] = get_queried_object()->term_id;
217
+ }
218
+
219
+ $cat_ids = apply_filters( 'advanced_sidebar_menu_category_ids', $cat_ids, $args, $instance, $asm );
220
+
221
+ if( empty( $cat_ids ) ){
222
+ return;
223
+ }
224
+
225
+ //Go through each category there will be only one if this is a category page multiple possible if this is single
226
+ $top_level_cats = array();
227
+ foreach( $cat_ids as $cat_id ){
228
+ $top_level_cat = $asm->getTopCat( $cat_id );
229
+ if( !in_array( $top_level_cat, $top_level_cats ) ){
230
+ $top_level_cats[] = $top_level_cat;
231
+ }
232
+ }
233
+
234
+ if( !empty( $top_level_cats ) ){
235
+ $top_level_cats = get_terms( array(
236
+ 'include' => $top_level_cats,
237
+ 'hide_empty' => false,
238
+ 'orderby' => $asm->order_by,
239
+ 'order' => $asm->order,
240
+ ) );
241
+ }
242
+
243
+ foreach( $top_level_cats as $_cat ){
244
+ $asm->top_id = $_cat->term_id;
245
+
246
+ //Check for children
247
+ $all_categories = $all = array_filter(
248
+ get_terms(
249
+ $asm->taxonomy, array(
250
+ 'parent' => $asm->top_id,
251
+ 'orderby' => $asm->order_by,
252
+ 'order' => $asm->order,
253
+ )
254
+ )
255
+ );
256
+
257
+
258
+ //If there are no children and not displaying childless parent - bail
259
+ if( empty( $all_categories ) && !( $asm->checked( 'include_childless_parent' ) ) ){
260
+ continue;
261
+ }
262
+ //If there are no children and the parent is excluded bail
263
+ if( empty( $all_categories ) && in_array( $asm->top_id, $asm->exclude ) ){
264
+ continue;
265
+ }
266
+
267
+ //Creates a new widget for each category the single page has if the options are selected to do so
268
+ //Also starts the first widget
269
+ if( !$asm_once || ( $instance[ 'new_widget' ] == 'widget' ) ){
270
+
271
+ //Start the menu
272
+ echo $args[ 'before_widget' ];
273
+ if( !$asm_once ){
274
+ //must remain in the loop instead of the template because we only want it to display once
275
+ $asm->title();
276
+
277
+ if( $asm->checked( 'css' ) ){
278
+ echo '<style type="text/css">';
279
+ include( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'sidebar-menu.css' ) );
280
+ echo '</style>';
281
+ }
282
+
283
+ $asm_once = true; //There has been a div
284
+ $close = true; //The div should be closed at the end
285
+
286
+ if( $instance[ 'new_widget' ] == 'list' ){
287
+ $close = false; //If this is a list leave it open for now
288
+ }
289
+ }
290
+ }
291
+
292
+ //Bring in the view
293
+ $output = require( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'category_list.php' ) );
294
+
295
+ //backward compatibility for old views that didn't returns
296
+ if( empty( $output ) && isset( $content ) ){
297
+ $output = $content;
298
+ }
299
+ echo apply_filters( 'advanced_sidebar_menu_category_widget_output', $output, $args, $instance, $asm );
300
+
301
+ if( $close ){
302
+ //End the Widget Area
303
+ echo $args[ 'after_widget' ];
304
+ echo '<!-- First $after_widget -->';
305
+ }
306
+
307
+ } //End of each cat loop
308
+
309
+ //IF we were waiting for all the individual lists to complete
310
+ if( !$close && $asm_once ){
311
+ //End the Widget Area
312
+ echo $args[ 'after_widget' ];;
313
+ echo '<!-- Second $after_widget -->';
314
+
315
+ }
316
+ }
317
+
318
+ }
 
 
 
 
 
 
 
 
 
 
 
src/widgets/advanced_sidebar_menu_page.php CHANGED
@@ -1,309 +1,245 @@
1
- <?php
2
-
3
-
4
- /**
5
- * Advanced Sidebar Menu Page
6
- *
7
- * Creates a Widget of parent Child Pages
8
- *
9
- * @author mat lipe <mat@matlipe.com>
10
- *
11
- * @package Advanced Sidebar Menu
12
- * @class advanced_sidebar_menu_page
13
- *
14
- */
15
- class advanced_sidebar_menu_page extends WP_Widget {
16
-
17
- private $defaults = array(
18
- 'title' => false,
19
- 'include_parent' => false,
20
- 'include_childless_parent' => false,
21
- 'order_by' => 'menu_order',
22
- 'css' => false,
23
- 'exclude' => false,
24
- 'display_all' => false,
25
- 'levels' => 1
26
- );
27
-
28
-
29
- function __construct(){
30
-
31
- $widget_ops = array(
32
- 'classname' => 'advanced-sidebar-menu',
33
- 'description' => __( 'Creates a menu of all the pages using the child/parent relationship', 'advanced-sidebar-menu' )
34
- );
35
- $control_ops = array(
36
- 'width' => 290
37
- );
38
-
39
-
40
- parent::__construct( 'advanced_sidebar_menu', __( 'Advanced Sidebar Pages Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
41
-
42
- }
43
-
44
-
45
- /**
46
- * Output a simple widget Form
47
- * Not of ton of options here but who need them
48
- * Most of the magic happens automatically
49
- *
50
- * @filters do_action('advanced_sidebar_menu_page_widget_form', $instance, $this->get_field_name('parent_only'), $this->get_field_id('parent_only'));
51
- *
52
- * @since 11.4.13
53
- */
54
- function form( $instance ){
55
-
56
- $instance = wp_parse_args( $instance, $this->defaults );
57
-
58
- ?>
59
- <p> <?php _e( 'Title', 'advanced-sidebar-menu' ); ?>
60
- <br>
61
- <input id="<?php echo $this->get_field_id( 'title' ); ?>"
62
- name="<?php echo $this->get_field_name( 'title' ); ?>" class="widefat" type="text" value="<?php echo $instance[ 'title' ]; ?>"/>
63
- </p>
64
-
65
- <p> <?php _e( 'Include Parent Page', 'advanced-sidebar-menu' ); ?>:
66
- <input id="<?php echo $this->get_field_id( 'include_parent' ); ?>"
67
- name="<?php echo $this->get_field_name( 'include_parent' ); ?>" type="checkbox" value="checked"
68
- <?php echo $instance[ 'include_parent' ]; ?>/>
69
- </p>
70
-
71
-
72
- <p> <?php _e( 'Include Parent Even With No Children', 'advanced-sidebar-menu' ); ?>:
73
- <input id="<?php echo $this->get_field_id( 'include_childless_parent' ); ?>"
74
- name="<?php echo $this->get_field_name( 'include_childless_parent' ); ?>" type="checkbox" value="checked"
75
- <?php echo $instance[ 'include_childless_parent' ]; ?>/>
76
- </p>
77
-
78
- <p> <?php _e( 'Order By', 'advanced-sidebar-menu' ); ?>:
79
- <select id="<?php echo $this->get_field_id( 'order_by' ); ?>"
80
- name="<?php echo $this->get_field_name( 'order_by' ); ?>">
81
- <?php
82
-
83
- $order_by = array(
84
- 'menu_order' => 'Page Order',
85
- 'post_title' => 'Title',
86
- 'post_date' => 'Published Date'
87
- );
88
-
89
- foreach( $order_by as $key => $order ){
90
-
91
- printf( '<option value="%s" %s>%s</option>', $key, selected( $instance[ 'order_by' ], $key, false ), $order );
92
- }
93
- ?>
94
- </select>
95
- </p>
96
-
97
- <p> <?php _e( "Use this Plugin's Styling", 'advanced-sidebar-menu' ); ?>:
98
- <input id="<?php echo $this->get_field_id( 'css' ); ?>"
99
- name="<?php echo $this->get_field_name( 'css' ); ?>" type="checkbox" value="checked"
100
- <?php echo $instance[ 'css' ]; ?>/>
101
- </p>
102
-
103
- <p> <?php _e( "Pages to Exclude (ids), Comma Separated", 'advanced-sidebar-menu' ); ?>:
104
- <input id="<?php echo $this->get_field_id( 'exclude' ); ?>"
105
- name="<?php echo $this->get_field_name( 'exclude' ); ?>" class="widefat" type="text" value="<?php echo $instance[ 'exclude' ]; ?>"/>
106
- </p>
107
-
108
- <p> <?php _e( "Always Display Child Pages", 'advanced-sidebar-menu' ); ?>:
109
- <input id="<?php echo $this->get_field_id( 'display_all' ); ?>"
110
- name="<?php echo $this->get_field_name( 'display_all' ); ?>" type="checkbox" value="checked"
111
- onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_id( 'levels' ); ?>' )"
112
- <?php echo $instance[ 'display_all' ]; ?>/>
113
- </p>
114
-
115
- <span id="levels-<?php echo $this->get_field_id( 'levels' ); ?>" style="<?php
116
- if( $instance[ 'display_all' ] == 'checked' ){
117
- echo 'display:block';
118
- } else {
119
- echo 'display:none';
120
- } ?>">
121
- <p> <?php _e( "Levels to Display", 'advanced-sidebar-menu' ); ?>:
122
- <select id="<?php echo $this->get_field_id( 'levels' ); ?>"
123
- name="<?php echo $this->get_field_name( 'levels' ); ?>">
124
- <?php
125
- for( $i = 1; $i < 6; $i ++ ){
126
- if( $i == $instance[ 'levels' ] ){
127
- echo '<option value="' . $i . '" selected>' . $i . '</option>';
128
- } else {
129
- echo '<option value="' . $i . '">' . $i . '</option>';
130
- }
131
- }
132
- echo '</select></p></span>';
133
-
134
- do_action( 'advanced_sidebar_menu_page_widget_form', $instance, $this->get_field_name( 'parent_only' ), $this->get_field_id( 'parent_only' ), $this );
135
-
136
- do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
137
-
138
-
139
- }
140
-
141
-
142
- /**
143
- * Handles the saving of the widget
144
- *
145
- * @filters apply_filters('advanced_sidebar_menu_page_widget_update', $newInstance, $oldInstance );
146
- *
147
- * @since 4.26.13
148
- */
149
- function update( $newInstance, $oldInstance ){
150
- $newInstance[ 'exclude' ] = strip_tags( $newInstance[ 'exclude' ] );
151
-
152
- $newInstance = apply_filters( 'advanced_sidebar_menu_page_widget_update', $newInstance, $oldInstance );
153
-
154
- return $newInstance;
155
- }
156
-
157
-
158
- #---------------------------------------------------------------------------------------------------------------------------
159
-
160
- /**
161
- * Outputs the page list
162
- *
163
- * @see WP_Widget::widget()
164
- *
165
- * @uses for custom post types send the type to the filter titled 'advanced_sidebar_menu_post_type'
166
- * @uses change the top parent manually with the filter 'advanced_sidebar_menu_top_parent'
167
- * @uses change the order of the 2nd level pages with 'advanced_sidebar_menu_order_by' filter
168
- *
169
- * @filter apply_filters('advanced_sidebar_menu_page_widget_output',$content, $args, $instance );
170
- * apply_filters('advanced_sidebar_menu_order_by', 'menu_order', $post, $args, $instance );
171
- * apply_filters('advanced_sidebar_menu_top_parent', $top_parent, $post, $args, $instance );
172
- * apply_filters('advanced_sidebar_menu_post_type', 'page', $args, $instance );
173
- *
174
- *
175
- *
176
- * @see Geansai - pointed out a notice level error. Thanks Geansai!!
177
- */
178
- function widget( $args, $instance ){
179
- global $post;
180
-
181
- $asm = new Advanced_Sidebar_Menu_Menu();
182
- $asm->instance = $instance;
183
- $asm->args = $args;
184
- $asm->exclude = apply_filters( 'advanced_sidebar_menu_excluded_pages', explode( ',', $instance[ 'exclude' ] ), $post, $asm->args, $asm->instance, $asm );
185
-
186
- do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
187
-
188
- extract( $args );
189
-
190
- $filter_args = array(
191
- 1 => $asm->args,
192
- 2 => $asm->instance,
193
- 3 => $asm
194
- );
195
-
196
- $filter_args[ 0 ] = 'page';
197
- $asm->post_type = $post_type = apply_filters_ref_array( 'advanced_sidebar_menu_post_type', $filter_args );
198
-
199
- if( 'page' == $asm->post_type ){
200
- add_filter( 'page_css_class', array( $asm, 'add_has_children_class' ), 2, 2 );
201
-
202
- } else {
203
- add_filter( 'page_css_class', array( $asm, 'custom_post_type_css' ), 2, 4 );
204
- }
205
-
206
- $proper_single = !( is_page() || ( is_single() && $asm->post_type == get_post_type() ) );
207
- $filter_args[ 0 ] = $proper_single;
208
- if( apply_filters_ref_array( 'advanced_sidebar_menu_proper_single', $filter_args ) ){
209
- return;
210
- }
211
-
212
- if( $post->ancestors ){
213
- $ancestors = $post->ancestors;
214
- $top_parent = end( $ancestors );
215
- } else {
216
- $top_parent = $post->ID;
217
- }
218
-
219
- $filter_args[ 0 ] = $top_parent;
220
- $asm->top_id = $top_parent = apply_filters_ref_array( 'advanced_sidebar_menu_top_parent', $filter_args );
221
- if( get_post_type( $asm->top_id ) != $asm->post_type ){
222
- return;
223
- }
224
-
225
- unset( $filter_args[ 0 ] );
226
- array_unshift( $filter_args, $post );
227
- array_unshift( $filter_args, $instance[ 'order_by' ] );
228
-
229
- $asm->order_by = $order_by = apply_filters_ref_array( 'advanced_sidebar_menu_order_by', $filter_args );
230
-
231
- $child_pages = $this->get_child_pages( $asm, $filter_args );
232
-
233
- #---- if there are no children do not display the parent unless it is check to do so
234
- if( ( !empty( $child_pages ) ) || $asm->checked( 'include_childless_parent' ) && ( !in_array( $top_parent, $asm->exclude ) ) ){
235
-
236
- if( $asm->checked( 'css' ) ){
237
- echo '<style type="text/css">';
238
- include( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'sidebar-menu.css' ) );
239
- echo '</style>';
240
- }
241
-
242
- echo $args[ 'before_widget' ];
243
-
244
- $content = '';
245
- require( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'page_list.php' ) );
246
- echo apply_filters( 'advanced_sidebar_menu_page_widget_output', $content, $args, $instance );
247
- echo $args[ 'after_widget' ];
248
-
249
- }
250
-
251
- }
252
-
253
-
254
- /**
255
- * get_child_pages
256
- *
257
- * Get the children's ids of the top level parent
258
- *
259
- * @param Advanced_Sidebar_Menu_Menu $asm
260
- * @param array $filter_args
261
- *
262
- * @filter advanced_sidebar_menu_child_pages
263
- *
264
- * @return mixed
265
- */
266
- private function get_child_pages( $asm, $filter_args ){
267
- $cache = Advanced_Sidebar_Menu_Cache::get_instance();
268
- $child_pages = $cache->get_child_pages( $asm );
269
-
270
- if( $child_pages === false ){
271
- $child_page_args = array(
272
- 'post_type' => $asm->post_type,
273
- 'orderby' => $asm->order_by,
274
- 'post_parent' => $asm->top_id,
275
- 'fields' => 'ids',
276
- );
277
-
278
- $excluded = $asm->get_excluded_ids();
279
- if( !empty( $excluded ) ){
280
- $child_page_args[ 'post__not_in' ] = $excluded;
281
- }
282
-
283
- $child_pages = get_posts( $child_page_args );
284
-
285
- $cache->add_child_pages( $asm, $child_pages );
286
- }
287
-
288
- $filter_args[ 0 ] = $child_pages;
289
-
290
- if( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ){
291
- /**
292
- * Pro version 1.4.3 or below had a typeset for the arg
293
- * of this filter. This changed in version 6.0.0 so we have
294
- * to disable the filter. If someone has an issue then make
295
- * sure they update to version 1.4.4 to restore this filter
296
- */
297
- if( version_compare( ADVANCED_SIDEBAR_MENU_PRO_VERSION, '1.4.4', '>=' ) ){
298
- $child_pages = apply_filters_ref_array( 'advanced_sidebar_menu_child_pages', $filter_args );
299
- }
300
-
301
- } else {
302
- $child_pages = apply_filters_ref_array( 'advanced_sidebar_menu_child_pages', $filter_args );
303
- }
304
-
305
- return $child_pages;
306
-
307
- }
308
-
309
  }
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced Sidebar Menu Page
6
+ *
7
+ * Creates a Widget of parent Child Pages
8
+ *
9
+ * @author mat lipe <mat@matlipe.com>
10
+ *
11
+ * @package Advanced Sidebar Menu
12
+ * @class advanced_sidebar_menu_page
13
+ *
14
+ */
15
+ class advanced_sidebar_menu_page extends WP_Widget {
16
+
17
+ //@todo set the rest to constants
18
+ const DISPLAY_PARENT = 'include_parent';
19
+
20
+ private $defaults = array(
21
+ 'title' => false,
22
+ 'include_parent' => false,
23
+ 'include_childless_parent' => false,
24
+ 'order_by' => 'menu_order',
25
+ 'css' => false,
26
+ 'exclude' => false,
27
+ 'display_all' => false,
28
+ 'levels' => 1
29
+ );
30
+
31
+
32
+ function __construct(){
33
+
34
+ $widget_ops = array(
35
+ 'classname' => 'advanced-sidebar-menu',
36
+ 'description' => __( 'Creates a menu of all the pages using the child/parent relationship', 'advanced-sidebar-menu' )
37
+ );
38
+ $control_ops = array(
39
+ 'width' => 290
40
+ );
41
+
42
+
43
+ parent::__construct( 'advanced_sidebar_menu', __( 'Advanced Sidebar Pages Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
44
+
45
+ }
46
+
47
+
48
+ /**
49
+ * Output a simple widget Form
50
+ * Not of ton of options here but who need them
51
+ * Most of the magic happens automatically
52
+ *
53
+ * @filters do_action('advanced_sidebar_menu_page_widget_form', $instance, $this->get_field_name('parent_only'), $this->get_field_id('parent_only'));
54
+ *
55
+ * @since 11.4.13
56
+ */
57
+ function form( $instance ){
58
+
59
+ $instance = wp_parse_args( $instance, $this->defaults );
60
+
61
+ ?>
62
+ <p> <?php _e( 'Title', 'advanced-sidebar-menu' ); ?>
63
+ <br>
64
+ <input id="<?php echo $this->get_field_id( 'title' ); ?>"
65
+ name="<?php echo $this->get_field_name( 'title' ); ?>" class="widefat" type="text" value="<?php echo $instance[ 'title' ]; ?>"/>
66
+ </p>
67
+
68
+ <p> <?php _e( 'Display parent page', 'advanced-sidebar-menu' ); ?>:
69
+ <input id="<?php echo $this->get_field_id( self::DISPLAY_PARENT ); ?>"
70
+ name="<?php echo $this->get_field_name( self::DISPLAY_PARENT ); ?>" type="checkbox" value="checked"
71
+ <?php echo $instance[ self::DISPLAY_PARENT ]; ?>/>
72
+ </p>
73
+
74
+
75
+ <p> <?php _e( 'Display menu when there is only the parent page', 'advanced-sidebar-menu' ); ?>:
76
+ <input id="<?php echo $this->get_field_id( 'include_childless_parent' ); ?>"
77
+ name="<?php echo $this->get_field_name( 'include_childless_parent' ); ?>" type="checkbox" value="checked"
78
+ <?php echo $instance[ 'include_childless_parent' ]; ?>/>
79
+ </p>
80
+
81
+ <p> <?php _e( 'Order By', 'advanced-sidebar-menu' ); ?>:
82
+ <select id="<?php echo $this->get_field_id( 'order_by' ); ?>"
83
+ name="<?php echo $this->get_field_name( 'order_by' ); ?>">
84
+ <?php
85
+
86
+ $order_by = array(
87
+ 'menu_order' => 'Page Order',
88
+ 'post_title' => 'Title',
89
+ 'post_date' => 'Published Date'
90
+ );
91
+
92
+ foreach( $order_by as $key => $order ){
93
+
94
+ printf( '<option value="%s" %s>%s</option>', $key, selected( $instance[ 'order_by' ], $key, false ), $order );
95
+ }
96
+ ?>
97
+ </select>
98
+ </p>
99
+
100
+ <p> <?php _e( "Use this Plugin's Styling", 'advanced-sidebar-menu' ); ?>:
101
+ <input id="<?php echo $this->get_field_id( 'css' ); ?>"
102
+ name="<?php echo $this->get_field_name( 'css' ); ?>" type="checkbox" value="checked"
103
+ <?php echo $instance[ 'css' ]; ?>/>
104
+ </p>
105
+
106
+ <p> <?php _e( "Pages to Exclude (ids), Comma Separated", 'advanced-sidebar-menu' ); ?>:
107
+ <input id="<?php echo $this->get_field_id( 'exclude' ); ?>"
108
+ name="<?php echo $this->get_field_name( 'exclude' ); ?>" class="widefat" type="text" value="<?php echo $instance[ 'exclude' ]; ?>"/>
109
+ </p>
110
+
111
+ <p> <?php _e( "Always Display Child Pages", 'advanced-sidebar-menu' ); ?>:
112
+ <input id="<?php echo $this->get_field_id( 'display_all' ); ?>"
113
+ name="<?php echo $this->get_field_name( 'display_all' ); ?>" type="checkbox" value="checked"
114
+ onclick="javascript:asm_reveal_element( 'levels-<?php echo $this->get_field_id( 'levels' ); ?>' )"
115
+ <?php echo $instance[ 'display_all' ]; ?>/>
116
+ </p>
117
+
118
+ <span id="levels-<?php echo $this->get_field_id( 'levels' ); ?>" style="<?php
119
+ if( $instance[ 'display_all' ] == 'checked' ){
120
+ echo 'display:block';
121
+ } else {
122
+ echo 'display:none';
123
+ } ?>">
124
+ <p> <?php _e( "Levels to Display", 'advanced-sidebar-menu' ); ?>:
125
+ <select id="<?php echo $this->get_field_id( 'levels' ); ?>"
126
+ name="<?php echo $this->get_field_name( 'levels' ); ?>">
127
+ <?php
128
+ for( $i = 1; $i < 6; $i ++ ){
129
+ if( $i == $instance[ 'levels' ] ){
130
+ echo '<option value="' . $i . '" selected>' . $i . '</option>';
131
+ } else {
132
+ echo '<option value="' . $i . '">' . $i . '</option>';
133
+ }
134
+ }
135
+ echo '</select></p></span>';
136
+
137
+ do_action( 'advanced_sidebar_menu_page_widget_form', $instance, $this->get_field_name( 'parent_only' ), $this->get_field_id( 'parent_only' ), $this );
138
+
139
+ do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
140
+
141
+
142
+ }
143
+
144
+
145
+ /**
146
+ * Handles the saving of the widget
147
+ *
148
+ * @filters apply_filters('advanced_sidebar_menu_page_widget_update', $newInstance, $oldInstance );
149
+ *
150
+ * @since 4.26.13
151
+ */
152
+ function update( $newInstance, $oldInstance ){
153
+ $newInstance[ 'exclude' ] = strip_tags( $newInstance[ 'exclude' ] );
154
+
155
+ $newInstance = apply_filters( 'advanced_sidebar_menu_page_widget_update', $newInstance, $oldInstance );
156
+
157
+ return $newInstance;
158
+ }
159
+
160
+
161
+
162
+ /**
163
+ * The Widgets Output
164
+ *
165
+ *
166
+ * @param array $args
167
+ * @param array $instance
168
+ *
169
+ * @return void
170
+ */
171
+ public function widget( $args, $instance ){
172
+ $instance = wp_parse_args( $instance, $this->defaults );
173
+ $post = get_post();
174
+ $asm = Advanced_Sidebar_Menu_Menu::factory( $instance, $args );
175
+
176
+ do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
177
+
178
+ $asm->exclude = apply_filters( 'advanced_sidebar_menu_excluded_pages', explode( ',', $instance[ 'exclude' ] ), $post, $asm->args, $asm->instance, $asm );
179
+
180
+ $filter_args = array(
181
+ 0 => $asm->post_type,
182
+ 1 => $asm->args,
183
+ 2 => $asm->instance,
184
+ 3 => $asm,
185
+ 4 => $this,
186
+ );
187
+
188
+ $asm->post_type = $post_type = apply_filters_ref_array( 'advanced_sidebar_menu_post_type', $filter_args );
189
+
190
+ $proper_single = !( is_page() || ( is_single() && $asm->post_type === get_post_type() ) );
191
+ $filter_args[ 0 ] = $proper_single;
192
+ if( apply_filters_ref_array( 'advanced_sidebar_menu_proper_single', $filter_args ) ){
193
+ return;
194
+ }
195
+
196
+ if( $post->ancestors ){
197
+ $ancestors = $post->ancestors;
198
+ $asm->top_id = end( $ancestors );
199
+ } else {
200
+ $asm->top_id = $post->ID;
201
+ }
202
+
203
+ $filter_args[ 0 ] = $asm->top_id;
204
+ $asm->top_id = apply_filters_ref_array( 'advanced_sidebar_menu_top_parent', $filter_args );
205
+ if( get_post_type( $asm->top_id ) !== $asm->post_type ){
206
+ return;
207
+ }
208
+
209
+ unset( $filter_args[ 0 ] );
210
+ array_unshift( $filter_args, $post );
211
+ array_unshift( $filter_args, $instance[ 'order_by' ] );
212
+
213
+ $asm->order_by = apply_filters_ref_array( 'advanced_sidebar_menu_order_by', $filter_args );
214
+ $filter_args[ 0 ] = $asm->order;
215
+ $asm->order = apply_filters_ref_array( 'advanced_sidebar_menu_page_order', $filter_args );
216
+
217
+ //backward compatibility $child_pages for old views
218
+ $list_pages = Advanced_Sidebar_Menu_List_Pages::factory( $asm );
219
+ $child_pages = $list_pages->get_child_pages( $list_pages->top_parent_id, true );
220
+
221
+ //if there are no children do not display the parent unless it is check to do so
222
+ if( ( !empty( $child_pages ) ) || ($asm->checked( 'include_childless_parent' ) && ( !in_array( $asm->top_id, $asm->exclude, false ) ) ) ){
223
+
224
+ if( $asm->checked( 'css' ) ){
225
+ echo '<style type="text/css">';
226
+ include( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'sidebar-menu.css' ) );
227
+ echo '</style>';
228
+ }
229
+
230
+ echo $args[ 'before_widget' ];
231
+ $output = require( Advanced_Sidebar_Menu::get_instance()->get_template_part( 'page_list.php' ) );
232
+
233
+ //backward compatibility for old views that didn't returns
234
+ if( empty( $output ) && isset( $content ) ){
235
+ $output = $content;
236
+ }
237
+
238
+ $filter_args[ 0 ] = $output;
239
+ echo apply_filters_ref_array( 'advanced_sidebar_menu_page_widget_output', $filter_args );
240
+ echo $args[ 'after_widget' ];
241
+
242
+ }
243
+
244
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
views/category_list.php CHANGED
@@ -1,72 +1,110 @@
1
- <?php
2
-
3
- /**
4
- * The Output of the Advanced Sidebar Categories Widget
5
- * @author Mat Lipe
6
- * @since 4.3.1
7
- *
8
- *
9
- * @uses to edit create a file named category_list.php and put in a folder in the your child theme called 'advanced-sidebar-menu
10
- * @uses copy the contents of the file into that file and edit at will
11
- * @param Do not edit this file in this location or it will break on update
12
- */
13
-
14
- /** @var Advanced_Sidebar_Menu_Menu $asm */
15
-
16
- $content = '';
17
-
18
- //Include the parent page if chosen
19
- if( $asm->include_parent() ){
20
- $content .= '<ul class="parent-sidebar-menu">';
21
- $content .= $asm->openListItem( wp_list_categories( 'echo=0&orderby='.$asm->order_by.'&taxonomy='.$asm->taxonomy.'&title_li=&hide_empty=0&include=' . trim($asm->top_id)) );
22
-
23
- }
24
-
25
- //If there are children to display
26
- if( !empty($all_categories) ){
27
- $content .= '<ul class="child-sidebar-menu">';
28
-
29
- #-- If they want all the child categories displayed always
30
- if( $asm->display_all() ){
31
- $content .= wp_list_categories('echo=0&orderby='.$asm->order_by.'&taxonomy='.$asm->taxonomy.'&title_li=&child_of=' . $asm->top_id .'&depth=' .$instance['levels'] );
32
-
33
- } else {
34
-
35
- #-- to Display the categories based a parent child relationship
36
- foreach( $all_categories as $child_cat ){
37
-
38
- //IF this is a child category of the top one
39
- if( $asm->first_level_category( $child_cat ) ){
40
-
41
- //List the child category and the children if it is the current one
42
- $content .= $asm->openListItem(wp_list_categories('echo=0&orderby='.$asm->order_by.'&taxonomy='.$asm->taxonomy.'&title_li=&include=' . $child_cat->term_id . '&depth=1' ) );
43
-
44
-
45
- //If there are children of this cat and it is a parent or child or the current cat
46
- if( $asm->second_level_cat( $child_cat ) ){
47
- #-- Create a new menu with all the children under it
48
- $content .= '<ul class="grandchild-sidebar-menu">';
49
- $content .= wp_list_categories('echo=0&orderby='.$asm->order_by.'&taxonomy='.$asm->taxonomy.'&title_li=&exclude='.$instance['exclude'].'&depth=3&child_of=' .$child_cat->term_id );
50
- $content .= '</ul>';
51
-
52
- }
53
-
54
- $content .= '</li>';
55
- }
56
- } //End foreach
57
-
58
-
59
-
60
- } //End if display all is not checked
61
-
62
- $content .= '</ul><!-- End #child-sidebar-menu -->';
63
-
64
- } //End if the are child categories
65
-
66
-
67
- #-- if a parent category was displayed
68
- if( $asm->include_parent() ){
69
- $content .= '</li>
70
- </ul><!-- End #parent-sidebar-menu -->';
71
- }
72
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The Output of the Advanced Sidebar Categories Widget
5
+ *
6
+ * @since 6.2.5
7
+ *
8
+ * @todo split args into class similar to Advanced_Sidebar_Menu_List_Pages
9
+ *
10
+ * To edit create a file named category_list.php and put in a folder in the your
11
+ * theme called 'advanced-sidebar-menu' copy the contents of the file into that file and edit at will
12
+ *
13
+ * @notice Do NOT edit this file in this location or it will break on update
14
+ */
15
+ $asm = Advanced_Sidebar_Menu_Menu::get_current();
16
+ $instance = $asm->get_widget_instance();
17
+ $content = '';
18
+
19
+ //Include the parent page if chosen
20
+ if( $asm->include_parent() ){
21
+ $content .= '<ul class="parent-sidebar-menu">';
22
+ $_args = array(
23
+ 'echo' => 0,
24
+ 'orderby' => $asm->order_by,
25
+ 'order' => $asm->order,
26
+ 'taxonomy' => $asm->taxonomy,
27
+ 'title_li' => '',
28
+ 'hide_empty' => 0,
29
+ 'include' => trim( $asm->top_id ),
30
+ );
31
+ $content .= $asm->openListItem( wp_list_categories( $_args ) );
32
+
33
+ }
34
+
35
+ //If there are children to display
36
+ if( !empty( $all_categories ) ){
37
+ $content .= '<ul class="child-sidebar-menu">';
38
+
39
+ #-- If we want all the child categories displayed always
40
+ if( $asm->display_all() ){
41
+ $_args = array(
42
+ 'echo' => 0,
43
+ 'orderby' => $asm->order_by,
44
+ 'order' => $asm->order,
45
+ 'taxonomy' => $asm->taxonomy,
46
+ 'title_li' => '',
47
+ 'child_of' => $asm->top_id,
48
+ 'depth' => $instance[ 'levels' ],
49
+ 'exclude' => $instance[ 'exclude' ],
50
+ 'show_option_none' => false,
51
+ );
52
+ $content .= wp_list_categories( $_args );
53
+ } else {
54
+
55
+ #-- to Display the categories based a parent child relationship
56
+ foreach( $all_categories as $child_cat ){
57
+
58
+ //IF this is a child category of the top one
59
+ if( $asm->first_level_category( $child_cat ) ){
60
+
61
+ //List the child category and the children if it is the current one
62
+ $_args = array(
63
+ 'echo' => 0,
64
+ 'orderby' => $asm->order_by,
65
+ 'order' => $asm->order,
66
+ 'taxonomy' => $asm->taxonomy,
67
+ 'title_li' => '',
68
+ 'include' => $child_cat->term_id,
69
+ 'depth' => 1,
70
+ 'show_option_none' => false,
71
+
72
+ );
73
+ $content .= $asm->openListItem( wp_list_categories( $_args ) );
74
+
75
+ //If there are children of this cat and it is a parent or child or the current cat
76
+ if( $asm->second_level_cat( $child_cat ) ){
77
+ #-- Create a new menu with all the children under it
78
+ $content .= '<ul class="grandchild-sidebar-menu children">';
79
+ $_args = array(
80
+ 'echo' => 0,
81
+ 'orderby' => $asm->order_by,
82
+ 'order' => $asm->order,
83
+ 'taxonomy' => $asm->taxonomy,
84
+ 'title_li' => '',
85
+ 'exclude' => $instance[ 'exclude' ],
86
+ 'depth' => 3,
87
+ 'child_of' => $child_cat->term_id,
88
+ 'show_option_none' => false,
89
+ );
90
+ $content .= wp_list_categories( $_args );
91
+ $content .= '</ul>';
92
+
93
+ }
94
+
95
+ $content .= '</li>';
96
+ }
97
+ }
98
+
99
+ }
100
+
101
+ $content .= '</ul><!-- End #child-sidebar-menu -->';
102
+
103
+ }
104
+
105
+ #-- if a parent category was displayed
106
+ if( $asm->include_parent() ){
107
+ $content .= '</li></ul><!-- End #parent-sidebar-menu -->';
108
+ }
109
+
110
+ return $content;
views/page_list.php CHANGED
@@ -1,49 +1,58 @@
1
- <?php
2
- /**
3
- * The Output of the Advanced Sidebar Page Widget
4
- *
5
- * @author Mat Lipe
6
- *
7
- * @since 6.1.0
8
- *
9
- * @example to edit, create a file named page_list.php and put in a folder in the your theme called 'advanced-sidebar-menu.
10
- * Copy the contents of the file into that file and edit at will.
11
- * @notice Do not edit this file in its original location or it will break on upgrade
12
- */
13
- $menu = new Advanced_Sidebar_Menu_List_Pages( $asm->top_id, $asm );
14
- $_args = $menu->get_args();
15
-
16
- /** @var Advanced_Sidebar_Menu_Menu $asm */
17
- $asm->title();
18
-
19
- #-- list the parent page if chosen
20
- if( $asm->include_parent() ){
21
- $content .= '<ul class="parent-sidebar-menu" >';
22
- $_args[ 'include' ] = $asm->top_id;
23
- $content .= wp_list_pages( $_args );
24
- }
25
-
26
-
27
- //If there are children start the Child Sidebar Menu
28
- if( $child_pages ){
29
- $content .= '<ul class="child-sidebar-menu">';
30
-
31
- #-- If they want all the pages displayed always
32
- if( $asm->display_all() ){
33
- unset( $_args[ 'include' ] );
34
- $_args[ 'child_of' ] = $asm->top_id;
35
- $_args[ 'depth' ] = $instance[ 'levels' ];
36
- $content .= wp_list_pages( $_args );
37
-
38
- } else {
39
- $content .= $menu->list_pages();
40
-
41
- }
42
-
43
- #-- Close the First Level menu
44
- $content .= '</ul><!-- End child-sidebar-menu -->';
45
-
46
- }
47
- if( $asm->include_parent() ){
48
- $content .= '</li></ul><!-- .parent-sidebar-menu -->';
49
- }
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Output of the Advanced Sidebar Page Widget
4
+ *
5
+ * @author Mat Lipe
6
+ *
7
+ * @since 6.4.0
8
+ *
9
+ * @example to edit, create a file named page_list.php and
10
+ * put in a folder in the your theme called 'advanced-sidebar-menu.
11
+ * Copy the contents of the file into that file and edit at will.
12
+ *
13
+ * @notice Do not edit this file in its original location or it will break on upgrade
14
+ */
15
+ $asm = Advanced_Sidebar_Menu_Menu::get_current();
16
+ $menu = Advanced_Sidebar_Menu_List_Pages::factory( $asm );
17
+ $child_pages = $menu->get_child_pages( $asm->top_id, true );
18
+ $instance = $asm->get_widget_instance();
19
+ $_args = $menu->get_args();
20
+
21
+ /** @var Advanced_Sidebar_Menu_Menu $asm */
22
+ $asm->title();
23
+
24
+ $content = '';
25
+
26
+ #-- list the parent page if chosen
27
+ if( $asm->include_parent() ){
28
+ $content .= '<ul class="parent-sidebar-menu" >';
29
+ $_args[ 'include' ] = $asm->top_id;
30
+ $content .= wp_list_pages( $_args );
31
+ }
32
+
33
+
34
+ //If there are children start the Child Sidebar Menu
35
+ if( !empty( $child_pages ) ){
36
+ $content .= '<ul class="child-sidebar-menu">';
37
+
38
+ #-- If they want all the pages displayed always
39
+ if( $asm->display_all() ){
40
+ unset( $_args[ 'include' ] );
41
+ $_args[ 'child_of' ] = $asm->top_id;
42
+ $_args[ 'depth' ] = $instance[ 'levels' ];
43
+ $content .= wp_list_pages( $_args );
44
+
45
+ } else {
46
+ $content .= $menu->list_pages();
47
+
48
+ }
49
+
50
+ #-- Close the First Level menu
51
+ $content .= '</ul><!-- End child-sidebar-menu -->';
52
+
53
+ }
54
+ if( $asm->include_parent() ){
55
+ $content .= '</li></ul><!-- .parent-sidebar-menu -->';
56
+ }
57
+
58
+ return $content;
views/sidebar-menu.css CHANGED
@@ -1,39 +1,39 @@
1
- .advanced-sidebar-menu ul li a{
2
- font-weight: bold;
3
- font-size: 130%;
4
- text-decoration: none;
5
- }
6
-
7
- .advanced-sidebar-menu ul li a:hover{
8
- text-decoration: underline;
9
- }
10
-
11
- .advanced-sidebar-menu ul ul li a{
12
- font-weight: normal;
13
- font-size: 100%;
14
- }
15
-
16
- .advanced-sidebar-menu ul{
17
- margin: 0 0 0 18px;
18
- list-style: none;
19
- list-style-type: none;
20
- }
21
-
22
- .advanced-sidebar-menu ul li{
23
- list-style:none;
24
- list-style-type: none;
25
- margin: 0;
26
-
27
- }
28
-
29
- .advanced-sidebar-menu li.current_page_item{
30
- list-style-type: disc;
31
- }
32
-
33
- .advanced-sidebar-menu li.current_page_item a{
34
- font-weight: bold;
35
- }
36
-
37
- .advanced-sidebar-menu li.current_page_item li a{
38
- font-weight: normal;
39
- }
1
+ .advanced-sidebar-menu ul li a{
2
+ font-weight: bold;
3
+ font-size: 130%;
4
+ text-decoration: none;
5
+ }
6
+
7
+ .advanced-sidebar-menu ul li a:hover{
8
+ text-decoration: underline;
9
+ }
10
+
11
+ .advanced-sidebar-menu ul ul li a{
12
+ font-weight: normal;
13
+ font-size: 100%;
14
+ }
15
+
16
+ .advanced-sidebar-menu ul{
17
+ margin: 0 0 0 18px;
18
+ list-style: none;
19
+ list-style-type: none;
20
+ }
21
+
22
+ .advanced-sidebar-menu ul li{
23
+ list-style:none;
24
+ list-style-type: none;
25
+ margin: 0;
26
+
27
+ }
28
+
29
+ .advanced-sidebar-menu li.current_page_item{
30
+ list-style-type: disc;
31
+ }
32
+
33
+ .advanced-sidebar-menu li.current_page_item a{
34
+ font-weight: bold;
35
+ }
36
+
37
+ .advanced-sidebar-menu li.current_page_item li a{
38
+ font-weight: normal;
39
+ }