run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄class-walker-nav-menu.php
1<?php
2/**
3 * Nav Menu API: Walker_Nav_Menu class
4 *
5 * @package WordPress
6 * @subpackage Nav_Menus
7 * @since 4.6.0
8 */
9
10/**
11 * Core class used to implement an HTML list of nav menu items.
12 *
13 * @since 3.0.0
14 *
15 * @see Walker
16 */
17class Walker_Nav_Menu extends Walker {
18 /**
19 * What the class handles.
20 *
21 * @since 3.0.0
22 * @var string
23 *
24 * @see Walker::$tree_type
25 */
26 public $tree_type = array( 'post_type', 'taxonomy', 'custom' );
27
28 /**
29 * Database fields to use.
30 *
31 * @since 3.0.0
32 * @todo Decouple this.
33 * @var string[]
34 *
35 * @see Walker::$db_fields
36 */
37 public $db_fields = array(
38 'parent' => 'menu_item_parent',
39 'id' => 'db_id',
40 );
41
42 /**
43 * The URL to the privacy policy page.
44 *
45 * @since 6.8.0
46 * @var string
47 */
48 private $privacy_policy_url;
49
50 /**
51 * Constructor.
52 *
53 * @since 6.8.0
54 */
55 public function __construct() {
56 $this->privacy_policy_url = get_privacy_policy_url();
57 }
58
59 /**
60 * Starts the list before the elements are added.
61 *
62 * @since 3.0.0
63 *
64 * @see Walker::start_lvl()
65 *
66 * @param string $output Used to append additional content (passed by reference).
67 * @param int $depth Depth of menu item. Used for padding.
68 * @param stdClass $args An object of wp_nav_menu() arguments.
69 */
70 public function start_lvl( &$output, $depth = 0, $args = null ) {
71 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
72 $t = '';
73 $n = '';
74 } else {
75 $t = "\t";
76 $n = "\n";
77 }
78 $indent = str_repeat( $t, $depth );
79
80 // Default class.
81 $classes = array( 'sub-menu' );
82
83 /**
84 * Filters the CSS class(es) applied to a menu list element.
85 *
86 * @since 4.8.0
87 *
88 * @param string[] $classes Array of the CSS classes that are applied to the menu `<ul>` element.
89 * @param stdClass $args An object of `wp_nav_menu()` arguments.
90 * @param int $depth Depth of menu item. Used for padding.
91 */
92 $class_names = implode( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
93
94 $atts = array();
95 $atts['class'] = ! empty( $class_names ) ? $class_names : '';
96
97 /**
98 * Filters the HTML attributes applied to a menu list element.
99 *
100 * @since 6.3.0
101 *
102 * @param array $atts {
103 * The HTML attributes applied to the `<ul>` element, empty strings are ignored.
104 *
105 * @type string $class HTML CSS class attribute.
106 * }
107 * @param stdClass $args An object of `wp_nav_menu()` arguments.
108 * @param int $depth Depth of menu item. Used for padding.
109 */
110 $atts = apply_filters( 'nav_menu_submenu_attributes', $atts, $args, $depth );
111 $attributes = $this->build_atts( $atts );
112
113 $output .= "{$n}{$indent}<ul{$attributes}>{$n}";
114 }
115
116 /**
117 * Ends the list of after the elements are added.
118 *
119 * @since 3.0.0
120 *
121 * @see Walker::end_lvl()
122 *
123 * @param string $output Used to append additional content (passed by reference).
124 * @param int $depth Depth of menu item. Used for padding.
125 * @param stdClass $args An object of wp_nav_menu() arguments.
126 */
127 public function end_lvl( &$output, $depth = 0, $args = null ) {
128 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
129 $t = '';
130 $n = '';
131 } else {
132 $t = "\t";
133 $n = "\n";
134 }
135 $indent = str_repeat( $t, $depth );
136 $output .= "$indent</ul>{$n}";
137 }
138
139 /**
140 * Starts the element output.
141 *
142 * @since 3.0.0
143 * @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
144 * @since 5.9.0 Renamed `$item` to `$data_object` and `$id` to `$current_object_id`
145 * to match parent class for PHP 8 named parameter support.
146 * @since 6.7.0 Removed redundant title attributes.
147 *
148 * @see Walker::start_el()
149 *
150 * @param string $output Used to append additional content (passed by reference).
151 * @param WP_Post $data_object Menu item data object.
152 * @param int $depth Depth of menu item. Used for padding.
153 * @param stdClass $args An object of wp_nav_menu() arguments.
154 * @param int $current_object_id Optional. ID of the current menu item. Default 0.
155 */
156 public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {
157 // Restores the more descriptive, specific name for use within this method.
158 $menu_item = $data_object;
159
160 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
161 $t = '';
162 $n = '';
163 } else {
164 $t = "\t";
165 $n = "\n";
166 }
167 $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
168
169 $classes = empty( $menu_item->classes ) ? array() : (array) $menu_item->classes;
170 $classes[] = 'menu-item-' . $menu_item->ID;
171
172 /**
173 * Filters the arguments for a single nav menu item.
174 *
175 * @since 4.4.0
176 *
177 * @param stdClass $args An object of wp_nav_menu() arguments.
178 * @param WP_Post $menu_item Menu item data object.
179 * @param int $depth Depth of menu item. Used for padding.
180 */
181 $args = apply_filters( 'nav_menu_item_args', $args, $menu_item, $depth );
182
183 /**
184 * Filters the CSS classes applied to a menu item's list item element.
185 *
186 * @since 3.0.0
187 * @since 4.1.0 The `$depth` parameter was added.
188 *
189 * @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
190 * @param WP_Post $menu_item The current menu item object.
191 * @param stdClass $args An object of wp_nav_menu() arguments.
192 * @param int $depth Depth of menu item. Used for padding.
193 */
194 $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
195
196 /**
197 * Filters the ID attribute applied to a menu item's list item element.
198 *
199 * @since 3.0.1
200 * @since 4.1.0 The `$depth` parameter was added.
201 *
202 * @param string $menu_item_id The ID attribute applied to the menu item's `<li>` element.
203 * @param WP_Post $menu_item The current menu item.
204 * @param stdClass $args An object of wp_nav_menu() arguments.
205 * @param int $depth Depth of menu item. Used for padding.
206 */
207 $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $menu_item->ID, $menu_item, $args, $depth );
208
209 $li_atts = array();
210 $li_atts['id'] = ! empty( $id ) ? $id : '';
211 $li_atts['class'] = ! empty( $class_names ) ? $class_names : '';
212
213 /**
214 * Filters the HTML attributes applied to a menu's list item element.
215 *
216 * @since 6.3.0
217 *
218 * @param array $li_atts {
219 * The HTML attributes applied to the menu item's `<li>` element, empty strings are ignored.
220 *
221 * @type string $class HTML CSS class attribute.
222 * @type string $id HTML id attribute.
223 * }
224 * @param WP_Post $menu_item The current menu item object.
225 * @param stdClass $args An object of wp_nav_menu() arguments.
226 * @param int $depth Depth of menu item. Used for padding.
227 */
228 $li_atts = apply_filters( 'nav_menu_item_attributes', $li_atts, $menu_item, $args, $depth );
229 $li_attributes = $this->build_atts( $li_atts );
230
231 $output .= $indent . '<li' . $li_attributes . '>';
232
233 /** This filter is documented in wp-includes/post-template.php */
234 $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
235
236 // Save filtered value before filtering again.
237 $the_title_filtered = $title;
238
239 /**
240 * Filters a menu item's title.
241 *
242 * @since 4.4.0
243 *
244 * @param string $title The menu item's title.
245 * @param WP_Post $menu_item The current menu item object.
246 * @param stdClass $args An object of wp_nav_menu() arguments.
247 * @param int $depth Depth of menu item. Used for padding.
248 */
249 $title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );
250
251 $atts = array();
252 $atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
253 $atts['rel'] = ! empty( $menu_item->xfn ) ? $menu_item->xfn : '';
254
255 if ( ! empty( $menu_item->url ) ) {
256 if ( $this->privacy_policy_url === $menu_item->url ) {
257 $atts['rel'] = empty( $atts['rel'] ) ? 'privacy-policy' : $atts['rel'] . ' privacy-policy';
258 }
259
260 $atts['href'] = $menu_item->url;
261 } else {
262 $atts['href'] = '';
263 }
264
265 $atts['aria-current'] = $menu_item->current ? 'page' : '';
266
267 // Add title attribute only if it does not match the link text (before or after filtering).
268 if ( ! empty( $menu_item->attr_title )
269 && trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $menu_item->title ) )
270 && trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $the_title_filtered ) )
271 && trim( strtolower( $menu_item->attr_title ) ) !== trim( strtolower( $title ) )
272 ) {
273 $atts['title'] = $menu_item->attr_title;
274 } else {
275 $atts['title'] = '';
276 }
277
278 /**
279 * Filters the HTML attributes applied to a menu item's anchor element.
280 *
281 * @since 3.6.0
282 * @since 4.1.0 The `$depth` parameter was added.
283 *
284 * @param array $atts {
285 * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
286 *
287 * @type string $title Title attribute.
288 * @type string $target Target attribute.
289 * @type string $rel The rel attribute.
290 * @type string $href The href attribute.
291 * @type string $aria-current The aria-current attribute.
292 * }
293 * @param WP_Post $menu_item The current menu item object.
294 * @param stdClass $args An object of wp_nav_menu() arguments.
295 * @param int $depth Depth of menu item. Used for padding.
296 */
297 $atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
298 $attributes = $this->build_atts( $atts );
299
300 $item_output = $args->before;
301 $item_output .= '<a' . $attributes . '>';
302 $item_output .= $args->link_before . $title . $args->link_after;
303 $item_output .= '</a>';
304 $item_output .= $args->after;
305
306 /**
307 * Filters a menu item's starting output.
308 *
309 * The menu item's starting output only includes `$args->before`, the opening `<a>`,
310 * the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
311 * no filter for modifying the opening and closing `<li>` for a menu item.
312 *
313 * @since 3.0.0
314 *
315 * @param string $item_output The menu item's starting HTML output.
316 * @param WP_Post $menu_item Menu item data object.
317 * @param int $depth Depth of menu item. Used for padding.
318 * @param stdClass $args An object of wp_nav_menu() arguments.
319 */
320 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );
321 }
322
323 /**
324 * Ends the element output, if needed.
325 *
326 * @since 3.0.0
327 * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
328 *
329 * @see Walker::end_el()
330 *
331 * @param string $output Used to append additional content (passed by reference).
332 * @param WP_Post $data_object Menu item data object. Not used.
333 * @param int $depth Depth of page. Not Used.
334 * @param stdClass $args An object of wp_nav_menu() arguments.
335 */
336 public function end_el( &$output, $data_object, $depth = 0, $args = null ) {
337 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
338 $t = '';
339 $n = '';
340 } else {
341 $t = "\t";
342 $n = "\n";
343 }
344 $output .= "</li>{$n}";
345 }
346
347 /**
348 * Builds a string of HTML attributes from an array of key/value pairs.
349 * Empty values are ignored.
350 *
351 * @since 6.3.0
352 *
353 * @param array $atts Optional. An array of HTML attribute key/value pairs. Default empty array.
354 * @return string A string of HTML attributes.
355 */
356 protected function build_atts( $atts = array() ) {
357 $attribute_string = '';
358 foreach ( $atts as $attr => $value ) {
359 if ( false !== $value && '' !== $value && is_scalar( $value ) ) {
360 $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
361 $attribute_string .= ' ' . $attr . '="' . $value . '"';
362 }
363 }
364 return $attribute_string;
365 }
366}
367
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.