Advanced Sidebar Menu - Version 7.1.0

Version Description

  • Support Pro Version 3.0.0
  • Add German translations
  • Begin converting code formatting to strict WordPress standards
Download this release

Release Info

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

Code changes from version 7.0.3 to 7.1.0

advanced-sidebar-menu.php CHANGED
@@ -1,103 +1,103 @@
1
- <?php
2
- /*
3
- 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: 7.0.3
8
- Author URI: https://matlipe.com
9
- Text Domain: advanced-sidebar-menu
10
- */
11
-
12
-
13
- if( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ){
14
- return;
15
- }
16
-
17
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.0.2' );
18
- define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
19
-
20
- if( !function_exists( 'advanced_sidebar_menu_load' ) ){
21
- function advanced_sidebar_menu_load(){
22
- Advanced_Sidebar_Menu_Core::init();
23
- Advanced_Sidebar_Menu_Cache::init();
24
- Advanced_Sidebar_Menu_Debug::init();
25
- }
26
-
27
- add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
28
- }
29
-
30
- /**
31
- * Autoload classes from PSR4 src directory
32
- * Mirrored after Composer dump-autoload for performance
33
- *
34
- * @param string $class
35
- *
36
- * @return void
37
- */
38
- function advanced_sidebar_menu_autoload( $class ) {
39
- $classes = array(
40
- //widgets
41
- 'Advanced_Sidebar_Menu_Widget_Page' => 'Widget/Page.php',
42
- 'Advanced_Sidebar_Menu_Widget_Category' => 'Widget/Category.php',
43
-
44
- //core
45
- 'Advanced_Sidebar_Menu_Cache' => 'Cache.php',
46
- 'Advanced_Sidebar_Menu_Core' => 'Core.php',
47
- 'Advanced_Sidebar_Menu_Debug' => 'Debug.php',
48
- 'Advanced_Sidebar_Menu_List_Pages' => 'List_Pages.php',
49
- 'Advanced_Sidebar_Menu_Menu' => 'Menu.php',
50
- 'Advanced_Sidebar_Menu_Page_Walker' => 'Page_Walker.php',
51
-
52
- //menus
53
- 'Advanced_Sidebar_Menu_Menus_Category' => 'Menus/Category.php',
54
- 'Advanced_Sidebar_Menu_Menus_Abstract' => 'Menus/Abstract.php',
55
- 'Advanced_Sidebar_Menu_Menus_Page' => 'Menus/Page.php',
56
- );
57
- if( isset( $classes[ $class ] ) ){
58
- require dirname( __FILE__ ) . '/src/' . $classes[ $class ];
59
- }
60
- }
61
-
62
- spl_autoload_register( 'advanced_sidebar_menu_autoload' );
63
-
64
-
65
-
66
- #-- Translate
67
- add_action( 'plugins_loaded', 'advanced_sidebar_menu_translate' );
68
- function advanced_sidebar_menu_translate(){
69
- load_plugin_textdomain( 'advanced-sidebar-menu', false, 'advanced-sidebar-menu/languages' );
70
- }
71
-
72
- add_action( 'admin_print_scripts', 'advanced_sidebar_menu_script' );
73
- function advanced_sidebar_menu_script(){
74
- wp_enqueue_script(
75
- apply_filters( 'asm_script', 'advanced-sidebar-menu-script' ),
76
- plugins_url( 'resources/js/advanced-sidebar-menu.js', __FILE__ ),
77
- array( 'jquery' ),
78
- ADVANCED_SIDEBAR_BASIC_VERSION
79
- );
80
- }
81
-
82
- #-- Let know about new Pro Version
83
- add_action( 'advanced_sidebar_menu_after_widget_form', 'advanced_sidebar_menu_pro_notice' );
84
- function advanced_sidebar_menu_pro_notice() {
85
- if( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ){
86
- return;
87
- }
88
- ?>
89
- <fieldset style="border: 1px solid black; border-radius: 10px; padding: 10px;">
90
- <legend style="font-size: 14px; font-weight: bold;">
91
- <?php _e( 'Checkout Advanced Sidebar Menu Pro!', 'advanced-sidebar-menu' ); ?>
92
- </legend>
93
- <p>
94
- <?php printf( __( 'Upgrade to %sAdvanced Sidebar Menu Pro%s for Priority Support, Styles, Custom Link Text, Accordions, Custom Post Types, and so much more!', 'advanced-sidebar-menu' ), '<a target="blank" href="https://matlipe.com/product/advanced-sidebar-menu-pro/">', '</a>' ); ?>
95
-
96
- <p>
97
- </fieldset>
98
- <?php
99
- }
100
-
101
-
102
-
103
-
1
+ <?php
2
+ /*
3
+ 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: 7.1.0
8
+ Author URI: https://matlipe.com
9
+ Text Domain: advanced-sidebar-menu
10
+ */
11
+
12
+
13
+ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
14
+ return;
15
+ }
16
+
17
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.1.0' );
18
+ define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
19
+
20
+ if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
21
+ function advanced_sidebar_menu_load() {
22
+ Advanced_Sidebar_Menu_Core::init();
23
+ Advanced_Sidebar_Menu_Cache::init();
24
+ Advanced_Sidebar_Menu_Debug::init();
25
+ }
26
+
27
+ add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
28
+ }
29
+
30
+ /**
31
+ * Autoload classes from PSR4 src directory
32
+ * Mirrored after Composer dump-autoload for performance
33
+ *
34
+ * @param string $class
35
+ *
36
+ * @return void
37
+ */
38
+ function advanced_sidebar_menu_autoload( $class ) {
39
+ $classes = array(
40
+ //widgets
41
+ 'Advanced_Sidebar_Menu_Widget_Page' => 'Widget/Page.php',
42
+ 'Advanced_Sidebar_Menu_Widget_Category' => 'Widget/Category.php',
43
+
44
+ //core
45
+ 'Advanced_Sidebar_Menu_Cache' => 'Cache.php',
46
+ 'Advanced_Sidebar_Menu_Core' => 'Core.php',
47
+ 'Advanced_Sidebar_Menu_Debug' => 'Debug.php',
48
+ 'Advanced_Sidebar_Menu_List_Pages' => 'List_Pages.php',
49
+ 'Advanced_Sidebar_Menu_Menu' => 'Menu.php',
50
+ 'Advanced_Sidebar_Menu_Page_Walker' => 'Page_Walker.php',
51
+
52
+ //menus
53
+ 'Advanced_Sidebar_Menu_Menus_Category' => 'Menus/Category.php',
54
+ 'Advanced_Sidebar_Menu_Menus_Abstract' => 'Menus/Abstract.php',
55
+ 'Advanced_Sidebar_Menu_Menus_Page' => 'Menus/Page.php',
56
+ );
57
+ if ( isset( $classes[ $class ] ) ) {
58
+ require dirname( __FILE__ ) . '/src/' . $classes[ $class ];
59
+ }
60
+ }
61
+
62
+ spl_autoload_register( 'advanced_sidebar_menu_autoload' );
63
+
64
+
65
+ #-- Translate
66
+ add_action( 'plugins_loaded', 'advanced_sidebar_menu_translate' );
67
+ function advanced_sidebar_menu_translate() {
68
+ load_plugin_textdomain( 'advanced-sidebar-menu', false, 'advanced-sidebar-menu/languages' );
69
+ }
70
+
71
+ add_action( 'admin_print_scripts', 'advanced_sidebar_menu_script' );
72
+ function advanced_sidebar_menu_script() {
73
+ wp_enqueue_script(
74
+ apply_filters( 'asm_script', 'advanced-sidebar-menu-script' ),
75
+ plugins_url( 'resources/js/advanced-sidebar-menu.js', __FILE__ ),
76
+ array( 'jquery' ),
77
+ ADVANCED_SIDEBAR_BASIC_VERSION
78
+ );
79
+ }
80
+
81
+ #-- Let know about new Pro Version
82
+ add_action( 'advanced_sidebar_menu_after_widget_form', 'advanced_sidebar_menu_pro_notice' );
83
+ function advanced_sidebar_menu_pro_notice() {
84
+ if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
85
+ return;
86
+ }
87
+ ?>
88
+ <fieldset style="border: 1px solid black; border-radius: 10px; padding: 10px;">
89
+ <legend style="font-size: 14px; font-weight: bold;">
90
+ <?php esc_html_e( 'Checkout Advanced Sidebar Menu Pro!', 'advanced-sidebar-menu' ); ?>
91
+ </legend>
92
+ <p>
93
+ <?php
94
+ /* translators: {<a>}{</a>} links to https://matlipe.com/product/advanced-sidebar-menu-pro/ */
95
+ printf( esc_html_x( 'Upgrade to %1$sAdvanced Sidebar Menu Pro%2$s for Priority Support, Styles, Custom Link Text, Accordions, Custom Post Types, and so much more!', '{<a>}{</a>}', 'advanced-sidebar-menu' ), '<a target="blank" href="https://matlipe.com/product/advanced-sidebar-menu-pro/">', '</a>' ); ?>
96
+ <p>
97
+ </fieldset>
98
+ <?php
99
+ }
100
+
101
+
102
+
103
+
languages/advanced-sidebar-menu-de_DE.mo ADDED
Binary file
languages/advanced-sidebar-menu-de_DE.po ADDED
@@ -0,0 +1,150 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Advanced Sidebar Menu\n"
4
+ "POT-Creation-Date: 2018-01-09 09:48-0500\n"
5
+ "PO-Revision-Date: 2018-01-09 09:48-0500\n"
6
+ "Last-Translator: Mat Lipe <mat@matlipe.com>\n"
7
+ "Language-Team: \n"
8
+ "Language: de\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Generator: Poedit 2.0.5\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:90
25
+ msgid "Checkout Advanced Sidebar Menu Pro!"
26
+ msgstr "Kasse Advanced Sidebar Menu Pro!"
27
+
28
+ #. translators: {<a>}{</a>} links to https://matlipe.com/product/advanced-sidebar-menu-pro/
29
+ #: advanced-sidebar-menu.php:95
30
+ #, php-format
31
+ msgctxt "{<a>}{</a>}"
32
+ msgid ""
33
+ "Upgrade to %1$sAdvanced Sidebar Menu Pro%2$s for Priority Support, Styles, "
34
+ "Custom Link Text, Accordions, Custom Post Types, and so much more!"
35
+ msgstr ""
36
+ "Upgrade auf %1$sAdvanced Sidebar Menu Pro %2$s für Priority-Support, Styles, "
37
+ "Custom-Link-Text, Akkordeons, Custom Post Types und vieles mehr!"
38
+
39
+ #: src/Widget/Category.php:42
40
+ msgid ""
41
+ "Creates a menu of all the categories using the child/parent relationship"
42
+ msgstr ""
43
+ "Erstellt ein Menü aller Kategorien, die unter Zugrundelegung der Eltern-Kind-"
44
+ "Beziehung"
45
+
46
+ #: src/Widget/Category.php:46
47
+ msgid "Advanced Sidebar Categories Menu"
48
+ msgstr "Advanced Sidebar Kategorien-Menü"
49
+
50
+ #: src/Widget/Category.php:65 src/Widget/Page.php:65
51
+ msgid "Title"
52
+ msgstr "Titel"
53
+
54
+ #: src/Widget/Category.php:72
55
+ msgid "Display parent category"
56
+ msgstr "Übergeordnete Kategorie anzeigen"
57
+
58
+ #: src/Widget/Category.php:79
59
+ msgid "Display menu when there is only the parent category"
60
+ msgstr "Menü \"Anzeige\" wird nur die übergeordnete Kategorie"
61
+
62
+ #: src/Widget/Category.php:85
63
+ msgid "Use this plugins styling"
64
+ msgstr "Verwenden Sie dieses Plugins-styling"
65
+
66
+ #: src/Widget/Category.php:91
67
+ msgid "Display categories on single posts"
68
+ msgstr "Kategorien auf einzelne Beiträge anzeigen"
69
+
70
+ #: src/Widget/Category.php:104
71
+ msgid "Display each single post's category"
72
+ msgstr "Zeigen Sie die einzelnen Kategorien der einzelnen Posts an"
73
+
74
+ #: src/Widget/Category.php:111 src/Widget/Category.php:120
75
+ msgid "In a new widget"
76
+ msgstr "In einem neuen Widget"
77
+
78
+ #: src/Widget/Category.php:114 src/Widget/Category.php:123
79
+ msgid "In another list in the same widget"
80
+ msgstr "In einer anderen Liste im selben Widget"
81
+
82
+ #: src/Widget/Category.php:134
83
+ msgid "Categories to exclude (ids), comma separated"
84
+ msgstr "Kategorien ausschließen (Ids), durch Kommata getrennt"
85
+
86
+ #: src/Widget/Category.php:139
87
+ msgid "Always display child categories"
88
+ msgstr "Immer untergeordnete Kategorien anzeigen"
89
+
90
+ #: src/Widget/Category.php:153 src/Widget/Page.php:131
91
+ msgid "Levels to display"
92
+ msgstr "Anzuzeigenden Ebenen"
93
+
94
+ #: src/Widget/Page.php:38
95
+ msgid "Creates a menu of all the pages using the child/parent relationship"
96
+ msgstr ""
97
+ "Erstellt ein Menü mit allen Seiten, die die Child / Parent-Beziehung "
98
+ "verwenden"
99
+
100
+ #: src/Widget/Page.php:44
101
+ msgid "Advanced Sidebar Pages Menu"
102
+ msgstr "Advanced Sidebar Seitenmenü"
103
+
104
+ #: src/Widget/Page.php:71
105
+ msgid "Display parent page"
106
+ msgstr "Zeigen Sie die übergeordnete Seite an"
107
+
108
+ #: src/Widget/Page.php:78
109
+ msgid "Display menu when there is only the parent page"
110
+ msgstr "Menü \"Anzeige\" wird nur die übergeordnete Seite"
111
+
112
+ #: src/Widget/Page.php:84
113
+ msgid "Order By"
114
+ msgstr "Sortieren nach"
115
+
116
+ #: src/Widget/Page.php:103
117
+ msgid "Use this Plugin's Styling"
118
+ msgstr "Benutze das Plugin Styling"
119
+
120
+ #: src/Widget/Page.php:109
121
+ msgid "Pages to exclude (ids), comma separated"
122
+ msgstr "Auszuschließende Seiten (IDs), durch Kommas getrennt"
123
+
124
+ #: src/Widget/Page.php:114
125
+ msgid "Always display child pages"
126
+ msgstr "Immer untergeordnete Seiten anzeigen"
127
+
128
+ #. Plugin Name of the plugin/theme
129
+ msgid "Advanced Sidebar Menu"
130
+ msgstr "Advanced Sidebar Menu"
131
+
132
+ #. Plugin URI of the plugin/theme
133
+ msgid "https://matlipe.com/advanced-sidebar-menu/"
134
+ msgstr "https://matlipe.com/advanced-sidebar-menu/"
135
+
136
+ #. Description of the plugin/theme
137
+ msgid ""
138
+ "Creates dynamic menus based on parent/child relationship of your pages or "
139
+ "categories."
140
+ msgstr ""
141
+ "Dynamische Menüs basierend auf Parent/Child-Beziehung Ihrer Seiten oder "
142
+ "Kategorien erstellt."
143
+
144
+ #. Author of the plugin/theme
145
+ msgid "Mat Lipe"
146
+ msgstr "Mat Lipe"
147
+
148
+ #. Author URI of the plugin/theme
149
+ msgid "https://matlipe.com"
150
+ msgstr "https://matlipe.com"
languages/advanced-sidebar-menu.pot CHANGED
@@ -3,32 +3,34 @@ msgid ""
3
msgstr ""
4
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
"Project-Id-Version: Advanced Sidebar Menu\n"
6
- "POT-Creation-Date: 2017-11-28 14:34-0500\n"
7
- "PO-Revision-Date: 2017-11-28 14:34-0500\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.4\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:91
25
msgid "Checkout Advanced Sidebar Menu Pro!"
26
msgstr ""
27
28
- #: advanced-sidebar-menu.php:94
29
#, php-format
30
msgid ""
31
- "Upgrade to %sAdvanced Sidebar Menu Pro%s for Priority Support, Styles, "
32
"Custom Link Text, Accordions, Custom Post Types, and so much more!"
33
msgstr ""
34
@@ -50,7 +52,7 @@ msgid "Display parent category"
50
msgstr ""
51
52
#: src/Widget/Category.php:79
53
- msgid "Display menu where there is only the parent category"
54
msgstr ""
55
56
#: src/Widget/Category.php:85
3
msgstr ""
4
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
"Project-Id-Version: Advanced Sidebar Menu\n"
6
+ "POT-Creation-Date: 2018-01-09 09:48-0500\n"
7
+ "PO-Revision-Date: 2018-01-09 07:14-0500\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.5\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;"
20
+ "_n_noop:1,2;_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:90
25
msgid "Checkout Advanced Sidebar Menu Pro!"
26
msgstr ""
27
28
+ #. translators: {<a>}{</a>} links to https://matlipe.com/product/advanced-sidebar-menu-pro/
29
+ #: advanced-sidebar-menu.php:95
30
#, php-format
31
+ msgctxt "{<a>}{</a>}"
32
msgid ""
33
+ "Upgrade to %1$sAdvanced Sidebar Menu Pro%2$s for Priority Support, Styles, "
34
"Custom Link Text, Accordions, Custom Post Types, and so much more!"
35
msgstr ""
36
52
msgstr ""
53
54
#: src/Widget/Category.php:79
55
+ msgid "Display menu when there is only the parent category"
56
msgstr ""
57
58
#: src/Widget/Category.php:85
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
5
Tags: menus, sidebar menu, hierarchy, category menu, pages menu
6
Requires at least: 4.6.0
7
Tested up to: 4.9.1
8
- Stable tag: 7.0.3
9
10
== Description ==
11
@@ -16,9 +16,8 @@ Keeps the menu clean and usable. Only related items display so you don't have to
16
17
<strong>Check out <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/">Advanced Sidebar Menu Pro</a> for more features including priority support, the ability to customize the look and feel, custom text for your links, excluding of pages, category link ordering, accordions, custom post types, and so much more!</strong>
18
19
- <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 2.4.0</a> just dropped with lots of great new stuff!</blockquote>
20
21
-
22
<h4>Page Widget Options</h4>
23
* Add a title to the widget
24
* Include the highest level parent page
@@ -62,6 +61,10 @@ Keeps the menu clean and usable. Only related items display so you don't have to
62
* Number of levels of pages to show when always displayed child pages is not checked.
63
* Ability to select and display custom post types **NEW**
64
* Ability to select and display custom taxonomies **NEW**
65
66
<h4>Developers</h4>
67
Developer docs may be found <a target="_blank" href="https://matlipe.com/advanced-sidebar-menu/developer-docs/">here</a>.
@@ -92,10 +95,6 @@ Manual Installation
92
Developer docs may be found here:
93
<a href="https://matlipe.com/advanced-sidebar-menu/developer-docs/" target="_blank">https://matlipe.com/advanced-sidebar-menu/developer-docs/</a>
94
95
- = What text domain do I use for translation and where is the .pot file? =
96
-
97
- The .pot file may be found in the plugins' languages folder. Use the 'advanced-sidebar-menu' text domain.
98
-
99
100
= How do I change the styling of the current page? =
101
@@ -135,6 +134,11 @@ You can add classes to your theme's style.css file to style it accordingly.
135
You may want to use something like margins to set the levels apart.
136
137
== Changelog ==
138
= 7.0.0 =
139
* Restructure the codebase to a more modern PSR4 structure
140
* Improve cache handling
5
Tags: menus, sidebar menu, hierarchy, category menu, pages menu
6
Requires at least: 4.6.0
7
Tested up to: 4.9.1
8
+ Stable tag: 7.1.0
9
10
== Description ==
11
16
17
<strong>Check out <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/">Advanced Sidebar Menu Pro</a> for more features including priority support, the ability to customize the look and feel, custom text for your links, excluding of pages, category link ordering, accordions, custom post types, and so much more!</strong>
18
19
+ <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 3.0.0</a> just dropped with lots of great new stuff!</blockquote>
20
21
<h4>Page Widget Options</h4>
22
* Add a title to the widget
23
* Include the highest level parent page
61
* Number of levels of pages to show when always displayed child pages is not checked.
62
* Ability to select and display custom post types **NEW**
63
* Ability to select and display custom taxonomies **NEW**
64
+
65
+ <h4>Currently ships with the following languages</h4>
66
+ * English (US)
67
+ * German (de_DE)
68
69
<h4>Developers</h4>
70
Developer docs may be found <a target="_blank" href="https://matlipe.com/advanced-sidebar-menu/developer-docs/">here</a>.
95
Developer docs may be found here:
96
<a href="https://matlipe.com/advanced-sidebar-menu/developer-docs/" target="_blank">https://matlipe.com/advanced-sidebar-menu/developer-docs/</a>
97
98
99
= How do I change the styling of the current page? =
100
134
You may want to use something like margins to set the levels apart.
135
136
== Changelog ==
137
+ = 7.1.0 =
138
+ * Support Pro Version 3.0.0
139
+ * Add German translations
140
+ * Begin converting code formatting to strict WordPress standards
141
+
142
= 7.0.0 =
143
* Restructure the codebase to a more modern PSR4 structure
144
* Improve cache handling
src/Debug.php CHANGED
@@ -11,8 +11,9 @@
11
class Advanced_Sidebar_Menu_Debug {
12
const DEBUG_PARAM = 'asm_debug';
13
14
protected 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
}
@@ -20,19 +21,35 @@ class Advanced_Sidebar_Menu_Debug {
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="<?php echo self::DEBUG_PARAM; ?>">
31
- var <?php echo self::DEBUG_PARAM; ?> = window.<?php echo self::DEBUG_PARAM; ?> || {};
32
- <?php echo self::DEBUG_PARAM; ?>['version'] = '<?php echo ADVANCED_SIDEBAR_BASIC_VERSION; ?>';
33
- <?php echo self::DEBUG_PARAM; ?>['<?php echo $widget->id; ?>'] = <?php echo json_encode( $asm->instance ); ?>;
34
- </script>
35
- <?php
36
}
37
38
//********** SINGLETON **********/
@@ -63,10 +80,10 @@ class Advanced_Sidebar_Menu_Debug {
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
- }
11
class Advanced_Sidebar_Menu_Debug {
12
const DEBUG_PARAM = 'asm_debug';
13
14
+
15
protected function hook() {
16
+ if ( ! empty( $_GET[ self::DEBUG_PARAM ] ) ) {
17
add_action( 'advanced_sidebar_menu_widget_pre_render', array( $this, 'print_instance' ), 1, 2 );
18
}
19
}
21
22
/**
23
*
24
+ * @param Advanced_Sidebar_Menu_Menu $asm
25
+ * @param Advanced_Sidebar_Menu_Widget_Page $widget
26
*
27
* @return void
28
*/
29
+ public function print_instance( $asm, $widget ) {
30
+ static $printed = false;
31
+ $data = array(
32
+ 'version' => ADVANCED_SIDEBAR_BASIC_VERSION,
33
+ $widget->id => $asm->instance,
34
+ );
35
+ if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
36
+ $data['pro_version'] = ADVANCED_SIDEBAR_MENU_PRO_VERSION;
37
+ }
38
+
39
+ if ( ! $printed ) {
40
+ ?>
41
+ <script class="<?php echo esc_attr( self::DEBUG_PARAM ); ?>">
42
+ var <?php echo esc_attr( self::DEBUG_PARAM ); ?> = <?php echo wp_json_encode( $data ); ?>;
43
+ </script>
44
+ <?php
45
+ $printed = true;
46
+ } else {
47
+ ?>
48
+ <script class="<?php echo esc_attr( self::DEBUG_PARAM ); ?>">
49
+ <?php echo esc_attr( self::DEBUG_PARAM ); ?>['<?php echo esc_js( $widget->id ); ?>'] = <?php echo wp_json_encode( $asm->instance ); ?>;
50
+ </script>
51
+ <?php
52
+ }
53
}
54
55
//********** SINGLETON **********/
80
* @return self
81
*/
82
public static function instance() {
83
+ if ( ! is_a( self::$instance, __CLASS__ ) ) {
84
self::$instance = new self();
85
}
86
87
return self::$instance;
88
}
89
+ }
src/List_Pages.php CHANGED
@@ -91,9 +91,9 @@ class Advanced_Sidebar_Menu_List_Pages {
91
* @param \Advanced_Sidebar_Menu_Menus_Page $menu
92
*/
93
protected function __construct( Advanced_Sidebar_Menu_Menus_Page $menu ) {
94
- $this->menu = $menu;
95
$this->top_parent_id = $menu->get_top_parent_id();
96
- $this->current_page = $menu->get_current_post();
97
98
$args = array(
99
'post_type' => $menu->get_post_type(),
@@ -130,21 +130,21 @@ class Advanced_Sidebar_Menu_List_Pages {
130
* @return array
131
*/
132
public function add_list_item_classes( $classes, WP_Post $post ) {
133
- if( $post->ID === $this->top_parent_id ){
134
$children = $this->get_child_pages( $post->ID, true );
135
} else {
136
$children = $this->get_child_pages( $post->ID );
137
}
138
- if( !empty( $children ) ){
139
$classes[] = 'has_children';
140
}
141
142
//page posts are handled by wp core. This is for custom post types
143
- if( $post->post_type !== 'page' ){
144
$ancestors = get_post_ancestors( $post );
145
- if( !empty( $ancestors ) && in_array( $this->current_page->ID, $ancestors, false ) ){
146
$classes[] = 'current_page_ancestor';
147
- } elseif( $this->current_page->ID === $post->post_parent ) {
148
$classes[] = 'current_page_parent';
149
}
150
}
@@ -162,17 +162,17 @@ class Advanced_Sidebar_Menu_List_Pages {
162
* @return array
163
*/
164
public function get_args( $level = null ) {
165
- if( null === $level ){
166
return $this->args;
167
}
168
$args = $this->args;
169
- switch ( $level ){
170
case 'parent':
171
- $args[ 'include' ] = $this->menu->get_top_parent_id();
172
break;
173
case 'display-all':
174
- $args[ 'child_of' ] = $this->menu->get_top_parent_id();
175
- $args[ 'depth' ] = $this->menu->get_levels_to_display();
176
break;
177
}
178
@@ -180,6 +180,16 @@ class Advanced_Sidebar_Menu_List_Pages {
180
}
181
182
183
/**
184
* __toString
185
*
@@ -202,26 +212,27 @@ class Advanced_Sidebar_Menu_List_Pages {
202
*/
203
protected function parse_args( $args ) {
204
$defaults = array(
205
- 'exclude' => '',
206
- 'echo' => 0,
207
- 'order' => 'ASC',
208
- 'orderby' => 'menu_order, post_title',
209
- 'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
210
- 'link_before' => '',
211
- 'link_after' => '',
212
- 'title_li' => '',
213
- 'levels' => 100,
214
- 'item_spacing' => 'preserve',
215
- 'nopaging' => true,
216
);
217
218
$args = wp_parse_args( $args, $defaults );
219
220
- if( is_string( $args[ 'exclude' ] ) ){
221
- $args[ 'exclude' ] = explode( ',', $args[ 'exclude' ] );
222
}
223
//sanitize, mostly to keep spaces out
224
- $args[ 'exclude' ] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args[ 'exclude' ] ) ) );
225
226
return apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
227
@@ -237,14 +248,14 @@ class Advanced_Sidebar_Menu_List_Pages {
237
*/
238
public function list_pages() {
239
$pages = $this->get_child_pages( $this->top_parent_id, true );
240
- foreach( $pages as $page ){
241
$this->output .= walk_page_tree( array( $page ), 1, $this->current_page->ID, $this->args );
242
$this->output .= $this->list_grandchild_pages( $page->ID );
243
$this->output .= '</li>' . "\n";
244
}
245
246
$this->output = apply_filters( 'wp_list_pages', $this->output, $this->args );
247
- if( !$this->args[ 'echo' ] ){
248
return $this->output;
249
}
250
echo $this->output;
@@ -261,14 +272,14 @@ class Advanced_Sidebar_Menu_List_Pages {
261
* @return string
262
*/
263
protected function list_grandchild_pages( $parent_page_id ) {
264
- if( $this->level >= (int) $this->args[ 'levels' ] ){
265
return '';
266
}
267
- if( !$this->is_current_page_ancestor( $parent_page_id ) ){
268
return '';
269
}
270
$pages = $this->get_child_pages( $parent_page_id );
271
- if( empty( $pages ) ){
272
return '';
273
}
274
@@ -276,13 +287,13 @@ class Advanced_Sidebar_Menu_List_Pages {
276
$content = sprintf( '<ul class="grandchild-sidebar-menu level-%s children">', $this->level );
277
278
$inside = '';
279
- foreach( $pages as $page ){
280
$inside .= walk_page_tree( array( $page ), 1, $this->current_page->ID, $this->args );
281
$inside .= $this->list_grandchild_pages( $page->ID );
282
$inside .= "</li>\n";
283
}
284
285
- if( '' === $inside ){
286
return '';
287
}
288
@@ -291,26 +302,24 @@ class Advanced_Sidebar_Menu_List_Pages {
291
292
293
/**
294
- * page_children
295
- *
296
* Retrieve the child pages of specific page_id
297
*
298
* @param int $parent_page_id
299
* @param bool $is_first_level
300
*
301
- * @return array
302
*/
303
public function get_child_pages( $parent_page_id, $is_first_level = false ) {
304
//holds a unique key so Cache can distinguish calls
305
$this->current_children_parent = $parent_page_id;
306
307
- $cache = Advanced_Sidebar_Menu_Cache::instance();
308
$child_pages = $cache->get_child_pages( $this );
309
- if( $child_pages === false ){
310
- $args = $this->args;
311
- $args[ 'post_parent' ] = $parent_page_id;
312
- $args[ 'fields' ] = 'ids';
313
- $child_pages = get_posts( $args );
314
315
$cache->add_child_pages( $this, $child_pages );
316
}
@@ -318,8 +327,14 @@ class Advanced_Sidebar_Menu_List_Pages {
318
$child_pages = array_map( 'get_post', (array) $child_pages );
319
320
//we only filter the first level with this filter for backward pro compatibility
321
- if( $is_first_level ){
322
- $child_pages = apply_filters( 'advanced_sidebar_menu_child_pages', $child_pages, $this->current_page, $this->menu->instance, $this->menu->args, $this->menu );
323
}
324
325
return $child_pages;
@@ -336,16 +351,16 @@ class Advanced_Sidebar_Menu_List_Pages {
336
*
337
* @return bool
338
*/
339
- protected function is_current_page_ancestor( $page_id ) {
340
$return = false;
341
- if( !empty( $this->current_page->ID ) ){
342
- if( (int) $page_id === $this->current_page->ID ){
343
$return = true;
344
- } elseif( $this->current_page->post_parent === (int) $page_id ) {
345
$return = true;
346
} else {
347
$ancestors = get_post_ancestors( $this->current_page );
348
- if( !empty( $ancestors ) && in_array( (int) $page_id, $ancestors, true ) ){
349
$return = true;
350
}
351
}
@@ -367,4 +382,4 @@ class Advanced_Sidebar_Menu_List_Pages {
367
return new self( $menu );
368
}
369
370
- }
91
* @param \Advanced_Sidebar_Menu_Menus_Page $menu
92
*/
93
protected function __construct( Advanced_Sidebar_Menu_Menus_Page $menu ) {
94
+ $this->menu = $menu;
95
$this->top_parent_id = $menu->get_top_parent_id();
96
+ $this->current_page = $menu->get_current_post();
97
98
$args = array(
99
'post_type' => $menu->get_post_type(),
130
* @return array
131
*/
132
public function add_list_item_classes( $classes, WP_Post $post ) {
133
+ if ( $post->ID === $this->top_parent_id ) {
134
$children = $this->get_child_pages( $post->ID, true );
135
} else {
136
$children = $this->get_child_pages( $post->ID );
137
}
138
+ if ( ! empty( $children ) ) {
139
$classes[] = 'has_children';
140
}
141
142
//page posts are handled by wp core. This is for custom post types
143
+ if ( 'page' !== $post->post_type ) {
144
$ancestors = get_post_ancestors( $post );
145
+ if ( ! empty( $ancestors ) && in_array( $this->current_page->ID, $ancestors, false ) ) {
146
$classes[] = 'current_page_ancestor';
147
+ } elseif ( $this->current_page->ID === $post->post_parent ) {
148
$classes[] = 'current_page_parent';
149
}
150
}
162
* @return array
163
*/
164
public function get_args( $level = null ) {
165
+ if ( null === $level ) {
166
return $this->args;
167
}
168
$args = $this->args;
169
+ switch ( $level ) {
170
case 'parent':
171
+ $args['include'] = $this->menu->get_top_parent_id();
172
break;
173
case 'display-all':
174
+ $args['child_of'] = $this->menu->get_top_parent_id();
175
+ $args['depth'] = $this->menu->get_levels_to_display();
176
break;
177
}
178
180
}
181
182
183
+ /**
184
+ * Return menu which was passed to this class
185
+ *
186
+ * @return Advanced_Sidebar_Menu_Menus_Page
187
+ */
188
+ public function get_menu() {
189
+ return $this->menu;
190
+ }
191
+
192
+
193
/**
194
* __toString
195
*
212
*/
213
protected function parse_args( $args ) {
214
$defaults = array(
215
+ 'exclude' => '',
216
+ 'echo' => 0,
217
+ 'order' => 'ASC',
218
+ 'orderby' => 'menu_order, post_title',
219
+ 'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
220
+ 'link_before' => '',
221
+ 'link_after' => '',
222
+ 'title_li' => '',
223
+ 'levels' => 100,
224
+ 'item_spacing' => 'preserve',
225
+ 'posts_per_page' => 100,
226
+ 'suppress_filters' => false,
227
);
228
229
$args = wp_parse_args( $args, $defaults );
230
231
+ if ( is_string( $args['exclude'] ) ) {
232
+ $args['exclude'] = explode( ',', $args['exclude'] );
233
}
234
//sanitize, mostly to keep spaces out
235
+ $args['exclude'] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args['exclude'] ) ) );
236
237
return apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
238
248
*/
249
public function list_pages() {
250
$pages = $this->get_child_pages( $this->top_parent_id, true );
251
+ foreach ( $pages as $page ) {
252
$this->output .= walk_page_tree( array( $page ), 1, $this->current_page->ID, $this->args );
253
$this->output .= $this->list_grandchild_pages( $page->ID );
254
$this->output .= '</li>' . "\n";
255
}
256
257
$this->output = apply_filters( 'wp_list_pages', $this->output, $this->args );
258
+ if ( ! $this->args['echo'] ) {
259
return $this->output;
260
}
261
echo $this->output;
272
* @return string
273
*/
274
protected function list_grandchild_pages( $parent_page_id ) {
275
+ if ( $this->level >= (int) $this->args['levels'] ) {
276
return '';
277
}
278
+ if ( ! $this->is_current_page_ancestor( $parent_page_id ) ) {
279
return '';
280
}
281
$pages = $this->get_child_pages( $parent_page_id );
282
+ if ( empty( $pages ) ) {
283
return '';
284
}
285
287
$content = sprintf( '<ul class="grandchild-sidebar-menu level-%s children">', $this->level );
288
289
$inside = '';
290
+ foreach ( $pages as $page ) {
291
$inside .= walk_page_tree( array( $page ), 1, $this->current_page->ID, $this->args );
292
$inside .= $this->list_grandchild_pages( $page->ID );
293
$inside .= "</li>\n";
294
}
295
296
+ if ( '' === $inside ) {
297
return '';
298
}
299
302
303
304
/**
305
* Retrieve the child pages of specific page_id
306
*
307
* @param int $parent_page_id
308
* @param bool $is_first_level
309
*
310
+ * @return WP_Post[]
311
*/
312
public function get_child_pages( $parent_page_id, $is_first_level = false ) {
313
//holds a unique key so Cache can distinguish calls
314
$this->current_children_parent = $parent_page_id;
315
316
+ $cache = Advanced_Sidebar_Menu_Cache::instance();
317
$child_pages = $cache->get_child_pages( $this );
318
+ if ( false === $child_pages ) {
319
+ $args = $this->args;
320
+ $args['post_parent'] = $parent_page_id;
321
+ $args['fields'] = 'ids';
322
+ $child_pages = get_posts( $args );
323
324
$cache->add_child_pages( $this, $child_pages );
325
}
327
$child_pages = array_map( 'get_post', (array) $child_pages );
328
329
//we only filter the first level with this filter for backward pro compatibility
330
+ if ( $is_first_level ) {
331
+ if ( has_filter( 'advanced_sidebar_menu_child_pages' ) ) {
332
+ //@todo uncomment deprecated hook notice once pro 3.0.0 is released
333
+ //_deprecated_hook( 'advanced_sidebar_menu_child_pages', '7.1.0', 'advanced-sidebar-menu/list-pages/first-level-child-pages' );
334
+ $child_pages = apply_filters( 'advanced_sidebar_menu_child_pages', $child_pages, $this->current_page, $this->menu->instance, $this->menu->args, $this->menu );
335
+ }
336
+
337
+ $child_pages = apply_filters( 'advanced-sidebar-menu/list-pages/first-level-child-pages', $child_pages, $this, $this->menu );
338
}
339
340
return $child_pages;
351
*
352
* @return bool
353
*/
354
+ public function is_current_page_ancestor( $page_id ) {
355
$return = false;
356
+ if ( ! empty( $this->current_page->ID ) ) {
357
+ if ( (int) $page_id === $this->current_page->ID ) {
358
$return = true;
359
+ } elseif ( $this->current_page->post_parent === (int) $page_id ) {
360
$return = true;
361
} else {
362
$ancestors = get_post_ancestors( $this->current_page );
363
+ if ( ! empty( $ancestors ) && in_array( (int) $page_id, $ancestors, true ) ) {
364
$return = true;
365
}
366
}
382
return new self( $menu );
383
}
384
385
+ }
src/Menus/Abstract.php CHANGED
@@ -1,24 +1,22 @@
1
<?php
2
3
-
4
/**
5
* Advanced_Sidebar_Menu_Menus_Abstract
6
*
7
* @author Mat Lipe
8
* @since 7.0.0
9
- *
10
*/
11
abstract class Advanced_Sidebar_Menu_Menus_Abstract {
12
- //both widgets
13
- const TITLE = 'title';
14
- const INCLUDE_PARENT = 'include_parent';
15
const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
16
- const ORDER = 'order';
17
- const ORDER_BY = 'order_by';
18
- const USE_PLUGIN_STYLES = 'css';
19
- const EXCLUDE = 'exclude';
20
- const DISPLAY_ALL = 'display_all';
21
- const LEVELS = 'levels';
22
23
/**
24
* args
@@ -65,6 +63,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
65
66
/**
67
* order_by
68
* @deprecated 7.0.0
69
*
70
* @var string
@@ -83,7 +82,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
83
84
public function __construct( array $widget_instance, array $widget_args ) {
85
$this->instance = $widget_instance;
86
- $this->args = $widget_args;
87
}
88
89
abstract public function get_top_parent_id();
@@ -101,6 +100,19 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
101
abstract public function get_menu_depth();
102
103
104
/**
105
* The instance arguments from the current widget
106
*
@@ -110,18 +122,27 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
110
return $this->instance;
111
}
112
113
114
/**
115
* Checks if a widgets checkbox is checked.
116
*
117
* Checks first for a value then verifies the value = checked
118
*
119
- * @param string $name - name of checkbox
120
*
121
* @return bool
122
*/
123
public function checked( $name ) {
124
- return isset( $this->instance[ $name ] ) && $this->instance[ $name ] === 'checked';
125
}
126
127
@@ -141,7 +162,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
141
* @return bool
142
*/
143
public function include_parent() {
144
- if( $this->checked( self::INCLUDE_PARENT ) && !$this->is_excluded( $this->get_top_parent_id() ) ){
145
return true;
146
}
147
@@ -181,14 +202,13 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
181
* Echos the title of the widget to the page
182
*
183
* @todo find somewhere more appropriate for this?
184
- *
185
*/
186
public function title() {
187
- if( !empty( $this->instance[ self::TITLE ] ) ){
188
$title = apply_filters( 'widget_title', $this->instance[ self::TITLE ], $this->args, $this->instance );
189
$title = apply_filters( 'advanced_sidebar_menu_widget_title', esc_html( $title ), $this->args, $this->instance, $this );
190
191
- echo $this->args[ 'before_title' ] . $title . $this->args[ 'after_title' ];
192
}
193
}
194
@@ -230,8 +250,8 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
230
* @return mixed
231
*/
232
public static function _factory( $class, array $widget_instance, array $widget_args ) {
233
- $menu = new $class( $widget_instance, $widget_args );
234
self::$current = $menu;
235
return $menu;
236
}
237
- }
1
<?php
2
3
/**
4
* Advanced_Sidebar_Menu_Menus_Abstract
5
*
6
* @author Mat Lipe
7
* @since 7.0.0
8
*/
9
abstract class Advanced_Sidebar_Menu_Menus_Abstract {
10
+ // keys available in both widgets.
11
+ const TITLE = 'title';
12
+ const INCLUDE_PARENT = 'include_parent';
13
const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
14
+ const ORDER = 'order';
15
+ const ORDER_BY = 'order_by';
16
+ const USE_PLUGIN_STYLES = 'css';
17
+ const EXCLUDE = 'exclude';
18
+ const DISPLAY_ALL = 'display_all';
19
+ const LEVELS = 'levels';
20
21
/**
22
* args
63
64
/**
65
* order_by
66
+ *
67
* @deprecated 7.0.0
68
*
69
* @var string
82
83
public function __construct( array $widget_instance, array $widget_args ) {
84
$this->instance = $widget_instance;
85
+ $this->args = $widget_args;
86
}
87
88
abstract public function get_top_parent_id();
100
abstract public function get_menu_depth();
101
102
103
+ /**
104
+ * Return the type of widget we are working with
105
+ * Used for comparisons like so
106
+ *
107
+ * $menu->get_widget_type() === Menus_Page::WIDGET
108
+ *
109
+ * @return string - 'page', 'category',
110
+ */
111
+ public function get_widget_type() {
112
+ return self::WIDGET;
113
+ }
114
+
115
+
116
/**
117
* The instance arguments from the current widget
118
*
122
return $this->instance;
123
}
124
125
+ /**
126
+ * The widget arguments from the current widget
127
+ *
128
+ * @return array
129
+ */
130
+ public function get_widget_args() {
131
+ return $this->args;
132
+ }
133
+
134
135
/**
136
* Checks if a widgets checkbox is checked.
137
*
138
* Checks first for a value then verifies the value = checked
139
*
140
+ * @param string $name - name of checkbox.
141
*
142
* @return bool
143
*/
144
public function checked( $name ) {
145
+ return isset( $this->instance[ $name ] ) && 'checked' === $this->instance[ $name ];
146
}
147
148
162
* @return bool
163
*/
164
public function include_parent() {
165
+ if ( $this->checked( self::INCLUDE_PARENT ) && ! $this->is_excluded( $this->get_top_parent_id() ) ) {
166
return true;
167
}
168
202
* Echos the title of the widget to the page
203
*
204
* @todo find somewhere more appropriate for this?
205
*/
206
public function title() {
207
+ if ( ! empty( $this->instance[ self::TITLE ] ) ) {
208
$title = apply_filters( 'widget_title', $this->instance[ self::TITLE ], $this->args, $this->instance );
209
$title = apply_filters( 'advanced_sidebar_menu_widget_title', esc_html( $title ), $this->args, $this->instance, $this );
210
211
+ echo $this->args['before_title'] . $title . $this->args['after_title'];
212
}
213
}
214
250
* @return mixed
251
*/
252
public static function _factory( $class, array $widget_instance, array $widget_args ) {
253
+ $menu = new $class( $widget_instance, $widget_args );
254
self::$current = $menu;
255
return $menu;
256
}
257
+ }
src/Menus/Category.php CHANGED
@@ -190,6 +190,9 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
190
191
192
public function get_top_parent_id() {
193
return $this->current_term->term_id;
194
}
195
190
191
192
public function get_top_parent_id() {
193
+ if( empty( $this->current_term->term_id ) ){
194
+ return null;
195
+ }
196
return $this->current_term->term_id;
197
}
198
src/Widget/Category.php CHANGED
@@ -76,7 +76,7 @@ class Advanced_Sidebar_Menu_Widget_Category extends WP_Widget {
76
</p>
77
78
79
- <p> <?php _e( 'Display menu where there is only the parent category', 'advanced-sidebar-menu' ); ?>
80
<input id="<?php echo $this->get_field_name( self::INCLUDE_CHILDLESS_PARENT ); ?>"
81
name="<?php echo $this->get_field_name( self::INCLUDE_CHILDLESS_PARENT ); ?>" type="checkbox" value="checked"
82
<?php echo $instance[ self::INCLUDE_CHILDLESS_PARENT ]; ?>/>
@@ -210,4 +210,4 @@ class Advanced_Sidebar_Menu_Widget_Category extends WP_Widget {
210
$asm->render();
211
}
212
213
- }
76
</p>
77
78
79
+ <p> <?php _e( 'Display menu when there is only the parent category', 'advanced-sidebar-menu' ); ?>
80
<input id="<?php echo $this->get_field_name( self::INCLUDE_CHILDLESS_PARENT ); ?>"
81
name="<?php echo $this->get_field_name( self::INCLUDE_CHILDLESS_PARENT ); ?>" type="checkbox" value="checked"
82
<?php echo $instance[ self::INCLUDE_CHILDLESS_PARENT ]; ?>/>
210
$asm->render();
211
}
212
213
+ }