Advanced Sidebar Menu - Version 8.0.0

Version Description

Major version update. See migration guide if you are extending the plugin's functionality via action, filters, or calling plugin classes.

  • Entirely new code structure.
  • Removed all deprecated code and filters.
  • Improved filter and action names.
  • Improved performance.
  • Remove default plugin styling.
Download this release

Release Info

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

Code changes from version 7.7.4 to 8.0.0

advanced-sidebar-menu.php CHANGED
@@ -4,40 +4,55 @@
4
  * Plugin URI: https://onpointplugins.com/advanced-sidebar-menu/
5
  * Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
6
  * Author: OnPoint Plugins
7
- * Version: 7.7.4
8
  * Author URI: https://onpointplugins.com
9
  * Text Domain: advanced-sidebar-menu
10
  *
11
  * @package advanced-sidebar-menu
12
  */
13
 
14
- use Advanced_Sidebar_Menu\Scripts;
15
- use Advanced_Sidebar_Menu\Traits\Singleton;
16
-
17
  if ( defined( 'ADVANCED_SIDEBAR_BASIC_VERSION' ) ) {
18
  return;
19
  }
20
 
21
- define( 'ADVANCED_SIDEBAR_BASIC_VERSION', '7.7.4' );
 
22
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
23
  define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
24
 
25
- if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
26
- /**
27
- * Load the plugin
28
- *
29
- * @return void
30
- */
31
- function advanced_sidebar_menu_load() {
32
- Advanced_Sidebar_Menu_Core::init();
33
- Advanced_Sidebar_Menu_Cache::init();
34
- Advanced_Sidebar_Menu_Debug::init();
35
- Scripts::init();
36
- }
 
37
 
38
- add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
 
 
41
  /**
42
  * Autoload classes from PSR4 src directory
43
  * Mirrored after Composer dump-autoload for performance
@@ -48,27 +63,29 @@ if ( ! function_exists( 'advanced_sidebar_menu_load' ) ) {
48
  */
