PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.2
Kubio AI Page Builder v2.8.2
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / menu / class-kubio-menu-wallker.php
kubio / lib / menu Last commit date
class-kubio-menu-wallker.php 1 year ago class-wp-rest-menu-locations-controller.php 4 years ago class-wp-rest-menus-controller.php 1 year ago index.php 1 year ago locations.php 1 year ago menu-rest-controller.php 1 year ago
class-kubio-menu-wallker.php
230 lines
1 <?php
2
3 class Kubio_Nav_Menu_Walker extends \Walker_Nav_Menu {
4
5 /**
6 * Starts the list before the elements are added.
7 *
8 * @since 3.0.0
9 *
10 * @see Walker::start_lvl()
11 *
12 * @param string $output Used to append additional content (passed by reference).
13 * @param int $depth Depth of menu item. Used for padding.
14 * @param stdClass $args An object of wp_nav_menu() arguments.
15 */
16 public function start_lvl( &$output, $depth = 0, $args = null ) {
17 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
18 $t = '';
19 $n = '';
20 } else {
21 $t = "\t";
22 $n = "\n";
23 }
24 $indent = str_repeat( $t, $depth );
25
26 // Default class.
27 $classes = array( 'sub-menu' );
28
29 /**
30 * Filters the CSS class(es) applied to a menu list element.
31 *
32 * @since 4.8.0
33 *
34 * @param string[] $classes Array of the CSS classes that are applied to the menu `<ul>` element.
35 * @param stdClass $args An object of `wp_nav_menu()` arguments.
36 * @param int $depth Depth of menu item. Used for padding.
37 */
38 $class_names = implode( ' ', $classes );
39 $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
40
41 $output .= "{$n}{$indent}<ul$class_names>{$n}";
42 }
43
44 /**
45 * Ends the list of after the elements are added.
46 *
47 * @since 3.0.0
48 *
49 * @see Walker::end_lvl()
50 *
51 * @param string $output Used to append additional content (passed by reference).
52 * @param int $depth Depth of menu item. Used for padding.
53 * @param stdClass $args An object of wp_nav_menu() arguments.
54 */
55 public function end_lvl( &$output, $depth = 0, $args = null ) {
56 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
57 $t = '';
58 $n = '';
59 } else {
60 $t = "\t";
61 $n = "\n";
62 }
63 $indent = str_repeat( $t, $depth );
64 $output .= "$indent</ul>{$n}";
65 }
66
67 /**
68 * Starts the element output.
69 *
70 * @since 3.0.0
71 * @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
72 * @since 5.9.0 Renamed `$item` to `$data_object` and `$id` to `$current_object_id`
73 * to match parent class for PHP 8 named parameter support.
74 *
75 * @see Walker::start_el()
76 *
77 * @param string $output Used to append additional content (passed by reference).
78 * @param WP_Post $data_object Menu item data object.
79 * @param int $depth Depth of menu item. Used for padding.
80 * @param stdClass $args An object of wp_nav_menu() arguments.
81 * @param int $current_object_id Optional. ID of the current menu item. Default 0.
82 */
83 public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {
84 // Restores the more descriptive, specific name for use within this method.
85 $menu_item = $data_object;
86
87 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
88 $t = '';
89 $n = '';
90 } else {
91 $t = "\t";
92 $n = "\n";
93 }
94 $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
95
96 $classes = empty( $menu_item->classes ) ? array() : (array) $menu_item->classes;
97 $classes[] = 'menu-item-' . $menu_item->ID;
98
99 /**
100 * Filters the arguments for a single nav menu item.
101 *
102 * @since 4.4.0
103 *
104 * @param stdClass $args An object of wp_nav_menu() arguments.
105 * @param WP_Post $menu_item Menu item data object.
106 * @param int $depth Depth of menu item. Used for padding.
107 */
108 $args = apply_filters( 'kubio/nav_menu_item_args', $args, $menu_item, $depth );
109
110 /**
111 * Filters the CSS classes applied to a menu item's list item element.
112 *
113 * @since 3.0.0
114 * @since 4.1.0 The `$depth` parameter was added.
115 *
116 * @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
117 * @param WP_Post $menu_item The current menu item object.
118 * @param stdClass $args An object of wp_nav_menu() arguments.
119 * @param int $depth Depth of menu item. Used for padding.
120 */
121 $class_names = implode( ' ', apply_filters( 'kubio/nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
122 $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
123
124 /**
125 * Filters the ID applied to a menu item's list item element.
126 *
127 * @since 3.0.1
128 * @since 4.1.0 The `$depth` parameter was added.
129 *
130 * @param string $menu_id The ID that is applied to the menu item's `<li>` element.
131 * @param WP_Post $menu_item The current menu item.
132 * @param stdClass $args An object of wp_nav_menu() arguments.
133 * @param int $depth Depth of menu item. Used for padding.
134 */
135 $id = apply_filters( 'kubio/nav_menu_item_id', 'menu-item-' . $menu_item->ID, $menu_item, $args, $depth );
136 $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
137
138 $output .= $indent . '<li' . $id . $class_names . '>';
139
140 $atts = array();
141 $atts['title'] = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : '';
142 $atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
143 if ( '_blank' === $menu_item->target && empty( $menu_item->xfn ) ) {
144 $atts['rel'] = 'noopener';
145 } else {
146 $atts['rel'] = $menu_item->xfn;
147 }
148 $atts['href'] = ! empty( $menu_item->url ) ? $menu_item->url : '';
149 $atts['aria-current'] = $menu_item->current ? 'page' : '';
150
151 /**
152 * Filters the HTML attributes applied to a menu item's anchor element.
153 *
154 * @since 3.6.0
155 * @since 4.1.0 The `$depth` parameter was added.
156 *
157 * @param array $atts {
158 * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
159 *
160 * @type string $title Title attribute.
161 * @type string $target Target attribute.
162 * @type string $rel The rel attribute.
163 * @type string $href The href attribute.
164 * @type string $aria-current The aria-current attribute.
165 * }
166 * @param WP_Post $menu_item The current menu item object.
167 * @param stdClass $args An object of wp_nav_menu() arguments.
168 * @param int $depth Depth of menu item. Used for padding.
169 */
170 $atts = apply_filters( 'kubio/nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
171
172 $attributes = '';
173 foreach ( $atts as $attr => $value ) {
174 if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
175 $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
176 $attributes .= ' ' . $attr . '="' . $value . '"';
177 }
178 }
179
180 /** This filter is documented in wp-includes/post-template.php */
181 $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
182
183 $item_output = $args->before;
184 $item_output .= '<a' . $attributes . '>';
185 $item_output .= $args->link_before . $title . $args->link_after;
186 $item_output .= '</a>';
187 $item_output .= $args->after;
188
189 /**
190 * Filters a menu item's starting output.
191 *
192 * The menu item's starting output only includes `$args->before`, the opening `<a>`,
193 * the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
194 * no filter for modifying the opening and closing `<li>` for a menu item.
195 *
196 * @since 3.0.0
197 *
198 * @param string $item_output The menu item's starting HTML output.
199 * @param WP_Post $menu_item Menu item data object.
200 * @param int $depth Depth of menu item. Used for padding.
201 * @param stdClass $args An object of wp_nav_menu() arguments.
202 */
203 $output .= $item_output;
204 }
205
206 /**
207 * Ends the element output, if needed.
208 *
209 * @since 3.0.0
210 * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
211 *
212 * @see Walker::end_el()
213 *
214 * @param string $output Used to append additional content (passed by reference).
215 * @param WP_Post $data_object Menu item data object. Not used.
216 * @param int $depth Depth of page. Not Used.
217 * @param stdClass $args An object of wp_nav_menu() arguments.
218 */
219 public function end_el( &$output, $data_object, $depth = 0, $args = null ) {
220 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
221 $t = '';
222 $n = '';
223 } else {
224 $t = "\t";
225 $n = "\n";
226 }
227 $output .= "</li>{$n}";
228 }
229 }
230