Advanced Sidebar Menu - Version 7.6.2

Version Description

Download this release

Release Info

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

Code changes from version 7.6.1 to 7.6.2

7.6.1/advanced-sidebar-menu.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.6.2
8
+ * Author URI: https://matlipe.com
9
+ * Text Domain: advanced-sidebar-menu
10
+ *
11
+ * @package advanced-sidebar-menu
12
+ */
13
+
14
+ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
15
+ return;
16
+ }
17
+
18
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.6.2' );
19
+ define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
+
21
+ if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
22
+ /**
23
+ * Load the plugin
24
+ *
25
+ * @return void
26
+ */
27
+ function advanced_sidebar_menu_load() {
28
+ Advanced_Sidebar_Menu_Core::init();
29
+ Advanced_Sidebar_Menu_Cache::init();
30
+ Advanced_Sidebar_Menu_Debug::init();
31
+ }
32
+
33
+ add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
34
+ }
35
+
36
+ /**
37
+ * Autoload classes from PSR4 src directory
38
+ * Mirrored after Composer dump-autoload for performance
39
+ *
40
+ * @param string $class - class being loaded.
41
+ *
42
+ * @return void
43
+ */
44
+ function advanced_sidebar_menu_autoload( $class ) {
45
+ $classes = array(
46
+ // widgets.
47
+ 'Advanced_Sidebar_Menu__Widget__Widget' => 'Widget/Widget.php',
48
+ 'Advanced_Sidebar_Menu_Widget_Page' => 'Widget/Page.php',
49
+ 'Advanced_Sidebar_Menu_Widget_Category' => 'Widget/Category.php',
50
+
51
+ // core.
52
+ 'Advanced_Sidebar_Menu_Cache' => 'Cache.php',
53
+ 'Advanced_Sidebar_Menu_Core' => 'Core.php',
54
+ 'Advanced_Sidebar_Menu_Debug' => 'Debug.php',
55
+ 'Advanced_Sidebar_Menu_List_Pages' => 'List_Pages.php',
56
+ 'Advanced_Sidebar_Menu_Menu' => 'Menu.php',
57
+ 'Advanced_Sidebar_Menu_Page_Walker' => 'Page_Walker.php',
58
+
59
+ // menus.
60
+ 'Advanced_Sidebar_Menu_Menus_Category' => 'Menus/Category.php',
61
+ 'Advanced_Sidebar_Menu_Menus_Abstract' => 'Menus/Abstract.php',
62
+ 'Advanced_Sidebar_Menu_Menus_Page' => 'Menus/Page.php',
63
+ );
64
+ if ( isset( $classes[ $class ] ) ) {
65
+ require dirname( __FILE__ ) . '/src/' . $classes[ $class ];
66
+ }
67
+ }
68
+
69
+ spl_autoload_register( 'advanced_sidebar_menu_autoload' );
70
+
71
+
72
+ add_action( 'plugins_loaded', 'advanced_sidebar_menu_translate' );
73
+ /**
74
+ * Load translations
75
+ *
76
+ * @return void
77
+ */
78
+ function advanced_sidebar_menu_translate() {
79
+ load_plugin_textdomain( 'advanced-sidebar-menu', false, 'advanced-sidebar-menu/languages' );
80
+ }
81
+
82
+ add_action( 'admin_print_scripts', 'advanced_sidebar_menu_script' );
83
+ // UGH! Beaver Builder hack.
84
+ if ( isset( $_GET['fl_builder'] ) ) {
85
+ add_action( 'wp_enqueue_scripts', 'advanced_sidebar_menu_script' );
86
+ }
87
+ /**
88
+ * Add js and css to the admin and in specific cases the front-end.
89
+ *
90
+ * @return void
91
+ */
92
+ function advanced_sidebar_menu_script() {
93
+ wp_enqueue_script(
94
+ apply_filters( 'asm_script', 'advanced-sidebar-menu-script' ),
95
+ plugins_url( 'resources/js/advanced-sidebar-menu.js', __FILE__ ),
96
+ array( 'jquery' ),
97
+ ADVANCED_SIDEBAR_BASIC_VERSION,
98
+ false
99
+ );
100
+
101
+ wp_enqueue_style(
102
+ apply_filters( 'asm_style', 'advanced-sidebar-menu-style' ),
103
+ plugins_url( 'resources/css/advanced-sidebar-menu.css', __FILE__ ),
104
+ array(),
105
+ ADVANCED_SIDEBAR_BASIC_VERSION
106
+ );
107
+ }
108
+
109
+ add_action( 'advanced-sidebar-menu/widget/category/after-form', 'advanced_sidebar_menu_init_widget_js', 1000 );
110
+ add_action( 'advanced-sidebar-menu/widget/page/after-form', 'advanced_sidebar_menu_init_widget_js', 1000 );
111
+ add_action( 'advanced-sidebar-menu/widget/navigation-menu/after-form', 'advanced_sidebar_menu_init_widget_js', 1000 );
112
+
113
+ /**
114
+ * Trigger any JS needed by the widgets.
115
+ * This is outputted into the markup for each widget so it may be
116
+ * trigger whether the widget is loaded on the front-end by
117
+ * page builders or the backend by standard WordPress or
118
+ * really anywhere.
119
+ *
120
+ * @return void
121
+ */
122
+ function advanced_sidebar_menu_init_widget_js() {
123
+ if ( WP_DEBUG ) {
124
+ ?>
125
+ <!-- <?php echo __FILE__; ?>-->
126
+ <?php
127
+ }
128
+ ?>
129
+ <script>
130
+ if (typeof (advanced_sidebar_menu) !== 'undefined') {
131
+ advanced_sidebar_menu.init()
132
+ }
133
+ </script>
134
+ <?php
135
+ }
136
+
137
+
138
+ add_action( 'advanced-sidebar-menu/widget/category/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
139
+ add_action( 'advanced-sidebar-menu/widget/page/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
140
+
141
+
142
+ /**
143
+ * Notify widget users about the PRO options
144
+ *
145
+ * @param array $instance - widget instance.
146
+ * @param WP_Widget $widget - widget class.
147
+ *
148
+ * @return void
149
+ */
150
+ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widget ) {
151
+ if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
152
+ return;
153
+ }
154
+ ?>
155
+ <div class="advanced-sidebar-menu-column-box">
156
+ <h3><?php esc_html_e( 'Checkout Advanced Sidebar Menu Pro!', 'advanced-sidebar-menu' ); ?></h3>
157
+ <p>
158
+ <strong>
159
+ <?php
160
+ /* translators: {<a>}{</a>} links to https://matlipe.com/product/advanced-sidebar-menu-pro/ */
161
+ printf( esc_html_x( 'Upgrade to %1$sAdvanced Sidebar Menu Pro%2$s for these features and so much more!', '{<a>}{</a>}', 'advanced-sidebar-menu' ), '<a target="blank" href="https://matlipe.com/product/advanced-sidebar-menu-pro/">', '</a>' );
162
+ ?>
163
+ </strong>
164
+ <ol style="list-style: disc">
165
+ <li><?php esc_html_e( 'Priority support, including access to Members Only Support Area.', 'advanced-sidebar-menu' ); ?></li>
166
+ <li><?php esc_html_e( 'Accordion menu support.', 'advanced-sidebar-menu' ); ?></li>
167
+ <li><?php esc_html_e( 'Click and drag menu styling including bullets, colors, sizes, block styles, borders, and border colors.', 'advanced-sidebar-menu' ); ?></li>
168
+ <?php
169
+ // page widget options.
170
+ if ( 'advanced_sidebar_menu' === $widget->id_base ) {
171
+ ?>
172
+ <li><?php esc_html_e( "Ability to customize each page's link text.", 'advanced-sidebar-menu' ); ?></li>
173
+ <li><?php esc_html_e( 'Ability to exclude a page from all menus using a simple checkbox.', 'advanced-sidebar-menu' ); ?></li>
174
+ <li><?php esc_html_e( 'Number of levels of pages to show when always displayed child pages is not checked.', 'advanced-sidebar-menu' ); ?></li>
175
+ <li><?php esc_html_e( 'Ability to select and display custom post types.', 'advanced-sidebar-menu' ); ?></li>
176
+ <li><?php esc_html_e( 'Option to display the current page’s parents, grandparents, and children only, as well as siblings options.', 'advanced-sidebar-menu' ); ?></li>
177
+ <?php
178
+ // category widget options.
179
+ } else {
180
+ ?>
181
+ <li><?php esc_html_e( 'Link ordering for the category widget.', 'advanced-sidebar-menu' ); ?></li>
182
+ <li><?php esc_html_e( 'Ability to select and display custom taxonomies.', 'advanced-sidebar-menu' ); ?></li>
183
+ <li><?php esc_html_e( 'Ability to display assigned posts or custom post types under categories.', 'advanced-sidebar-menu' ); ?></li>
184
+ <?php
185
+ }
186
+ ?>
187
+ <li><?php esc_html_e( 'Ability to display the widgets everywhere the sidebar displays.', 'advanced-sidebar-menu' ); ?></li>
188
+ <li><?php esc_html_e( 'Support for custom navigation menus from Appearance -> Menus.', 'advanced-sidebar-menu' ); ?></li>
189
+ </ol>
190
+ <p>
191
+ </div>
192
+ <?php
193
+ }
7.6.1/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": "MIT",
6
+ "authors": [
7
+ {
8
+ "name": "lipemat",
9
+ "email": "mat@matlipe.com"
10
+ }
11
+ ],
12
+ "minimum-stability": "dev",
13
+ "require": {}
14
+ }
7.6.1/languages/advanced-sidebar-menu-de_DE.mo ADDED
Binary file
7.6.1/languages/advanced-sidebar-menu-de_DE.po ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Advanced Sidebar Menu\n"
4
+ "POT-Creation-Date: 2019-03-05 12:29-0500\n"
5
+ "PO-Revision-Date: 2019-03-05 12:30-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.2.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:156
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:161
30
+ #, php-format
31
+ msgctxt "{<a>}{</a>}"
32
+ msgid ""
33
+ "Upgrade to %1$sAdvanced Sidebar Menu Pro%2$s for these features and so much "
34
+ "more!"
35
+ msgstr ""
36
+ "Upgrade auf %1$sAdvanced Sidebar Menu Pro%2$s für diese Funktionen und "
37
+ "vieles mehr!"
38
+
39
+ #: advanced-sidebar-menu.php:165
40
+ msgid "Priority support, including access to Members Only Support Area."
41
+ msgstr ""
42
+ "Prioritätsunterstützung, einschließlich Zugang zum Supportbereich für "
43
+ "Mitglieder."
44
+
45
+ #: advanced-sidebar-menu.php:166
46
+ msgid "Accordion menu support."
47
+ msgstr "Akkordeon-Menü-Unterstützung."
48
+
49
+ #: advanced-sidebar-menu.php:167
50
+ msgid ""
51
+ "Click and drag menu styling including bullets, colors, sizes, block styles, "
52
+ "borders, and border colors."
53
+ msgstr ""
54
+ "Klicken und ziehen Sie das Menü-Styling, einschließlich Aufzählungszeichen, "
55
+ "Farben, Größen, Blockstile, Rahmen und Rahmenfarben."
56
+
57
+ #: advanced-sidebar-menu.php:172
58
+ msgid "Ability to customize each page's link text."
59
+ msgstr "Möglichkeit, den Linktext jeder Seite anzupassen."
60
+
61
+ #: advanced-sidebar-menu.php:173
62
+ msgid "Ability to exclude a page from all menus using a simple checkbox."
63
+ msgstr ""
64
+ "Möglichkeit, eine Seite mit einem einfachen Kontrollkästchen aus allen Menüs "
65
+ "auszuschließen."
66
+
67
+ #: advanced-sidebar-menu.php:174
68
+ msgid ""
69
+ "Number of levels of pages to show when always displayed child pages is not "
70
+ "checked."
71
+ msgstr ""
72
+ "Anzahl der Seitenebenen, die angezeigt werden sollen, wenn immer "
73
+ "untergeordnete Seiten angezeigt werden, ist nicht aktiviert."
74
+
75
+ #: advanced-sidebar-menu.php:175
76
+ msgid "Ability to select and display custom post types."
77
+ msgstr ""
78
+ "Möglichkeit, benutzerdefinierte Beitragstypen auszuwählen und anzuzeigen."
79
+
80
+ #: advanced-sidebar-menu.php:176
81
+ msgid ""
82
+ "Option to display the current page’s parents, grandparents, and children "
83
+ "only, as well as siblings options."
84
+ msgstr ""
85
+ "Option, um die Eltern, Großeltern und Kinder der aktuellen Seite anzuzeigen, "
86
+ "sowie Geschwisteroptionen."
87
+
88
+ #: advanced-sidebar-menu.php:181
89
+ msgid "Link ordering for the category widget."
90
+ msgstr "Verknüpfungsreihenfolge für das Kategorie-Widget."
91
+
92
+ #: advanced-sidebar-menu.php:182
93
+ msgid "Ability to select and display custom taxonomies."
94
+ msgstr "Möglichkeit, benutzerdefinierte Taxonomien auszuwählen und anzuzeigen."
95
+
96
+ #: advanced-sidebar-menu.php:183
97
+ msgid ""
98
+ "Ability to display assigned posts or custom post types under categories."
99
+ msgstr ""
100
+ "Fähigkeit, zugewiesene Beiträge oder benutzerdefinierte Posttypen unter "
101
+ "Kategorien anzuzeigen."
102
+
103
+ #: advanced-sidebar-menu.php:187
104
+ msgid "Ability to display the widgets everywhere the sidebar displays."
105
+ msgstr "Die Fähigkeit, die Widgets überall in der Sidebar-Anzeige anzuzeigen."
106
+
107
+ #: advanced-sidebar-menu.php:188
108
+ msgid "Support for custom navigation menus from Appearance -> Menus."
109
+ msgstr ""
110
+ "Unterstützung für kundenspezifische Navigationsmenüs von Appearance-> Menü."
111
+
112
+ #: src/Widget/Category.php:44
113
+ msgid ""
114
+ "Creates a menu of all the categories using the child/parent relationship"
115
+ msgstr ""
116
+ "Erstellt ein Menü aller Kategorien, die unter Zugrundelegung der Eltern-Kind-"
117
+ "Beziehung"
118
+
119
+ #: src/Widget/Category.php:48
120
+ msgid "Advanced Sidebar Categories Menu"
121
+ msgstr "Advanced Sidebar Kategorien-Menü"
122
+
123
+ #: src/Widget/Category.php:83
124
+ msgid "Display highest level parent category"
125
+ msgstr "Anzeige der übergeordneten Kategorie der höchsten Ebene"
126
+
127
+ #: src/Widget/Category.php:89
128
+ msgid "Display menu when there is only the parent category"
129
+ msgstr "Menü \"Anzeige\" wird nur die übergeordnete Kategorie"
130
+
131
+ #: src/Widget/Category.php:95
132
+ msgid "Always display child categories"
133
+ msgstr "Immer untergeordnete Kategorien anzeigen"
134
+
135
+ #: src/Widget/Category.php:101
136
+ msgid "Levels of child categories to display"
137
+ msgstr "Niveau der Kinderkategorien zu zeigen"
138
+
139
+ #: src/Widget/Category.php:138 src/Widget/Page.php:150
140
+ msgid "Use this plugin's default styling"
141
+ msgstr "Verwenden Sie das Standardstyling dieses Plugins"
142
+
143
+ #: src/Widget/Category.php:161
144
+ msgid "Display categories on single posts"
145
+ msgstr "Kategorien auf einzelne Beiträge anzeigen"
146
+
147
+ #: src/Widget/Category.php:167
148
+ msgid "Display each single post's category"
149
+ msgstr "Zeigen Sie die einzelnen Kategorien der einzelnen Posts an"
150
+
151
+ #: src/Widget/Category.php:173
152
+ msgid "In a new widget"
153
+ msgstr "In einem neuen Widget"
154
+
155
+ #: src/Widget/Category.php:176
156
+ msgid "In another list in the same widget"
157
+ msgstr "In einer anderen Liste im selben Widget"
158
+
159
+ #: src/Widget/Category.php:200
160
+ msgid "Categories to exclude (ids), comma separated"
161
+ msgstr "Kategorien ausschließen (Ids), durch Kommata getrennt"
162
+
163
+ #: src/Widget/Category.php:233 src/Widget/Page.php:242
164
+ msgid "Title"
165
+ msgstr "Titel"
166
+
167
+ #: src/Widget/Page.php:39
168
+ msgid "Creates a menu of all the pages using the child/parent relationship"
169
+ msgstr ""
170
+ "Erstellt ein Menü mit allen Seiten, die die Child / Parent-Beziehung "
171
+ "verwenden"
172
+
173
+ #: src/Widget/Page.php:45
174
+ msgid "Advanced Sidebar Pages Menu"
175
+ msgstr "Advanced Sidebar Seitenmenü"
176
+
177
+ #: src/Widget/Page.php:82
178
+ msgid "Display highest level parent page"
179
+ msgstr "Zeigt die oberste Seite der obersten Ebene an"
180
+
181
+ #: src/Widget/Page.php:90
182
+ msgid "Display menu when there is only the parent page"
183
+ msgstr "Menü \"Anzeige\" wird nur die übergeordnete Seite"
184
+
185
+ #: src/Widget/Page.php:97
186
+ msgid "Always display child pages"
187
+ msgstr "Immer untergeordnete Seiten anzeigen"
188
+
189
+ #: src/Widget/Page.php:110
190
+ msgid "Maximum level of child pages to display"
191
+ msgstr "Maximale Höhe der zu zeigestellenden Kinderseiten"
192
+
193
+ #: src/Widget/Page.php:114
194
+ msgid " - All - "
195
+ msgstr " Alle "
196
+
197
+ #: src/Widget/Page.php:171
198
+ msgid "Order by"
199
+ msgstr "Sortieren nach"
200
+
201
+ #: src/Widget/Page.php:210
202
+ msgid "Pages to exclude (ids), comma separated"
203
+ msgstr "Auszuschließende Seiten (IDs), durch Kommas getrennt"
204
+
205
+ #. Plugin Name of the plugin/theme
206
+ msgid "Advanced Sidebar Menu"
207
+ msgstr "Advanced Sidebar Menu"
208
+
209
+ #. Plugin URI of the plugin/theme
210
+ msgid "https://matlipe.com/advanced-sidebar-menu/"
211
+ msgstr "https://matlipe.com/advanced-sidebar-menu/"
212
+
213
+ #. Description of the plugin/theme
214
+ msgid ""
215
+ "Creates dynamic menus based on parent/child relationship of your pages or "
216
+ "categories."
217
+ msgstr ""
218
+ "Dynamische Menüs basierend auf Parent/Child-Beziehung Ihrer Seiten oder "
219
+ "Kategorien erstellt."
220
+
221
+ #. Author of the plugin/theme
222
+ msgid "Mat Lipe"
223
+ msgstr "Mat Lipe"
224
+
225
+ #. Author URI of the plugin/theme
226
+ msgid "https://matlipe.com"
227
+ msgstr "https://matlipe.com"
228
+
229
+ #~ msgid "Use this Plugin's Styling"
230
+ #~ msgstr "Benutze das Plugin Styling"
7.6.1/languages/advanced-sidebar-menu.pot ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 2019-03-05 12:29-0500\n"
7
+ "PO-Revision-Date: 2019-03-05 12:29-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.2.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:156
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:161
30
+ #, php-format
31
+ msgctxt "{<a>}{</a>}"
32
+ msgid ""
33
+ "Upgrade to %1$sAdvanced Sidebar Menu Pro%2$s for these features and so much "
34
+ "more!"
35
+ msgstr ""
36
+
37
+ #: advanced-sidebar-menu.php:165
38
+ msgid "Priority support, including access to Members Only Support Area."
39
+ msgstr ""
40
+
41
+ #: advanced-sidebar-menu.php:166
42
+ msgid "Accordion menu support."
43
+ msgstr ""
44
+
45
+ #: advanced-sidebar-menu.php:167
46
+ msgid ""
47
+ "Click and drag menu styling including bullets, colors, sizes, block styles, "
48
+ "borders, and border colors."
49
+ msgstr ""
50
+
51
+ #: advanced-sidebar-menu.php:172
52
+ msgid "Ability to customize each page's link text."
53
+ msgstr ""
54
+
55
+ #: advanced-sidebar-menu.php:173
56
+ msgid "Ability to exclude a page from all menus using a simple checkbox."
57
+ msgstr ""
58
+
59
+ #: advanced-sidebar-menu.php:174
60
+ msgid ""
61
+ "Number of levels of pages to show when always displayed child pages is not "
62
+ "checked."
63
+ msgstr ""
64
+
65
+ #: advanced-sidebar-menu.php:175
66
+ msgid "Ability to select and display custom post types."
67
+ msgstr ""
68
+
69
+ #: advanced-sidebar-menu.php:176
70
+ msgid ""
71
+ "Option to display the current page’s parents, grandparents, and children "
72
+ "only, as well as siblings options."
73
+ msgstr ""
74
+
75
+ #: advanced-sidebar-menu.php:181
76
+ msgid "Link ordering for the category widget."
77
+ msgstr ""
78
+
79
+ #: advanced-sidebar-menu.php:182
80
+ msgid "Ability to select and display custom taxonomies."
81
+ msgstr ""
82
+
83
+ #: advanced-sidebar-menu.php:183
84
+ msgid ""
85
+ "Ability to display assigned posts or custom post types under categories."
86
+ msgstr ""
87
+
88
+ #: advanced-sidebar-menu.php:187
89
+ msgid "Ability to display the widgets everywhere the sidebar displays."
90
+ msgstr ""
91
+
92
+ #: advanced-sidebar-menu.php:188
93
+ msgid "Support for custom navigation menus from Appearance -> Menus."
94
+ msgstr ""
95
+
96
+ #: src/Widget/Category.php:44
97
+ msgid ""
98
+ "Creates a menu of all the categories using the child/parent relationship"
99
+ msgstr ""
100
+
101
+ #: src/Widget/Category.php:48
102
+ msgid "Advanced Sidebar Categories Menu"
103
+ msgstr ""
104
+
105
+ #: src/Widget/Category.php:83
106
+ msgid "Display highest level parent category"
107
+ msgstr ""
108
+
109
+ #: src/Widget/Category.php:89
110
+ msgid "Display menu when there is only the parent category"
111
+ msgstr ""
112
+
113
+ #: src/Widget/Category.php:95
114
+ msgid "Always display child categories"
115
+ msgstr ""
116
+
117
+ #: src/Widget/Category.php:101
118
+ msgid "Levels of child categories to display"
119
+ msgstr ""
120
+
121
+ #: src/Widget/Category.php:138 src/Widget/Page.php:150
122
+ msgid "Use this plugin's default styling"
123
+ msgstr ""
124
+
125
+ #: src/Widget/Category.php:161
126
+ msgid "Display categories on single posts"
127
+ msgstr ""
128
+
129
+ #: src/Widget/Category.php:167
130
+ msgid "Display each single post's category"
131
+ msgstr ""
132
+
133
+ #: src/Widget/Category.php:173
134
+ msgid "In a new widget"
135
+ msgstr ""
136
+
137
+ #: src/Widget/Category.php:176
138
+ msgid "In another list in the same widget"
139
+ msgstr ""
140
+
141
+ #: src/Widget/Category.php:200
142
+ msgid "Categories to exclude (ids), comma separated"
143
+ msgstr ""
144
+
145
+ #: src/Widget/Category.php:233 src/Widget/Page.php:242
146
+ msgid "Title"
147
+ msgstr ""
148
+
149
+ #: src/Widget/Page.php:39
150
+ msgid "Creates a menu of all the pages using the child/parent relationship"
151
+ msgstr ""
152
+
153
+ #: src/Widget/Page.php:45
154
+ msgid "Advanced Sidebar Pages Menu"
155
+ msgstr ""
156
+
157
+ #: src/Widget/Page.php:82
158
+ msgid "Display highest level parent page"
159
+ msgstr ""
160
+
161
+ #: src/Widget/Page.php:90
162
+ msgid "Display menu when there is only the parent page"
163
+ msgstr ""
164
+
165
+ #: src/Widget/Page.php:97
166
+ msgid "Always display child pages"
167
+ msgstr ""
168
+
169
+ #: src/Widget/Page.php:110
170
+ msgid "Maximum level of child pages to display"
171
+ msgstr ""
172
+
173
+ #: src/Widget/Page.php:114
174
+ msgid " - All - "
175
+ msgstr ""
176
+
177
+ #: src/Widget/Page.php:171
178
+ msgid "Order by"
179
+ msgstr ""
180
+
181
+ #: src/Widget/Page.php:210
182
+ msgid "Pages to exclude (ids), comma separated"
183
+ msgstr ""
184
+
185
+ #. Plugin Name of the plugin/theme
186
+ msgid "Advanced Sidebar Menu"
187
+ msgstr ""
188
+
189
+ #. Plugin URI of the plugin/theme
190
+ msgid "https://matlipe.com/advanced-sidebar-menu/"
191
+ msgstr ""
192
+
193
+ #. Description of the plugin/theme
194
+ msgid ""
195
+ "Creates dynamic menus based on parent/child relationship of your pages or "
196
+ "categories."
197
+ msgstr ""
198
+
199
+ #. Author of the plugin/theme
200
+ msgid "Mat Lipe"
201
+ msgstr ""
202
+
203
+ #. Author URI of the plugin/theme
204
+ msgid "https://matlipe.com"
205
+ msgstr ""
7.6.1/readme.txt ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Advanced Sidebar Menu ===
2
+
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.8.0
7
+ Tested up to: 5.2.3
8
+ Requires PHP: 5.6.0
9
+ Stable tag: 7.6.2
10
+
11
+ == Description ==
12
+
13
+ Uses the parent/child relationship of your pages or categories to generate menus based on the current section of your site. Assign a page or category to a parent and this will do the rest for you.
14
+
15
+ Keeps the menu clean and usable. Only related items display so you don't have to worry about keeping a custom menu up to date or displaying links to items that don't belong.
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 link text, excluding of pages, category ordering, accordions, custom post types, custom taxonomies, and so much more!</strong>
18
+
19
+ <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 3.9.0</a> is now available with support to exclude and change titles of navigation menu items using each page's settings!</blockquote>
20
+
21
+ <h4>Features</h4>
22
+ * Page and Category widgets.
23
+ * Option to display or not display the highest level parent page or category.
24
+ * Option to display the menu when there is only the highest level parent.
25
+ * Ability to order pages by (date, title, page order).
26
+ * Exclude pages or categories by entering a comma separated list of ids.
27
+ * Option to always display child pages or categories.
28
+ * Option to select the levels of pages or categories to display when always display child is used.
29
+ * Option to display or not display categories on single posts.
30
+ * Ability to display each single post's category in a new widget or in same list.
31
+
32
+ <h4>Page Widget Options</h4>
33
+ * Add a title to the widget
34
+ * Display highest level parent page
35
+ * Display menu when there is only the parent page
36
+ * Order pages by (date, title, page order)
37
+ * Use built in styling (very plain styling, for more advanced styling <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Go Pro!</a>)
38
+ * Exclude pages
39
+ * Always display child Pages
40
+ * Number of levels of child pages to display when always display child pages is checked
41
+
42
+ <h4>Category Widget Options</h4>
43
+ * Add a title to the widget
44
+ * Display highest level parent category
45
+ * Display menu when there is only the parent category
46
+ * Use built in styling (very plain styling, for more advanced styling <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Go Pro!</a>)
47
+ * Display categories on single posts
48
+ * Display each single post's category in a new widget or in same list
49
+ * Exclude categories
50
+ * Always display child categories
51
+ * Levels of Categories to display when always display child categories is checked
52
+
53
+ <h4>Pro Features</h4>
54
+ * Priority support.
55
+ * Ability to customize each page's link text.
56
+ * Click and drag styling for page, category, and navigation menu widgets.
57
+ * Styling options for links including color, background color, size, and font weight.
58
+ * Styling options for different levels of links.
59
+ * Styling options for the current page or category.
60
+ * Styling options for the parent of the current page or category.
61
+ * Block styling options including borders and border colors.
62
+ * Bullet style selection from 7 styles or select none to have no bullets.
63
+ * Accordion menu support for pages, categories, and navigation menus.
64
+ * Accordion icon style and color selection.
65
+ * Accordion option to keep all sections closed until clicked.
66
+ * Accordion option to include highest level parent in accordion.
67
+ * Ability to exclude a page from all menus using a simple checkbox.
68
+ * Link ordering for the category widget.
69
+ * Number of levels of pages to show when always displayed child pages is not checked.
70
+ * Ability to select and display custom post types.
71
+ * Ability to select and display custom taxonomies.
72
+ * Optionally display the current page's parents, grandparents, and children only.
73
+ * Optionally display child page siblings when on a child page. With our without grandchildren available. .
74
+ * Ability to display the widgets everywhere the sidebar displays.
75
+ * Ability to select the parent page/category when using the display widget everywhere option.
76
+ * Ability to display assigned posts or custom post types under categories. **NEW**
77
+ * Ability to select which levels of categories assigned posts should display under. **NEW**
78
+ * Ability to limit the number of posts or custom post types to display under categories.
79
+ * Support for custom navigation menus from Appearance -> Menus.
80
+ * Ability to display the current Navigation Menu's items parents and children only.
81
+ * Optionally display the top level Navigation Menu's items when there are no child items or not viewing a menu item. **NEW**
82
+ * Access to members only support area.
83
+
84
+ <h4>Currently ships with the following languages</h4>
85
+ * English (US)
86
+ * German (de_DE)
87
+
88
+ <h4>Developers</h4>
89
+ Developer docs may be found <a target="_blank" href="https://matlipe.com/advanced-sidebar-menu/developer-docs/">here</a>.
90
+
91
+ <h4>Contribute</h4>
92
+ Send pull requests via the <a target="_blank" href="https://github.com/lipemat/advanced-sidebar-menu">GitHub Repo</a>
93
+
94
+
95
+ == Installation ==
96
+
97
+ Use the standard WordPress plugins search and install feature.
98
+
99
+ Manual Installation
100
+
101
+ 1. Upload the `advanced-sidebar-menu` folder to the `/wp-content/plugins/` directory
102
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
103
+ 1. Drag the "Advanced Sidebar Pages Menu" widget or the "Advanced Sidebar Categories Menu" widget into a sidebar.
104
+
105
+
106
+ == Screenshots ==
107
+
108
+ 1. Page widget options
109
+ 2. Category widget options
110
+ 3. Example of a page menu using the 2017 theme and default styles
111
+ 3. Example of a category menu ordered by title using the 2017 theme and default styles
112
+
113
+
114
+ == Frequently Asked Questions ==
115
+
116
+ Developer docs may be found here:
117
+ <a href="https://matlipe.com/advanced-sidebar-menu/developer-docs/" target="_blank">https://matlipe.com/advanced-sidebar-menu/developer-docs/</a>
118
+
119
+
120
+ = How do I change the styling of the current page? =
121
+
122
+ You may add css to your theme's style.css to change the way the menu looks
123
+
124
+ For Instance This would remove the dot and change the color
125
+ <code>
126
+ .advanced-sidebar-menu li.current_page_item a {
127
+ color: black;
128
+ }
129
+
130
+ .advanced-sidebar-menu li.current_page_item {
131
+ list-style-type: none !important;
132
+ }
133
+ </code>
134
+
135
+ To style your menu without using any code <a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Go Pro!</a>
136
+
137
+ = How do you get the categories to display on single post pages? =
138
+
139
+ There is a checkbox in the widget options that will display the same structure for the categories the post is in.
140
+
141
+ = How do you edit the output or built in css? =
142
+
143
+ Create a folder in your child theme named "advanced-sidebar-menu" copy any of the files from the "views" folder into
144
+ the folder you just created. You may edit the files to change the output or css. 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.
145
+
146
+
147
+ = Does the menu change for each page you are on? =
148
+
149
+ Yes. Based on whatever page, post, or category you are on, the menu will change automatically to display the current parents and children.
150
+
151
+
152
+ == Changelog ==
153
+ = 7.6.0 =
154
+ * Elementor support for multiple widgets of the same type on the same page.
155
+ * Automatically increment widget ids under any cases where they would duplicate.
156
+ * Bump required WordPress Core version to 4.8.0.
157
+
158
+ = 7.5.0 =
159
+ * Convert "Always display child pages" to use our List_Pages structure and support all widget options.
160
+ * Bump required PHP version to 5.4.4.
161
+
162
+ = 7.4.0 =
163
+ * Added support for Beaver Builder
164
+
165
+ = 7.3.0 =
166
+ * Greatly improve category widget performance
167
+
168
+ = 7.2.0 =
169
+ * New improved widget structure
170
+
171
+ = 7.1.0 =
172
+ * Support Pro Version 3.0.0
173
+ * Add German translations
174
+ * Begin converting code formatting to strict WordPress standards
175
+
176
+ = 7.0.0 =
177
+ * Restructure the codebase to a more modern PSR4 structure
178
+ * Improve cache handling
179
+ * Improve verbiage in admin
180
+ * Implement new actions and filters
181
+ * Rebuild templates for improved stability and future changes
182
+ * Improve performance
183
+ * Kill conflicting backward compatibility with version 5
184
+ * Open up more extendability possibilities
185
+
186
+ = 6.4.0 =
187
+ * Code improvements
188
+ * Performance improvements via shared child retrieval
189
+
190
+ = 6.3.0
191
+ * Improve category class handling for pro version accordion support
192
+
193
+ = 6.2.0 =
194
+ * Improve sorting of categories
195
+
196
+ = 6.1.0 =
197
+ * Improve page list view
198
+ * Add advanced_sidebar_menu_list_pages_args filter
199
+
200
+ = 6.0.0 =
201
+ * Remove legacy template support
202
+ * Restructure plugin
203
+ * Introduce 'advanced_sidebar_menu_template_part' filter
204
+
205
+
206
+ = 5.1.0 =
207
+ * Convert query over to get_posts() to allow for more extendability
208
+ * Implement object caching to improve performance for environments using external object caches
209
+ * Begin modernizing the naming conventions of methods and improving PHPdocs
210
+
211
+ = 5.0.0 =
212
+ * Greatly improved performance
213
+ * Improved code structure
214
+
215
+ = 4.7.0 =
216
+ * Added Internationalization (I18n) support
217
+
218
+ = 4.6.0 =
219
+ * Added support for Pro Version
220
+
221
+ = 4.5.0 =
222
+ * Improved filter structure to allow for add-ons to work more effectively
223
+
224
+
225
+ = 4.4.0 =
226
+ * Added a has_children class to page links with hidden children
227
+
228
+ = 4.3.0 =
229
+ * Added many filters into the category widget for things like taxonomies, parent category, display on override, order by, and much more. There is no UI support for any of this yet, but developers may now tap into this.
230
+
231
+ = 4.2.0 =
232
+ * Added Order By Selection in Page Widget
233
+
234
+ = 4.0.0 =
235
+ * Added support for an unlimited number of page levels
236
+ * Change structure slightly for future enhancements
237
+ * Added Legacy Mode for backwards compatibility
238
+
239
+
240
+ == Upgrade Notice ==
241
+ = 7.5.0 =
242
+ Update to support PRO version 3.6.0
243
+
244
+ = 7.4.7 =
245
+ Update to support PRO version 3.5.0
246
+
247
+ = 7.4.2 =
248
+ Update to support PRO version 3.4.3
249
+
250
+ = 7.4.0 =
251
+ Update to support PRO version 3.4.0
252
+
253
+ = 7.2.2 =
254
+ Update to support PRO version 3.2.0
255
+
256
+ = 7.1.2 =
257
+ Update to support PRO version 3.1.0
258
+
259
+ = 7.0.0 =
260
+ The templates have been improved drastically. While the old version 6 templates will work for now they have been deprecated and will one day stop working. If you are using custom templates please being converting them to the new structure.
261
+
262
+ = 6.0.0 =
263
+ If you are using the Pro version of this plugin be sure to update to Pro version 1.4.4 to keep all functionality intact with this version.
264
+
265
+ = 5.0.0 =
266
+ If you used a custom page_list.php template previously you may want to redo it on this version to take advantage of the new structure.
267
+
7.6.1/resources/css/advanced-sidebar-menu.css ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .advanced-sidebar-menu-column {
2
+ float: left;
3
+ width: 49%;
4
+ }
5
+
6
+ .advanced-sidebar-menu-column-right {
7
+ margin-left: 2%;
8
+ }
9
+
10
+ .advanced-sidebar-menu-column-box {
11
+ margin-bottom: 10px;
12
+ padding: 10px;
13
+ border: 1px solid #ddd;
14
+ background: #f1f1f1;
15
+ }
16
+
17
+ .advanced-sidebar-menu-full-width {
18
+ width: 100%;
19
+ clear: both;
20
+ }
21
+
22
+ @media all and ( max-width: 620px ) {
23
+ .advanced-sidebar-menu-column {
24
+ width: 100%;
25
+ }
26
+ }
7.6.1/resources/js/advanced-sidebar-menu.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ var el = jQuery('[data-js="' + this_element_id + '"]');
9
+
10
+ el.toggle();
11
+ var status = el.is(':visible') ? 'show' : 'hide';
12
+ advanced_sidebar_menu.set_hide_state(el);
13
+ jQuery(document).trigger('advanced-sidebar-menu/reveal-element', [this_element_id, status]);
14
+ }
15
+
16
+ /**
17
+ * Proper handling of the show/hide of elements
18
+ * for widgets
19
+ *
20
+ * @since 7.4.5
21
+ */
22
+ var advanced_sidebar_menu = {
23
+
24
+ /**
25
+ * Called by PHP so this will run no matter where the widget is loaded.
26
+ * This solves issues with page builders as well as widget updating.
27
+ *
28
+ * @since 7.4.5
29
+ */
30
+ init: function () {
31
+ this.show_hide_elements();
32
+ jQuery(document).trigger('advanced-sidebar-menu/init');
33
+ },
34
+
35
+ /**
36
+ * Set the data attribute to the current show/hide state so we
37
+ * can track it's visibility and not improperly show/hide an element
38
+ * when a widget is saved.
39
+ *
40
+ * Solves the issue where updating one widget could affect another.
41
+ *
42
+ * @since 7.4.5
43
+ *
44
+ * @param el
45
+ */
46
+ set_hide_state: function (el) {
47
+ if (el.is(':visible')) {
48
+ el.data('advanced-sidebar-menu-hide', 0);
49
+ } else {
50
+ el.data('advanced-sidebar-menu-hide', 1);
51
+ }
52
+ },
53
+
54
+ /**
55
+ * Use JS to show/hide widget elements instead of PHP because sometimes widgets are loaded
56
+ * in weird ways like ajax and we don't want any fields hidden if the JS is never loaded
57
+ * to later show them
58
+ *
59
+ * @since 7.4.5
60
+ *
61
+ */
62
+ show_hide_elements: function () {
63
+ jQuery('[data-advanced-sidebar-menu-hide]').each(function () {
64
+ var el = jQuery(this);
65
+ if (el.data('advanced-sidebar-menu-hide')) {
66
+ el.hide();
67
+ } else {
68
+ el.show();
69
+ }
70
+ });
71
+ }
72
+ };
7.6.1/src/Cache.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
16
+ protected function hook() {
17
+ add_action( 'save_post', array( $this, 'clear_cache_group' ) );
18
+ }
19
+
20
+
21
+ /**
22
+ * Clear all of items in this cache group
23
+ *
24
+ * @return void
25
+ */
26
+ public function clear_cache_group() {
27
+ if( function_exists( 'wp_cache_get_last_changed' ) ){
28
+ wp_cache_set( 'last_changed', microtime(), self::CACHE_GROUP . ':' . ADVANCED_SIDEBAR_BASIC_VERSION );
29
+ } else {
30
+ wp_cache_delete( self::CHILD_PAGES_KEY, $this->get_cache_group() );
31
+ }
32
+ }
33
+
34
+
35
+ /**
36
+ * Get unique key for this group
37
+ * Use wp_cache_get_last_changed() if on WP 4.7+
38
+ *
39
+ * @return string
40
+ */
41
+ public function get_cache_group() {
42
+ $key = '';
43
+ if( function_exists( 'wp_cache_get_last_changed' ) ){
44
+ $key = wp_cache_get_last_changed( self::CACHE_GROUP . ':' . ADVANCED_SIDEBAR_BASIC_VERSION );
45
+ }
46
+
47
+ return self::CACHE_GROUP . ':' . ADVANCED_SIDEBAR_BASIC_VERSION . ':' . $key;
48
+ }
49
+
50
+
51
+ /**
52
+ * Retrieve a posts child pages from the cache
53
+ * If no exist in the cache will return false
54
+ *
55
+ * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
56
+ *
57
+ * @return array|false
58
+ */
59
+ public function get_child_pages( $class ) {
60
+ $key = $this->get_key_from_asm( $class );
61
+ $all_child_pages = (array) wp_cache_get( self::CHILD_PAGES_KEY, $this->get_cache_group() );
62
+ if( isset( $all_child_pages[ $key ] ) ){
63
+ return $all_child_pages[ $key ];
64
+ }
65
+ return false;
66
+ }
67
+
68
+
69
+ /**
70
+ * Add a post and its children to the cache
71
+ * Uses a global key for all posts so this appends to an array
72
+ *
73
+ * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
74
+ * @param array $child_pages
75
+ *
76
+ * @return void
77
+ */
78
+ public function add_child_pages( $class, $child_pages ) {
79
+ $key = $this->get_key_from_asm( $class );
80
+ $all_child_pages = (array) wp_cache_get( self::CHILD_PAGES_KEY, $this->get_cache_group() );
81
+ $all_child_pages[ $key ] = $child_pages;
82
+ wp_cache_set( self::CHILD_PAGES_KEY, $all_child_pages, $this->get_cache_group() );
83
+ }
84
+
85
+
86
+ /**
87
+ * There are many possibilities for properties
88
+ * set to the object used for generations.
89
+ * To guarantee we have a unique id for the cache
90
+ * we serialize the whole object and hash it
91
+ *
92
+ *
93
+ * @param Advanced_Sidebar_Menu_Menu|Advanced_Sidebar_Menu_List_Pages $class
94
+ *
95
+ * @return string
96
+ */
97
+ private function get_key_from_asm( $class ) {
98
+ $string = serialize( $class );
99
+ return md5( $string );
100
+ }
101
+
102
+
103
+ //********** SINGLETON FUNCTIONS **********/
104
+
105
+
106
+ /**
107
+ * Instance of this class for use as singleton
108
+ */
109
+ private static $instance;
110
+
111
+
112
+ /**
113
+ * Create the instance of the class
114
+ *
115
+ * @static
116
+ * @return void
117
+ */
118
+ public static function init() {
119
+ self::instance()->hook();
120
+ }
121
+
122
+
123
+ /**
124
+ * Get (and instantiate, if necessary) the instance of the
125
+ * class
126
+ *
127
+ * @static
128
+ * @return self
129
+ */
130
+ public static function instance() {
131
+ if( !is_a( self::$instance, __CLASS__ ) ){
132
+ self::$instance = new self();
133
+ }
134
+
135
+ return self::$instance;
136
+ }
137
+ }
7.6.1/src/Core.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu
6
+ *
7
+ * @author Mat Lipe
8
+ * @since 7.0.0
9
+ *
10
+ */
11
+ class Advanced_Sidebar_Menu_Core {
12
+
13
+ protected function hook() {
14
+ add_action( 'widgets_init', array( $this, 'register_widgets' ) );
15
+ }
16
+
17
+
18
+ public function register_widgets() {
19
+ register_widget( 'Advanced_Sidebar_Menu_Widget_Page' );
20
+ register_widget( 'Advanced_Sidebar_Menu_Widget_Category' );
21
+ }
22
+
23
+
24
+ /**
25
+ * The plugin styles are universal
26
+ * This ensures that we only include them once on a single request
27
+ *
28
+ * @return void
29
+ */
30
+ public function include_plugin_styles() {
31
+ ?>
32
+ <style>
33
+ <?php include_once $this->get_template_part( 'sidebar-menu.css' ); ?>
34
+ </style>
35
+ <?php
36
+ }
37
+
38
+
39
+ /**
40
+ * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
41
+ * or this plugins views folder if one does not exist
42
+ *
43
+ * @since 6.0.0
44
+ *
45
+ * @param string $file_name
46
+ *
47
+ * @return string
48
+ */
49
+ public function get_template_part( $file_name ) {
50
+ $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
51
+ if ( empty( $file ) ) {
52
+ $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
53
+ }
54
+
55
+ $file = apply_filters( 'advanced_sidebar_menu_template_part', $file, $file_name, $this );
56
+
57
+ return $file;
58
+ }
59
+
60
+ //********** SINGLETON FUNCTIONS **********/
61
+
62
+
63
+ /**
64
+ * Instance of this class for use as singleton
65
+ */
66
+ protected static $instance;
67
+
68
+
69
+ /**
70
+ * Create the instance of the class
71
+ *
72
+ * @static
73
+ * @return void
74
+ */
75
+ public static function init() {
76
+ self::instance()->hook();
77
+ }
78
+
79
+
80
+ /**
81
+ * Get (and instantiate, if necessary) the instance of the
82
+ * class
83
+ *
84
+ * @static
85
+ * @return self
86
+ */
87
+ public static function instance() {
88
+ if ( ! is_a( self::$instance, __CLASS__ ) ) {
89
+ self::$instance = new self();
90
+ }
91
+
92
+ return self::$instance;
93
+ }
94
+ }
7.6.1/src/Debug.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Advanced_Sidebar_Menu_Debug
5
+ *
6
+ * @author Mat Lipe
7
+ * @since 6.3.1
8
+ * @since 7.4.8 - Use URL arguments to test different configurations.
9
+ */
10
+ class Advanced_Sidebar_Menu_Debug {
11
+ const DEBUG_PARAM = 'asm_debug';
12
+
13
+
14
+ /**
15
+ * Add actions and filters.
16
+ *
17
+ * @return void
18
+ */
19
+ protected function hook() {
20
+ if ( ! empty( $_GET[ self::DEBUG_PARAM ] ) ) { //phpcs:ignore
21
+ add_action( 'advanced_sidebar_menu_widget_pre_render', array( $this, 'print_instance' ), 1, 2 );
22
+
23
+ if ( is_array( $_GET[ self::DEBUG_PARAM ] ) ) { //phpcs:ignore
24
+ add_filter( 'advanced-sidebar-menu/menus/widget-instance', array( $this, 'adjust_widget_settings' ) );
25
+ }
26
+ }
27
+ }
28
+
29
+
30
+ /**
31
+ * Adjust widget settings using the URL.
32
+ *
33
+ * @param array $instance - Widget settings.
34
+ *
35
+ * @return array
36
+ */
37
+ public function adjust_widget_settings( array $instance ) {
38
+ //phpcs:ignore
39
+ $overrides = array_map( 'sanitize_text_field', (array) $_GET[ self::DEBUG_PARAM ] );
40
+
41
+ return wp_parse_args( $overrides, $instance );
42
+ }
43
+
44
+
45
+ /**
46
+ * Print the widget settings as a js variable.
47
+ *
48
+ * @param Advanced_Sidebar_Menu_Menus_Abstract $asm - Menu class.
49
+ * @param Advanced_Sidebar_Menu_Widget_Page $widget - Widget class.
50
+ *
51
+ * @return void
52
+ */
53
+ public function print_instance( $asm, $widget ) {
54
+ static $printed = false;
55
+ $data = array(
56
+ 'version' => ADVANCED_SIDEBAR_BASIC_VERSION,
57
+ $widget->id => $asm->instance,
58
+ );
59
+ if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
60
+ $data['pro_version'] = ADVANCED_SIDEBAR_MENU_PRO_VERSION;
61
+ }
62
+
63
+ if ( ! $printed ) {
64
+ ?>
65
+ <script class="<?php echo esc_attr( self::DEBUG_PARAM ); ?>">
66
+ var <?php echo esc_attr( self::DEBUG_PARAM ); ?> = <?php echo wp_json_encode( $data ); ?>;
67
+ </script>
68
+ <?php
69
+ $printed = true;
70
+ } else {
71
+ ?>
72
+ <script class="<?php echo esc_attr( self::DEBUG_PARAM ); ?>">
73
+ <?php echo esc_attr( self::DEBUG_PARAM ); ?>['<?php echo esc_js( $widget->id ); ?>'] = <?php echo wp_json_encode( $asm->instance ); ?>;
74
+ </script>
75
+ <?php
76
+ }
77
+ }
78
+
79
+
80
+ /**
81
+ * Instance of this class for use as singleton
82
+ *
83
+ * @var Advanced_Sidebar_Menu_Debug
84
+ */
85
+ private static $instance;
86
+
87
+
88
+ /**
89
+ * Create the instance of the class
90
+ *
91
+ * @static
92
+ * @return void
93
+ */
94
+ public static function init() {
95
+ self::instance()->hook();
96
+ }
97
+
98
+
99
+ /**
100
+ * Get (and instantiate, if necessary) the instance of the
101
+ * class
102
+ *
103
+ * @static
104
+ * @return self
105
+ */
106
+ public static function instance() {
107
+ if ( ! is_a( self::$instance, __CLASS__ ) ) {
108
+ self::$instance = new self();
109
+ }
110
+
111
+ return self::$instance;
112
+ }
113
+ }
7.6.1/src/List_Pages.php ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu_List_Pages
6
+ *
7
+ * Parse and build the child and grandchild menus
8
+ * Create the opening and closing <ul class="child-sidebar-menu">
9
+ * in the view and this will fill in the guts.
10
+ *
11
+ * Send the args ( similar to wp_list_pages ) to the constructor and then
12
+ * display by calling list_pages()
13
+ *
14
+ * @package Advanced Sidebar Menu
15
+ *
16
+ * @author Mat Lipe <mat@matlipe.com>
17
+ *
18
+ * @since 5.0.0
19
+ */
20
+ class Advanced_Sidebar_Menu_List_Pages {
21
+
22
+ /**
23
+ * The page list
24
+ *
25
+ * @var string
26
+ */
27
+ public $output = '';
28
+
29
+ /**
30
+ * Used when walking the list
31
+ *
32
+ * @var WP_Post
33
+ */
34
+ protected $current_page;
35
+
36
+ /**
37
+ * The top level parent id according to the menu class
38
+ *
39
+ * @var int
40
+ */
41
+ protected $top_parent_id;
42
+
43
+ /**
44
+ * Passed during construct given to walker and used for queries
45
+ *
46
+ * @var array
47
+ */
48
+ protected $args = array();
49
+
50
+ /**
51
+ * Used exclusively for caching
52
+ * Holds the value of the latest parent we
53
+ * retrieve children for so Cache can distinguish
54
+ * between calls.
55
+ *
56
+ * @var int
57
+ */
58
+ protected $current_children_parent = 0;
59
+
60
+ /**
61
+ * Menu class
62
+ *
63
+ * @var \Advanced_Sidebar_Menu_Menus_Page
64
+ */
65
+ protected $menu;
66
+
67
+
68
+ /**
69
+ * Constructor
70
+ *
71
+ * @param \Advanced_Sidebar_Menu_Menus_Page $menu - The menu class.
72
+ */
73
+ protected function __construct( Advanced_Sidebar_Menu_Menus_Page $menu ) {
74
+ $this->menu = $menu;
75
+ $this->top_parent_id = $menu->get_top_parent_id();
76
+ $this->current_page = $menu->get_current_post();
77
+
78
+ $args = array(
79
+ 'post_type' => $menu->get_post_type(),
80
+ 'orderby' => $menu->get_order_by(),
81
+ 'order' => $menu->get_order(),
82
+ 'exclude' => $menu->get_excluded_ids(),
83
+ 'levels' => $menu->get_levels_to_display(),
84
+ );
85
+
86
+ $this->args = $this->parse_args( $args );
87
+ $this->hook();
88
+ }
89
+
90
+
91
+ /**
92
+ * Hooks should only hook once
93
+ *
94
+ * @todo find a more appropriate place for this?
95
+ *
96
+ * @return void
97
+ */
98
+ protected function hook() {
99
+ add_filter( 'page_css_class', array( $this, 'add_list_item_classes' ), 2, 2 );
100
+ }
101
+
102
+
103
+ /**
104
+ * Add the custom classes to the list items
105
+ *
106
+ * @param array $classes - Provided classes for item.
107
+ * @param \WP_Post $post - The item.
108
+ *
109
+ * @return array
110
+ */
111
+ public function add_list_item_classes( $classes, WP_Post $post ) {
112
+ if ( $post->ID === $this->top_parent_id ) {
113
+ $children = $this->get_child_pages( $post->ID, true );
114
+ } else {
115
+ $children = $this->get_child_pages( $post->ID );
116
+ }
117
+ if ( ! empty( $children ) ) {
118
+ $classes[] = 'has_children';
119
+ }
120
+
121
+ // page posts are handled by wp core. This is for custom post types.
122
+ if ( 'page' !== $post->post_type ) {
123
+ $ancestors = get_post_ancestors( $post );
124
+ if ( ! empty( $ancestors ) && in_array( $this->current_page->ID, $ancestors, false ) ) { //phpcs:ignore
125
+ $classes[] = 'current_page_ancestor';
126
+ } elseif ( $this->current_page->ID === $post->post_parent ) {
127
+ $classes[] = 'current_page_parent';
128
+ }
129
+ }
130
+
131
+ return array_unique( $classes );
132
+ }
133
+
134
+
135
+ /**
136
+ * Return the list of args that have been populated by this class
137
+ * For use with wp_list_pages()
138
+ *
139
+ * @param string $level - level of menu so we have full control of updates.
140
+ *
141
+ * @return array
142
+ */
143
+ public function get_args( $level = null ) {
144
+ if ( null === $level ) {
145
+ return $this->args;
146
+ }
147
+ $args = $this->args;
148
+ switch ( $level ) {
149
+ case Advanced_Sidebar_Menu_Menus_Page::LEVEL_PARENT:
150
+ $args['include'] = $this->menu->get_top_parent_id();
151
+ break;
152
+ case Advanced_Sidebar_Menu_Menus_Page::LEVEL_DISPLAY_ALL:
153
+ $args['child_of'] = $this->menu->get_top_parent_id();
154
+ $args['depth'] = $this->menu->get_levels_to_display();
155
+ $args['sort_column'] = $this->menu->get_order_by();
156
+ break;
157
+ }
158
+
159
+ return apply_filters( 'advanced-sidebar-menu/list-pages/get-args', $args, $level, $this );
160
+ }
161
+
162
+
163
+ /**
164
+ * Return menu which was passed to this class
165
+ *
166
+ * @return Advanced_Sidebar_Menu_Menus_Page
167
+ */
168
+ public function get_menu() {
169
+ return $this->menu;
170
+ }
171
+
172
+
173
+ /**
174
+ * __toString
175
+ *
176
+ * Magic method to allow using a simple echo to get output
177
+ *
178
+ * @return string
179
+ */
180
+ public function __toString() {
181
+ return $this->output;
182
+ }
183
+
184
+
185
+ /**
186
+ * Do any adjustments to class args here
187
+ *
188
+ * @param array $args - Arguments for walk_page_tree.
189
+ *
190
+ * @return array
191
+ */
192
+ protected function parse_args( $args ) {
193
+ $defaults = array(
194
+ 'exclude' => '',
195
+ 'echo' => 0,
196
+ 'order' => 'ASC',
197
+ 'orderby' => 'menu_order, title',
198
+ 'walker' => new Advanced_Sidebar_Menu_Page_Walker(),
199
+ 'link_before' => '',
200
+ 'link_after' => '',
201
+ 'title_li' => '',
202
+ 'levels' => 100,
203
+ 'item_spacing' => 'preserve',
204
+ 'posts_per_page' => 100,
205
+ 'suppress_filters' => false,
206
+ );
207
+
208
+ $args = wp_parse_args( $args, $defaults );
209
+
210
+ if ( is_string( $args['exclude'] ) ) {
211
+ $args['exclude'] = explode( ',', $args['exclude'] );
212
+ }
213
+ // sanitize, mostly to keep spaces out.
214
+ $args['exclude'] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args['exclude'] ) ) );
215
+
216
+ return apply_filters( 'advanced_sidebar_menu_list_pages_args', $args, $this );
217
+
218
+ }
219
+
220
+
221
+ /**
222
+ * List the pages very similar to wp_list_pages.
223
+ *
224
+ * @return string
225
+ */
226
+ public function list_pages() {
227
+ $pages = $this->get_child_pages( $this->top_parent_id, true );
228
+ foreach ( $pages as $page ) {
229
+ $this->output .= walk_page_tree( array( $page ), 1, $this->current_page->ID, $this->args );
230
+ $this->output .= $this->list_grandchild_pages( $page->ID, 0 );
231
+ $this->output .= '</li>' . "\n";
232
+ }
233
+
234
+ $this->output = apply_filters( 'wp_list_pages', $this->output, $this->args, $pages );
235
+ if ( ! $this->args['echo'] ) {
236
+ return $this->output;
237
+ }
238
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
239
+ echo $this->output;
240
+ return '';
241
+ }
242
+
243
+
244
+ /**
245
+ * List all levels of grandchild pages up to the limit set in the widget.
246
+ * All grandchild pages will be rendered inside `grandchild-sidebar-menu` uls.
247
+ *
248
+ * @param int $parent_page_id - Id of the page we are getting the grandchildren of.
249
+ * @param int $level - Level of grandchild pages we are displaying.
250
+ *
251
+ * @return string
252
+ */
253
+ protected function list_grandchild_pages( $parent_page_id, $level ) {
254
+ if ( $level >= (int) $this->args['levels'] ) {
255
+ return '';
256
+ }
257
+ if ( ! $this->menu->display_all() && ! $this->is_current_page_ancestor( $parent_page_id ) ) {
258
+ return '';
259
+ }
260
+ $pages = $this->get_child_pages( $parent_page_id );
261
+ if ( empty( $pages ) ) {
262
+ return '';
263
+ }
264
+
265
+ $content = sprintf( '<ul class="grandchild-sidebar-menu level-%s children">', $level );
266
+
267
+ $inside = '';
268
+ foreach ( $pages as $page ) {
269
+ $inside .= walk_page_tree( array( $page ), 1, $this->current_page->ID, $this->args );
270
+ $inside .= $this->list_grandchild_pages( $page->ID, $level + 1 );
271
+ $inside .= "</li>\n";
272
+ }
273
+
274
+ if ( '' === $inside ) {
275
+ return '';
276
+ }
277
+
278
+ return $content . $inside . "</ul>\n";
279
+ }
280
+
281
+
282
+ /**
283
+ * Retrieve the child pages of specific page_id
284
+ *
285
+ * @param int $parent_page_id - Page id we are getting children of.
286
+ * @param bool $is_first_level - Is this the first level of child pages?.
287
+ *
288
+ * @since 7.5.5 - Add 'advanced-sidebar-menu/list-pages/grandchild-pages' filter.
289
+ *
290
+ * @return WP_Post[]
291
+ */
292
+ public function get_child_pages( $parent_page_id, $is_first_level = false ) {
293
+ // holds a unique key so Cache can distinguish calls.
294
+ $this->current_children_parent = $parent_page_id;
295
+
296
+ $cache = Advanced_Sidebar_Menu_Cache::instance();
297
+ $child_pages = $cache->get_child_pages( $this );
298
+ if ( false === $child_pages ) {
299
+ $args = $this->args;
300
+ $args['post_parent'] = $parent_page_id;
301
+ $args['fields'] = 'ids';
302
+ $args['suppress_filters'] = false;
303
+ $child_pages = get_posts( $args );
304
+
305
+ $cache->add_child_pages( $this, $child_pages );
306
+ }
307
+
308
+ $child_pages = array_map( 'get_post', (array) $child_pages );
309
+
310
+ // We only filter the first level with this filter for backward pro compatibility.
311
+ if ( $is_first_level ) {
312
+ return apply_filters( 'advanced-sidebar-menu/list-pages/first-level-child-pages', $child_pages, $this, $this->menu );
313
+ }
314
+
315
+ // @since 7.5.5
316
+ return apply_filters( 'advanced-sidebar-menu/list-pages/grandchild-pages', $child_pages, $this, $this->menu );
317
+
318
+ }
319
+
320
+
321
+ /**
322
+ * Is the specified page an ancestor of the current page?
323
+ *
324
+ * @param int $page_id - Post id to check against.
325
+ *
326
+ * @return bool
327
+ */
328
+ public function is_current_page_ancestor( $page_id ) {
329
+ $return = false;
330
+ if ( ! empty( $this->current_page->ID ) ) {
331
+ if ( (int) $page_id === $this->current_page->ID ) {
332
+ $return = true;
333
+ } elseif ( $this->current_page->post_parent === (int) $page_id ) {
334
+ $return = true;
335
+ } else {
336
+ $ancestors = get_post_ancestors( $this->current_page );
337
+ if ( ! empty( $ancestors ) && in_array( (int) $page_id, $ancestors, true ) ) {
338
+ $return = true;
339
+ }
340
+ }
341
+ }
342
+
343
+ return apply_filters( 'advanced_sidebar_menu_page_ancestor', $return, $this->current_page->ID, $this );
344
+ }
345
+
346
+
347
+ /**
348
+ * List Pages Factory
349
+ *
350
+ * @param \Advanced_Sidebar_Menu_Menus_Page $menu - The menu class.
351
+ *
352
+ * @static
353
+ *
354
+ * @return Advanced_Sidebar_Menu_List_Pages
355
+ */
356
+ public static function factory( Advanced_Sidebar_Menu_Menus_Page $menu ) {
357
+ return new self( $menu );
358
+ }
359
+
360
+ }
7.6.1/src/Menu.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @deprecated
4
+ */
5
+ class Advanced_Sidebar_Menu_Menu {
6
+ /**
7
+ * Advanced_Sidebar_Menu_Menu constructor.
8
+ *
9
+ * @deprecated
10
+ */
11
+ public function __construct() {
12
+ _deprecated_constructor( 'Advanced_Sidebar_Menu_Menu', '7.0.0' );
13
+ }
14
+
15
+ /**
16
+ * @deprecated
17
+ */
18
+ public static function get_current() {
19
+ _deprecated_function( 'Advanced_Sidebar_Menu_Menu::get_current()', '7.0.0', 'Advanced_Sidebar_Menu_Menus_Abstract::get_current()' );
20
+
21
+ return Advanced_Sidebar_Menu_Menus_Abstract::get_current();
22
+ }
23
+ }
7.6.1/src/Menus/Abstract.php ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use Prophecy\Argument\Token\StringContainsToken;
4
+
5
+ /**
6
+ * Advanced_Sidebar_Menu_Menus_Abstract
7
+ *
8
+ * @author Mat Lipe
9
+ * @since 7.0.0
10
+ */
11
+ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
12
+ // keys available in 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
+ const LEVEL_CHILD = 'child';
24
+ const LEVEL_DISPLAY_ALL = 'display-all';
25
+ const LEVEL_GRANDCHILD = 'grandchild';
26
+ const LEVEL_PARENT = 'parent';
27
+
28
+ /**
29
+ * Widget Args
30
+ *
31
+ * @var array
32
+ */
33
+ public $args = array();
34
+
35
+ /**
36
+ * @deprecated
37
+ *
38
+ * @var array
39
+ */
40
+ public $exclude = array();
41
+
42
+ /**
43
+ * Widget instance
44
+ *
45
+ * @var array
46
+ */
47
+ public $instance;
48
+
49
+ /**
50
+ * @deprecated 7.0.0
51
+ *
52
+ * @var string
53
+ */
54
+ public $order = 'ASC';
55
+
56
+ /**
57
+ * @deprecated 7.0.0
58
+ *
59
+ * @var string
60
+ */
61
+ public $order_by;
62
+
63
+ /**
64
+ * Top post_id or term_id
65
+ *
66
+ * @deprecated 7.0.0
67
+ *
68
+ * @var int
69
+ */
70
+ public $top_id;
71
+
72
+ /**
73
+ * Track the ids which have been used in case of
74
+ * plugins like Elementor that we need to manually increment.
75
+ *
76
+ * @since 7.6.0
77
+ * @ticket #4775
78
+ *
79
+ * @var string[]
80
+ */
81
+ protected static $unique_widget_ids = array();
82
+
83
+
84
+ public function __construct( array $widget_instance, array $widget_args ) {
85
+ $this->instance = apply_filters( 'advanced-sidebar-menu/menus/widget-instance', $widget_instance, $widget_args, $this );
86
+ $this->args = $widget_args;
87
+
88
+ $this->increment_widget_id();
89
+ }
90
+
91
+
92
+ abstract public function get_top_parent_id();
93
+
94
+
95
+ abstract public function get_order_by();
96
+
97
+
98
+ abstract public function get_order();
99
+
100
+
101
+ abstract public function render();
102
+
103
+
104
+ abstract public function is_displayed();
105
+
106
+
107
+ abstract public function get_levels_to_display();
108
+
109
+
110
+ /**
111
+ * Increment the widget id until it is unique to all widgets being displayed
112
+ * in the current context.
113
+ *
114
+ * Required because plugins like Elementor will reuse the same generic id for
115
+ * widgets within page content and we need a unique id to properly target with
116
+ * styles, accordions, etc.
117
+ *
118
+ * @since 7.6.0
119
+ * @ticket #4775
120
+ *
121
+ * @return void
122
+ */
123
+ protected function increment_widget_id() {
124
+ if ( ! isset( $this->args['widget_id'] ) ) {
125
+ return;
126
+ }
127
+ if ( in_array( $this->args['widget_id'], self::$unique_widget_ids, true ) ) {
128
+ $suffix = 2;
129
+ do {
130
+ $alt_widget_id = $this->args['widget_id'] . "-$suffix";
131
+ $suffix ++;
132
+ } while ( in_array( $alt_widget_id, self::$unique_widget_ids, true ) );
133
+ $this->args['widget_id'] = $alt_widget_id;
134
+ self::$unique_widget_ids[] = $alt_widget_id;
135
+ } else {
136
+ self::$unique_widget_ids[] = $this->args['widget_id'];
137
+ }
138
+ }
139
+
140
+
141
+ /**
142
+ * Return the type of widget we are working with
143
+ * Used for comparisons like so
144
+ *
145
+ * $menu->get_widget_type() === Menus_Page::WIDGET
146
+ *
147
+ * @return string - 'page', 'category',
148
+ */
149
+ public function get_widget_type() {
150
+ return self::WIDGET;
151
+ }
152
+
153
+
154
+ /**
155
+ * The instance arguments from the current widget
156
+ *
157
+ * @return array
158
+ */
159
+ public function get_widget_instance() {
160
+ return $this->instance;
161
+ }
162
+
163
+
164
+ /**
165
+ * The widget arguments from the current widget
166
+ *
167
+ * @return array
168
+ */
169
+ public function get_widget_args() {
170
+ return $this->args;
171
+ }
172
+
173
+
174
+ /**
175
+ * Checks if a widgets checkbox is checked.
176
+ *
177
+ * Checks first for a value then verifies the value = checked
178
+ *
179
+ * @param string $name - name of checkbox.
180
+ *
181
+ * @return bool
182
+ */
183
+ public function checked( $name ) {
184
+ return isset( $this->instance[ $name ] ) && 'checked' === $this->instance[ $name ];
185
+ }
186
+
187
+
188
+ /**
189
+ * Determines if all the children should be included
190
+ *
191
+ * @return bool
192
+ */
193
+ public function display_all() {
194
+ return $this->checked( self::DISPLAY_ALL );
195
+ }
196
+
197
+
198
+ /**
199
+ * Determines if the parent page or cat should be included
200
+ *
201
+ * @return bool
202
+ */
203
+ public function include_parent() {
204
+ return $this->checked( self::INCLUDE_PARENT ) && ! $this->is_excluded( $this->get_top_parent_id() );
205
+ }
206
+
207
+
208
+ /**
209
+ * Is this id excluded from this menu?
210
+ *
211
+ * @param int $id
212
+ *
213
+ * @return bool
214
+ */
215
+ public function is_excluded( $id ) {
216
+ $exclude = $this->get_excluded_ids();
217
+
218
+ return in_array( (int) $id, $exclude, true );
219
+ }
220
+
221
+
222
+ /**
223
+ * Retrieve the excluded items' ids
224
+ *
225
+ * @return array
226
+ */
227
+ public function get_excluded_ids() {
228
+ $excluded = explode( ',', $this->instance[ self::EXCLUDE ] );
229
+ $excluded = array_filter( $excluded );
230
+ $excluded = array_filter( $excluded, 'is_numeric' );
231
+ $excluded = array_map( 'intval', $excluded );
232
+
233
+ return $excluded;
234
+ }
235
+
236
+
237
+ /**
238
+ * Echos the title of the widget to the page
239
+ *
240
+ * @todo find somewhere more appropriate for this?
241
+ */
242
+ public function title() {
243
+ if ( ! empty( $this->instance[ self::TITLE ] ) ) {
244
+ $title = apply_filters( 'widget_title', $this->instance[ self::TITLE ], $this->args, $this->instance );
245
+ $title = apply_filters( 'advanced_sidebar_menu_widget_title', esc_html( $title ), $this->args, $this->instance, $this );
246
+
247
+ // phpcs:disable
248
+ echo $this->args['before_title'] . $title . $this->args['after_title'];
249
+ // phpcs:enable
250
+ }
251
+ }
252
+
253
+
254
+ /**
255
+ *
256
+ * @static
257
+ *
258
+ * @var \Advanced_Sidebar_Menu_Menus_Page|\Advanced_Sidebar_Menu_Menus_Category
259
+ */
260
+ protected static $current;
261
+
262
+
263
+ /**
264
+ *
265
+ * @static
266
+ *
267
+ * @return \Advanced_Sidebar_Menu_Menus_Page|\Advanced_Sidebar_Menu_Menus_Category
268
+ */
269
+ public static function get_current() {
270
+ return self::$current;
271
+ }
272
+
273
+
274
+ /**
275
+ * static() does not exist until PHP 5.3 which means we have to do
276
+ * this hideous thing where we call the factory method from the child
277
+ * class and pass it's name.
278
+ * Chose to handle it this way instead of trying to maintain 2 separate
279
+ * factory methods with logic.
280
+ *
281
+ * @param string $class
282
+ * @param array $widget_instance
283
+ * @param array $widget_args
284
+ *
285
+ * @static
286
+ *
287
+ * @return mixed
288
+ */
289
+ public static function _factory( $class, array $widget_instance, array $widget_args ) {
290
+ $menu = new $class( $widget_instance, $widget_args );
291
+ self::$current = $menu;
292
+
293
+ return $menu;
294
+ }
295
+ }
7.6.1/src/Menus/Category.php ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Advanced_Sidebar_Menu_Menus_Category
5
+ *
6
+ * @author Mat Lipe
7
+ * @since 7.0.0
8
+ */
9
+ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_Abstract {
10
+ const WIDGET = 'category';
11
+
12
+ const DISPLAY_ON_SINGLE = 'single';
13
+ const EACH_CATEGORY_DISPLAY = 'new_widget';
14
+
15
+ /**
16
+ * ancestors
17
+ *
18
+ * @var array
19
+ */
20
+ public $ancestors = array();
21
+
22
+
23
+ /**
24
+ * top_level_term
25
+ *
26
+ * @var WP_Term
27
+ */
28
+ public $top_level_term;
29
+
30
+
31
+ /**
32
+ * @todo find a more appropriate place for this
33
+ *
34
+ * @return void
35
+ */
36
+ public function hook() {
37
+ add_filter( 'category_css_class', array( $this, 'add_has_children_category_class' ), 2, 2 );
38
+ }
39
+
40
+
41
+ /**
42
+ * If we are on a post we could potentially have more than one
43
+ * top level term so we end up calling this more than once.
44
+ *
45
+ * @param WP_Term $term
46
+ *
47
+ * @return void
48
+ */
49
+ public function set_current_top_level_term( WP_Term $term ) {
50
+ $this->top_level_term = $term;
51
+ }
52
+
53
+
54
+ /**
55
+ * Return the list of args for wp_list_categories()
56
+ *
57
+ * @param string $level - level of menu so we have full control of updates
58
+ * @param WP_Term $term - Term for child and grandchild
59
+ *
60
+ * @return array
61
+ */
62
+ public function get_list_categories_args( $level = null, $term = null ) {
63
+ $args = array(
64
+ 'echo' => 0,
65
+ 'exclude' => $this->get_excluded_ids(),
66
+ 'order' => $this->get_order(),
67
+ 'orderby' => $this->get_order_by(),
68
+ 'show_option_none' => false,
69
+ 'taxonomy' => $this->get_taxonomy(),
70
+ 'title_li' => '',
71
+ );
72
+
73
+ if ( null === $level ) {
74
+ return $args;
75
+ }
76
+ // @todo switch these to constants to be use across basic and pro.
77
+ switch ( $level ) {
78
+ case self::LEVEL_PARENT:
79
+ $args['hide_empty'] = 0;
80
+ $args['include'] = trim( $this->get_top_parent_id() );
81
+ break;
82
+ case self::LEVEL_DISPLAY_ALL:
83
+ $args['child_of'] = $this->get_top_parent_id();
84
+ $args['depth'] = $this->get_levels_to_display();
85
+ break;
86
+ case self::LEVEL_CHILD:
87
+ $args['include'] = $term->term_id;
88
+ $args['depth'] = 1;
89
+ break;
90
+ case self::LEVEL_GRANDCHILD:
91
+ $args['child_of'] = $term->term_id;
92
+ $args['depth'] = $this->get_levels_to_display();
93
+ break;
94
+ }
95
+
96
+ return apply_filters( 'advanced-sidebar-menu/menus/category/get-list-categories-args', $args, $level, $this );
97
+ }
98
+
99
+
100
+ /**
101
+ * Get the first level child terms.
102
+ *
103
+ * $this->set_current_top_level_term() most likely should be called
104
+ * before this.
105
+ *
106
+ * @see Advanced_Sidebar_Menu_Menus_Category::set_current_top_level_term()
107
+ *
108
+ * @return array
109
+ */
110
+ public function get_child_terms() {
111
+ $child_terms = array_filter(
112
+ get_terms(
113
+ array(
114
+ 'taxonomy' => $this->get_taxonomy(),
115
+ 'parent' => $this->get_top_parent_id(),
116
+ 'orderby' => $this->get_order_by(),
117
+ 'order' => $this->get_order(),
118
+ )
119
+ )
120
+ );
121
+
122
+ return $child_terms;
123
+ }
124
+
125
+
126
+ /**
127
+ * Gets the number of levels ot display when doing 'Always display'
128
+ *
129
+ * @return int
130
+ */
131
+ public function get_levels_to_display() {
132
+ $depth = 3;
133
+ if ( $this->display_all() ) {
134
+ $depth = $this->instance[ self::LEVELS ];
135
+ }
136
+
137
+ return apply_filters( 'advanced-sidebar-menu/menus/category/levels', $depth, $this->args, $this->instance, $this );
138
+ }
139
+
140
+
141
+ /**
142
+ * @deprecated
143
+ */
144
+ public function get_menu_depth() {
145
+ _deprecated_function( 'get_menu_depth', '7.5.0', 'get_levels_to_display' );
146
+ return apply_filters( 'advanced-sidebar-menu/menus/category/depth', $this->get_levels_to_display(), $this->args, $this->instance, $this );
147
+ }
148
+
149
+
150
+ /**
151
+ * Get the top level terms for current page
152
+ * If on a single this could be multiple.
153
+ * If on an archive this will be one.
154
+ *
155
+ * @return array
156
+ */
157
+ public function get_top_level_terms() {
158
+ $child_term_ids = $this->get_included_term_ids();
159
+ $top_level_term_ids = array();
160
+ foreach ( $child_term_ids as $_term_id ) {
161
+ $top_level_term_ids[] = $this->get_highest_parent( $_term_id );
162
+ }
163
+ $terms = array();
164
+ if ( ! empty( $top_level_term_ids ) ) {
165
+ $terms = get_terms(
166
+ array(
167
+ 'include' => array_unique( array_filter( $top_level_term_ids ) ),
168
+ 'hide_empty' => false,
169
+ 'orderby' => $this->get_order_by(),
170
+ 'order' => $this->get_order(),
171
+ )
172
+ );
173
+ }
174
+ if ( is_wp_error( $terms ) ) {
175
+ return array();
176
+ }
177
+
178
+ return $terms;
179
+
180
+ }
181
+
182
+
183
+ /**
184
+ * Get the term ids for either the current term archive
185
+ * or the terms attached to the current post
186
+ *
187
+ * @return array
188
+ */
189
+ public function get_included_term_ids() {
190
+ $term_ids = array();
191
+ if ( is_single() ) {
192
+ $term_ids = wp_get_object_terms( get_the_ID(), $this->get_taxonomy(), array( 'fields' => 'ids' ) );
193
+ } elseif ( $this->is_tax() ) {
194
+ $term_ids[] = get_queried_object()->term_id;
195
+ }
196
+
197
+ return (array) apply_filters( 'advanced_sidebar_menu_category_ids', $term_ids, $this->args, $this->instance, $this );
198
+ }
199
+
200
+
201
+ public function get_taxonomy() {
202
+ return apply_filters( 'advanced_sidebar_menu_taxonomy', 'category', $this->args, $this->instance, $this );
203
+ }
204
+
205
+
206
+ public function get_top_parent_id() {
207
+ if ( empty( $this->top_level_term->term_id ) ) {
208
+ return null;
209
+ }
210
+
211
+ return $this->top_level_term->term_id;
212
+ }
213
+
214
+
215
+ public function get_order_by() {
216
+ return apply_filters( 'advanced_sidebar_menu_category_orderby', 'name', $this->args, $this->instance, $this );
217
+ }
218
+
219
+
220
+ public function get_order() {
221
+ return apply_filters( 'advanced_sidebar_menu_category_order', 'ASC', $this->args, $this->instance, $this );
222
+ }
223
+
224
+
225
+ public function is_displayed() {
226
+ $display = false;
227
+ if ( is_single() ) {
228
+ if ( $this->checked( self::DISPLAY_ON_SINGLE ) ) {
229
+ $display = true;
230
+ }
231
+ } elseif ( $this->is_tax() ) {
232
+ $display = true;
233
+ }
234
+
235
+ return apply_filters( 'advanced-sidebar-menu/menus/category/is-displayed', $display, $this->args, $this->instance, $this );
236
+ }
237
+
238
+
239
+ /**
240
+ * Is this term and it's children displayed
241
+ *
242
+ * 1. If children not empty we always display (or at least let the view handle it)
243
+ * 2. If children empty and not include parent we don't display
244
+ * 3. If children empty and not include childless parent we don't display
245
+ * 4. If children empty and the top parent is excluded we don't display
246
+ *
247
+ * @param array $child_terms
248
+ *
249
+ * @return bool
250
+ */
251
+ public function is_term_displayed( array $child_terms ) {
252
+ if ( empty( $child_terms ) ) {
253
+ if ( ! $this->checked( self::INCLUDE_PARENT ) || ! $this->checked( self::INCLUDE_CHILDLESS_PARENT ) ) {
254
+ return false;
255
+ }
256
+ if ( $this->is_excluded( $this->get_top_parent_id() ) ) {
257
+ return false;
258
+ }
259
+ }
260
+
261
+ return true;
262
+ }
263
+
264
+
265
+ /**
266
+ * Simplified way to verify if we are on a taxonomy
267
+ * archive
268
+ *
269
+ * @return bool
270
+ */
271
+ protected function is_tax() {
272
+ $taxonomy = $this->get_taxonomy();
273
+ if ( 'category' === $taxonomy ) {
274
+ if ( is_category() ) {
275
+ return true;
276
+ }
277
+ } elseif ( is_tax( $taxonomy ) ) {
278
+ return true;
279
+ }
280
+
281
+ return false;
282
+ }
283
+
284
+
285
+ public function get_excluded_ids() {
286
+ $excluded = parent::get_excluded_ids();
287
+
288
+ return apply_filters( 'advanced_sidebar_menu_excluded_categories', $excluded, $this->args, $this->instance, $this );
289
+ }
290
+
291
+
292
+ /**
293
+ * Removes the closing </li> tag from a list item to allow for child menus inside of it
294
+ *
295
+ * @param string|bool $item - an <li></li> item
296
+ *
297
+ * @return string|bool
298
+ */
299
+ public function openListItem( $item = false ) {
300
+ if ( ! $item ) {
301
+ return false;
302
+ }
303
+
304
+ return substr( trim( $item ), 0, - 5 );
305
+ }
306
+
307
+
308
+ /**
309
+ * Retrieve the lights level term_id based on the a given
310
+ * term's ancestors
311
+ *
312
+ * @param int $term_id
313
+ *
314
+ * @return int
315
+ */
316
+ public function get_highest_parent( $term_id ) {
317
+ $cat_ancestors = array();
318
+ $cat_ancestors[] = $term_id;
319
+
320
+ do {
321
+ $term = get_term( $term_id, $this->get_taxonomy() );
322
+ if ( ! is_wp_error( $term ) ) {
323
+ $term_id = $term->parent;
324
+ $cat_ancestors[] = $term_id;
325
+ } else {
326
+ $term = false;
327
+ }
328
+ } while ( $term );
329
+
330
+ // we only track the last calls ancestors because we only care
331
+ // about these when on a single term archive
332
+ $this->ancestors = array_reverse( $cat_ancestors );
333
+ list( $_, $top_cat ) = $this->ancestors;
334
+
335
+ return $top_cat;
336
+
337
+ }
338
+
339
+
340
+ /**
341
+ * If a category has children add the has_children class
342
+ *
343
+ * @param [] $classes
344
+ * @param \WP_Term $category
345
+ *
346
+ * @return array
347
+ */
348
+ public function add_has_children_category_class( $classes, $category ) {
349
+ if ( $this->has_children( $category ) ) {
350
+ $classes[] = 'has_children';
351
+ }
352
+
353
+ return array_unique( $classes );
354
+ }
355
+
356
+
357
+ /**
358
+ * 1. Is this term's parent our top_parent_id?
359
+ * 2. Is this term not excluded?
360
+ * 3. Does the filter allow this term?
361
+ *
362
+ * When looping through the view via the terms from $this->get_child_terms()
363
+ * the term->parent conditions will most likely always be true.
364
+ *
365
+ * @param \WP_Term $term
366
+ *
367
+ * @return bool
368
+ */
369
+ public function is_first_level_term( WP_Term $term ) {
370
+ $return = false;
371
+ if ( ! $this->is_excluded( $term->term_id ) && (int) $term->parent === (int) $this->get_top_parent_id() ) {
372
+ $return = true;
373
+ }
374
+
375
+ return apply_filters( 'advanced_sidebar_menu_first_level_category', $return, $term, $this );
376
+ }
377
+
378
+
379
+ /**
380
+ * Is this term an ancestor of the current term?
381
+ * Does this term have children?
382
+ *
383
+ * @param \WP_Term $term
384
+ *
385
+ * @return mixed
386
+ */
387
+ public function is_current_term_ancestor( WP_Term $term ) {
388
+ $return = false;
389
+ if ( (int) $term->term_id === (int) $this->top_level_term->term_id || in_array( $term->term_id, $this->ancestors, false ) ) {
390
+ $children = get_term_children( $term->term_id, $this->get_taxonomy() );
391
+ if ( ! empty( $children ) ) {
392
+ $return = true;
393
+ }
394
+ }
395
+
396
+ return apply_filters( 'advanced-sidebar-menu/menus/category/is-current-term-ancestor', $return, $term, $this );
397
+
398
+ }
399
+
400
+
401
+ /**
402
+ * Does this term have children?
403
+ *
404
+ * @param \WP_Term $term
405
+ *
406
+ * @return mixed
407
+ */
408
+ public function has_children( WP_Term $term ) {
409
+ $return = false;
410
+ $children = get_term_children( $term->term_id, $this->get_taxonomy() );
411
+ if ( ! empty( $children ) ) {
412
+ $return = true;
413
+ }
414
+
415
+ return apply_filters( 'advanced-sidebar-menu/menus/category/has-children', $return, $term, $this );
416
+ }
417
+
418
+
419
+ /**
420
+ * Render the widget output
421
+ *
422
+ * @return void
423
+ */
424
+ public function render() {
425
+ if ( ! $this->is_displayed() ) {
426
+ return;
427
+ }
428
+
429
+ $menu_open = false;
430
+ $close_menu = false;
431
+
432
+ foreach ( $this->get_top_level_terms() as $_cat ) {
433
+ $this->set_current_top_level_term( $_cat );
434
+ if ( ! $this->is_term_displayed( $this->get_child_terms() ) ) {
435
+ continue;
436
+ }
437
+
438
+ if ( ! $menu_open || ( 'widget' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) ) {
439
+ //phpcs:disable
440
+ echo $this->args['before_widget'];
441
+
442
+ do_action( 'advanced-sidebar-menu/menus/category/render', $this );
443
+
444
+ if ( ! $menu_open ) {
445
+ //must remain in the loop vs the template
446
+ $this->title();
447
+ if ( $this->checked( self::USE_PLUGIN_STYLES ) ) {
448
+ Advanced_Sidebar_Menu_Core::instance()->include_plugin_styles();
449
+ }
450
+
451
+ $menu_open = true;
452
+ $close_menu = true;
453
+ if ( 'list' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) {
454
+ $close_menu = false;
455
+ }
456
+ }
457
+ }
458
+
459
+ $output = require Advanced_Sidebar_Menu_Core::instance()->get_template_part( 'category_list.php' );
460
+
461
+ echo apply_filters( 'advanced_sidebar_menu_category_widget_output', $output, $this->args, $this->instance, $this );
462
+
463
+ if ( $close_menu ) {
464
+ echo $this->args['after_widget'];
465
+ }
466
+ }
467
+
468
+ if ( ! $close_menu && $menu_open ) {
469
+ echo $this->args['after_widget'];
470
+ }
471
+
472
+ //phpcs:enable
473
+
474
+ }
475
+
476
+
477
+ /******************** static ****************************/
478
+
479
+ /**
480
+ * Mostly here to call the parent _factory in a PHP 5.2 structure
481
+ *
482
+ * @param array $widget_instance
483
+ * @param array $widget_args
484
+ *
485
+ * @static
486
+ *
487
+ * @return \Advanced_Sidebar_Menu_Menus_Category
488
+ */
489
+ public static function factory( array $widget_instance, array $widget_args ) {
490
+ $class = parent::_factory( __CLASS__, $widget_instance, $widget_args );
491
+ $class->hook();
492
+
493
+ return $class;
494
+ }
495
+
496
+ }
7.6.1/src/Menus/Page.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu_Menus_Page
6
+ *
7
+ * @author Mat Lipe
8
+ * @since 7.0.0
9
+ *
10
+ */
11
+ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstract {
12
+ const WIDGET = 'page';
13
+
14
+ /**
15
+ * post_type
16
+ *
17
+ * @deprecated
18
+ *
19
+ * @var string
20
+ */
21
+ public $post_type = 'page';
22
+
23
+ /**
24
+ * post
25
+ *
26
+ * @var \WP_Post
27
+ */
28
+ protected $post;
29
+
30
+ protected $ancestors;
31
+
32
+
33
+ public function set_current_post( WP_Post $post ) {
34
+ $this->post = $post;
35
+ }
36
+
37
+
38
+ /**
39
+ * Gets the current queried post unless it
40
+ * has been set explicitly.
41
+ *
42
+ * @return \WP_Post
43
+ */
44
+ public function get_current_post() {
45
+ if ( null === $this->post ) {
46
+ if ( is_page() || is_singular() ) {
47
+ $this->post = get_queried_object();
48
+ }
49
+ }
50
+
51
+ return $this->post;
52
+ }
53
+
54
+
55
+ public function get_order_by() {
56
+ return apply_filters( 'advanced_sidebar_menu_order_by', $this->instance[ self::ORDER_BY ], $this->get_current_post(), $this->args, $this->instance, $this );
57
+ }
58
+
59
+
60
+ public function get_order() {
61
+ return apply_filters( 'advanced_sidebar_menu_page_order', 'ASC', $this->get_current_post(), $this->args, $this->instance, $this );
62
+ }
63
+
64
+
65
+ public function get_top_parent_id() {
66
+ $ancestors = get_post_ancestors( $this->get_current_post() );
67
+ if ( ! empty( $ancestors ) ) {
68
+ $top_id = end( $ancestors );
69
+ } else {
70
+ $top_id = $this->get_current_post()->ID;
71
+ }
72
+
73
+ //$this->top_id is deprecated since 7.0.0
74
+ $this->top_id = apply_filters( 'advanced_sidebar_menu_top_parent', $top_id, $this->args, $this->instance, $this );
75
+
76
+ return $this->top_id;
77
+
78
+ }
79
+
80
+
81
+ public function is_displayed() {
82
+ $display = false;
83
+ $post_type = $this->get_post_type();
84
+ if ( is_page() || ( is_single() && $post_type === $this->get_current_post()->post_type ) ) {
85
+ //if we are on the correct post type
86
+ if ( get_post_type( $this->get_top_parent_id() ) === $post_type ) {
87
+ //if we have children
88
+ if ( $this->has_pages() ) {
89
+ $display = true;
90
+ //no children + not excluded + include parent +include childless parent
91
+ } elseif ( $this->checked( self::INCLUDE_CHILDLESS_PARENT ) && $this->checked( self::INCLUDE_PARENT ) && ! $this->is_excluded( $this->get_top_parent_id() ) ) {
92
+ $display = true;
93
+ }
94
+ }
95
+ }
96
+
97
+ $display = ! apply_filters_deprecated( 'advanced_sidebar_menu_proper_single', array(
98
+ ! $display,
99
+ $this->args,
100
+ $this->instance,
101
+ $this,
102
+ ), '7.0.0', 'advanced-sidebar-menu/menus/page/is-displayed' );
103
+
104
+
105
+ return apply_filters( 'advanced-sidebar-menu/menus/page/is-displayed', $display, $this->args, $this->instance, $this );
106
+
107
+ }
108
+
109
+
110
+ /**
111
+ * Do we have child pages at all on this menu?
112
+ *
113
+ * Return false if all we have is the top parent page
114
+ * Return true if we have at least a second level
115
+ *
116
+ * @return bool
117
+ */
118
+ public function has_pages() {
119
+ $list_pages = Advanced_Sidebar_Menu_List_Pages::factory( $this );
120
+ $children = $list_pages->get_child_pages( $this->get_top_parent_id(), true );
121
+
122
+ return ! empty( $children );
123
+ }
124
+
125
+
126
+ /**
127
+ * Gets the number of levels ot display when doing 'Always display'
128
+ *
129
+ * @return int
130
+ */
131
+ public function get_levels_to_display() {
132
+ $levels = 100;
133
+ if ( $this->display_all() ) {
134
+ // Subtract 1 level to account for the first level children.
135
+ $levels = $this->instance[ self::LEVELS ] - 1;
136
+ }
137
+ return apply_filters( 'advanced-sidebar-menu/menus/page/levels', $levels, $this->args, $this->instance, $this );
138
+ }
139
+
140
+
141
+ /**
142
+ * @deprecated
143
+ */
144
+ public function get_menu_depth() {
145
+ _deprecated_function( 'get_menu_depth', '7.5.0', 'get_levels_to_display' );
146
+ return apply_filters( 'advanced-sidebar-menu/menus/page/depth', $this->get_levels_to_display(), $this->args, $this->instance, $this );
147
+ }
148
+
149
+
150
+ public function get_post_type() {
151
+ return apply_filters( 'advanced_sidebar_menu_post_type', $this->post_type, $this->args, $this->instance, $this );
152
+ }
153
+
154
+
155
+ public function get_excluded_ids() {
156
+ $excluded = parent::get_excluded_ids();
157
+ if ( ! empty( $this->exclude ) ) {
158
+ //backward compatibility for PRO version
159
+ $excluded = array_merge( $excluded, $this->exclude );
160
+ }
161
+
162
+ return apply_filters( 'advanced_sidebar_menu_excluded_pages', $excluded, $this->get_current_post(), $this->args, $this->instance, $this );
163
+ }
164
+
165
+
166
+ /**
167
+ * Render the widget
168
+ *
169
+ * @return void
170
+ */
171
+ public function render() {
172
+ if ( ! $this->is_displayed() ) {
173
+ return;
174
+ }
175
+
176
+ // phpcs:disable
177
+ echo $this->args['before_widget'];
178
+
179
+ do_action( 'advanced-sidebar-menu/menus/page/render', $this );
180
+
181
+ if ( $this->checked( self::USE_PLUGIN_STYLES ) ) {
182
+ Advanced_Sidebar_Menu_Core::instance()->include_plugin_styles();
183
+ }
184
+
185
+ $output = require Advanced_Sidebar_Menu_Core::instance()->get_template_part( 'page_list.php' );
186
+ echo apply_filters( 'advanced_sidebar_menu_page_widget_output', $output, $this->get_current_post(), $this->args, $this->instance, $this );
187
+
188
+ echo $this->args['after_widget'];
189
+ // phpcs:enable
190
+ }
191
+
192
+
193
+ /**************** static *****************/
194
+ /**
195
+ * Mostly here to call the parent _factory() in a PHP 5.2 structure
196
+ *
197
+ * @param array $widget_instance
198
+ * @param array $widget_args
199
+ *
200
+ * @static
201
+ *
202
+ * @return \Advanced_Sidebar_Menu_Menus_Page
203
+ */
204
+ public static function factory( array $widget_instance, array $widget_args ) {
205
+ return parent::_factory( __CLASS__, $widget_instance, $widget_args );
206
+ }
207
+ }
7.6.1/src/Page_Walker.php ADDED
@@ -0,0 +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
+ }
7.6.1/src/Widget/Category.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Creates a Widget of parent Child Categories
6
+ *
7
+ * @author Mat Lipe
8
+ * @since 7.0.0
9
+ * @package Advanced Sidebar Menu
10
+ *
11
+ *
12
+ */
13
+ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widget__Widget {
14
+ const TITLE = Advanced_Sidebar_Menu_Menus_Abstract::TITLE;
15
+ const INCLUDE_PARENT = Advanced_Sidebar_Menu_Menus_Abstract::INCLUDE_PARENT;
16
+ const INCLUDE_CHILDLESS_PARENT = Advanced_Sidebar_Menu_Menus_Abstract::INCLUDE_CHILDLESS_PARENT;
17
+ const ORDER_BY = Advanced_Sidebar_Menu_Menus_Abstract::ORDER_BY;
18
+ const USE_PLUGIN_STYLES = Advanced_Sidebar_Menu_Menus_Abstract::USE_PLUGIN_STYLES;
19
+ const EXCLUDE = Advanced_Sidebar_Menu_Menus_Abstract::EXCLUDE;
20
+ const DISPLAY_ALL = Advanced_Sidebar_Menu_Menus_Abstract::DISPLAY_ALL;
21
+ const LEVELS = Advanced_Sidebar_Menu_Menus_Abstract::LEVELS;
22
+
23
+ const DISPLAY_ON_SINGLE = Advanced_Sidebar_Menu_Menus_Category::DISPLAY_ON_SINGLE;
24
+ const EACH_CATEGORY_DISPLAY = Advanced_Sidebar_Menu_Menus_Category::EACH_CATEGORY_DISPLAY;
25
+
26
+ protected static $defaults = array(
27
+ self::TITLE => '',
28
+ self::INCLUDE_PARENT => false,
29
+ self::INCLUDE_CHILDLESS_PARENT => false,
30
+ self::USE_PLUGIN_STYLES => false,
31
+ self::DISPLAY_ON_SINGLE => false,
32
+ self::EACH_CATEGORY_DISPLAY => 'widget',
33
+ self::EXCLUDE => '',
34
+ self::DISPLAY_ALL => false,
35
+ self::LEVELS => 1,
36
+ );
37
+
38
+ protected static $hooked = false;
39
+
40
+
41
+ public function __construct() {
42
+ $widget_ops = array(
43
+ 'classname' => 'advanced-sidebar-menu advanced-sidebar-category',
44
+ 'description' => __( 'Creates a menu of all the categories using the child/parent relationship', 'advanced-sidebar-menu' ),
45
+ );
46
+ $control_ops = array( 'width' => 620 );
47
+
48
+ parent::__construct( 'advanced_sidebar_menu_category', __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
49
+
50
+ if ( ! self::$hooked ) {
51
+ self::$hooked = true;
52
+ $this->hook();
53
+ }
54
+ }
55
+
56
+ /**
57
+ * @notice Anything using the column actions must use the $widget class passed
58
+ * via do_action instead of $this
59
+ *
60
+ * @return void
61
+ */
62
+ protected function hook() {
63
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_display' ), 5, 2 );
64
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_styles' ), 10, 2 );
65
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_singles' ), 15, 2 );
66
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_exclude' ), 20, 2 );
67
+
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @param array $instance
73
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
74
+ *
75
+ * @return void
76
+ */
77
+ public function box_display( array $instance, $widget ) {
78
+ ?>
79
+ <div class="advanced-sidebar-menu-column-box">
80
+ <p>
81
+ <?php $widget->checkbox( self::INCLUDE_PARENT ); ?>
82
+ <label>
83
+ <?php esc_html_e( 'Display highest level parent category', 'advanced-sidebar-menu' ); ?>
84
+ </label>
85
+ </p>
86
+ <p>
87
+ <?php $widget->checkbox( self::INCLUDE_CHILDLESS_PARENT ); ?>
88
+ <label>
89
+ <?php esc_html_e( 'Display menu when there is only the parent category', 'advanced-sidebar-menu' ); ?>
90
+ </label>
91
+ </p>
92
+ <p>
93
+ <?php $widget->checkbox( self::DISPLAY_ALL, self::LEVELS ); ?>
94
+ <label>
95
+ <?php esc_html_e( 'Always display child categories', 'advanced-sidebar-menu' ); ?>
96
+ </label>
97
+ </p>
98
+ <div <?php $widget->hide_element( self::DISPLAY_ALL, self::LEVELS ); ?>>
99
+ <p>
100
+ <label>
101
+ <?php esc_html_e( 'Levels of child categories to display', 'advanced-sidebar-menu' ); ?>:</label>
102
+ <select
103
+ name="<?php echo esc_attr( $widget->get_field_name( self::LEVELS ) ); ?>">
104
+ <?php
105
+ for ( $i = 1; $i < 6; $i ++ ) {
106
+ ?>
107
+ <option
108
+ value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, (int) $instance[ self::LEVELS ] ); ?>>
109
+ <?php echo esc_html( $i ); ?>
110
+ </option>
111
+
112
+ <?php
113
+ }
114
+ ?>
115
+ </select>
116
+ </p>
117
+ </div>
118
+
119
+ <?php do_action( 'advanced-sidebar-menu/widget/category/display-box', $instance, $widget ); ?>
120
+
121
+ </div>
122
+ <?php
123
+ }
124
+
125
+ /**
126
+ *
127
+ * @param array $instance
128
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
129
+ *
130
+ * @return void
131
+ */
132
+ public function box_styles( array $instance, $widget ) {
133
+ ?>
134
+ <div class="advanced-sidebar-menu-column-box">
135
+ <p>
136
+ <?php $widget->checkbox( self::USE_PLUGIN_STYLES ); ?>
137
+ <label>
138
+ <?php esc_html_e( "Use this plugin's default styling", 'advanced-sidebar-menu' ); ?>
139
+ </label>
140
+ </p>
141
+
142
+ <?php do_action( 'advanced-sidebar-menu/widget/category/styles-box', $instance, $widget ); ?>
143
+ </div>
144
+ <?php
145
+ }
146
+
147
+ /**
148
+ *
149
+ * @param array $instance
150
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
151
+ *
152
+ * @return void
153
+ */
154
+ public function box_singles( array $instance, $widget ) {
155
+ ?>
156
+ <div class="advanced-sidebar-menu-column-box">
157
+ <p>
158
+
159
+ <?php $widget->checkbox( self::DISPLAY_ON_SINGLE, self::EACH_CATEGORY_DISPLAY ); ?>
160
+ <label>
161
+ <?php esc_html_e( 'Display categories on single posts', 'advanced-sidebar-menu' ); ?>
162
+ </label>
163
+ </p>
164
+
165
+ <div <?php $widget->hide_element( self::DISPLAY_ON_SINGLE, self::EACH_CATEGORY_DISPLAY ); ?>>
166
+ <p>
167
+ <label><?php esc_html_e( "Display each single post's category", 'advanced-sidebar-menu' ); ?>
168
+ :</label>
169
+ <select
170
+ name="<?php echo esc_attr( $widget->get_field_name( self::EACH_CATEGORY_DISPLAY ) ); ?>">
171
+ <option
172
+ value="widget" <?php selected( 'widget', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
173
+ <?php esc_html_e( 'In a new widget', 'advanced-sidebar-menu' ); ?>
174
+ </option>
175
+ <option value="list" <?php selected( 'list', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
176
+ <?php esc_html_e( 'In another list in the same widget', 'advanced-sidebar-menu' ); ?>
177
+ </option>
178
+ </select>
179
+ </p>
180
+ </div>
181
+
182
+ <?php do_action( 'advanced-sidebar-menu/widget/category/singles-box', $instance, $widget ); ?>
183
+
184
+ </div>
185
+ <?php
186
+ }
187
+
188
+ /**
189
+ *
190
+ * @param array $instance
191
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
192
+ *
193
+ * @return void
194
+ */
195
+ public function box_exclude( array $instance, $widget ) {
196
+ ?>
197
+ <div class="advanced-sidebar-menu-column-box">
198
+ <p>
199
+ <label>
200
+ <?php esc_html_e( 'Categories to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
201
+ </label>
202
+ <input
203
+ id="<?php echo esc_attr( $widget->get_field_id( self::EXCLUDE ) ); ?>"
204
+ name="<?php echo esc_attr( $widget->get_field_name( self::EXCLUDE ) ); ?>"
205
+ type="text"
206
+ class="widefat"
207
+ value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
208
+ </p>
209
+
210
+ <?php
211
+ do_action( 'advanced-sidebar-menu/widget/category/exclude-box', $instance, $widget );
212
+ ?>
213
+ </div>
214
+ <?php
215
+ }
216
+
217
+
218
+ /**
219
+ * Form
220
+ *
221
+ * @since 7.2.1
222
+ *
223
+ * @param array $instance
224
+ *
225
+ * @return void
226
+ */
227
+ public function form( $instance ) {
228
+ $instance = $this->set_instance( $instance, self::$defaults );
229
+ do_action( 'advanced-sidebar-menu/widget/category/before-form', $instance, $this );
230
+ ?>
231
+ <p>
232
+ <label>
233
+ <?php esc_html_e( 'Title', 'advanced-sidebar-menu' ); ?>:
234
+ </label>
235
+
236
+ <input
237
+ id="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>"
238
+ name="<?php echo esc_attr( $this->get_field_name( self::TITLE ) ); ?>"
239
+ class="widefat"
240
+ type="text"
241
+ value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
242
+ </p>
243
+
244
+ <div class="advanced-sidebar-menu-column">
245
+ <?php
246
+ do_action( 'advanced-sidebar-menu/widget/category/left-column', $instance, $this );
247
+
248
+ if ( has_action( 'advanced_sidebar_menu_category_widget_form' ) ) {
249
+ ?>
250
+ <div class="advanced-sidebar-menu-column-box">
251
+ <?php do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this ); ?>
252
+ </div>
253
+ <?php
254
+ }
255
+
256
+ ?>
257
+ </div>
258
+
259
+ <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
260
+ <?php
261
+ do_action( 'advanced-sidebar-menu/widget/category/right-column', $instance, $this );
262
+ // @deprecated action.
263
+ do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
264
+ ?>
265
+ </div>
266
+ <div class="advanced-sidebar-menu-full-width"><!-- clear --></div>
267
+
268
+ <?php
269
+ do_action( 'advanced-sidebar-menu/widget/category/after-form', $instance, $this );
270
+
271
+ }
272
+
273
+
274
+ /**
275
+ * Update
276
+ *
277
+ * @param array $new_instance
278
+ * @param array $old_instance
279
+ *
280
+ * @return array|mixed
281
+ */
282
+ public function update( $new_instance, $old_instance ) {
283
+ $new_instance['exclude'] = strip_tags( $new_instance['exclude'] );
284
+
285
+ return apply_filters( 'advanced_sidebar_menu_category_widget_update', $new_instance, $old_instance );
286
+ }
287
+
288
+
289
+ /**
290
+ * Widget Output
291
+ *
292
+ * @since 7.0.0
293
+ *
294
+ * @see \Advanced_Sidebar_Menu_Menus_Category
295
+ *
296
+ * @param array $args
297
+ * @param array $instance
298
+ *
299
+ * @return void
300
+ */
301
+ public function widget( $args, $instance ) {
302
+ $instance = $this->set_instance( $instance, self::$defaults );
303
+ $asm = Advanced_Sidebar_Menu_Menus_Category::factory( $instance, $args );
304
+
305
+ do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
306
+
307
+ $asm->render();
308
+ }
309
+
310
+ }
7.6.1/src/Widget/Page.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Advanced_Sidebar_Menu_Widgets_Page
6
+ *
7
+ * Parent child menu based on pages.
8
+ *
9
+ * @author Mat Lipe
10
+ * @since 7.0.0
11
+ */
12
+ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__Widget {
13
+ const TITLE = Advanced_Sidebar_Menu_Menus_Abstract::TITLE;
14
+ const INCLUDE_PARENT = Advanced_Sidebar_Menu_Menus_Abstract::INCLUDE_PARENT;
15
+ const INCLUDE_CHILDLESS_PARENT = Advanced_Sidebar_Menu_Menus_Abstract::INCLUDE_CHILDLESS_PARENT;
16
+ const ORDER_BY = Advanced_Sidebar_Menu_Menus_Abstract::ORDER_BY;
17
+ const USE_PLUGIN_STYLES = Advanced_Sidebar_Menu_Menus_Abstract::USE_PLUGIN_STYLES;
18
+ const EXCLUDE = Advanced_Sidebar_Menu_Menus_Abstract::EXCLUDE;
19
+ const DISPLAY_ALL = Advanced_Sidebar_Menu_Menus_Abstract::DISPLAY_ALL;
20
+ const LEVELS = Advanced_Sidebar_Menu_Menus_Abstract::LEVELS;
21
+
22
+ protected static $defaults = array(
23
+ self::TITLE => false,
24
+ self::INCLUDE_PARENT => false,
25
+ self::INCLUDE_CHILDLESS_PARENT => false,
26
+ self::ORDER_BY => 'menu_order',
27
+ self::USE_PLUGIN_STYLES => false,
28
+ self::EXCLUDE => false,
29
+ self::DISPLAY_ALL => false,
30
+ self::LEVELS => 1,
31
+ );
32
+
33
+ protected static $hooked = false;
34
+
35
+
36
+ public function __construct() {
37
+ $widget_ops = array(
38
+ 'classname' => 'advanced-sidebar-menu',
39
+ 'description' => __( 'Creates a menu of all the pages using the child/parent relationship', 'advanced-sidebar-menu' ),
40
+ );
41
+ $control_ops = array(
42
+ 'width' => 620,
43
+ );
44
+
45
+ parent::__construct( 'advanced_sidebar_menu', __( 'Advanced Sidebar Pages Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
46
+
47
+ if ( ! self::$hooked ) {
48
+ self::$hooked = true;
49
+ $this->hook();
50
+ }
51
+
52
+ }
53
+
54
+
55
+ /**
56
+ * @notice Anything using the column actions must use the $widget class passed
57
+ * via do_action instead of $this
58
+ *
59
+ * @return void
60
+ */
61
+ protected function hook() {
62
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_display' ), 5, 2 );
63
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_styles' ), 10, 2 );
64
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_order' ), 15, 2 );
65
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_exclude' ), 20, 2 );
66
+
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @param array $instance
72
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
73
+ *
74
+ * @return void
75
+ */
76
+ public function box_display( array $instance, $widget ) {
77
+ ?>
78
+ <div class="advanced-sidebar-menu-column-box">
79
+ <p>
80
+ <?php $widget->checkbox( self::INCLUDE_PARENT ); ?>
81
+ <label>
82
+ <?php esc_html_e( 'Display highest level parent page', 'advanced-sidebar-menu' ); ?>
83
+ </label>
84
+ </p>
85
+
86
+
87
+ <p>
88
+ <?php $widget->checkbox( self::INCLUDE_CHILDLESS_PARENT ); ?>
89
+ <label>
90
+ <?php esc_html_e( 'Display menu when there is only the parent page', 'advanced-sidebar-menu' ); ?>
91
+ </label>
92
+ </p>
93
+
94
+ <p>
95
+ <?php $widget->checkbox( self::DISPLAY_ALL, self::LEVELS ); ?>
96
+ <label>
97
+ <?php esc_html_e( 'Always display child pages', 'advanced-sidebar-menu' ); ?>
98
+ </label>
99
+ </p>
100
+
101
+ <div
102
+ <?php
103
+ if ( apply_filters( 'advanced-sidebar-menu/widget/page/hide-levels-field', true ) ) {
104
+ $widget->hide_element( self::DISPLAY_ALL, self::LEVELS );
105
+ }
106
+ ?>
107
+ >
108
+ <p>
109
+ <label>
110
+ <?php esc_html_e( 'Maximum level of child pages to display', 'advanced-sidebar-menu' ); ?>:</label>
111
+ <select
112
+ name="<?php echo esc_attr( $widget->get_field_name( self::LEVELS ) ); ?>">
113
+ <option value="100">
114
+ <?php esc_html_e( ' - All - ', 'advanced-sidebar-menu' ); ?>
115
+ </option>
116
+ <?php
117
+ for ( $i = 1; $i < 10; $i ++ ) {
118
+ ?>
119
+ <option
120
+ value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, (int) $instance[ self::LEVELS ] ); ?>>
121
+ <?php echo esc_html( $i ); ?>
122
+ </option>
123
+
124
+ <?php
125
+ }
126
+ ?>
127
+ </select>
128
+ </p>
129
+ </div>
130
+
131
+ <?php do_action( 'advanced-sidebar-menu/widget/page/display-box', $instance, $widget ); ?>
132
+
133
+ </div>
134
+ <?php
135
+ }
136
+
137
+ /**
138
+ *
139
+ * @param array $instance
140
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
141
+ *
142
+ * @return void
143
+ */
144
+ public function box_styles( array $instance, $widget ) {
145
+ ?>
146
+ <div class="advanced-sidebar-menu-column-box">
147
+ <p>
148
+ <?php $widget->checkbox( self::USE_PLUGIN_STYLES ); ?>
149
+ <label>
150
+ <?php esc_html_e( "Use this plugin's default styling", 'advanced-sidebar-menu' ); ?>
151
+ </label>
152
+ </p>
153
+ <?php do_action( 'advanced-sidebar-menu/widget/page/styles-box', $instance, $widget ); ?>
154
+ </div>
155
+ <?php
156
+ }
157
+
158
+ /**
159
+ *
160
+ * @param array $instance
161
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
162
+ *
163
+ * @return void
164
+ */
165
+ public function box_order( array $instance, $widget ) {
166
+ ?>
167
+ <div class="advanced-sidebar-menu-column-box">
168
+
169
+ <p>
170
+ <label>
171
+ <?php esc_html_e( 'Order by', 'advanced-sidebar-menu' ); ?>:
172
+ </label>
173
+ <select
174
+ id="<?php echo esc_attr( $widget->get_field_id( self::ORDER_BY ) ); ?>"
175
+ name="<?php echo esc_attr( $widget->get_field_name( self::ORDER_BY ) ); ?>">
176
+ <?php
177
+ $order_by = (array) apply_filters(
178
+ 'advanced-sidebar-menu/widget/page/order-by-options',
179
+ array(
180
+ 'menu_order' => 'Page Order',
181
+ 'post_title' => 'Title',
182
+ 'post_date' => 'Published Date',
183
+ )
184
+ );
185
+
186
+ foreach ( $order_by as $key => $order ) {
187
+ printf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( $instance[ self::ORDER_BY ], $key, false ), esc_html( $order ) );
188
+ }
189
+ ?>
190
+ </select>
191
+ </p>
192
+ <?php do_action( 'advanced-sidebar-menu/widget/page/order-box', $instance, $widget ); ?>
193
+
194
+ </div>
195
+ <?php
196
+ }
197
+
198
+ /**
199
+ *
200
+ * @param array $instance
201
+ * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
202
+ *
203
+ * @return void
204
+ */
205
+ public function box_exclude( array $instance, $widget ) {
206
+ ?>
207
+ <div class="advanced-sidebar-menu-column-box">
208
+ <p>
209
+ <label>
210
+ <?php esc_html_e( 'Pages to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
211
+ </label>
212
+ <input
213
+ id="<?php echo esc_attr( $widget->get_field_id( self::EXCLUDE ) ); ?>"
214
+ name="<?php echo esc_attr( $widget->get_field_name( self::EXCLUDE ) ); ?>"
215
+ class="widefat"
216
+ type="text"
217
+ value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
218
+ </p>
219
+ <?php
220
+ do_action( 'advanced-sidebar-menu/widget/page/exclude-box', $instance, $widget );
221
+ ?>
222
+ </div>
223
+ <?php
224
+ }
225
+
226
+
227
+ /**
228
+ * Form
229
+ *
230
+ * @since 7.2.1
231
+ *
232
+ * @param array $instance
233
+ *
234
+ * @return void
235
+ */
236
+ public function form( $instance ) {
237
+ $instance = $this->set_instance( $instance, self::$defaults );
238
+ do_action( 'advanced-sidebar-menu/widget/page/before-form', $instance, $this );
239
+ ?>
240
+ <p xmlns="http://www.w3.org/1999/html">
241
+ <label>
242
+ <?php esc_html_e( 'Title', 'advanced-sidebar-menu' ); ?>:
243
+ </label>
244
+
245
+ <input
246
+ id="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>"
247
+ name="<?php echo esc_attr( $this->get_field_name( self::TITLE ) ); ?>"
248
+ class="widefat"
249
+ type="text"
250
+ value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
251
+ </p>
252
+ <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-left">
253
+ <?php
254
+ do_action( 'advanced-sidebar-menu/widget/page/left-column', $instance, $this );
255
+ if ( has_action( 'advanced_sidebar_menu_page_widget_form' ) ) {
256
+ ?>
257
+ <div class="advanced-sidebar-menu-column-box">
258
+ <?php do_action( 'advanced_sidebar_menu_page_widget_form', $this->get_field_id( 'parent_only' ), $this, $instance ); ?>
259
+ </div>
260
+ <?php
261
+ }
262
+ ?>
263
+ </div>
264
+ <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
265
+ <?php
266
+
267
+ // @deprecated action
268
+ do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
269
+
270
+ do_action( 'advanced-sidebar-menu/widget/page/right-column', $instance, $this );
271
+ ?>
272
+ </div>
273
+ <div class="advanced-sidebar-menu-full-width"><!-- clear --></div>
274
+ <?php
275
+ do_action( 'advanced-sidebar-menu/widget/page/after-form', $instance, $this );
276
+ }
277
+
278
+
279
+ /**
280
+ * Update
281
+ *
282
+ * @param array $new_instance
283
+ * @param array $old_instance
284
+ *
285
+ * @return array|mixed
286
+ */
287
+ public function update( $new_instance, $old_instance ) {
288
+ if ( isset( $new_instance['exclude'] ) ) {
289
+ $new_instance['exclude'] = wp_strip_all_tags( $new_instance['exclude'] );
290
+ }
291
+
292
+ return apply_filters( 'advanced_sidebar_menu_page_widget_update', $new_instance, $old_instance );
293
+ }
294
+
295
+
296
+ /**
297
+ * Widget Output
298
+ *
299
+ * @since 7.0.0
300
+ *
301
+ * @see \Advanced_Sidebar_Menu_Menus_Page
302
+ *
303
+ * @param array $args
304
+ * @param array $instance
305
+ *
306
+ * @return void
307
+ */
308
+ public function widget( $args, $instance ) {
309
+ $instance = wp_parse_args( $instance, self::$defaults );
310
+ $asm = Advanced_Sidebar_Menu_Menus_Page::factory( $instance, $args );
311
+
312
+ do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
313
+
314
+ $asm->render();
315
+
316
+ }
317
+ }
7.6.1/src/Widget/Widget.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Advanced_Sidebar_Menu__Widget__Widget
4
+ *
5
+ * @author Mat Lipe
6
+ *
7
+ * @since 7.2.0
8
+ */
9
+ abstract class Advanced_Sidebar_Menu__Widget__Widget extends WP_Widget {
10
+ /**
11
+ * The current widget instance
12
+ *
13
+ * @var array
14
+ */
15
+ protected $_instance;
16
+
17
+
18
+ /**
19
+ * Store the instance to this class.
20
+ * We do this manually because there are filters etc which
21
+ * hit the instance before we get to self::form() and self::widget()
22
+ *
23
+ * @see WP_Widget::form_callback()
24
+ *
25
+ * @param array $instance - widget settings.
26
+ * @param array $defaults - defaults for all widgets.
27
+ *
28
+ * @since 7.2.0
29
+ *
30
+ * @return array
31
+ */
32
+ protected function set_instance( array $instance, array $defaults ) {
33
+ $instance = wp_parse_args( $instance, $defaults );
34
+ $this->_instance = $instance;
35
+
36
+ return $instance;
37
+
38
+ }
39
+
40
+
41
+ /**
42
+ * Checks if a widgets checkbox is checked.
43
+ *
44
+ * Checks first for a value then verifies the value = checked
45
+ *
46
+ * @param string $name - name of checkbox.
47
+ *
48
+ * @since 7.2.0
49
+ *
50
+ * @return bool
51
+ */
52
+ public function checked( $name ) {
53
+ return isset( $this->_instance[ $name ] ) && 'checked' === $this->_instance[ $name ];
54
+ }
55
+
56
+
57
+ /**
58
+ * Hide an element_key if a controlling_checkbox is checked.
59
+ *
60
+ * @param string $controlling_checkbox - Name of controlling_checkbox field which controls whether to hide this element or not.
61
+ * @param string $element_key - Match the `element_to_reveal` passed to $this->checkbox() for the checkbox which controls this.
62
+ * @param bool $reverse - hide on check instead of show on check.
63
+ *
64
+ * @todo Convert all uses of this method to supply the $element_key
65
+ *
66
+ * @since 7.2.0
67
+ * @since 7.2.2 Added the `element_key` argument.
68
+ *
69
+ * @return void
70
+ */
71
+ public function hide_element( $controlling_checkbox, $element_key = null, $reverse = false ) {
72
+ $hide = false;
73
+ if ( ( $reverse && $this->checked( $controlling_checkbox ) ) || ( ! $reverse && ! $this->checked( $controlling_checkbox ) ) ) {
74
+ $hide = true;
75
+ }
76
+
77
+ if ( null !== $element_key ) {
78
+ ?> data-js="<?php echo esc_attr( $this->get_field_id( $element_key ) ); ?>"
79
+ <?php
80
+ }
81
+ // Append the hide to a global variable so it can be picked up only if the advanced-sidebar-menu JS is present.
82
+ // Prevents hiding of elements when widgets are loaded in unique ways like ajax.
83
+ if ( $hide ) {
84
+ ?>
85
+ data-advanced-sidebar-menu-hide="1"
86
+ <?php
87
+ }
88
+ }
89
+
90
+
91
+ /**
92
+ * Outputs a <input type="checkbox" with id and name filled
93
+ *
94
+ * @param string $name - name of field.
95
+ * @param string|null $element_to_reveal - element to reveal/hide when box is checked/unchecked.
96
+ *
97
+ * @since 7.2.0
98
+ */
99
+ public function checkbox( $name, $element_to_reveal = null ) {
100
+ if ( empty( $this->_instance[ $name ] ) ) {
101
+ $this->_instance[ $name ] = null;
102
+ }
103
+
104
+ ?>
105
+ <input
106
+ id="<?php echo esc_attr( $this->get_field_id( $name ) ); ?>"
107
+ name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>"
108
+ type="checkbox"
109
+ value="checked"
110
+ data-js="advanced-sidebar-menu/widget/<?php echo esc_attr( $this->id_base ); ?>/<?php echo esc_attr( $name ); ?>"
111
+ <?php echo ( null !== $element_to_reveal ) ? 'onclick="asm_reveal_element( \'' . esc_attr( $this->get_field_id( $element_to_reveal ) ) . '\')"' : ''; ?>
112
+ <?php echo esc_html( $this->_instance[ $name ] ); ?>
113
+ />
114
+ <?php
115
+
116
+ }
117
+ }
7.6.1/views/category_list.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Output of the Advanced Sidebar Categories Widget
4
+ *
5
+ * @since 7.4.7
6
+ * @package advanced-sidebar-menu
7
+ *
8
+ * To edit create a file named category_list.php and put in a folder in the your
9
+ * theme called 'advanced-sidebar-menu' copy the contents of the file into that file and edit at will
10
+ *
11
+ * @notice Do NOT edit this file in this location or it will break on update
12
+ */
13
+
14
+ $current_menu = Advanced_Sidebar_Menu_Menus_Category::get_current();
15
+ $child_terms = $current_menu->get_child_terms();
16
+ $content = '';
17
+
18
+ // Display parent category.
19
+ if ( $current_menu->include_parent() ) {
20
+ $content .= '<ul class="parent-sidebar-menu">';
21
+
22
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_PARENT );
23
+ $content .= $current_menu->openListItem( wp_list_categories( $list_args ) );
24
+ }
25
+
26
+ if ( ! empty( $child_terms ) ) {
27
+ $content .= '<ul class="child-sidebar-menu">';
28
+
29
+ // Always display child categories.
30
+ if ( $current_menu->display_all() ) {
31
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_DISPLAY_ALL );
32
+ $content .= wp_list_categories( $list_args );
33
+
34
+ } else {
35
+ foreach ( $child_terms as $_term ) {
36
+ // Child terms.
37
+ if ( $current_menu->is_first_level_term( $_term ) ) {
38
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_CHILD, $_term );
39
+ $content .= $current_menu->openListItem( wp_list_categories( $list_args ) );
40
+
41
+ // Grandchild terms.
42
+ if ( $current_menu->is_current_term_ancestor( $_term ) && $current_menu->has_children( $_term ) ) {
43
+ $content .= '<ul class="grandchild-sidebar-menu children">';
44
+
45
+ $list_args = $current_menu->get_list_categories_args( Advanced_Sidebar_Menu_Menus_Category::LEVEL_GRANDCHILD, $_term );
46
+ $content .= wp_list_categories( $list_args );
47
+
48
+ $content .= '</ul>';
49
+ }
50
+
51
+ $content .= '</li>';
52
+ }
53
+ }
54
+ }
55
+
56
+ $content .= '</ul><!-- End .child-sidebar-menu -->';
57
+ }
58
+
59
+ if ( $current_menu->include_parent() ) {
60
+ $content .= '</li></ul><!-- End .parent-sidebar-menu -->';
61
+ }
62
+
63
+ return $content;
7.6.1/views/page_list.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Output of the Advanced Sidebar Page Widget
4
+ *
5
+ * @author Mat Lipe
6
+ *
7
+ * @since 7.5.0
8
+ * @package advanced-sidebar-menu
9
+ *
10
+ * @example to edit, create a file named page_list.php and
11
+ * put in a folder in the your theme called 'advanced-sidebar-menu.
12
+ * Copy the contents of the file into that file and edit at will.
13
+ *
14
+ * @notice Do not edit this file in its original location or it will break on upgrade
15
+ */
16
+
17
+ $current_menu = Advanced_Sidebar_Menu_Menus_Page::get_current();
18
+ $list_pages = Advanced_Sidebar_Menu_List_Pages::factory( $current_menu );
19
+ $child_pages = $list_pages->get_child_pages( $current_menu->get_top_parent_id(), true );
20
+ $content = '';
21
+
22
+ $current_menu->title();
23
+
24
+ // Display parent page.
25
+ if ( $current_menu->include_parent() ) {
26
+ $content .= '<ul class="parent-sidebar-menu" >';
27
+ $list_args = $list_pages->get_args( Advanced_Sidebar_Menu_Menus_Page::LEVEL_PARENT );
28
+ $content .= wp_list_pages( $list_args );
29
+ }
30
+
31
+ if ( ! empty( $child_pages ) ) {
32
+ $content .= '<ul class="child-sidebar-menu">';
33
+ // Child and grandchild pages.
34
+ $content .= $list_pages->list_pages();
35
+ $content .= '</ul><!-- End .child-sidebar-menu -->';
36
+
37
+ }
38
+ if ( $current_menu->include_parent() ) {
39
+ $content .= '</li></ul><!-- End .parent-sidebar-menu -->';
40
+ }
41
+
42
+ return $content;
7.6.1/views/sidebar-menu.css ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
20
+
21
+ .advanced-sidebar-menu ul li{
22
+ list-style:none;
23
+ margin: 0;
24
+ }
25
+
26
+ .advanced-sidebar-menu li.current_page_item{
27
+ list-style-type: disc;
28
+ }
29
+
30
+ .advanced-sidebar-menu li.current_page_item a{
31
+ font-weight: bold;
32
+ }
33
+
34
+ .advanced-sidebar-menu li.current_page_item li a{
35
+ font-weight: normal;
36
+ }
advanced-sidebar-menu.php CHANGED
@@ -4,7 +4,7 @@
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.6.1
8
  * Author URI: https://matlipe.com
9
  * Text Domain: advanced-sidebar-menu
10
  *
@@ -15,7 +15,7 @@ if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
15
  return;
16
  }
17
 
18
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.6.1' );
19
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
 
21
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
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.6.2
8
  * Author URI: https://matlipe.com
9
  * Text Domain: advanced-sidebar-menu
10
  *
15
  return;
16
  }