49
  function advanced_sidebar_menu_autoload( $class ) {
50
  $classes = [
51
- // widgets.
52
- 'Advanced_Sidebar_Menu__Widget__Widget' => 'Widget/Widget.php',
53
- 'Advanced_Sidebar_Menu_Widget_Page' => 'Widget/Page.php',
54
- 'Advanced_Sidebar_Menu_Widget_Category' => 'Widget/Category.php',
55
-
56
- // core.
57
- 'Advanced_Sidebar_Menu_Cache' => 'Cache.php',
58
- 'Advanced_Sidebar_Menu_Core' => 'Core.php',
59
- 'Advanced_Sidebar_Menu_Debug' => 'Debug.php',
60
- 'Advanced_Sidebar_Menu_List_Pages' => 'List_Pages.php',
61
- 'Advanced_Sidebar_Menu_Menu' => 'Menu.php',
62
- 'Advanced_Sidebar_Menu_Page_Walker' => 'Page_Walker.php',
63
- Scripts::class => 'Scripts.php',
64
-
65
- // menus.
66
- 'Advanced_Sidebar_Menu_Menus_Category' => 'Menus/Category.php',
67
- 'Advanced_Sidebar_Menu_Menus_Abstract' => 'Menus/Abstract.php',
68
- 'Advanced_Sidebar_Menu_Menus_Page' => 'Menus/Page.php',
69
 
70
  // Traits.
71
- Singleton::class => 'Traits/Singleton.php',
 
 
 
 
72
  ];
73
  if ( isset( $classes[ $class ] ) ) {
74
  require __DIR__ . '/src/' . $classes[ $class ];
@@ -77,7 +94,6 @@ function advanced_sidebar_menu_autoload( $class ) {
77
 
78
  spl_autoload_register( 'advanced_sidebar_menu_autoload' );
79
 
80
-
81
  add_action( 'plugins_loaded', 'advanced_sidebar_menu_translate' );
82
  /**
83
  * Load translations
@@ -88,7 +104,6 @@ function advanced_sidebar_menu_translate() {
88
  load_plugin_textdomain( 'advanced-sidebar-menu', false, 'advanced-sidebar-menu/languages' );
89
  }
90
 
91
-
92
  add_action( 'advanced-sidebar-menu/widget/category/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
93
  add_action( 'advanced-sidebar-menu/widget/page/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
94
  add_action( 'advanced-sidebar-menu/widget/page/after-form', 'advanced_sidebar_menu_widget_docs', 99, 2 );
@@ -101,10 +116,13 @@ add_action( 'advanced-sidebar-menu/widget/category/after-form', 'advanced_sideba
101
  * @param WP_Widget $widget - Current widget.
102
  */
103
  function advanced_sidebar_menu_widget_docs( $instance, WP_Widget $widget ) {
104
- $anchor = 'advanced_sidebar_menu_category' === $widget->id_base ? 'categories-menu' : 'pages-menu';
105
  ?>
106
  <p style="text-align: right">
107
- <a href="https://onpointplugins.com/advanced-sidebar-menu/#advanced-sidebar-<?php echo esc_attr( $anchor ); ?>" target="blank">
 
 
 
108
  <?php esc_html_e( 'widget documentation', 'advanced-sidebar-menu' ); ?>
109
  </a>
110
  </p>
@@ -115,22 +133,30 @@ function advanced_sidebar_menu_widget_docs( $instance, WP_Widget $widget ) {
115
  * Notify widget users about the PRO options
116
  *
117
  * @param array $instance - widget instance.
118
- * @param WP_Widget $widget - widget class.
119
  *
120
  * @return void
121
  */
122
  function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widget ) {
123
  if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
 
 
 
 
 
 
 
 
124
  return;
125
  }
126
  ?>
127
  <div class="advanced-sidebar-menu-column-box">
128
- <h3><?php esc_html_e( 'Checkout Advanced Sidebar Menu Pro!', 'advanced-sidebar-menu' ); ?></h3>
129
  <p>
130
  <strong>
131
  <?php
132
  /* translators: {<a>}{</a>} links to https://onpointplugins.com/product/advanced-sidebar-menu-pro/ */
133
- 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://onpointplugins.com/product/advanced-sidebar-menu-pro/">', '</a>' );
134
  ?>
135
  </strong>
136
  <ol style="list-style: disc">
@@ -138,8 +164,7 @@ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widge
138
  <li><?php esc_html_e( 'Accordion menu support.', 'advanced-sidebar-menu' ); ?></li>
139
  <li><?php esc_html_e( 'Click and drag menu styling including bullets, colors, sizes, block styles, borders, and border colors.', 'advanced-sidebar-menu' ); ?></li>
140
  <?php
141
- // page widget options.
142
- if ( 'advanced_sidebar_menu' === $widget->id_base ) {
143
  ?>
144
  <li><?php esc_html_e( "Ability to customize each page's link text.", 'advanced-sidebar-menu' ); ?></li>
145
  <li><?php esc_html_e( 'Ability to exclude a page from all menus using a simple checkbox.', 'advanced-sidebar-menu' ); ?></li>
@@ -147,7 +172,6 @@ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widge
147
  <li><?php esc_html_e( 'Ability to select and display custom post types.', 'advanced-sidebar-menu' ); ?></li>
148
  <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>
149
  <?php
150
- // category widget options.
151
  } else {
152
  ?>
153
  <li><?php esc_html_e( 'Link ordering for the category widget.', 'advanced-sidebar-menu' ); ?></li>
@@ -163,3 +187,25 @@ function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widge
163
  </div>
164
  <?php
165
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  * Plugin URI: https://onpointplugins.com/advanced-sidebar-menu/
5
  * Description: Creates dynamic menus based on parent/child relationship of your pages or categories.
6
  * Author: OnPoint Plugins
7
+ * Version: 8.0.0
8
  * Author URI: https://onpointplugins.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', '8.0.0' );
19
+ define( 'ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION', '8.0.0' );
20
  define( 'ADVANCED_SIDEBAR_DIR', plugin_dir_path( __FILE__ ) );
21
  define( 'ADVANCED_SIDEBAR_MENU_URL', plugin_dir_url( __FILE__ ) );
22
 
23
+ use Advanced_Sidebar_Menu\Cache;
24
+ use Advanced_Sidebar_Menu\Core;
25
+ use Advanced_Sidebar_Menu\Debug;
26
+ use Advanced_Sidebar_Menu\List_Pages;
27
+ use Advanced_Sidebar_Menu\Menus\Category;
28
+ use Advanced_Sidebar_Menu\Menus\Menu_Abstract;
29
+ use Advanced_Sidebar_Menu\Menus\Page;
30
+ use Advanced_Sidebar_Menu\Scripts;
31
+ use Advanced_Sidebar_Menu\Traits\Singleton;
32
+ use Advanced_Sidebar_Menu\Walkers\Page_Walker;
33
+ use Advanced_Sidebar_Menu\Widget\Category as Widget_Category;
34
+ use Advanced_Sidebar_Menu\Widget\Page as Widget_Page;
35
+ use Advanced_Sidebar_Menu\Widget\Widget_Abstract;
36
 
37
+ /**
38
+ * Load the plugin
39
+ *
40
+ * @return void
41
+ */
42
+ function advanced_sidebar_menu_load() {
43
+ Core::init();
44
+ Cache::init();
45
+ Debug::init();
46
+ Scripts::init();
47
+
48
+ if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) && version_compare( ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION, ADVANCED_SIDEBAR_MENU_PRO_VERSION, '>' ) ) {
49
+ add_action( 'admin_notices', 'advanced_sidebar_menu_pro_version_warning' );
50
+ remove_action( 'plugins_loaded', 'advanced_sidebar_menu_pro_init', 11 );
51
+ }
52
  }
53
 
54
+ add_action( 'plugins_loaded', 'advanced_sidebar_menu_load' );
55
+
56
  /**
57
  * Autoload classes from PSR4 src directory
58
  * Mirrored after Composer dump-autoload for performance
63
  */
64
  function advanced_sidebar_menu_autoload( $class ) {
65
  $classes = [
66
+ // Widgets.
67
+ Widget_Abstract::class => 'Widget/Widget_Abstract.php',
68
+ Widget_Page::class => 'Widget/Page.php',
69
+ Widget_Category::class => 'Widget/Category.php',
70
+
71
+ // Core.
72
+ Cache::class => 'Cache.php',
73
+ Core::class => 'Core.php',
74
+ Debug::class => 'Debug.php',
75
+ List_Pages::class => 'List_Pages.php',
76
+ Scripts::class => 'Scripts.php',
77
+
78
+ // Menus.
79
+ Category::class => 'Menus/Category.php',
80
+ Menu_Abstract::class => 'Menus/Menu_Abstract.php',
81
+ Page::class => 'Menus/Page.php',
 
 
82
 
83
  // Traits.
84
+ Singleton::class => 'Traits/Singleton.php',
85
+
86
+ // Walkers.
87
+ Page_Walker::class => 'Walkers/Page_Walker.php',
88
+
89
  ];
90
  if ( isset( $classes[ $class ] ) ) {
91
  require __DIR__ . '/src/' . $classes[ $class ];
94
 
95
  spl_autoload_register( 'advanced_sidebar_menu_autoload' );
96
 
 
97
  add_action( 'plugins_loaded', 'advanced_sidebar_menu_translate' );
98
  /**
99
  * Load translations
104
  load_plugin_textdomain( 'advanced-sidebar-menu', false, 'advanced-sidebar-menu/languages' );
105
  }
106
 
 
107
  add_action( 'advanced-sidebar-menu/widget/category/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
108
  add_action( 'advanced-sidebar-menu/widget/page/right-column', 'advanced_sidebar_menu_upgrade_notice', 1, 2 );
109
  add_action( 'advanced-sidebar-menu/widget/page/after-form', 'advanced_sidebar_menu_widget_docs', 99, 2 );
116
  * @param WP_Widget $widget - Current widget.
117
  */
118
  function advanced_sidebar_menu_widget_docs( $instance, WP_Widget $widget ) {
119
+ $anchor = \Advanced_Sidebar_Menu\Widget\Category::NAME === $widget->id_base ? 'categories-menu' : 'pages-menu';
120
  ?>
121
  <p style="text-align: right">
122
+ <a
123
+ href="https://onpointplugins.com/advanced-sidebar-menu/#advanced-sidebar-<?php echo esc_attr( $anchor ); ?>"
124
+ target="_blank"
125
+ rel="noopener noreferrer">
126
  <?php esc_html_e( 'widget documentation', 'advanced-sidebar-menu' ); ?>
127
  </a>
128
  </p>
133
  * Notify widget users about the PRO options
134
  *
135
  * @param array $instance - widget instance.
136
+ * @param WP_Widget $widget - widget class.
137
  *
138
  * @return void
139
  */
140
  function advanced_sidebar_menu_upgrade_notice( array $instance, WP_Widget $widget ) {
141
  if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
142
+ if ( version_compare( ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION, ADVANCED_SIDEBAR_MENU_PRO_VERSION, '>' ) ) {
143
+ ?>
144
+ <div class="advanced-sidebar-menu-column-box" style="border-color: red">
145
+ <?php advanced_sidebar_menu_pro_version_warning( true ); ?>
146
+ </div>
147
+ <?php
148
+ }
149
+
150
  return;
151
  }
152
  ?>
153
  <div class="advanced-sidebar-menu-column-box">
154
+ <h3><?php esc_html_e( 'Advanced Sidebar Menu PRO!', 'advanced-sidebar-menu' ); ?></h3>
155
  <p>
156
  <strong>
157
  <?php
158
  /* translators: {<a>}{</a>} links to https://onpointplugins.com/product/advanced-sidebar-menu-pro/ */
159
+ 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://onpointplugins.com/product/advanced-sidebar-menu-pro/">', '</a>' );
160
  ?>
161
  </strong>
162
  <ol style="list-style: disc">
164
  <li><?php esc_html_e( 'Accordion menu support.', 'advanced-sidebar-menu' ); ?></li>
165
  <li><?php esc_html_e( 'Click and drag menu styling including bullets, colors, sizes, block styles, borders, and border colors.', 'advanced-sidebar-menu' ); ?></li>
166
  <?php
167
+ if ( \Advanced_Sidebar_Menu\Widget\Page::NAME === $widget->id_base ) {
 
168
  ?>
169
  <li><?php esc_html_e( "Ability to customize each page's link text.", 'advanced-sidebar-menu' ); ?></li>
170
  <li><?php esc_html_e( 'Ability to exclude a page from all menus using a simple checkbox.', 'advanced-sidebar-menu' ); ?></li>
172
  <li><?php esc_html_e( 'Ability to select and display custom post types.', 'advanced-sidebar-menu' ); ?></li>
173
  <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>
174
  <?php
 
175
  } else {
176
  ?>
177
  <li><?php esc_html_e( 'Link ordering for the category widget.', 'advanced-sidebar-menu' ); ?></li>
187
  </div>
188
  <?php
189
  }
190
+
191
+ /**
192
+ * Display a warning if we don't have the required PRO version installed.
193
+ *
194
+ * @param bool $no_banner - Display as "message" banner.
195
+ *
196
+ * @since 8.0.0
197
+ *
198
+ * @return void
199
+ */
200
+ function advanced_sidebar_menu_pro_version_warning( $no_banner = false ) {
201
+ ?>
202
+ <div class="<?php echo true === $no_banner ? '' : 'error'; ?>">
203
+ <p>
204
+ <?php
205
+ /* translators: {%1$s}[<a>]{%2$s}[</a>] https://wordpress.org/plugins/advanced-sidebar-menu/ */ //phpcs:disable
206
+ printf( esc_html_x( 'Advanced Sidebar Menu requires %1$sAdvanced Sidebar Menu PRO%2$s version %3$s+. Please update or deactivate the PRO version.', '{<a>}{</a>}', 'advanced-sidebar-menu' ), '<a target="_blank" rel="noreferrer noopener" href="https://onpointplugins.com/product/advanced-sidebar-menu-pro/">', '</a>', esc_attr( ADVANCED_SIDEBAR_MENU_REQUIRED_PRO_VERSION ) );
207
+ ?>
208
+ </p>
209
+ </div>
210
+ <?php
211
+ }
languages/advanced-sidebar-menu-de_DE.mo CHANGED
Binary file
languages/advanced-sidebar-menu-de_DE.po CHANGED
@@ -1,8 +1,8 @@
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 <support@onpointplugins.com>\n"
7
  "Language-Team: \n"
8
  "Language: de\n"
@@ -10,7 +10,7 @@ msgstr ""
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"
@@ -21,32 +21,36 @@ msgstr ""
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://onpointplugins.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."
@@ -54,17 +58,17 @@ 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."
@@ -72,12 +76,12 @@ 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."
@@ -85,120 +89,128 @@ 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
 
@@ -219,12 +231,21 @@ msgstr ""
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://onpointplugins.com"
227
  msgstr "https://onpointplugins.com"
228
 
 
 
 
 
 
 
 
 
 
229
  #~ msgid "Use this Plugin's Styling"
230
  #~ msgstr "Benutze das Plugin Styling"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Advanced Sidebar Menu\n"
4
+ "POT-Creation-Date: 2020-07-10 21:16-0600\n"
5
+ "PO-Revision-Date: 2020-07-10 21:16-0600\n"
6
  "Last-Translator: Mat Lipe <support@onpointplugins.com>\n"
7
  "Language-Team: \n"
8
  "Language: de\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.3.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"
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
+ #: advanced-sidebar-menu.php:126
25
+ msgid "widget documentation"
26
+ msgstr "widget-dokumentation"
27
+
28
+ #: advanced-sidebar-menu.php:146
29
+ msgid "Advanced Sidebar Menu PRO!"
30
+ msgstr "Advanced Sidebar Menu PRO!"
31
 
32
  #. translators: {<a>}{</a>} links to https://onpointplugins.com/product/advanced-sidebar-menu-pro/
33
+ #: advanced-sidebar-menu.php:151
34
  #, php-format
35
  msgctxt "{<a>}{</a>}"
36
  msgid ""
37
+ "Upgrade to %1$sAdvanced Sidebar Menu PRO%2$s for these features and so much "
38
  "more!"
39
  msgstr ""
40
+ "Upgrade auf %1$sAdvanced Sidebar Menu PRO%2$s für diese Funktionen und "
41
  "vieles mehr!"
42
 
43
+ #: advanced-sidebar-menu.php:155
44
  msgid "Priority support, including access to Members Only Support Area."
45
  msgstr ""
46
  "Prioritätsunterstützung, einschließlich Zugang zum Supportbereich für "
47
  "Mitglieder."
48
 
49
+ #: advanced-sidebar-menu.php:156
50
  msgid "Accordion menu support."
51
  msgstr "Akkordeon-Menü-Unterstützung."
52
 
53
+ #: advanced-sidebar-menu.php:157
54
  msgid ""
55
  "Click and drag menu styling including bullets, colors, sizes, block styles, "
56
  "borders, and border colors."
58
  "Klicken und ziehen Sie das Menü-Styling, einschließlich Aufzählungszeichen, "
59
  "Farben, Größen, Blockstile, Rahmen und Rahmenfarben."
60
 
61
+ #: advanced-sidebar-menu.php:161
62
  msgid "Ability to customize each page's link text."
63
  msgstr "Möglichkeit, den Linktext jeder Seite anzupassen."
64
 
65
+ #: advanced-sidebar-menu.php:162
66
  msgid "Ability to exclude a page from all menus using a simple checkbox."
67
  msgstr ""
68
  "Möglichkeit, eine Seite mit einem einfachen Kontrollkästchen aus allen Menüs "
69
  "auszuschließen."
70
 
71
+ #: advanced-sidebar-menu.php:163
72
  msgid ""
73
  "Number of levels of pages to show when always displayed child pages is not "
74
  "checked."
76
  "Anzahl der Seitenebenen, die angezeigt werden sollen, wenn immer "
77
  "untergeordnete Seiten angezeigt werden, ist nicht aktiviert."
78
 
79
+ #: advanced-sidebar-menu.php:164
80
  msgid "Ability to select and display custom post types."
81
  msgstr ""
82
  "Möglichkeit, benutzerdefinierte Beitragstypen auszuwählen und anzuzeigen."
83
 
84
+ #: advanced-sidebar-menu.php:165
85
  msgid ""
86
  "Option to display the current page’s parents, grandparents, and children "
87
  "only, as well as siblings options."
89
  "Option, um die Eltern, Großeltern und Kinder der aktuellen Seite anzuzeigen, "
90
  "sowie Geschwisteroptionen."
91
 
92
+ #: advanced-sidebar-menu.php:169
93
  msgid "Link ordering for the category widget."
94
  msgstr "Verknüpfungsreihenfolge für das Kategorie-Widget."
95
 
96
+ #: advanced-sidebar-menu.php:170
97
  msgid "Ability to select and display custom taxonomies."
98
  msgstr "Möglichkeit, benutzerdefinierte Taxonomien auszuwählen und anzuzeigen."
99
 
100
+ #: advanced-sidebar-menu.php:171
101
  msgid ""
102
  "Ability to display assigned posts or custom post types under categories."
103
  msgstr ""
104
  "Fähigkeit, zugewiesene Beiträge oder benutzerdefinierte Posttypen unter "
105
  "Kategorien anzuzeigen."
106
 
107
+ #: advanced-sidebar-menu.php:175
108
  msgid "Ability to display the widgets everywhere the sidebar displays."
109
  msgstr "Die Fähigkeit, die Widgets überall in der Sidebar-Anzeige anzuzeigen."
110
 
111
+ #: advanced-sidebar-menu.php:176
112
  msgid "Support for custom navigation menus from Appearance -> Menus."
113
  msgstr ""
114
  "Unterstützung für kundenspezifische Navigationsmenüs von Appearance-> Menü."
115
 
116
+ #. translators: {%1$s}[<a>]{%2$s}[</a>] https://wordpress.org/plugins/advanced-sidebar-menu/
117
+ #. phpcs:disable
118
+ #: advanced-sidebar-menu.php:196
119
+ #, php-format
120
+ msgctxt "{<a>}{</a>}"
121
+ msgid ""
122
+ "Advanced Sidebar Menu requires %1$sAdvanced Sidebar Menu PRO%2$s version %3$s"
123
+ "+. Please update or deactivate the PRO version."
124
+ msgstr ""
125
+ "Das Advanced Sidebar Menu erfordert %1$s sAdvanced Sidebar Menu PRO%2$s es "
126
+ "Version %3$s+. Bitte aktualisieren oder deaktivieren Sie die PRO-Version."
127
+
128
+ #: src/Widget/Category.php:52
129
  msgid ""
130
  "Creates a menu of all the categories using the child/parent relationship"
131
  msgstr ""
132
  "Erstellt ein Menü aller Kategorien, die unter Zugrundelegung der Eltern-Kind-"
133
  "Beziehung"
134
 
135
+ #: src/Widget/Category.php:58
136
  msgid "Advanced Sidebar Categories Menu"
137
  msgstr "Advanced Sidebar Kategorien-Menü"
138
 
139
+ #: src/Widget/Category.php:93
140
+ msgid "Display the highest level parent category"
141
  msgstr "Anzeige der übergeordneten Kategorie der höchsten Ebene"
142
 
143
+ #: src/Widget/Category.php:99
144
  msgid "Display menu when there is only the parent category"
145
  msgstr "Menü \"Anzeige\" wird nur die übergeordnete Kategorie"
146
 
147
+ #: src/Widget/Category.php:105
148
  msgid "Always display child categories"
149
  msgstr "Immer untergeordnete Kategorien anzeigen"
150
 
151
+ #: src/Widget/Category.php:111
152
  msgid "Levels of child categories to display"
153
  msgstr "Niveau der Kinderkategorien zu zeigen"
154
 
155
+ #: src/Widget/Category.php:153
 
 
 
 
156
  msgid "Display categories on single posts"
157
  msgstr "Kategorien auf einzelne Beiträge anzeigen"
158
 
159
+ #: src/Widget/Category.php:160
160
  msgid "Display each single post's category"
161
  msgstr "Zeigen Sie die einzelnen Kategorien der einzelnen Posts an"
162
 
163
+ #: src/Widget/Category.php:167
164
  msgid "In a new widget"
165
  msgstr "In einem neuen Widget"
166
 
167
+ #: src/Widget/Category.php:170
168
  msgid "In another list in the same widget"
169
  msgstr "In einer anderen Liste im selben Widget"
170
 
171
+ #: src/Widget/Category.php:196
172
  msgid "Categories to exclude (ids), comma separated"
173
  msgstr "Kategorien ausschließen (Ids), durch Kommata getrennt"
174
 
175
+ #: src/Widget/Category.php:229 src/Widget/Page.php:234
176
  msgid "Title"
177
  msgstr "Titel"
178
 
179
+ #: src/Widget/Page.php:48
180
  msgid "Creates a menu of all the pages using the child/parent relationship"
181
  msgstr ""
182
  "Erstellt ein Menü mit allen Seiten, die die Child / Parent-Beziehung "
183
  "verwenden"
184
 
185
+ #: src/Widget/Page.php:54
186
  msgid "Advanced Sidebar Pages Menu"
187
  msgstr "Advanced Sidebar Seitenmenü"
188
 
189
+ #: src/Widget/Page.php:89
190
  msgid "Display highest level parent page"
191
  msgstr "Zeigt die oberste Seite der obersten Ebene an"
192
 
193
+ #: src/Widget/Page.php:97
194
  msgid "Display menu when there is only the parent page"
195
  msgstr "Menü \"Anzeige\" wird nur die übergeordnete Seite"
196
 
197
+ #: src/Widget/Page.php:104
198
  msgid "Always display child pages"
199
  msgstr "Immer untergeordnete Seiten anzeigen"
200
 
201
+ #: src/Widget/Page.php:117
202
  msgid "Maximum level of child pages to display"
203
  msgstr "Maximale Höhe der zu zeigestellenden Kinderseiten"
204
 
205
+ #: src/Widget/Page.php:123
206
  msgid " - All - "
207
  msgstr " Alle "
208
 
209
+ #: src/Widget/Page.php:161
210
  msgid "Order by"
211
  msgstr "Sortieren nach"
212
 
213
+ #: src/Widget/Page.php:202
214
  msgid "Pages to exclude (ids), comma separated"
215
  msgstr "Auszuschließende Seiten (IDs), durch Kommas getrennt"
216
 
231
  "Kategorien erstellt."
232
 
233
  #. Author of the plugin/theme
234
+ msgid "OnPoint Plugins"
235
+ msgstr ""
236
 
237
  #. Author URI of the plugin/theme
238
  msgid "https://onpointplugins.com"
239
  msgstr "https://onpointplugins.com"
240
 
241
+ #~ msgid "Checkout Advanced Sidebar Menu Pro!"
242
+ #~ msgstr "Kasse Advanced Sidebar Menu Pro!"
243
+
244
+ #~ msgid "Use this plugin's default styling"
245
+ #~ msgstr "Verwenden Sie das Standardstyling dieses Plugins"
246
+
247
+ #~ msgid "Mat Lipe"
248
+ #~ msgstr "Mat Lipe"
249
+
250
  #~ msgid "Use this Plugin's Styling"
251
  #~ msgstr "Benutze das Plugin Styling"
languages/advanced-sidebar-menu.pot CHANGED
@@ -3,182 +3,192 @@ 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://onpointplugins.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
 
@@ -197,7 +207,7 @@ msgid ""
197
  msgstr ""
198
 
199
  #. Author of the plugin/theme
200
- msgid "Mat Lipe"
201
  msgstr ""
202
 
203
  #. Author URI of the plugin/theme
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Advanced Sidebar Menu\n"
6
+ "POT-Creation-Date: 2020-07-10 21:16-0600\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.3.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;"
20
+ "_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
 
24
+ #: advanced-sidebar-menu.php:126
25
+ msgid "widget documentation"
26
+ msgstr ""
27
+
28
+ #: advanced-sidebar-menu.php:146
29
+ msgid "Advanced Sidebar Menu PRO!"
30
  msgstr ""
31
 
32
  #. translators: {<a>}{</a>} links to https://onpointplugins.com/product/advanced-sidebar-menu-pro/
33
+ #: advanced-sidebar-menu.php:151
34
  #, php-format
35
  msgctxt "{<a>}{</a>}"
36
  msgid ""
37
+ "Upgrade to %1$sAdvanced Sidebar Menu PRO%2$s for these features and so much "
38
  "more!"
39
  msgstr ""
40
 
41
+ #: advanced-sidebar-menu.php:155
42
  msgid "Priority support, including access to Members Only Support Area."
43
  msgstr ""
44
 
45
+ #: advanced-sidebar-menu.php:156
46
  msgid "Accordion menu support."
47
  msgstr ""
48
 
49
+ #: advanced-sidebar-menu.php:157
50
  msgid ""
51
  "Click and drag menu styling including bullets, colors, sizes, block styles, "
52
  "borders, and border colors."
53
  msgstr ""
54
 
55
+ #: advanced-sidebar-menu.php:161
56
  msgid "Ability to customize each page's link text."
57
  msgstr ""
58
 
59
+ #: advanced-sidebar-menu.php:162
60
  msgid "Ability to exclude a page from all menus using a simple checkbox."
61
  msgstr ""
62
 
63
+ #: advanced-sidebar-menu.php:163
64
  msgid ""
65
  "Number of levels of pages to show when always displayed child pages is not "
66
  "checked."
67
  msgstr ""
68
 
69
+ #: advanced-sidebar-menu.php:164
70
  msgid "Ability to select and display custom post types."
71
  msgstr ""
72
 
73
+ #: advanced-sidebar-menu.php:165
74
  msgid ""
75
  "Option to display the current page’s parents, grandparents, and children "
76
  "only, as well as siblings options."
77
  msgstr ""
78
 
79
+ #: advanced-sidebar-menu.php:169
80
  msgid "Link ordering for the category widget."
81
  msgstr ""
82
 
83
+ #: advanced-sidebar-menu.php:170
84
  msgid "Ability to select and display custom taxonomies."
85
  msgstr ""
86
 
87
+ #: advanced-sidebar-menu.php:171
88
  msgid ""
89
  "Ability to display assigned posts or custom post types under categories."
90
  msgstr ""
91
 
92
+ #: advanced-sidebar-menu.php:175
93
  msgid "Ability to display the widgets everywhere the sidebar displays."
94
  msgstr ""
95
 
96
+ #: advanced-sidebar-menu.php:176
97
  msgid "Support for custom navigation menus from Appearance -> Menus."
98
  msgstr ""
99
 
100
+ #. translators: {%1$s}[<a>]{%2$s}[</a>] https://wordpress.org/plugins/advanced-sidebar-menu/
101
+ #. phpcs:disable
102
+ #: advanced-sidebar-menu.php:196
103
+ #, php-format
104
+ msgctxt "{<a>}{</a>}"
105
+ msgid ""
106
+ "Advanced Sidebar Menu requires %1$sAdvanced Sidebar Menu PRO%2$s version "
107
+ "%3$s+. Please update or deactivate the PRO version."
108
+ msgstr ""
109
+
110
+ #: src/Widget/Category.php:52
111
  msgid ""
112
  "Creates a menu of all the categories using the child/parent relationship"
113
  msgstr ""
114
 
115
+ #: src/Widget/Category.php:58
116
  msgid "Advanced Sidebar Categories Menu"
117
  msgstr ""
118
 
119
+ #: src/Widget/Category.php:93
120
+ msgid "Display the highest level parent category"
121
  msgstr ""
122
 
123
+ #: src/Widget/Category.php:99
124
  msgid "Display menu when there is only the parent category"
125
  msgstr ""
126
 
127
+ #: src/Widget/Category.php:105
128
  msgid "Always display child categories"
129
  msgstr ""
130
 
131
+ #: src/Widget/Category.php:111
132
  msgid "Levels of child categories to display"
133
  msgstr ""
134
 
135
+ #: src/Widget/Category.php:153
 
 
 
 
136
  msgid "Display categories on single posts"
137
  msgstr ""
138
 
139
+ #: src/Widget/Category.php:160
140
  msgid "Display each single post's category"
141
  msgstr ""
142
 
143
+ #: src/Widget/Category.php:167
144
  msgid "In a new widget"
145
  msgstr ""
146
 
147
+ #: src/Widget/Category.php:170
148
  msgid "In another list in the same widget"
149
  msgstr ""
150
 
151
+ #: src/Widget/Category.php:196
152
  msgid "Categories to exclude (ids), comma separated"
153
  msgstr ""
154
 
155
+ #: src/Widget/Category.php:229 src/Widget/Page.php:234
156
  msgid "Title"
157
  msgstr ""
158
 
159
+ #: src/Widget/Page.php:48
160
  msgid "Creates a menu of all the pages using the child/parent relationship"
161
  msgstr ""
162
 
163
+ #: src/Widget/Page.php:54
164
  msgid "Advanced Sidebar Pages Menu"
165
  msgstr ""
166
 
167
+ #: src/Widget/Page.php:89
168
  msgid "Display highest level parent page"
169
  msgstr ""
170
 
171
+ #: src/Widget/Page.php:97
172
  msgid "Display menu when there is only the parent page"
173
  msgstr ""
174
 
175
+ #: src/Widget/Page.php:104
176
  msgid "Always display child pages"
177
  msgstr ""
178
 
179
+ #: src/Widget/Page.php:117
180
  msgid "Maximum level of child pages to display"
181
  msgstr ""
182
 
183
+ #: src/Widget/Page.php:123
184
  msgid " - All - "
185
  msgstr ""
186
 
187
+ #: src/Widget/Page.php:161
188
  msgid "Order by"
189
  msgstr ""
190
 
191
+ #: src/Widget/Page.php:202
192
  msgid "Pages to exclude (ids), comma separated"
193
  msgstr ""
194
 
207
  msgstr ""
208
 
209
  #. Author of the plugin/theme
210
+ msgid "OnPoint Plugins"
211
  msgstr ""
212
 
213
  #. Author URI of the plugin/theme
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: menus, sidebar menu, hierarchy, category menu, pages menu
6
  Requires at least: 4.8.0
7
  Tested up to: 5.4.2
8
  Requires PHP: 5.6.0
9
- Stable tag: 7.7.4
10
 
11
  == Description ==
12
 
@@ -155,6 +155,15 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
155
 
156
 
157
  == Changelog ==
 
 
 
 
 
 
 
 
 
158
  = 7.7.3 =
159
  * Fix widget info pane links.
160
  * Fix widget editing on mobile devices.
@@ -206,11 +215,11 @@ Yes. Based on whatever page, post, or category you are on, the menu will change
206
  * Kill conflicting backward compatibility with version 5
207
  * Open up more extendability possibilities
208
 
209
- = 6.4.0 =
210
- * Code improvements
211
- * Performance improvements via shared child retrieval
212
 
213
  == Upgrade Notice ==
 
 
 
214
  = 7.7.0 =
215
  Update to support PRO version 3.10.0
216
 
6
  Requires at least: 4.8.0
7
  Tested up to: 5.4.2
8
  Requires PHP: 5.6.0
9
+ Stable tag: 8.0.0
10
 
11
  == Description ==
12
 
155
 
156
 
157
  == Changelog ==
158
+ = 8.0.0 =
159
+ Major version update. See <a href="https://onpointplugins.com/advanced-sidebar-menu/advanced-sidebar-menu-version-8-migration-guide/">migration guide</a> if you are extending the plugin's functionality via action, filters, or calling plugin classes.
160
+
161
+ * Entirely new code structure.
162
+ * Removed all deprecated code and filters.
163
+ * Improved filter and action names.
164
+ * Improved performance.
165
+ * Remove default plugin styling.
166
+
167
  = 7.7.3 =
168
  * Fix widget info pane links.
169
  * Fix widget editing on mobile devices.
215
  * Kill conflicting backward compatibility with version 5
216
  * Open up more extendability possibilities
217
 
 
 
 
218
 
219
  == Upgrade Notice ==
220
+ = 8.0.0 =
221
+ Major version update. Not fully backward compatible with version 7 filters or code. Please see migration guide if you are extending the plugin via code.
222
+
223
  = 7.7.0 =
224
  Update to support PRO version 3.10.0
225
 
src/Cache.php CHANGED
@@ -1,65 +1,62 @@
1
  <?php
2
 
 
 
 
3
 
4
  /**
5
- * Advanced_Sidebar_Menu_Cache
6
  *
7
  * @author OnPoint Plugins
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;
@@ -70,8 +67,8 @@ class Advanced_Sidebar_Menu_Cache {
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
  */
@@ -89,49 +86,12 @@ class Advanced_Sidebar_Menu_Cache {
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
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu;
4
+
5
+ use Advanced_Sidebar_Menu\Traits\Singleton;
6
 
7
  /**
8
+ * Menu Cache
9
  *
10
  * @author OnPoint Plugins
 
 
11
  */
12
+ class Cache {
13
+ use Singleton;
14
+
15
+ const CACHE_GROUP = 'advanced-sidebar-menu';
16
  const CHILD_PAGES_KEY = 'child-pages';
17
 
18
 
19
+ /**
20
+ * Actions.
21
+ */
22
  protected function hook() {
23
+ add_action( 'save_post', [ $this, 'clear_cache_group' ] );
24
  }
25
 
26
 
27
  /**
28
+ * Clear all items in this cache group
29
  *
30
  * @return void
31
  */
32
  public function clear_cache_group() {
33
+ wp_cache_set( 'last_changed', microtime(), self::CACHE_GROUP . ':' . ADVANCED_SIDEBAR_BASIC_VERSION );
 
 
 
 
34
  }
35
 
36
 
37
  /**
38
  * Get unique key for this group
 
39
  *
40
  * @return string
41
  */
42
  public function get_cache_group() {
43
+ $key = wp_cache_get_last_changed( self::CACHE_GROUP . ':' . ADVANCED_SIDEBAR_BASIC_VERSION );
 
 
 
 
44
  return self::CACHE_GROUP . ':' . ADVANCED_SIDEBAR_BASIC_VERSION . ':' . $key;
45
  }
46
 
47
 
48
  /**
49
+ * Retrieve a post's child pages from the cache.
50
+ * If no exist in the cache will return false.
51
  *
52
+ * @param List_Pages $class - Full menu class with all properties set.
53
  *
54
  * @return array|false
55
  */
56
  public function get_child_pages( $class ) {
57
  $key = $this->get_key_from_asm( $class );
58
  $all_child_pages = (array) wp_cache_get( self::CHILD_PAGES_KEY, $this->get_cache_group() );
59
+ if ( isset( $all_child_pages[ $key ] ) ) {
60
  return $all_child_pages[ $key ];
61
  }
62
  return false;
67
  * Add a post and its children to the cache
68
  * Uses a global key for all posts so this appends to an array
69
  *
70
+ * @param List_Pages $class - Full menu class with all properties set.
71
+ * @param array $child_pages - List of child pages to store.
72
  *
73
  * @return void
74
  */
86
  * To guarantee we have a unique id for the cache
87
  * we serialize the whole object and hash it
88
  *
89
+ * @param List_Pages $class - Full menu class with all properties set.
 
90
  *
91
  * @return string
92
  */
93
  private function get_key_from_asm( $class ) {
94
+ $string = serialize( $class ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
95
  return md5( $string );
96
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
src/Core.php CHANGED
@@ -1,60 +1,62 @@
1
  <?php
2
 
 
 
 
 
 
3
 
4
  /**
5
- * Advanced_Sidebar_Menu
6
  *
7
  * @author OnPoint Plugins
8
  * @since 7.0.0
9
- *
10
  */
11
- class Advanced_Sidebar_Menu_Core {
12
- use \Advanced_Sidebar_Menu\Traits\Singleton;
13
 
 
 
 
14
  protected function hook() {
15
- add_action( 'widgets_init', array( $this, 'register_widgets' ) );
16
- }
17
-
18
-
19
- public function register_widgets() {
20
- register_widget( 'Advanced_Sidebar_Menu_Widget_Page' );
21
- register_widget( 'Advanced_Sidebar_Menu_Widget_Category' );
22
  }
23
 
24
 
25
  /**
26
- * The plugin styles are universal
27
- * This ensures that we only include them once on a single request
28
  *
29
  * @return void
30
  */
31
- public function include_plugin_styles() {
32
- ?>
33
- <style>
34
- <?php include_once $this->get_template_part( 'sidebar-menu.css' ); ?>
35
- </style>
36
- <?php
37
  }
38
 
39
 
40
  /**
41
  * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
42
- * or this plugins views folder if one does not exist
43
  *
44
- * @since 6.0.0
45
  *
46
- * @param string $file_name
47
  *
48
  * @return string
49
  */
50
  public function get_template_part( $file_name ) {
51
  $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
52
  if ( empty( $file ) ) {
 
 
 
53
  $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
 
 
 
 
54
  }
55
 
56
- $file = apply_filters( 'advanced_sidebar_menu_template_part', $file, $file_name, $this );
57
-
58
- return $file;
59
  }
60
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu;
4
+
5
+ use Advanced_Sidebar_Menu\Traits\Singleton;
6
+ use Advanced_Sidebar_Menu\Widget\Category;
7
+ use Advanced_Sidebar_Menu\Widget\Page;
8
 
9
  /**
10
+ * Core functionality for Advanced Sidebar Menu Plugin
11
  *
12
  * @author OnPoint Plugins
13
  * @since 7.0.0
 
14
  */
15
+ class Core {
16
+ use Singleton;
17
 
18
+ /**
19
+ * Actions
20
+ */
21
  protected function hook() {
22
+ add_action( 'widgets_init', [ $this, 'register_widgets' ] );
 
 
 
 
 
 
23
  }
24
 
25
 
26
  /**
27
+ * Register the page and category widgets.
 
28
  *
29
  * @return void
30
  */
31
+ public function register_widgets() {
32
+ register_widget( Page::class );
33
+ register_widget( Category::class );
 
 
 
34
  }
35
 
36
 
37
  /**
38
  * Retrieve a template file from either the theme's 'advanced-sidebar-menu' directory
39
+ * or this plugin's view folder if one does not exist.
40
  *
41
+ * @param string $file_name - Name of template file without the PHP extension.
42
  *
43
+ * @since 6.0.0
44
  *
45
  * @return string
46
  */
47
  public function get_template_part( $file_name ) {
48
  $file = locate_template( 'advanced-sidebar-menu/' . $file_name );
49
  if ( empty( $file ) ) {
50
+ ?>
51
+ <!-- advanced-sidebar-menu/core-template -->
52
+ <?php
53
  $file = ADVANCED_SIDEBAR_DIR . 'views/' . $file_name;
54
+ } else {
55
+ ?>
56
+ <!-- advanced-sidebar-menu/template-override -->
57
+ <?php
58
  }
59
 
60
+ return apply_filters( 'advanced-sidebar-menu/core/get-template-part', $file, $file_name, $this );
 
 
61
  }
62
  }
src/Debug.php CHANGED
@@ -1,13 +1,21 @@
1
  <?php
2
 
 
 
 
 
 
 
3
  /**
4
- * Advanced_Sidebar_Menu_Debug
5
  *
6
  * @author OnPoint Plugins
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
 
@@ -18,10 +26,10 @@ class Advanced_Sidebar_Menu_Debug {
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
  }
@@ -35,8 +43,7 @@ class Advanced_Sidebar_Menu_Debug {
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
  }
@@ -45,17 +52,17 @@ class Advanced_Sidebar_Menu_Debug {
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
  }
@@ -70,44 +77,9 @@ class Advanced_Sidebar_Menu_Debug {
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
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu;
4
+
5
+ use Advanced_Sidebar_Menu\Menus\Menu_Abstract;
6
+ use Advanced_Sidebar_Menu\Traits\Singleton;
7
+ use Advanced_Sidebar_Menu\Widget\Page;
8
+
9
  /**
10
+ * Advanced_Sidebar_Menu\Advanced_Sidebar_Menu_Debug
11
  *
12
  * @author OnPoint Plugins
13
  * @since 6.3.1
14
  * @since 7.4.8 - Use URL arguments to test different configurations.
15
  */
16
+ class Debug {
17
+ use Singleton;
18
+
19
  const DEBUG_PARAM = 'asm_debug';
20
 
21
 
26
  */
27
  protected function hook() {
28
  if ( ! empty( $_GET[ self::DEBUG_PARAM ] ) ) { //phpcs:ignore
29
+ add_action( 'advanced-sidebar-menu/widget/before-render', [ $this, 'print_instance' ], 1, 2 );
30
 
31
  if ( is_array( $_GET[ self::DEBUG_PARAM ] ) ) { //phpcs:ignore
32
+ add_filter( 'advanced-sidebar-menu/menus/widget-instance', [ $this, 'adjust_widget_settings' ] );
33
  }
34
  }
35
  }
43
  * @return array
44
  */
45
  public function adjust_widget_settings( array $instance ) {
46
+ $overrides = array_map( 'sanitize_text_field', (array) $_GET[ self::DEBUG_PARAM ] ); //phpcs:ignore
 
47
 
48
  return wp_parse_args( $overrides, $instance );
49
  }
52
  /**
53
  * Print the widget settings as a js variable.
54
  *
55
+ * @param Menu_Abstract $asm - Menu class.
56
+ * @param Page $widget - Widget class.
57
  *
58
  * @return void
59
  */
60
  public function print_instance( $asm, $widget ) {
61
  static $printed = false;
62
+ $data = [
63
  'version' => ADVANCED_SIDEBAR_BASIC_VERSION,
64
  $widget->id => $asm->instance,
65
+ ];
66
  if ( defined( 'ADVANCED_SIDEBAR_MENU_PRO_VERSION' ) ) {
67
  $data['pro_version'] = ADVANCED_SIDEBAR_MENU_PRO_VERSION;
68
  }
77
  } else {
78
  ?>
79
  <script class="<?php echo esc_attr( self::DEBUG_PARAM ); ?>">
80
+ <?php echo esc_attr( self::DEBUG_PARAM ); ?>[ '<?php echo esc_js( $widget->id ); ?>' ] = <?php echo wp_json_encode( $asm->instance ); ?>;
81
  </script>
82
  <?php
83
  }
84
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
src/List_Pages.php CHANGED
@@ -1,9 +1,11 @@
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.
@@ -11,13 +13,11 @@
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 OnPoint Plugins <support@onpointplugins.com>
17
  *
18
  * @since 5.0.0
19
  */
20
- class Advanced_Sidebar_Menu_List_Pages {
21
 
22
  /**
23
  * The page list
@@ -34,7 +34,7 @@ class Advanced_Sidebar_Menu_List_Pages {
34
  protected $current_page;
35
 
36
  /**
37
- * The top level parent id according to the menu class
38
  *
39
  * @var int
40
  */
@@ -45,7 +45,7 @@ class Advanced_Sidebar_Menu_List_Pages {
45
  *
46
  * @var array
47
  */
48
- protected $args = array();
49
 
50
  /**
51
  * Used exclusively for caching
@@ -60,7 +60,7 @@ class Advanced_Sidebar_Menu_List_Pages {
60
  /**
61
  * Menu class
62
  *
63
- * @var \Advanced_Sidebar_Menu_Menus_Page
64
  */
65
  protected $menu;
66
 
@@ -68,20 +68,20 @@ class Advanced_Sidebar_Menu_List_Pages {
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();
@@ -89,14 +89,12 @@ class Advanced_Sidebar_Menu_List_Pages {
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
 
@@ -104,11 +102,11 @@ class Advanced_Sidebar_Menu_List_Pages {
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 {
@@ -136,7 +134,7 @@ class Advanced_Sidebar_Menu_List_Pages {
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
  */
@@ -146,12 +144,12 @@ class Advanced_Sidebar_Menu_List_Pages {
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
  }
@@ -163,7 +161,7 @@ class Advanced_Sidebar_Menu_List_Pages {
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;
@@ -183,19 +181,19 @@ class Advanced_Sidebar_Menu_List_Pages {
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' => '',
@@ -203,23 +201,22 @@ class Advanced_Sidebar_Menu_List_Pages {
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
- * Return the ID of the current page or 0 if not on a page.
223
  * Helper method to prevent a bunch of conditionals throughout.
224
  *
225
  * @since 7.7.2
@@ -238,10 +235,9 @@ class Advanced_Sidebar_Menu_List_Pages {
238
  * @return string
239
  */
240
  public function list_pages() {
241
-
242
  $pages = $this->get_child_pages( $this->top_parent_id, true );
243
  foreach ( $pages as $page ) {
244
- $this->output .= walk_page_tree( array( $page ), 1, $this->get_current_page_id(), $this->args );
245
  $this->output .= $this->list_grandchild_pages( $page->ID, 0 );
246
  $this->output .= '</li>' . "\n";
247
  }
@@ -250,8 +246,8 @@ class Advanced_Sidebar_Menu_List_Pages {
250
  if ( ! $this->args['echo'] ) {
251
  return $this->output;
252
  }
253
- // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
254
- echo $this->output;
255
  return '';
256
  }
257
 
@@ -260,8 +256,8 @@ class Advanced_Sidebar_Menu_List_Pages {
260
  * List all levels of grandchild pages up to the limit set in the widget.
261
  * All grandchild pages will be rendered inside `grandchild-sidebar-menu` uls.
262
  *
263
- * @param int $parent_page_id - Id of the page we are getting the grandchildren of.
264
- * @param int $level - Level of grandchild pages we are displaying.
265
  *
266
  * @return string
267
  */
@@ -302,20 +298,20 @@ class Advanced_Sidebar_Menu_List_Pages {
302
  *
303
  * @since 7.5.5 - Add 'advanced-sidebar-menu/list-pages/grandchild-pages' filter.
304
  *
305
- * @return WP_Post[]
306
  */
307
  public function get_child_pages( $parent_page_id, $is_first_level = false ) {
308
- // holds a unique key so Cache can distinguish calls.
309
  $this->current_children_parent = $parent_page_id;
310
 
311
- $cache = Advanced_Sidebar_Menu_Cache::instance();
312
  $child_pages = $cache->get_child_pages( $this );
313
  if ( false === $child_pages ) {
314
- $args = $this->args;
315
- $args['post_parent'] = $parent_page_id;
316
- $args['fields'] = 'ids';
317
  $args['suppress_filters'] = false;
318
- $child_pages = get_posts( $args );
319
 
320
  $cache->add_child_pages( $this, $child_pages );
321
  }
@@ -326,9 +322,7 @@ class Advanced_Sidebar_Menu_List_Pages {
326
  return apply_filters( 'advanced-sidebar-menu/list-pages/first-level-child-pages', $child_pages, $this, $this->menu );
327
  }
328
 
329
- // @since 7.5.5
330
  return apply_filters( 'advanced-sidebar-menu/list-pages/grandchild-pages', $child_pages, $this, $this->menu );
331
-
332
  }
333
 
334
 
@@ -355,20 +349,20 @@ class Advanced_Sidebar_Menu_List_Pages {
355
  }
356
  }
357
 
358
- return apply_filters( 'advanced_sidebar_menu_page_ancestor', $return, $current_page_id, $this );
359
  }
360
 
361
 
362
  /**
363
  * List Pages Factory
364
  *
365
- * @param \Advanced_Sidebar_Menu_Menus_Page $menu - The menu class.
366
  *
367
  * @static
368
  *
369
- * @return Advanced_Sidebar_Menu_List_Pages
370
  */
371
- public static function factory( Advanced_Sidebar_Menu_Menus_Page $menu ) {
372
  return new self( $menu );
373
  }
374
 
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu;
4
+
5
+ use Advanced_Sidebar_Menu\Menus\Page;
6
+ use Advanced_Sidebar_Menu\Walkers\Page_Walker;
7
 
8
  /**
 
 
9
  * Parse and build the child and grandchild menus
10
  * Create the opening and closing <ul class="child-sidebar-menu">
11
  * in the view and this will fill in the guts.
13
  * Send the args ( similar to wp_list_pages ) to the constructor and then
14
  * display by calling list_pages()
15
  *
 
 
16
  * @author OnPoint Plugins <support@onpointplugins.com>
17
  *
18
  * @since 5.0.0
19
  */
20
+ class List_Pages {
21
 
22
  /**
23
  * The page list
34
  protected $current_page;
35
 
36
  /**
37
+ * The top-level parent id according to the menu class
38
  *
39
  * @var int
40
  */
45
  *
46
  * @var array
47
  */
48
+ protected $args = [];
49
 
50
  /**
51
  * Used exclusively for caching
60
  /**
61
  * Menu class
62
  *
63
+ * @var Page
64
  */
65
  protected $menu;
66
 
68
  /**
69
  * Constructor
70
  *
71
+ * @param Page $menu - The menu class.
72
  */
73
+ protected function __construct( 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 = [
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();
89
 
90
 
91
  /**
92
+ * Filters
 
 
93
  *
94
  * @return void
95
  */
96
  protected function hook() {
97
+ add_filter( 'page_css_class', [ $this, 'add_list_item_classes' ], 2, 2 );
98
  }
99
 
100
 
102
  * Add the custom classes to the list items
103
  *
104
  * @param array $classes - Provided classes for item.
105
+ * @param \WP_Post $post - The item.
106
  *
107
  * @return array
108
  */
109
+ public function add_list_item_classes( $classes, \WP_Post $post ) {
110
  if ( $post->ID === $this->top_parent_id ) {
111
  $children = $this->get_child_pages( $post->ID, true );
112
  } else {
134
  * Return the list of args that have been populated by this class
135
  * For use with wp_list_pages()
136
  *
137
+ * @param string $level - Level of menu to retrieve arguments for.
138
  *
139
  * @return array
140
  */
144
  }
145
  $args = $this->args;
146
  switch ( $level ) {
147
+ case Page::LEVEL_PARENT:
148
  $args['include'] = $this->menu->get_top_parent_id();
149
  break;
150
+ case Page::LEVEL_DISPLAY_ALL:
151
+ $args['child_of'] = $this->menu->get_top_parent_id();
152
+ $args['depth'] = $this->menu->get_levels_to_display();
153
  $args['sort_column'] = $this->menu->get_order_by();
154
  break;
155
  }
161
  /**
162
  * Return menu which was passed to this class
163
  *
164
+ * @return Page
165
  */
166
  public function get_menu() {
167
  return $this->menu;
181
 
182
 
183
  /**
184
+ * Do any adjustments to list page arguments here.
185
  *
186
+ * @param array $args - Arguments for the walk_page_tree function.
187
  *
188
  * @return array
189
  */
190
  protected function parse_args( $args ) {
191
+ $defaults = [
192
  'exclude' => '',
193
  'echo' => 0,
194
  'order' => 'ASC',
195
  'orderby' => 'menu_order, title',
196
+ 'walker' => new Page_Walker(),
197
  'link_before' => '',
198
  'link_after' => '',
199
  'title_li' => '',
201
  'item_spacing' => 'preserve',
202
  'posts_per_page' => 100,
203
  'suppress_filters' => false,
204
+ ];
205
 
206
+ $args = (array) wp_parse_args( $args, $defaults );
207
 
208
  if ( is_string( $args['exclude'] ) ) {
209
  $args['exclude'] = explode( ',', $args['exclude'] );
210
  }
211
+ // Sanitize, mostly to keep spaces out.
212
  $args['exclude'] = preg_replace( '/[^0-9,]/', '', implode( ',', apply_filters( 'wp_list_pages_excludes', $args['exclude'] ) ) );
213
 
214
+ return apply_filters( 'advanced-sidebar-menu/list-pages/parse-args', $args, $this );
 
215
  }
216
 
217
 
218
  /**
219
+ * Return the ID of the current page if we are on a page.
220
  * Helper method to prevent a bunch of conditionals throughout.
221
  *
222
  * @since 7.7.2
235
  * @return string
236
  */
237
  public function list_pages() {
 
238
  $pages = $this->get_child_pages( $this->top_parent_id, true );
239
  foreach ( $pages as $page ) {
240
+ $this->output .= walk_page_tree( [ $page ], 1, $this->get_current_page_id(), $this->args );
241
  $this->output .= $this->list_grandchild_pages( $page->ID, 0 );
242
  $this->output .= '</li>' . "\n";
243
  }
246
  if ( ! $this->args['echo'] ) {
247
  return $this->output;
248
  }
249
+
250
+ echo $this->output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
251
  return '';
252
  }
253
 
256
  * List all levels of grandchild pages up to the limit set in the widget.
257
  * All grandchild pages will be rendered inside `grandchild-sidebar-menu` uls.
258
  *
259
+ * @param int $parent_page_id - ID of the page we are getting the grandchildren of.
260
+ * @param int $level - Level of grandchild pages we are displaying.
261
  *
262
  * @return string
263
  */
298
  *
299
  * @since 7.5.5 - Add 'advanced-sidebar-menu/list-pages/grandchild-pages' filter.
300
  *
301
+ * @return \WP_Post[]
302
  */
303
  public function get_child_pages( $parent_page_id, $is_first_level = false ) {
304
+ // Holds a unique key so cache can distinguish calls.
305
  $this->current_children_parent = $parent_page_id;
306
 
307
+ $cache = Cache::instance();
308
  $child_pages = $cache->get_child_pages( $this );
309
  if ( false === $child_pages ) {
310
+ $args = $this->args;
311
+ $args['post_parent'] = $parent_page_id;
312
+ $args['fields'] = 'ids';
313
  $args['suppress_filters'] = false;
314
+ $child_pages = get_posts( $args );
315
 
316
  $cache->add_child_pages( $this, $child_pages );
317
  }
322
  return apply_filters( 'advanced-sidebar-menu/list-pages/first-level-child-pages', $child_pages, $this, $this->menu );
323
  }
324
 
 
325
  return apply_filters( 'advanced-sidebar-menu/list-pages/grandchild-pages', $child_pages, $this, $this->menu );
 
326
  }
327
 
328
 
349
  }
350
  }
351
 
352
+ return apply_filters( 'advanced-sidebar-menu/list-pages/is-current-page-ancestor', $return, $current_page_id, $this );
353
  }
354
 
355
 
356
  /**
357
  * List Pages Factory
358
  *
359
+ * @param Page $menu - Menu class.
360
  *
361
  * @static
362
  *
363
+ * @return List_Pages
364
  */
365
+ public static function factory( Page $menu ) {
366
  return new self( $menu );
367
  }
368
 
src/Menu.php DELETED
@@ -1,23 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Menus/Category.php CHANGED
@@ -1,52 +1,45 @@
1
  <?php
2
 
 
 
 
 
3
  /**
4
- * Advanced_Sidebar_Menu_Menus_Category
5
  *
6
  * @author OnPoint Plugins
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
 
@@ -54,13 +47,13 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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(),
@@ -68,7 +61,7 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
68
  'show_option_none' => false,
69
  'taxonomy' => $this->get_taxonomy(),
70
  'title_li' => '',
71
- );
72
 
73
  if ( null === $level ) {
74
  return $args;
@@ -77,19 +70,19 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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
 
@@ -103,23 +96,21 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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
 
@@ -139,70 +130,71 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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;
@@ -212,16 +204,31 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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() ) {
@@ -237,19 +244,19 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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
  }
@@ -282,17 +289,20 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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
  */
@@ -306,42 +316,41 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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
  */
@@ -362,11 +371,11 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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;
@@ -380,13 +389,13 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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;
@@ -394,19 +403,18 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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;
@@ -426,29 +434,28 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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;
@@ -456,47 +463,21 @@ class Advanced_Sidebar_Menu_Menus_Category extends Advanced_Sidebar_Menu_Menus_A
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
- // @since 7.6.5.
465
  do_action( 'advanced-sidebar-menu/menus/category/render/after', $this );
466
-
467
  echo $this->args['after_widget'];
468
  }
469
  }
470
 
471
  if ( ! $close_menu && $menu_open ) {
472
- // @since 7.6.5.
473
  do_action( 'advanced-sidebar-menu/menus/category/render/after', $this );
474
-
475
  echo $this->args['after_widget'];
476
  }
477
-
478
- //phpcs:enable
479
-
480
- }
481
-
482
-
483
- /******************** static ****************************/
484
-
485
- /**
486
- * Mostly here to call the parent _factory in a PHP 5.2 structure
487
- *
488
- * @param array $widget_instance
489
- * @param array $widget_args
490
- *
491
- * @static
492
- *
493
- * @return \Advanced_Sidebar_Menu_Menus_Category
494
- */
495
- public static function factory( array $widget_instance, array $widget_args ) {
496
- $class = parent::_factory( __CLASS__, $widget_instance, $widget_args );
497
- $class->hook();
498
-
499
- return $class;
500
  }
501
 
502
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu\Menus;
4
+
5
+ use Advanced_Sidebar_Menu\Core;
6
+
7
  /**
8
+ * Category menu.
9
  *
10
  * @author OnPoint Plugins
11
  * @since 7.0.0
12
  */
13
+ class Category extends Menu_Abstract {
14
  const WIDGET = 'category';
15
 
16
  const DISPLAY_ON_SINGLE = 'single';
17
  const EACH_CATEGORY_DISPLAY = 'new_widget';
18
 
19
  /**
20
+ * Parents and grandparents fo current term.
21
  *
22
  * @var array
23
  */
24
+ public $ancestors = [];
 
25
 
26
  /**
27
+ * Top_level_term.
28
  *
29
+ * @var \WP_Term
30
  */
31
  public $top_level_term;
32
 
33
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * If we are on a post we could potentially have more than one
36
+ * top-level term, so we end up calling this more than once.
37
  *
38
+ * @param \WP_Term $term - The highest level term.
39
  *
40
  * @return void
41
  */
42
+ public function set_current_top_level_term( \WP_Term $term ) {
43
  $this->top_level_term = $term;
44
  }
45
 
47
  /**
48
  * Return the list of args for wp_list_categories()
49
  *
50
+ * @param string $level - level of menu, so we have full control of updates.
51
+ * @param \WP_Term $term - Term to use for this level.
52
  *
53
  * @return array
54
  */
55
  public function get_list_categories_args( $level = null, $term = null ) {
56
+ $args = [
57
  'echo' => 0,
58
  'exclude' => $this->get_excluded_ids(),
59
  'order' => $this->get_order(),
61
  'show_option_none' => false,
62
  'taxonomy' => $this->get_taxonomy(),
63
  'title_li' => '',
64
+ ];
65
 
66
  if ( null === $level ) {
67
  return $args;
70
  switch ( $level ) {
71
  case self::LEVEL_PARENT:
72
  $args['hide_empty'] = 0;
73
+ $args['include'] = trim( $this->get_top_parent_id() );
74
  break;
75
  case self::LEVEL_DISPLAY_ALL:
76
  $args['child_of'] = $this->get_top_parent_id();
77
+ $args['depth'] = $this->get_levels_to_display();
78
  break;
79
  case self::LEVEL_CHILD:
80
  $args['include'] = $term->term_id;
81
+ $args['depth'] = 1;
82
  break;
83
  case self::LEVEL_GRANDCHILD:
84
  $args['child_of'] = $term->term_id;
85
+ $args['depth'] = $this->get_levels_to_display();
86
  break;
87
  }
88
 
96
  * $this->set_current_top_level_term() most likely should be called
97
  * before this.
98
  *
99
+ * @see \Advanced_Sidebar_Menu\Menus\Category::set_current_top_level_term()
100
  *
101
+ * @return \WP_Term[]
102
  */
103
  public function get_child_terms() {
104
+ return array_filter(
105
  get_terms(
106
+ [
107
  'taxonomy' => $this->get_taxonomy(),
108
  'parent' => $this->get_top_parent_id(),
109
  'orderby' => $this->get_order_by(),
110
  'order' => $this->get_order(),
111
+ ]
112
  )
113
  );
 
 
114
  }
115
 
116
 
130
 
131
 
132
  /**
133
+ * Get the top-level terms for the current page.
 
 
 
 
 
 
 
 
 
134
  * If on a single this could be multiple.
135
  * If on an archive this will be one.
136
  *
137
  * @return array
138
  */
139
  public function get_top_level_terms() {
140
+ $child_term_ids = $this->get_included_term_ids();
141
+ $top_level_term_ids = [];
142
  foreach ( $child_term_ids as $_term_id ) {
143
  $top_level_term_ids[] = $this->get_highest_parent( $_term_id );
144
  }
145
+ $terms = [];
146
  if ( ! empty( $top_level_term_ids ) ) {
147
  $terms = get_terms(
148
+ [
149
  'include' => array_unique( array_filter( $top_level_term_ids ) ),
150
  'hide_empty' => false,
151
  'orderby' => $this->get_order_by(),
152
  'order' => $this->get_order(),
153
+ ]
154
  );
155
  }
156
  if ( is_wp_error( $terms ) ) {
157
+ return [];
158
  }
159
 
160
  return $terms;
 
161
  }
162
 
163
 
164
  /**
165
+ * Get the term ids for either the current term archive,
166
  * or the terms attached to the current post
167
  *
168
  * @return array
169
  */
170
  public function get_included_term_ids() {
171
+ $term_ids = [];
172
  if ( is_single() ) {
173
+ $term_ids = wp_get_object_terms( get_the_ID(), $this->get_taxonomy(), [ 'fields' => 'ids' ] );
174
  } elseif ( $this->is_tax() ) {
175
  $term_ids[] = get_queried_object()->term_id;
176
  }
177
 
178
+ return (array) apply_filters( 'advanced-sidebar-menu/menus/category/included-term-ids', $term_ids, $this->args, $this->instance, $this );
179
  }
180
 
181
 
182
+ /**
183
+ * Get this menu's taxonomy.
184
+ * Defaults to 'category'.
185
+ *
186
+ * @return int
187
+ */
188
  public function get_taxonomy() {
189
+ return apply_filters( 'advanced-sidebar-menu/menus/category/taxonomy', 'category', $this->args, $this->instance, $this );
190
  }
191
 
192
 
193
+ /**
194
+ * Get id of the highest level parent item.
195
+ *
196
+ * @return int
197
+ */
198
  public function get_top_parent_id() {
199
  if ( empty( $this->top_level_term->term_id ) ) {
200
  return null;
204
  }
205
 
206
 
207
+ /**
208
+ * Get key to order the menu items by.
209
+ *
210
+ * @return string
211
+ */
212
  public function get_order_by() {
213
+ return apply_filters( 'advanced-sidebar-menu/menus/category/order-by', 'name', $this->args, $this->instance, $this );
214
  }
215
 
216
 
217
+ /**
218
+ * Get order of the menu (ASC|DESC).
219
+ *
220
+ * @return string
221
+ */
222
  public function get_order() {
223
+ return apply_filters( 'advanced-sidebar-menu/menus/category/order', 'ASC', $this->args, $this->instance, $this );
224
  }
225
 
226
 
227
+ /**
228
+ * Is this menu displayed?
229
+ *
230
+ * @return bool
231
+ */
232
  public function is_displayed() {
233
  $display = false;
234
  if ( is_single() ) {
244
 
245
 
246
  /**
247
+ * Is this term, and it's children displayed
248
  *
249
+ * 1. If children not empty we always display (or at least let the view handle it).
250
+ * 2. If children empty and not include a parent we don't display.
251
+ * 3. If children empty and not include a childless parent we don't display.
252
+ * 4. If children empty, and the top parent is excluded we don't display.
253
  *
254
+ * @param \WP_Term $term - Current top level term.
255
  *
256
  * @return bool
257
  */
258
+ public function is_term_displayed( $term ) {
259
+ if ( ! $this->has_children( $term ) ) {
260
  if ( ! $this->checked( self::INCLUDE_PARENT ) || ! $this->checked( self::INCLUDE_CHILDLESS_PARENT ) ) {
261
  return false;
262
  }
289
  }
290
 
291
 
292
+ /**
293
+ * Get list of excluded ids from widget settings.
294
+ *
295
+ * @return array
296
+ */
297
  public function get_excluded_ids() {
298
+ return apply_filters( 'advanced-sidebar-menu/menus/category/excluded', parent::get_excluded_ids(), $this->args, $this->instance, $this );
 
 
299
  }
300
 
301
 
302
  /**
303
  * Removes the closing </li> tag from a list item to allow for child menus inside of it
304
  *
305
+ * @param string|bool $item - An <li></li> item.
306
  *
307
  * @return string|bool
308
  */
316
 
317
 
318
  /**
319
+ * Retrieve the highest level term_id based on the given
320
  * term's ancestors
321
  *
322
+ * @param int $term_id - Provided term's id.
323
  *
324
  * @return int
325
  */
326
  public function get_highest_parent( $term_id ) {
327
+ $cat_ancestors = [];
328
  $cat_ancestors[] = $term_id;
329
 
330
  do {
331
  $term = get_term( $term_id, $this->get_taxonomy() );
332
  if ( ! is_wp_error( $term ) ) {
333
+ $term_id = $term->parent;
334
  $cat_ancestors[] = $term_id;
335
  } else {
336
  $term = false;
337
  }
338
  } while ( $term );
339
 
340
+ // We only track the last calls ancestors because we only care about these when on a single term archive.
341
+ $this->ancestors = array_reverse( $cat_ancestors );
342
+ return $this->ancestors[1];
 
 
 
 
343
  }
344
 
345
 
346
  /**
347
+ * If a category has children add the 'has_children' class
348
+ * to the list item.
349
  *
350
+ * @param [] $classes - List of classes added to category list item.
351
+ * @param \WP_Term $category - Current category.
352
+ *
353
+ * @filter category_css_class 11 2
354
  *
355
  * @return array
356
  */
371
  * When looping through the view via the terms from $this->get_child_terms()
372
  * the term->parent conditions will most likely always be true.
373
  *
374
+ * @param \WP_Term $term - Category or term.
375
  *
376
  * @return bool
377
  */
378
+ public function is_first_level_term( \WP_Term $term ) {
379
  $return = false;
380
  if ( ! $this->is_excluded( $term->term_id ) && (int) $term->parent === (int) $this->get_top_parent_id() ) {
381
  $return = true;
389
  * Is this term an ancestor of the current term?
390
  * Does this term have children?
391
  *
392
+ * @param \WP_Term $term - Category or term.
393
  *
394
  * @return mixed
395
  */
396
+ public function is_current_term_ancestor( \WP_Term $term ) {
397
  $return = false;
398
+ if ( (int) $term->term_id === (int) $this->top_level_term->term_id || in_array( $term->term_id, $this->ancestors, false ) ) { //phpcs:ignore WordPress.PHP.StrictInArray.FoundNonStrictFalse
399
  $children = get_term_children( $term->term_id, $this->get_taxonomy() );
400
  if ( ! empty( $children ) ) {
401
  $return = true;
403
  }
404
 
405
  return apply_filters( 'advanced-sidebar-menu/menus/category/is-current-term-ancestor', $return, $term, $this );
 
406
  }
407
 
408
 
409
  /**
410
  * Does this term have children?
411
  *
412
+ * @param \WP_Term $term - Current category or term.
413
  *
414
  * @return mixed
415
  */
416
+ public function has_children( \WP_Term $term ) {
417
+ $return = false;
418
  $children = get_term_children( $term->term_id, $this->get_taxonomy() );
419
  if ( ! empty( $children ) ) {
420
  $return = true;
434
  return;
435
  }
436
 
437
+ add_filter( 'category_css_class', [ $this, 'add_has_children_category_class' ], 11, 2 );
438
+
439
+ $menu_open = false;
440
  $close_menu = false;
441
 
442
  foreach ( $this->get_top_level_terms() as $_cat ) {
443
  $this->set_current_top_level_term( $_cat );
444
+ if ( ! $this->is_term_displayed( $_cat ) ) {
445
  continue;
446
  }
447
 
448
  if ( ! $menu_open || ( 'widget' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) ) {
449
+ //phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
450
  echo $this->args['before_widget'];
451
 
452
  do_action( 'advanced-sidebar-menu/menus/category/render', $this );
453
 
454
  if ( ! $menu_open ) {
455
+ // Must remain in the loop vs the template.
456
  $this->title();
 
 
 
457
 
458
+ $menu_open = true;
459
  $close_menu = true;
460
  if ( 'list' === $this->instance[ self::EACH_CATEGORY_DISPLAY ] ) {
461
  $close_menu = false;
463
  }
464
  }
465
 
466
+ $output = require Core::instance()->get_template_part( 'category_list.php' );
467
 
468
+ echo apply_filters( 'advanced-sidebar-menu/menus/category/output', $output, $this->args, $this->instance, $this );
469
 
470
  if ( $close_menu ) {
 
471
  do_action( 'advanced-sidebar-menu/menus/category/render/after', $this );
 
472
  echo $this->args['after_widget'];
473
  }
474
  }
475
 
476
  if ( ! $close_menu && $menu_open ) {
 
477
  do_action( 'advanced-sidebar-menu/menus/category/render/after', $this );
 
478
  echo $this->args['after_widget'];
479
  }
480
+ //phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  }
482
 
483
  }
src/Menus/{Abstract.php → Menu_Abstract.php} RENAMED
@@ -1,34 +1,33 @@
1
  <?php
2
 
 
 
3
  /**
4
- * Advanced_Sidebar_Menu_Menus_Abstract
5
  *
6
  * @author OnPoint Plugins
7
  * @since 7.0.0
8
  */
9
- abstract class Advanced_Sidebar_Menu_Menus_Abstract {
10
- // keys available in both widgets.
11
- const TITLE = 'title';
12
- const INCLUDE_PARENT = 'include_parent';
13
  const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
 
 
 
 
 
 
14
  const ORDER = 'order';
15
  const ORDER_BY = 'order_by';
16
- const USE_PLUGIN_STYLES = 'css';
17
- const EXCLUDE = 'exclude';
18
- const DISPLAY_ALL = 'display_all';
19
- const LEVELS = 'levels';
20
-
21
- const LEVEL_CHILD = 'child';
22
- const LEVEL_DISPLAY_ALL = 'display-all';
23
- const LEVEL_GRANDCHILD = 'grandchild';
24
- const LEVEL_PARENT = 'parent';
25
 
26
  /**
27
  * Widget Args
28
  *
29
  * @var array
30
  */
31
- public $args = array();
32
 
33
  /**
34
  * Widget instance
@@ -37,20 +36,6 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
37
  */
38
  public $instance;
39
 
40
- /**
41
- * @deprecated 7.0.0
42
- *
43
- * @var string
44
- */
45
- public $order = 'ASC';
46
-
47
- /**
48
- * @deprecated 7.0.0
49
- *
50
- * @var string
51
- */
52
- public $order_by;
53
-
54
  /**
55
  * Track the ids which have been used in case of
56
  * plugins like Elementor that we need to manually increment.
@@ -60,41 +45,77 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
60
  *
61
  * @var string[]
62
  */
63
- protected static $unique_widget_ids = array();
64
 
65
 
66
- public function __construct( array $widget_instance, array $widget_args ) {
67
- $this->instance = apply_filters( 'advanced-sidebar-menu/menus/widget-instance', $widget_instance, $widget_args, $this );
68
- $this->args = $widget_args;
 
 
 
 
 
 
69
 
70
  $this->increment_widget_id();
71
  }
72
 
73
 
 
 
 
 
 
74
  abstract public function get_top_parent_id();
75
 
76
 
 
 
 
 
 
77
  abstract public function get_order_by();
78
 
79
 
 
 
 
 
 
80
  abstract public function get_order();
81
 
82
 
83
- abstract public function render();
84
-
85
-
 
 
86
  abstract public function is_displayed();
87
 
88
 
 
 
 
 
 
89
  abstract public function get_levels_to_display();
90
 
91
 
 
 
 
 
 
 
 
 
92
  /**
93
  * Increment the widget id until it is unique to all widgets being displayed
94
  * in the current context.
95
  *
96
  * Required because plugins like Elementor will reuse the same generic id for
97
- * widgets within page content and we need a unique id to properly target with
98
  * styles, accordions, etc.
99
  *
100
  * @since 7.6.0
@@ -112,7 +133,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
112
  $alt_widget_id = $this->args['widget_id'] . "-$suffix";
113
  $suffix ++;
114
  } while ( in_array( $alt_widget_id, self::$unique_widget_ids, true ) );
115
- $this->args['widget_id'] = $alt_widget_id;
116
  self::$unique_widget_ids[] = $alt_widget_id;
117
  } else {
118
  self::$unique_widget_ids[] = $this->args['widget_id'];
@@ -121,20 +142,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
121
 
122
 
123
  /**
124
- * Return the type of widget we are working with
125
- * Used for comparisons like so
126
- *
127
- * $menu->get_widget_type() === Menus_Page::WIDGET
128
- *
129
- * @return string - 'page', 'category',
130
- */
131
- public function get_widget_type() {
132
- return self::WIDGET;
133
- }
134
-
135
-
136
- /**
137
- * The instance arguments from the current widget
138
  *
139
  * @return array
140
  */
@@ -144,7 +152,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
144
 
145
 
146
  /**
147
- * The widget arguments from the current widget
148
  *
149
  * @return array
150
  */
@@ -154,11 +162,11 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
154
 
155
 
156
  /**
157
- * Checks if a widgets checkbox is checked.
158
  *
159
  * Checks first for a value then verifies the value = checked
160
  *
161
- * @param string $name - name of checkbox.
162
  *
163
  * @return bool
164
  */
@@ -168,7 +176,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
168
 
169
 
170
  /**
171
- * Determines if all the children should be included
172
  *
173
  * @return bool
174
  */
@@ -178,7 +186,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
178
 
179
 
180
  /**
181
- * Determines if the parent page or cat should be included
182
  *
183
  * @return bool
184
  */
@@ -202,17 +210,12 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
202
 
203
 
204
  /**
205
- * Retrieve the excluded items' ids
206
  *
207
  * @return array
208
  */
209
  public function get_excluded_ids() {
210
- $excluded = explode( ',', $this->instance[ self::EXCLUDE ] );
211
- $excluded = array_filter( $excluded );
212
- $excluded = array_filter( $excluded, 'is_numeric' );
213
- $excluded = array_map( 'intval', $excluded );
214
-
215
- return $excluded;
216
  }
217
 
218
 
@@ -224,7 +227,7 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
224
  public function title() {
225
  if ( ! empty( $this->instance[ self::TITLE ] ) ) {
226
  $title = apply_filters( 'widget_title', $this->instance[ self::TITLE ], $this->args, $this->instance );
227
- $title = apply_filters( 'advanced_sidebar_menu_widget_title', esc_html( $title ), $this->args, $this->instance, $this );
228
 
229
  // phpcs:disable
230
  echo $this->args['before_title'] . $title . $this->args['after_title'];
@@ -234,19 +237,21 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
234
 
235
 
236
  /**
 
237
  *
238
  * @static
239
  *
240
- * @var \Advanced_Sidebar_Menu_Menus_Page|\Advanced_Sidebar_Menu_Menus_Category
241
  */
242
  protected static $current;
243
 
244
 
245
  /**
 
246
  *
247
  * @static
248
  *
249
- * @return \Advanced_Sidebar_Menu_Menus_Page|\Advanced_Sidebar_Menu_Menus_Category
250
  */
251
  public static function get_current() {
252
  return self::$current;
@@ -254,23 +259,18 @@ abstract class Advanced_Sidebar_Menu_Menus_Abstract {
254
 
255
 
256
  /**
257
- * static() does not exist until PHP 5.3 which means we have to do
258
- * this hideous thing where we call the factory method from the child
259
- * class and pass it's name.
260
- * Chose to handle it this way instead of trying to maintain 2 separate
261
- * factory methods with logic.
262
  *
263
- * @param string $class
264
- * @param array $widget_instance
265
- * @param array $widget_args
266
  *
267
  * @static
268
  *
269
- * @return mixed
270
  */
271
- public static function _factory( $class, array $widget_instance, array $widget_args ) {
272
- $menu = new $class( $widget_instance, $widget_args );
273
- self::$current = $menu;
274
 
275
  return $menu;
276
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu\Menus;
4
+
5
  /**
6
+ * Base for Menu classes.
7
  *
8
  * @author OnPoint Plugins
9
  * @since 7.0.0
10
  */
11
+ abstract class Menu_Abstract {
12
+ const DISPLAY_ALL = 'display_all';
13
+ const EXCLUDE = 'exclude';
 
14
  const INCLUDE_CHILDLESS_PARENT = 'include_childless_parent';
15
+ const INCLUDE_PARENT = 'include_parent';
16
+ const LEVELS = 'levels';
17
+ const LEVEL_CHILD = 'child';
18
+ const LEVEL_DISPLAY_ALL = 'display-all';
19
+ const LEVEL_GRANDCHILD = 'grandchild';
20
+ const LEVEL_PARENT = 'parent';
21
  const ORDER = 'order';
22
  const ORDER_BY = 'order_by';
23
+ const TITLE = 'title';
 
 
 
 
 
 
 
 
24
 
25
  /**
26
  * Widget Args
27
  *
28
  * @var array
29
  */
30
+ public $args = [];
31
 
32
  /**
33
  * Widget instance
36
  */
37
  public $instance;
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  /**
40
  * Track the ids which have been used in case of
41
  * plugins like Elementor that we need to manually increment.
45
  *
46
  * @var string[]
47
  */
48
+ protected static $unique_widget_ids = [];
49
 
50
 
51
+ /**
52
+ * Construct a new instance of this widget.
53
+ *
54
+ * @param array $instance - Widget settings.
55
+ * @param array $args - Widget registration arguments.
56
+ */
57
+ public function __construct( array $instance, array $args ) {
58
+ $this->instance = apply_filters( 'advanced-sidebar-menu/menus/widget-instance', $instance, $args, $this );
59
+ $this->args = $args;
60
 
61
  $this->increment_widget_id();
62
  }
63
 
64
 
65
+ /**
66
+ * Get id of the highest level parent item.
67
+ *
68
+ * @return int
69
+ */
70
  abstract public function get_top_parent_id();
71
 
72
 
73
+ /**
74
+ * Get key to order the menu items by.
75
+ *
76
+ * @return string
77
+ */
78
  abstract public function get_order_by();
79
 
80
 
81
+ /**
82
+ * Get order of the menu (ASC|DESC).
83
+ *
84
+ * @return string
85
+ */
86
  abstract public function get_order();
87
 
88
 
89
+ /**
90
+ * Should this widget be displayed.
91
+ *
92
+ * @return bool
93
+ */
94
  abstract public function is_displayed();
95
 
96
 
97
+ /**
98
+ * How many levels should be displayed.
99
+ *
100
+ * @return int
101
+ */
102
  abstract public function get_levels_to_display();
103
 
104
 
105
+ /**
106
+ * Render the widget
107
+ *
108
+ * @return void
109
+ */
110
+ abstract public function render();
111
+
112
+
113
  /**
114
  * Increment the widget id until it is unique to all widgets being displayed
115
  * in the current context.
116
  *
117
  * Required because plugins like Elementor will reuse the same generic id for
118
+ * widgets within page content, and we need a unique id to properly target with
119
  * styles, accordions, etc.
120
  *
121
  * @since 7.6.0
133
  $alt_widget_id = $this->args['widget_id'] . "-$suffix";
134
  $suffix ++;
135
  } while ( in_array( $alt_widget_id, self::$unique_widget_ids, true ) );
136
+ $this->args['widget_id'] = $alt_widget_id;
137
  self::$unique_widget_ids[] = $alt_widget_id;
138
  } else {
139
  self::$unique_widget_ids[] = $this->args['widget_id'];
142
 
143
 
144
  /**
145
+ * The instance arguments from the current widget.
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  *
147
  * @return array
148
  */
152
 
153
 
154
  /**
155
+ * The widget arguments from the current widget.
156
  *
157
  * @return array
158
  */
162
 
163
 
164
  /**
165
+ * Checks if a widget's checkbox is checked.
166
  *
167
  * Checks first for a value then verifies the value = checked
168
  *
169
+ * @param string $name - Name of checkbox.
170
  *
171
  * @return bool
172
  */
176
 
177
 
178
  /**
179
+ * Determines if all the children should be included.
180
  *
181
  * @return bool
182
  */
186
 
187
 
188
  /**
189
+ * Determines if the parent page or cat should be included.
190
  *
191
  * @return bool
192
  */
210
 
211
 
212
  /**
213
+ * Retrieve the excluded items' ids.
214
  *
215
  * @return array
216
  */
217
  public function get_excluded_ids() {
218
+ return array_map( 'intval', array_filter( explode( ',', $this->instance[ self::EXCLUDE ] ), 'is_numeric' ) );
 
 
 
 
 
219
  }
220
 
221
 
227
  public function title() {
228
  if ( ! empty( $this->instance[ self::TITLE ] ) ) {
229
  $title = apply_filters( 'widget_title', $this->instance[ self::TITLE ], $this->args, $this->instance );
230
+ $title = apply_filters( 'advanced-sidebar-menu/menus/widget-title', esc_html( $title ), $this->args, $this->instance, $this );
231
 
232
  // phpcs:disable
233
  echo $this->args['before_title'] . $title . $this->args['after_title'];
237
 
238
 
239
  /**
240
+ * Store current menu instance.
241
  *
242
  * @static
243
  *
244
+ * @var Page|Category
245
  */
246
  protected static $current;
247
 
248
 
249
  /**
250
+ * Get current menu instance.
251
  *
252
  * @static
253
  *
254
+ * @return Page|Category
255
  */
256
  public static function get_current() {
257
  return self::$current;
259
 
260
 
261
  /**
262
+ * Construct a new instance of this class.
 
 
 
 
263
  *
264
+ * @param array $widget_instance - Widget settings.
265
+ * @param array $widget_args - Widget registration args.
 
266
  *
267
  * @static
268
  *
269
+ * @return static
270
  */
271
+ public static function factory( array $widget_instance, array $widget_args ) {
272
+ $menu = new static( $widget_instance, $widget_args );
273
+ static::$current = $menu;
274
 
275
  return $menu;
276
  }
src/Menus/Page.php CHANGED
@@ -1,35 +1,36 @@
1
  <?php
2
 
 
 
 
 
3
 
4
  /**
5
- * Advanced_Sidebar_Menu_Menus_Page
6
  *
7
  * @author OnPoint Plugins
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
  *
25
  * @var null|\WP_Post
26
  */
27
  protected $post;
28
 
29
- protected $ancestors;
30
 
 
 
 
 
 
31
 
32
- public function set_current_post( WP_Post $post ) {
 
 
33
  $this->post = $post;
34
  }
35
 
@@ -51,18 +52,28 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
51
  }
52
 
53
 
 
 
 
 
 
54
  public function get_order_by() {
55
- return apply_filters( 'advanced_sidebar_menu_order_by', $this->instance[ self::ORDER_BY ], $this->get_current_post(), $this->args, $this->instance, $this );
56
  }
57
 
58
 
 
 
 
 
 
59
  public function get_order() {
60
- return apply_filters( 'advanced_sidebar_menu_page_order', 'ASC', $this->get_current_post(), $this->args, $this->instance, $this );
61
  }
62
 
63
 
64
  /**
65
- * Get the id of page which is the top level parent of
66
  * the page we are currently on.
67
  *
68
  * Returns -1 if we don't have one.
@@ -78,36 +89,32 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
78
  $top_id = $this->get_current_post()->ID;
79
  }
80
 
81
- return apply_filters( 'advanced_sidebar_menu_top_parent', $top_id, $this->args, $this->instance, $this );
82
  }
83
 
84
 
 
 
 
 
 
85
  public function is_displayed() {
86
- $display = false;
87
  $post_type = $this->get_post_type();
88
  if ( is_page() || ( is_single() && $post_type === $this->get_current_post()->post_type ) ) {
89
- //if we are on the correct post type
90
  if ( get_post_type( $this->get_top_parent_id() ) === $post_type ) {
91
- //if we have children
92
  if ( $this->has_pages() ) {
93
  $display = true;
94
- //no children + not excluded + include parent +include childless parent
95
  } elseif ( $this->checked( self::INCLUDE_CHILDLESS_PARENT ) && $this->checked( self::INCLUDE_PARENT ) && ! $this->is_excluded( $this->get_top_parent_id() ) ) {
96
  $display = true;
97
  }
98
  }
99
  }
100
 
101
- $display = ! apply_filters_deprecated( 'advanced_sidebar_menu_proper_single', array(
102
- ! $display,
103
- $this->args,
104
- $this->instance,
105
- $this,
106
- ), '7.0.0', 'advanced-sidebar-menu/menus/page/is-displayed' );
107
-
108
-
109
  return apply_filters( 'advanced-sidebar-menu/menus/page/is-displayed', $display, $this->args, $this->instance, $this );
110
-
111
  }
112
 
113
 
@@ -120,8 +127,8 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
120
  * @return bool
121
  */
122
  public function has_pages() {
123
- $list_pages = Advanced_Sidebar_Menu_List_Pages::factory( $this );
124
- $children = $list_pages->get_child_pages( $this->get_top_parent_id(), true );
125
 
126
  return ! empty( $children );
127
  }
@@ -143,16 +150,12 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
143
 
144
 
145
  /**
146
- * @deprecated
 
 
147
  */
148
- public function get_menu_depth() {
149
- _deprecated_function( 'get_menu_depth', '7.5.0', 'get_levels_to_display' );
150
- return apply_filters( 'advanced-sidebar-menu/menus/page/depth', $this->get_levels_to_display(), $this->args, $this->instance, $this );
151
- }
152
-
153
-
154
  public function get_post_type() {
155
- return apply_filters( 'advanced_sidebar_menu_post_type', $this->post_type, $this->args, $this->instance, $this );
156
  }
157
 
158
 
@@ -162,7 +165,7 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
162
  * @return array|mixed
163
  */
164
  public function get_excluded_ids() {
165
- return apply_filters( 'advanced_sidebar_menu_excluded_pages', parent::get_excluded_ids(), $this->get_current_post(), $this->args, $this->instance, $this );
166
  }
167
 
168
 
@@ -176,38 +179,18 @@ class Advanced_Sidebar_Menu_Menus_Page extends Advanced_Sidebar_Menu_Menus_Abstr
176
  return;
177
  }
178
 
179
- // phpcs:disable
180
  echo $this->args['before_widget'];
181
 
182
  do_action( 'advanced-sidebar-menu/menus/page/render', $this );
183
 
184
- if ( $this->checked( self::USE_PLUGIN_STYLES ) ) {
185
- Advanced_Sidebar_Menu_Core::instance()->include_plugin_styles();
186
- }
187
-
188
- $output = require Advanced_Sidebar_Menu_Core::instance()->get_template_part( 'page_list.php' );
189
- echo apply_filters( 'advanced_sidebar_menu_page_widget_output', $output, $this->get_current_post(), $this->args, $this->instance, $this );
190
 
191
- // @since 7.6.5.
192
  do_action( 'advanced-sidebar-menu/menus/page/render/after', $this );
193
 
194
  echo $this->args['after_widget'];
195
- // phpcs:enable
196
- }
197
 
198
-
199
- /**************** static *****************/
200
- /**
201
- * Mostly here to call the parent _factory() in a PHP 5.2 structure
202
- *
203
- * @param array $widget_instance
204
- * @param array $widget_args
205
- *
206
- * @static
207
- *
208
- * @return \Advanced_Sidebar_Menu_Menus_Page
209
- */
210
- public static function factory( array $widget_instance, array $widget_args ) {
211
- return parent::_factory( __CLASS__, $widget_instance, $widget_args );
212
  }
213
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu\Menus;
4
+
5
+ use Advanced_Sidebar_Menu\Core;
6
+ use Advanced_Sidebar_Menu\List_Pages;
7
 
8
  /**
9
+ * Page menu.
10
  *
11
  * @author OnPoint Plugins
12
  * @since 7.0.0
 
13
  */
14
+ class Page extends Menu_Abstract {
15
  const WIDGET = 'page';
16
 
17
  /**
18
+ * The current post
 
 
 
 
 
 
 
 
19
  *
20
  * @var null|\WP_Post
21
  */
22
  protected $post;
23
 
 
24
 
25
+ /**
26
+ * Used for setting the current post during unit testing
27
+ * or special extending.
28
+ *
29
+ * @param \WP_Post $post - New current post.
30
 
31
+ * @return void
32
+ */
33
+ public function set_current_post( \WP_Post $post ) {
34
  $this->post = $post;
35
  }
36
 
52
  }
53
 
54
 
55
+ /**
56
+ * Get key to order the menu items by.
57
+ *
58
+ * @return string
59
+ */
60
  public function get_order_by() {
61
+ return apply_filters( 'advanced-sidebar-menu/menus/page/order-by', $this->instance[ self::ORDER_BY ], $this->get_current_post(), $this->args, $this->instance, $this );
62
  }
63
 
64
 
65
+ /**
66
+ * Get order of the menu (ASC|DESC).
67
+ *
68
+ * @return string
69
+ */
70
  public function get_order() {
71
+ return apply_filters( 'advanced-sidebar-menu/menus/page/order', 'ASC', $this->get_current_post(), $this->args, $this->instance, $this );
72
  }
73
 
74
 
75
  /**
76
+ * Get the id of page which is the top-level parent of
77
  * the page we are currently on.
78
  *
79
  * Returns -1 if we don't have one.
89
  $top_id = $this->get_current_post()->ID;
90
  }
91
 
92
+ return apply_filters( 'advanced-sidebar-menu/menus/page/top-parent', $top_id, $this->args, $this->instance, $this );
93
  }
94
 
95
 
96
+ /**
97
+ * Is this menu displayed?
98
+ *
99
+ * @return bool
100
+ */
101
  public function is_displayed() {
102
+ $display = false;
103
  $post_type = $this->get_post_type();
104
  if ( is_page() || ( is_single() && $post_type === $this->get_current_post()->post_type ) ) {
105
+ // If we are on the correct post type.
106
  if ( get_post_type( $this->get_top_parent_id() ) === $post_type ) {
107
+ // Ff we have children.
108
  if ( $this->has_pages() ) {
109
  $display = true;
110
+ // No children + not excluded + include parent +include childless parent.
111
  } elseif ( $this->checked( self::INCLUDE_CHILDLESS_PARENT ) && $this->checked( self::INCLUDE_PARENT ) && ! $this->is_excluded( $this->get_top_parent_id() ) ) {
112
  $display = true;
113
  }
114
  }
115
  }
116
 
 
 
 
 
 
 
 
 
117
  return apply_filters( 'advanced-sidebar-menu/menus/page/is-displayed', $display, $this->args, $this->instance, $this );
 
118
  }
119
 
120
 
127
  * @return bool
128
  */
129
  public function has_pages() {
130
+ $list_pages = List_Pages::factory( $this );
131
+ $children = $list_pages->get_child_pages( $this->get_top_parent_id(), true );
132
 
133
  return ! empty( $children );
134
  }
150
 
151
 
152
  /**
153
+ * Get the post type of this menu.
154
+ *
155
+ * @return string
156
  */
 
 
 
 
 
 
157
  public function get_post_type() {
158
+ return apply_filters( 'advanced-sidebar-menu/menus/page/post-type', 'page', $this->args, $this->instance, $this );
159
  }
160
 
161
 
165
  * @return array|mixed
166
  */
167
  public function get_excluded_ids() {
168
+ return apply_filters( 'advanced-sidebar-menu/menus/page/excluded', parent::get_excluded_ids(), $this->get_current_post(), $this->args, $this->instance, $this );
169
  }
170
 
171
 
179
  return;
180
  }
181
 
182
+ // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
183
  echo $this->args['before_widget'];
184
 
185
  do_action( 'advanced-sidebar-menu/menus/page/render', $this );
186
 
187
+ $output = require Core::instance()->get_template_part( 'page_list.php' );
188
+ echo apply_filters( 'advanced-sidebar-menu/menus/page/output', $output, $this->get_current_post(), $this->args, $this->instance, $this );
 
 
 
 
189
 
 
190
  do_action( 'advanced-sidebar-menu/menus/page/render/after', $this );
191
 
192
  echo $this->args['after_widget'];
 
 
193
 
194
+ // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  }
196
  }
src/Page_Walker.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
-
4
- class Advanced_Sidebar_Menu_Page_Walker extends Walker_Page{
5
-
6
- function end_el( &$output, $page, $depth = 0, $args = array() ){
7
- /** Do Nothing */
8
- }
9
-
10
- }
 
 
 
 
 
 
 
 
 
 
src/Scripts.php CHANGED
@@ -13,7 +13,6 @@ use Advanced_Sidebar_Menu\Traits\Singleton;
13
  class Scripts {
14
  use Singleton;
15
 
16
-
17
  /**
18
  * Add various scripts to the cue.
19
  */
@@ -39,7 +38,7 @@ class Scripts {
39
  */
40
  public function admin_scripts() {
41
  wp_enqueue_script(
42
- apply_filters( 'asm_script', 'advanced-sidebar-menu-script' ),
43
  \trailingslashit( ADVANCED_SIDEBAR_MENU_URL ) . 'resources/js/advanced-sidebar-menu.js',
44
  [ 'jquery' ],
45
  ADVANCED_SIDEBAR_BASIC_VERSION,
@@ -47,7 +46,7 @@ class Scripts {
47
  );
48
 
49
  wp_enqueue_style(
50
- apply_filters( 'asm_style', 'advanced-sidebar-menu-style' ),
51
  \trailingslashit( ADVANCED_SIDEBAR_MENU_URL ) . 'resources/css/advanced-sidebar-menu.css',
52
  [],
53
  ADVANCED_SIDEBAR_BASIC_VERSION
@@ -57,7 +56,7 @@ class Scripts {
57
 
58
  /**
59
  * Trigger any JS needed by the widgets.
60
- * This is outputted into the markup for each widget so it may be
61
  * trigger whether the widget is loaded on the front-end by
62
  * page builders or the backend by standard WordPress or
63
  * really anywhere.
13
  class Scripts {
14
  use Singleton;
15
 
 
16
  /**
17
  * Add various scripts to the cue.
18
  */
38
  */
39
  public function admin_scripts() {
40
  wp_enqueue_script(
41
+ 'advanced-sidebar-menu-script',
42
  \trailingslashit( ADVANCED_SIDEBAR_MENU_URL ) . 'resources/js/advanced-sidebar-menu.js',
43
  [ 'jquery' ],
44
  ADVANCED_SIDEBAR_BASIC_VERSION,
46
  );
47
 
48
  wp_enqueue_style(
49
+ 'advanced-sidebar-menu-style',
50
  \trailingslashit( ADVANCED_SIDEBAR_MENU_URL ) . 'resources/css/advanced-sidebar-menu.css',
51
  [],
52
  ADVANCED_SIDEBAR_BASIC_VERSION
56
 
57
  /**
58
  * Trigger any JS needed by the widgets.
59
+ * This is outputted into the markup for each widget, so it may be
60
  * trigger whether the widget is loaded on the front-end by
61
  * page builders or the backend by standard WordPress or
62
  * really anywhere.
src/Walkers/Page_Walker.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Advanced_Sidebar_Menu\Walkers;
4
+
5
+ /**
6
+ * This walker's only purpose is to allow us to close our menus only when needed.
7
+ */
8
+ class Page_Walker extends \Walker_Page {
9
+ //phpcs:disable
10
+ function end_el( &$output, $page, $depth = 0, $args = [] ) {
11
+ /** Do Nothing */
12
+ }
13
+ }
src/Widget/Category.php CHANGED
@@ -1,41 +1,47 @@
1
  <?php
2
 
 
 
 
3
 
4
  /**
5
  * Creates a Widget of parent Child Categories
6
  *
7
  * @author OnPoint Plugins
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
  * Register the widget.
@@ -49,33 +55,32 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
49
  'width' => wp_is_mobile() ? false : 620,
50
  ];
51
 
52
- parent::__construct( 'advanced_sidebar_menu_category', __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
53
 
54
- if ( ! self::$hooked ) {
55
- self::$hooked = true;
56
- $this->hook();
57
- }
58
  }
59
 
60
 
61
  /**
 
 
62
  * @notice Anything using the column actions must use the $widget class passed
63
  * via do_action instead of $this
64
  *
65
  * @return void
66
  */
67
  protected function hook() {
68
- add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_display' ), 5, 2 );
69
- add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_styles' ), 10, 2 );
70
- add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_singles' ), 15, 2 );
71
- add_action( 'advanced-sidebar-menu/widget/category/left-column', array( $this, 'box_exclude' ), 20, 2 );
72
-
73
  }
74
 
 
75
  /**
 
76
  *
77
- * @param array $instance
78
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
79
  *
80
  * @return void
81
  */
@@ -85,7 +90,7 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
85
  <p>
86
  <?php $widget->checkbox( self::INCLUDE_PARENT ); ?>
87
  <label>
88
- <?php esc_html_e( 'Display highest level parent category', 'advanced-sidebar-menu' ); ?>
89
  </label>
90
  </p>
91
  <p>
@@ -102,9 +107,11 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
102
  </p>
103
  <div <?php $widget->hide_element( self::DISPLAY_ALL, self::LEVELS ); ?>>
104
  <p>
105
- <label>
106
- <?php esc_html_e( 'Levels of child categories to display', 'advanced-sidebar-menu' ); ?>:</label>
 
107
  <select
 
108
  name="<?php echo esc_attr( $widget->get_field_name( self::LEVELS ) ); ?>">
109
  <?php
110
  for ( $i = 1; $i < 6; $i ++ ) {
@@ -127,36 +134,16 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
127
  <?php
128
  }
129
 
130
- /**
131
- *
132
- * @param array $instance
133
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
134
- *
135
- * @return void
136
- */
137
- public function box_styles( array $instance, $widget ) {
138
- ?>
139
- <div class="advanced-sidebar-menu-column-box">
140
- <p>
141
- <?php $widget->checkbox( self::USE_PLUGIN_STYLES ); ?>
142
- <label>
143
- <?php esc_html_e( "Use this plugin's default styling", 'advanced-sidebar-menu' ); ?>
144
- </label>
145
- </p>
146
-
147
- <?php do_action( 'advanced-sidebar-menu/widget/category/styles-box', $instance, $widget ); ?>
148
- </div>
149
- <?php
150
- }
151
 
152
  /**
 
153
  *
154
- * @param array $instance
155
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
156
  *
157
  * @return void
158
  */
159
- public function box_singles( array $instance, $widget ) {
160
  ?>
161
  <div class="advanced-sidebar-menu-column-box">
162
  <p>
@@ -169,9 +156,11 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
169
 
170
  <div <?php $widget->hide_element( self::DISPLAY_ON_SINGLE, self::EACH_CATEGORY_DISPLAY ); ?>>
171
  <p>
172
- <label><?php esc_html_e( "Display each single post's category", 'advanced-sidebar-menu' ); ?>
173
- :</label>
 
174
  <select
 
175
  name="<?php echo esc_attr( $widget->get_field_name( self::EACH_CATEGORY_DISPLAY ) ); ?>">
176
  <option
177
  value="widget" <?php selected( 'widget', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
@@ -190,10 +179,12 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
190
  <?php
191
  }
192
 
 
193
  /**
 
194
  *
195
- * @param array $instance
196
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
197
  *
198
  * @return void
199
  */
@@ -201,7 +192,7 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
201
  ?>
202
  <div class="advanced-sidebar-menu-column-box">
203
  <p>
204
- <label>
205
  <?php esc_html_e( 'Categories to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
206
  </label>
207
  <input
@@ -209,7 +200,7 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
209
  name="<?php echo esc_attr( $widget->get_field_name( self::EXCLUDE ) ); ?>"
210
  type="text"
211
  class="widefat"
212
- value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
213
  </p>
214
 
215
  <?php
@@ -221,11 +212,11 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
221
 
222
 
223
  /**
224
- * Form
225
  *
226
- * @since 7.2.1
227
  *
228
- * @param array $instance
229
  *
230
  * @return void
231
  */
@@ -234,86 +225,63 @@ class Advanced_Sidebar_Menu_Widget_Category extends Advanced_Sidebar_Menu__Widge
234
  do_action( 'advanced-sidebar-menu/widget/category/before-form', $instance, $this );
235
  ?>
236
  <p>
237
- <label>
238
  <?php esc_html_e( 'Title', 'advanced-sidebar-menu' ); ?>:
239
  </label>
240
-
241
  <input
242
  id="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>"
243
  name="<?php echo esc_attr( $this->get_field_name( self::TITLE ) ); ?>"
244
  class="widefat"
245
  type="text"
246
- value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
247
  </p>
248
 
249
  <div class="advanced-sidebar-menu-column">
250
- <?php
251
- do_action( 'advanced-sidebar-menu/widget/category/left-column', $instance, $this );
252
-
253
- if ( has_action( 'advanced_sidebar_menu_category_widget_form' ) ) {
254
- ?>
255
- <div class="advanced-sidebar-menu-column-box">
256
- <?php do_action( 'advanced_sidebar_menu_category_widget_form', $instance, $this ); ?>
257
- </div>
258
- <?php
259
- }
260
-
261
- ?>
262
  </div>
263
 
264
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
265
- <?php
266
- do_action( 'advanced-sidebar-menu/widget/category/right-column', $instance, $this );
267
- // @deprecated action.
268
- do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
269
- ?>
270
  </div>
271
  <div class="advanced-sidebar-menu-full-width"><!-- clear --></div>
272
 
273
  <?php
274
  do_action( 'advanced-sidebar-menu/widget/category/after-form', $instance, $this );
275
-
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
- $new_instance['exclude'] = strip_tags( $new_instance['exclude'] );
289
 
290
- return apply_filters( 'advanced_sidebar_menu_category_widget_update', $new_instance, $old_instance );
291
  }
292
 
293
 
294
  /**
295
  * Widget Output
296
  *
297
- * @since 7.0.0
298
- *
299
- * @see \Advanced_Sidebar_Menu_Menus_Category
300
- *
301
- * @param array $args
302
- * @param array $instance
303
  *
304
  * @return void
305
  */
306
  public function widget( $args, $instance ) {
307
  $instance = $this->set_instance( $instance, self::$defaults );
308
- $asm = Advanced_Sidebar_Menu_Menus_Category::factory( $instance, $args );
309
-
310
- do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
311
 
312
- $asm->render();
313
 
314
- // @since 7.6.6.
315
- do_action( 'advanced-sidebar-menu/widget/after-render', $asm, $this );
316
 
 
317
  }
318
 
319
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu\Widget;
4
+
5
+ use Advanced_Sidebar_Menu\Menus\Menu_Abstract;
6
 
7
  /**
8
  * Creates a Widget of parent Child Categories
9
  *
10
  * @author OnPoint Plugins
11
  * @since 7.0.0
 
 
12
  *
13
+ * @package Advanced Sidebar Menu
14
  */
15
+ class Category extends Widget_Abstract {
16
+ const NAME = 'advanced_sidebar_menu_category';
17
+
18
+ const TITLE = Menu_Abstract::TITLE;
19
+ const INCLUDE_PARENT = Menu_Abstract::INCLUDE_PARENT;
20
+ const INCLUDE_CHILDLESS_PARENT = Menu_Abstract::INCLUDE_CHILDLESS_PARENT;
21
+ const ORDER_BY = Menu_Abstract::ORDER_BY;
22
+ const EXCLUDE = Menu_Abstract::EXCLUDE;
23
+ const DISPLAY_ALL = Menu_Abstract::DISPLAY_ALL;
24
+ const LEVELS = Menu_Abstract::LEVELS;
25
+
26
+ const DISPLAY_ON_SINGLE = \Advanced_Sidebar_Menu\Menus\Category::DISPLAY_ON_SINGLE;
27
+ const EACH_CATEGORY_DISPLAY = \Advanced_Sidebar_Menu\Menus\Category::EACH_CATEGORY_DISPLAY;
28
+
29
+ /**
30
+ * Default widget values.
31
+ *
32
+ * @var array
33
+ */
34
+ protected static $defaults = [
35
  self::TITLE => '',
36
  self::INCLUDE_PARENT => false,
37
  self::INCLUDE_CHILDLESS_PARENT => false,
 
38
  self::DISPLAY_ON_SINGLE => false,
39
  self::EACH_CATEGORY_DISPLAY => 'widget',
40
  self::EXCLUDE => '',
41
  self::DISPLAY_ALL => false,
42
  self::LEVELS => 1,
43
+ ];
44
 
 
45
 
46
  /**
47
  * Register the widget.
55
  'width' => wp_is_mobile() ? false : 620,
56
  ];
57
 
58
+ parent::__construct( self::NAME, __( 'Advanced Sidebar Categories Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
59
 
60
+ $this->hook();
 
 
 
61
  }
62
 
63
 
64
  /**
65
+ * Add the sections to the widget via actions.
66
+ *
67
  * @notice Anything using the column actions must use the $widget class passed
68
  * via do_action instead of $this
69
  *
70
  * @return void
71
  */
72
  protected function hook() {
73
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', [ $this, 'box_display' ], 5, 2 );
74
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', [ $this, 'box_display_on_single_posts' ], 15, 2 );
75
+ add_action( 'advanced-sidebar-menu/widget/category/left-column', [ $this, 'box_exclude' ], 20, 2 );
 
 
76
  }
77
 
78
+
79
  /**
80
+ * Display options.
81
  *
82
+ * @param array $instance - Widget settings.
83
+ * @param Widget_Abstract $widget - Registered widget arguments.
84
  *
85
  * @return void
86
  */
90
  <p>
91
  <?php $widget->checkbox( self::INCLUDE_PARENT ); ?>
92
  <label>
93
+ <?php esc_html_e( 'Display the highest level parent category', 'advanced-sidebar-menu' ); ?>
94
  </label>
95
  </p>
96
  <p>
107
  </p>
108
  <div <?php $widget->hide_element( self::DISPLAY_ALL, self::LEVELS ); ?>>
109
  <p>
110
+ <label for="<?php echo esc_attr( $widget->get_field_id( self::LEVELS ) ); ?>">
111
+ <?php esc_html_e( 'Levels of child categories to display', 'advanced-sidebar-menu' ); ?>:
112
+ </label>
113
  <select
114
+ id="<?php echo esc_attr( $widget->get_field_id( self::LEVELS ) ); ?>"
115
  name="<?php echo esc_attr( $widget->get_field_name( self::LEVELS ) ); ?>">
116
  <?php
117
  for ( $i = 1; $i < 6; $i ++ ) {
134
  <?php
135
  }
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  /**
139
+ * Display categories on single post settings.
140
  *
141
+ * @param array $instance - Widget settings.
142
+ * @param Widget_Abstract $widget - Registered widget arguments.
143
  *
144
  * @return void
145
  */
146
+ public function box_display_on_single_posts( array $instance, $widget ) {
147
  ?>
148
  <div class="advanced-sidebar-menu-column-box">
149
  <p>
156
 
157
  <div <?php $widget->hide_element( self::DISPLAY_ON_SINGLE, self::EACH_CATEGORY_DISPLAY ); ?>>
158
  <p>
159
+ <label for="<?php echo esc_attr( $widget->get_field_id( self::EACH_CATEGORY_DISPLAY ) ); ?>">
160
+ <?php esc_html_e( "Display each single post's category", 'advanced-sidebar-menu' ); ?>:
161
+ </label>
162
  <select
163
+ id="<?php echo esc_attr( $widget->get_field_id( self::EACH_CATEGORY_DISPLAY ) ); ?>"
164
  name="<?php echo esc_attr( $widget->get_field_name( self::EACH_CATEGORY_DISPLAY ) ); ?>">
165
  <option
166
  value="widget" <?php selected( 'widget', $instance[ self::EACH_CATEGORY_DISPLAY ] ); ?>>
179
  <?php
180
  }
181
 
182
+
183
  /**
184
+ * Categories to exclude settings.
185
  *
186
+ * @param array $instance - Widget settings.
187
+ * @param Widget_Abstract $widget - Registered widget arguments.
188
  *
189
  * @return void
190
  */
192
  ?>
193
  <div class="advanced-sidebar-menu-column-box">
194
  <p>
195
+ <label for="<?php echo esc_attr( $widget->get_field_id( self::EXCLUDE ) ); ?>">
196
  <?php esc_html_e( 'Categories to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
197
  </label>
198
  <input
200
  name="<?php echo esc_attr( $widget->get_field_name( self::EXCLUDE ) ); ?>"
201
  type="text"
202
  class="widefat"
203
+ value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>" />
204
  </p>
205
 
206
  <?php
212
 
213
 
214
  /**
215
+ * Widget form.
216
  *
217
+ * @param array $instance - Widget settings.
218
  *
219
+ * @since 7.2.1
220
  *
221
  * @return void
222
  */
225
  do_action( 'advanced-sidebar-menu/widget/category/before-form', $instance, $this );
226
  ?>
227
  <p>
228
+ <label for="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>">
229
  <?php esc_html_e( 'Title', 'advanced-sidebar-menu' ); ?>:
230
  </label>
 
231
  <input
232
  id="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>"
233
  name="<?php echo esc_attr( $this->get_field_name( self::TITLE ) ); ?>"
234
  class="widefat"
235
  type="text"
236
+ value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>" />
237
  </p>
238
 
239
  <div class="advanced-sidebar-menu-column">
240
+ <?php do_action( 'advanced-sidebar-menu/widget/category/left-column', $instance, $this ); ?>
 
 
 
 
 
 
 
 
 
 
 
241
  </div>
242
 
243
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
244
+ <?php do_action( 'advanced-sidebar-menu/widget/category/right-column', $instance, $this ); ?>
 
 
 
 
245
  </div>
246
  <div class="advanced-sidebar-menu-full-width"><!-- clear --></div>
247
 
248
  <?php
249
  do_action( 'advanced-sidebar-menu/widget/category/after-form', $instance, $this );
 
250
  }
251
 
252
 
253
  /**
254
+ * Save the widget settings.
255
  *
256
+ * @param array $new_instance - New widget settings.
257
+ * @param array $old_instance - Old widget settings.
258
  *
259
  * @return array|mixed
260
  */
261
  public function update( $new_instance, $old_instance ) {
262
+ $new_instance['exclude'] = wp_strip_all_tags( $new_instance['exclude'] );
263
 
264
+ return apply_filters( 'advanced-sidebar-menu/widget/category/update', $new_instance, $old_instance );
265
  }
266
 
267
 
268
  /**
269
  * Widget Output
270
  *
271
+ * @param array $args - Widget registration args.
272
+ * @param array $instance - Widget settings.
 
 
 
 
273
  *
274
  * @return void
275
  */
276
  public function widget( $args, $instance ) {
277
  $instance = $this->set_instance( $instance, self::$defaults );
278
+ $menu = \Advanced_Sidebar_Menu\Menus\Category::factory( $instance, $args );
 
 
279
 
280
+ do_action( 'advanced-sidebar-menu/widget/before-render', $menu, $this );
281
 
282
+ $menu->render();
 
283
 
284
+ do_action( 'advanced-sidebar-menu/widget/after-render', $menu, $this );
285
  }
286
 
287
  }
src/Widget/Page.php CHANGED
@@ -1,5 +1,8 @@
1
  <?php
2
 
 
 
 
3
 
4
  /**
5
  * Advanced_Sidebar_Menu_Widgets_Page
@@ -9,28 +12,31 @@
9
  * @author OnPoint Plugins
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 => 100,
31
- );
32
-
33
- protected static $hooked = false;
34
 
35
 
36
  /**
@@ -45,33 +51,32 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
45
  'width' => wp_is_mobile() ? false : 620,
46
  ];
47
 
48
- parent::__construct( 'advanced_sidebar_menu', __( 'Advanced Sidebar Pages 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
  /**
 
 
58
  * @notice Anything using the column actions must use the $widget class passed
59
  * via do_action instead of $this
60
  *
61
  * @return void
62
  */
63
  protected function hook() {
64
- add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_display' ), 5, 2 );
65
- add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_styles' ), 10, 2 );
66
- add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_order' ), 15, 2 );
67
- add_action( 'advanced-sidebar-menu/widget/page/left-column', array( $this, 'box_exclude' ), 20, 2 );
68
-
69
  }
70
 
 
71
  /**
 
72
  *
73
- * @param array $instance
74
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
75
  *
76
  * @return void
77
  */
@@ -108,9 +113,11 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
108
  ?>
109
  >
110
  <p>
111
- <label>
112
- <?php esc_html_e( 'Maximum level of child pages to display', 'advanced-sidebar-menu' ); ?>:</label>
 
113
  <select
 
114
  name="<?php echo esc_attr( $widget->get_field_name( self::LEVELS ) ); ?>">
115
  <option value="100">
116
  <?php esc_html_e( ' - All - ', 'advanced-sidebar-menu' ); ?>
@@ -136,31 +143,12 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
136
  <?php
137
  }
138
 
139
- /**
140
- *
141
- * @param array $instance
142
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
143
- *
144
- * @return void
145
- */
146
- public function box_styles( array $instance, $widget ) {
147
- ?>
148
- <div class="advanced-sidebar-menu-column-box">
149
- <p>
150
- <?php $widget->checkbox( self::USE_PLUGIN_STYLES ); ?>
151
- <label>
152
- <?php esc_html_e( "Use this plugin's default styling", 'advanced-sidebar-menu' ); ?>
153
- </label>
154
- </p>
155
- <?php do_action( 'advanced-sidebar-menu/widget/page/styles-box', $instance, $widget ); ?>
156
- </div>
157
- <?php
158
- }
159
 
160
  /**
 
161
  *
162
- * @param array $instance
163
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
164
  *
165
  * @return void
166
  */
@@ -169,7 +157,7 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
169
  <div class="advanced-sidebar-menu-column-box">
170
 
171
  <p>
172
- <label>
173
  <?php esc_html_e( 'Order by', 'advanced-sidebar-menu' ); ?>:
174
  </label>
175
  <select
@@ -178,11 +166,11 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
178
  <?php
179
  $order_by = (array) apply_filters(
180
  'advanced-sidebar-menu/widget/page/order-by-options',
181
- array(
182
  'menu_order' => 'Page Order',
183
  'post_title' => 'Title',
184
  'post_date' => 'Published Date',
185
- )
186
  );
187
 
188
  foreach ( $order_by as $key => $order ) {
@@ -197,10 +185,12 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
197
  <?php
198
  }
199
 
 
200
  /**
 
201
  *
202
- * @param array $instance
203
- * @param \Advanced_Sidebar_Menu__Widget__Widget $widget
204
  *
205
  * @return void
206
  */
@@ -208,7 +198,7 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
208
  ?>
209
  <div class="advanced-sidebar-menu-column-box">
210
  <p>
211
- <label>
212
  <?php esc_html_e( 'Pages to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
213
  </label>
214
  <input
@@ -216,7 +206,7 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
216
  name="<?php echo esc_attr( $widget->get_field_name( self::EXCLUDE ) ); ?>"
217
  class="widefat"
218
  type="text"
219
- value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>"/>
220
  </p>
221
  <?php
222
  do_action( 'advanced-sidebar-menu/widget/page/exclude-box', $instance, $widget );
@@ -227,11 +217,11 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
227
 
228
 
229
  /**
230
- * Form
231
  *
232
- * @since 7.2.1
233
  *
234
- * @param array $instance
235
  *
236
  * @return void
237
  */
@@ -240,37 +230,21 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
240
  do_action( 'advanced-sidebar-menu/widget/page/before-form', $instance, $this );
241
  ?>
242
  <p xmlns="http://www.w3.org/1999/html">
243
- <label>
244
  <?php esc_html_e( 'Title', 'advanced-sidebar-menu' ); ?>:
245
  </label>
246
-
247
  <input
248
  id="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>"
249
  name="<?php echo esc_attr( $this->get_field_name( self::TITLE ) ); ?>"
250
  class="widefat"
251
  type="text"
252
- value="<?php echo esc_attr( $instance[ self::TITLE ] ); ?>"/>
253
  </p>
254
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-left">
255
- <?php
256
- do_action( 'advanced-sidebar-menu/widget/page/left-column', $instance, $this );
257
- if ( has_action( 'advanced_sidebar_menu_page_widget_form' ) ) {
258
- ?>
259
- <div class="advanced-sidebar-menu-column-box">
260
- <?php do_action( 'advanced_sidebar_menu_page_widget_form', $this->get_field_id( 'parent_only' ), $this, $instance ); ?>
261
- </div>
262
- <?php
263
- }
264
- ?>
265
  </div>
266
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
267
- <?php
268
-
269
- // @deprecated action
270
- do_action( 'advanced_sidebar_menu_after_widget_form', $instance, $this );
271
-
272
- do_action( 'advanced-sidebar-menu/widget/page/right-column', $instance, $this );
273
- ?>
274
  </div>
275
  <div class="advanced-sidebar-menu-full-width"><!-- clear --></div>
276
  <?php
@@ -279,10 +253,10 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
279
 
280
 
281
  /**
282
- * Update
283
  *
284
- * @param array $new_instance
285
- * @param array $old_instance
286
  *
287
  * @return array|mixed
288
  */
@@ -291,32 +265,30 @@ class Advanced_Sidebar_Menu_Widget_Page extends Advanced_Sidebar_Menu__Widget__W
291
  $new_instance['exclude'] = wp_strip_all_tags( $new_instance['exclude'] );
292
  }
293
 
294
- return apply_filters( 'advanced_sidebar_menu_page_widget_update', $new_instance, $old_instance );
295
  }
296
 
297
 
298
  /**
299
- * Widget Output
300
  *
301
- * @since 7.0.0
 
302
  *
303
- * @see \Advanced_Sidebar_Menu_Menus_Page
304
  *
305
- * @param array $args
306
- * @param array $instance
307
  *
308
  * @return void
309
  */
310
  public function widget( $args, $instance ) {
311
- $instance = wp_parse_args( $instance, self::$defaults );
312
- $asm = Advanced_Sidebar_Menu_Menus_Page::factory( $instance, $args );
313
 
314
- do_action( 'advanced_sidebar_menu_widget_pre_render', $asm, $this );
315
 
316
  $asm->render();
317
 
318
- // @since 7.6.6.
319
  do_action( 'advanced-sidebar-menu/widget/after-render', $asm, $this );
320
-
321
  }
322
  }
1
  <?php
2
 
3
+ namespace Advanced_Sidebar_Menu\Widget;
4
+
5
+ use Advanced_Sidebar_Menu\Menus\Menu_Abstract;
6
 
7
  /**
8
  * Advanced_Sidebar_Menu_Widgets_Page
12
  * @author OnPoint Plugins
13
  * @since 7.0.0
14
  */
15
+ class Page extends Widget_Abstract {
16
+ const NAME = 'advanced_sidebar_menu';
17
+
18
+ const TITLE = Menu_Abstract::TITLE;
19
+ const INCLUDE_PARENT = Menu_Abstract::INCLUDE_PARENT;
20
+ const INCLUDE_CHILDLESS_PARENT = Menu_Abstract::INCLUDE_CHILDLESS_PARENT;
21
+ const ORDER_BY = Menu_Abstract::ORDER_BY;
22
+ const EXCLUDE = Menu_Abstract::EXCLUDE;
23
+ const DISPLAY_ALL = Menu_Abstract::DISPLAY_ALL;
24
+ const LEVELS = Menu_Abstract::LEVELS;
25
+
26
+ /**
27
+ * Default values for the widget.
28
+ *
29
+ * @var array
30
+ */
31
+ protected static $defaults = [
32
  self::TITLE => false,
33
  self::INCLUDE_PARENT => false,
34
  self::INCLUDE_CHILDLESS_PARENT => false,
35
  self::ORDER_BY => 'menu_order',
 
36
  self::EXCLUDE => false,
37
  self::DISPLAY_ALL => false,
38
  self::LEVELS => 100,
39
+ ];
 
 
40
 
41
 
42
  /**
51
  'width' => wp_is_mobile() ? false : 620,
52
  ];
53
 
54
+ parent::__construct( self::NAME, __( 'Advanced Sidebar Pages Menu', 'advanced-sidebar-menu' ), $widget_ops, $control_ops );
55
 
56
+ $this->hook();
 
 
 
57
  }
58
 
59
 
60
  /**
61
+ * Add the sections to the widget via actions.
62
+ *
63
  * @notice Anything using the column actions must use the $widget class passed
64
  * via do_action instead of $this
65
  *
66
  * @return void
67
  */
68
  protected function hook() {
69
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', [ $this, 'box_display' ], 5, 2 );
70
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', [ $this, 'box_order' ], 15, 2 );
71
+ add_action( 'advanced-sidebar-menu/widget/page/left-column', [ $this, 'box_exclude' ], 20, 2 );
 
 
72
  }
73
 
74
+
75
  /**
76
+ * Display options.
77
  *
78
+ * @param array $instance - Widget settings.
79
+ * @param Widget_Abstract $widget - Registered widget arguments.
80
  *
81
  * @return void
82
  */
113
  ?>
114
  >
115
  <p>
116
+ <label for="<?php echo esc_attr( $widget->get_field_id( self::LEVELS ) ); ?>">
117
+ <?php esc_html_e( 'Maximum level of child pages to display', 'advanced-sidebar-menu' ); ?>:
118
+ </label>
119
  <select
120
+ id="<?php echo esc_attr( $widget->get_field_id( self::LEVELS ) ); ?>"
121
  name="<?php echo esc_attr( $widget->get_field_name( self::LEVELS ) ); ?>">
122
  <option value="100">
123
  <?php esc_html_e( ' - All - ', 'advanced-sidebar-menu' ); ?>
143
  <?php
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  /**
148
+ * Order options.
149
  *
150
+ * @param array $instance - Widget settings.
151
+ * @param Widget_Abstract $widget - Registered widget arguments.
152
  *
153
  * @return void
154
  */
157
  <div class="advanced-sidebar-menu-column-box">
158
 
159
  <p>
160
+ <label for="<?php echo esc_attr( $widget->get_field_id( self::ORDER_BY ) ); ?>">
161
  <?php esc_html_e( 'Order by', 'advanced-sidebar-menu' ); ?>:
162
  </label>
163
  <select
166
  <?php
167
  $order_by = (array) apply_filters(
168
  'advanced-sidebar-menu/widget/page/order-by-options',
169
+ [
170
  'menu_order' => 'Page Order',
171
  'post_title' => 'Title',
172
  'post_date' => 'Published Date',
173
+ ]
174
  );
175
 
176
  foreach ( $order_by as $key => $order ) {
185
  <?php
186
  }
187
 
188
+
189
  /**
190
+ * Exclude options.
191
  *
192
+ * @param array $instance - Widget settings.
193
+ * @param Widget_Abstract $widget - Registered widget arguments.
194
  *
195
  * @return void
196
  */
198
  ?>
199
  <div class="advanced-sidebar-menu-column-box">
200
  <p>
201
+ <label for="<?php echo esc_attr( $widget->get_field_id( self::EXCLUDE ) ); ?>">
202
  <?php esc_html_e( 'Pages to exclude (ids), comma separated', 'advanced-sidebar-menu' ); ?>:
203
  </label>
204
  <input
206
  name="<?php echo esc_attr( $widget->get_field_name( self::EXCLUDE ) ); ?>"
207
  class="widefat"
208
  type="text"
209
+ value="<?php echo esc_attr( $instance[ self::EXCLUDE ] ); ?>" />
210
  </p>
211
  <?php
212
  do_action( 'advanced-sidebar-menu/widget/page/exclude-box', $instance, $widget );
217
 
218
 
219
  /**
220
+ * Widget form.
221
  *
222
+ * @param array $instance - Widget settings.
223
  *
224
+ * @since 7.2.1
225
  *
226
  * @return void
227
  */
230
  do_action( 'advanced-sidebar-menu/widget/page/before-form', $instance, $this );
231
  ?>
232
  <p xmlns="http://www.w3.org/1999/html">
233
+ <label for="<?php echo esc_attr( $this->get_field_id( self::TITLE ) ); ?>">
234
  <?php esc_html_e( 'Title', 'advanced-sidebar-menu' ); ?>:
235
  </label>
 
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
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-left">
244
+ <?php do_action( 'advanced-sidebar-menu/widget/page/left-column', $instance, $this ); ?>
 
 
 
 
 
 
 
 
 
245
  </div>
246
  <div class="advanced-sidebar-menu-column advanced-sidebar-menu-column-right">
247
+ <?php do_action( 'advanced-sidebar-menu/widget/page/right-column', $instance, $this ); ?>
 
 
 
 
 
 
248
  </div>
249
  <div class="advanced-sidebar-menu-full-width"><!-- clear --></div>
250
  <?php
253
 
254
 
255
  /**
256
+ * Save the widget settings.
257
  *
258
+ * @param array $new_instance - New widget settings.
259
+ * @param array $old_instance - Old widget settings.
260
  *
261
  * @return array|mixed
262
  */
265
  $new_instance['exclude'] = wp_strip_all_tags( $new_instance['exclude'] );
266
  }
267
 
268
+ return apply_filters( 'advanced-sidebar-menu/widget/page/update', $new_instance, $old_instance );
269
  }
270
 
271
 
272
  /**
273
+ * Widget Output.
274
  *
275
+ * @param array $args - Widget registration args.
276
+ * @param array $instance - Widget settings.
277
  *
278
+ * @see \Advanced_Sidebar_Menu\Menus\Page
279
  *
280
+ * @since 7.0.0
 
281
  *
282
  * @return void
283
  */
284
  public function widget( $args, $instance ) {
285
+ $instance = (array) wp_parse_args( $instance, self::$defaults );
286
+ $asm = \Advanced_Sidebar_Menu\Menus\Page::factory( $instance, $args );
287
 
288
+ do_action( 'advanced-sidebar-menu/widget/before-render', $asm, $this );
289
 
290
  $asm->render();
291
 
 
292
  do_action( 'advanced-sidebar-menu/widget/after-render', $asm, $this );
 
293
  }
294
  }
src/Widget/{Widget.php → Widget_Abstract.php} RENAMED
@@ -1,18 +1,20 @@
1
  <?php
 
 
2
  /**
3
- * Advanced_Sidebar_Menu__Widget__Widget
4
  *
5
  * @author OnPoint Plugins
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
  /**
@@ -20,26 +22,24 @@ abstract class Advanced_Sidebar_Menu__Widget__Widget extends WP_Widget {
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
  *
@@ -50,15 +50,17 @@ abstract class Advanced_Sidebar_Menu__Widget__Widget extends WP_Widget {
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
@@ -97,8 +99,8 @@ abstract class Advanced_Sidebar_Menu__Widget__Widget extends WP_Widget {
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
  ?>
@@ -109,9 +111,8 @@ abstract class Advanced_Sidebar_Menu__Widget__Widget extends WP_Widget {
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
  }
1
  <?php
2
+ namespace Advanced_Sidebar_Menu\Widget;
3
+
4
  /**
5
+ * Base class for this plugin's widgets.
6
  *
7
  * @author OnPoint Plugins
8
  *
9
  * @since 7.2.0
10
  */
11
+ abstract class Widget_Abstract extends \WP_Widget {
12
  /**
13
  * The current widget instance
14
  *
15
  * @var array
16
  */
17
+ protected $widget_settings;
18
 
19
 
20
  /**
22
  * We do this manually because there are filters etc which
23
  * hit the instance before we get to self::form() and self::widget()
24
  *
 
 
25
  * @param array $instance - widget settings.
26
  * @param array $defaults - defaults for all widgets.
27
  *
28
+ * @see \WP_Widget::form_callback()
29
+ *
30
  * @since 7.2.0
31
  *
32
  * @return array
33
  */
34
  protected function set_instance( array $instance, array $defaults ) {
35
+ $this->widget_settings = (array) wp_parse_args( $instance, $defaults );
 
 
 
36
 
37
+ return $this->widget_settings;
38
  }
39
 
40
 
41
  /**
42
+ * Checks if a widget's checkbox is checked.
43
  *
44
  * Checks first for a value then verifies the value = checked
45
  *
50
  * @return bool
51
  */
52
  public function checked( $name ) {
53
+ return isset( $this->widget_settings[ $name ] ) && 'checked' === $this->widget_settings[ $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
61
+ * element or not.
62
+ * @param string $element_key - Match the `element_to_reveal` passed to $this->checkbox() for the checkbox
63
+ * which controls this.
64
  * @param bool $reverse - hide on check instead of show on check.
65
  *
66
  * @todo Convert all uses of this method to supply the $element_key
99
  * @since 7.2.0
100
  */
101
  public function checkbox( $name, $element_to_reveal = null ) {
102
+ if ( empty( $this->widget_settings[ $name ] ) ) {
103
+ $this->widget_settings[ $name ] = null;
104
  }
105
 
106
  ?>
111
  value="checked"
112
  data-js="advanced-sidebar-menu/widget/<?php echo esc_attr( $this->id_base ); ?>/<?php echo esc_attr( $name ); ?>"
113
  <?php echo ( null !== $element_to_reveal ) ? 'onclick="asm_reveal_element( \'' . esc_attr( $this->get_field_id( $element_to_reveal ) ) . '\')"' : ''; ?>
114
+ <?php echo esc_html( $this->widget_settings[ $name ] ); ?>
115
  />
116
  <?php
 
117
  }
118
  }
views/category_list.php CHANGED
@@ -1,26 +1,28 @@
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 ) ) {
@@ -28,22 +30,21 @@ if ( ! empty( $child_terms ) ) {
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
  }
1
  <?php
2
  /**
3
+ * The output of the "Advanced Sidebar Categories Menu" widget
4
  *
5
+ * @since 8.0.0
6
+ *
7
+ * To edit copy this file to a folder in your theme called 'advanced-sidebar-menu' and edit at will.
8
  *
9
+ * @notice Do NOT edit this file in this location, or it will break on update.
 
10
  *
11
+ * @package advanced-sidebar-menu
12
  */
13
 
14
+ use Advanced_Sidebar_Menu\Menus\Category;
15
+
16
+ $current_menu = Category::get_current();
17
+ $child_terms = $current_menu->get_child_terms();
18
+ $content = '';
19
 
20
  // Display parent category.
21
  if ( $current_menu->include_parent() ) {
22
  $content .= '<ul class="parent-sidebar-menu">';
23
 
24
+ $list_args = $current_menu->get_list_categories_args( Category::LEVEL_PARENT );
25
+ $content .= $current_menu->openListItem( wp_list_categories( $list_args ) );
26
  }
27
 
28
  if ( ! empty( $child_terms ) ) {
30
 
31
  // Always display child categories.
32
  if ( $current_menu->display_all() ) {
33
+ $list_args = $current_menu->get_list_categories_args( Category::LEVEL_DISPLAY_ALL );
34
+ $content .= wp_list_categories( $list_args );
 
35
  } else {
36
  foreach ( $child_terms as $_term ) {
37
  // Child terms.
38
  if ( $current_menu->is_first_level_term( $_term ) ) {
39
+ $list_args = $current_menu->get_list_categories_args( Category::LEVEL_CHILD, $_term );
40
+ $content .= $current_menu->openListItem( wp_list_categories( $list_args ) );
41
 
42
  // Grandchild terms.
43
  if ( $current_menu->is_current_term_ancestor( $_term ) && $current_menu->has_children( $_term ) ) {
44
  $content .= '<ul class="grandchild-sidebar-menu children">';
45
 
46
+ $list_args = $current_menu->get_list_categories_args( Category::LEVEL_GRANDCHILD, $_term );
47
+ $content .= wp_list_categories( $list_args );
48
 
49
  $content .= '</ul>';
50
  }
views/page_list.php CHANGED
@@ -1,39 +1,38 @@
1
  <?php
2
  /**
3
- * The Output of the Advanced Sidebar Page Widget
4
  *
5
- * @author OnPoint Plugins
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 -->';
1
  <?php
2
  /**
3
+ * The output of the "Advanced Sidebar Pages Menu" widget
4
  *
5
+ * @since 8.0.0
6
  *
7
+ * To edit copy this file to a folder in your theme called 'advanced-sidebar-menu' and edit at will.
 
8
  *
9
+ * @notice Do not edit this file in its original location, or it will break on upgrade.
 
 
10
  *
11
+ * @package advanced-sidebar-menu
12
  */
13
 
14
+ use Advanced_Sidebar_Menu\List_Pages;
15
+ use Advanced_Sidebar_Menu\Menus\Page;
16
+
17
+ $current_menu = Page::get_current();
18
+ $list_pages = 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( 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
  if ( $current_menu->include_parent() ) {
38
  $content .= '</li></ul><!-- End .parent-sidebar-menu -->';
views/sidebar-menu.css DELETED
@@ -1,36 +0,0 @@
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
- }