17
 
18
+ define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.6.2' );
19
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
20
 
21
  if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
readme.txt CHANGED
@@ -4,9 +4,9 @@ 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.8.0
7
- Tested up to: 5.2.2
8
- Requires PHP: 5.4.4
9
- Stable tag: 7.6.1
10
 
11
  == Description ==
12
 
@@ -16,7 +16,7 @@ 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 link text, excluding of pages, category ordering, accordions, custom post types, custom taxonomies, and so much more!</strong>
18
 
19
- <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 3.7.0</a> is now available with support to exclude and change titles of navigation menu items using each page's settings!</blockquote>
20
 
21
  <h4>Features</h4>
22
  * Page and Category widgets.
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.8.0
7
+ Tested up to: 5.2.3
8
+ Requires PHP: 5.6.0
9
+ Stable tag: 7.6.2
10
 
11
  == Description ==
12
 
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 link text, excluding of pages, category ordering, accordions, custom post types, custom taxonomies, and so much more!</strong>
18
 
19
+ <blockquote><a href="https://matlipe.com/product/advanced-sidebar-menu-pro/" target="_blank">Pro version 3.9.0</a> is now available with support to exclude and change titles of navigation menu items using each page's settings!</blockquote>
20
 
21
  <h4>Features</h4>
22
  * Page and Category widgets.