PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.11.53
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.11.53
4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / includes / pa-nav-menu-walker.php
premium-addons-for-elementor / includes Last commit date
controls 6 months ago helpers 6 months ago pa-display-conditions 6 months ago templates 6 months ago acf-helper.php 6 months ago addons-cross-cp.php 6 months ago addons-integration.php 6 months ago assets-manager.php 6 months ago class-pa-core.php 6 months ago cm-pointer.php 6 months ago helper-functions.php 6 months ago live-editor-modal.php 6 months ago module-base.php 6 months ago pa-nav-menu-walker.php 6 months ago papro-promotion.php 6 months ago premium-template-tags.php 6 months ago
pa-nav-menu-walker.php
517 lines
1 <?php
2 /**
3 * PA Nav Menu Walker.
4 */
5
6 namespace PremiumAddons\Includes;
7
8 // PA classes.
9 use PremiumAddons\Includes\Helper_Functions;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Class Pa_Nav_Menu_Walker.
17 */
18 class Pa_Nav_Menu_Walker extends \Walker_Nav_Menu {
19
20 /**
21 * Menu Settings.
22 *
23 * @var settings
24 */
25 private $settings = null;
26
27 /**
28 * Is mobile menu flag.
29 *
30 * @var is_mobile_menu
31 */
32 private $is_mobile_menu = null;
33
34
35 /**
36 * Class Constructor.
37 *
38 * @param array $widget_settings widget settings.
39 * @param bool $is_mobile_menu is toggle menu flag.
40 */
41 public function __construct( $widget_settings, $is_mobile_menu = false ) {
42
43 $this->settings = $widget_settings;
44
45 $this->is_mobile_menu = $is_mobile_menu;
46 }
47
48 /**
49 * Get Item Postmeta data.
50 *
51 * @since 4.9.4
52 * @access public
53 *
54 * @param int|string $item_id menu item id.
55 *
56 * @return object
57 */
58 public function get_item_postmeta( $item_id ) {
59
60 $defauls = array(
61 'item_id' => '',
62 'item_icon' => '',
63 'item_badge' => '',
64 'item_depth' => '',
65 'item_badge_bg' => '',
66 'item_icon_type' => '',
67 'item_lottie_url' => '',
68 'item_icon_color' => '',
69 'item_badge_color' => '',
70 'mega_content_pos' => '',
71 'mega_content_width' => '',
72 'mega_content_enabled' => '',
73 'full_width_mega_content' => '',
74 );
75
76 $item_meta = array_merge( $defauls, (array) json_decode( get_post_meta( $item_id, 'pa_megamenu_item_meta', true ) ) );
77
78 return (object) $item_meta;
79 }
80
81 /**
82 * Get Mega Content ID.
83 * Retrieves mega content id from postmeta table.
84 *
85 * @access public
86 * @since 4.9.4
87 *
88 * @param string $item_id menu item id.
89 *
90 * @return string
91 */
92 public function get_mega_content_id( $item_id ) {
93 return get_post_meta( $item_id, 'pa_mega_content_temp', true );
94 }
95
96 /**
97 * Get default submenu icon.
98 *
99 * @access public
100 * @since 4.9.18
101 *
102 * @param string $layout main menu layout.
103 *
104 * @return string
105 */
106 public function get_default_submenu_icon() {
107
108 // toggle menu icon.
109 if ( $this->is_mobile_menu ) {
110 return 'fas fa-angle-down';
111 }
112
113 $icon = 'fas fa-angle-right';
114 $layout = $this->settings['pa_nav_menu_layout'];
115
116 switch ( $layout ) {
117 case 'hor':
118 if ( is_rtl() ) {
119 $icon = 'fas fa-angle-left';
120 }
121 break;
122
123 case 'slide':
124 case 'dropdown':
125 $icon = 'fas fa-angle-down';
126 break;
127
128 case 'ver':
129 $icon = 'fas fa-angle-' . $this->settings['pa_nav_ver_submenu'];
130 break;
131 }
132
133 return $icon;
134 }
135
136 /**
137 * Starts the list before the elements are added.
138 *
139 * @since 3.0.0
140 *
141 * @see Walker::start_lvl()
142 *
143 * @param string $output Used to append additional content (passed by reference).
144 * @param int $depth Depth of menu item. Used for padding.
145 * @param stdClass $args An object of wp_nav_menu() arguments.
146 */
147 public function start_lvl( &$output, $depth = 0, $args = null ) {
148
149 $settings = $this->settings;
150
151 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
152 $t = '';
153 $n = '';
154 } else {
155 $t = "\t";
156 $n = "\n";
157 }
158
159 $indent = str_repeat( $t, $depth );
160
161 $classes = array( 'premium-sub-menu', 'premium-lq__' . $settings['submenu_lq_effect'] );
162
163 /**
164 * Filters the CSS class(es) applied to a menu list element.
165 *
166 * @since 4.8.0
167 *
168 * @param string[] $classes Array of the CSS classes that are applied to the menu `<ul>` element.
169 * @param stdClass $args An object of `wp_nav_menu()` arguments.
170 * @param int $depth Depth of menu item. Used for padding.
171 */
172 $class_names = implode( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) );
173 $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
174
175 $output .= "{$n}{$indent}<ul$class_names>{$n}";
176 }
177
178 /**
179 * Ends the list of after the elements are added.
180 *
181 * @since 3.0.0
182 *
183 * @see Walker::end_lvl()
184 *
185 * @param string $output Used to append additional content (passed by reference).
186 * @param int $depth Depth of menu item. Used for padding.
187 * @param stdClass $args An object of wp_nav_menu() arguments.
188 */
189 public function end_lvl( &$output, $depth = 0, $args = null ) {
190 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
191 $t = '';
192 $n = '';
193 } else {
194 $t = "\t";
195 $n = "\n";
196 }
197 $indent = str_repeat( $t, $depth );
198 $output .= "$indent</ul>{$n}";
199 }
200
201 /**
202 * Starts the element output.
203 *
204 * @since 3.0.0
205 * @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
206 * @since 5.9.0 Renamed `$item` to `$data_object` and `$id` to `$current_object_id`
207 * to match parent class for PHP 8 named parameter support.
208 *
209 * @see Walker::start_el()
210 *
211 * @param string $output Used to append additional content (passed by reference).
212 * @param WP_Post $data_object Menu item data object.
213 * @param int $depth Depth of menu item. Used for padding.
214 * @param stdClass $args An object of wp_nav_menu() arguments.
215 * @param int $current_object_id Optional. ID of the current menu item. Default 0.
216 */
217 public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
218
219 $settings = $this->settings;
220
221 // Restores the more descriptive, specific name for use within this method.
222 $menu_item = $data_object;
223
224 if ( is_null( $menu_item ) ) {
225 return;
226 }
227
228 $item_meta = $this->get_item_postmeta( $menu_item->ID );
229
230 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
231 $t = '';
232 $n = '';
233 } else {
234 $t = "\t";
235 $n = "\n";
236 }
237
238 $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
239
240 $classes = empty( $menu_item->classes ) ? array() : (array) $menu_item->classes; // has default classes.
241
242 $classes[] = 'premium-nav-menu-item'; // add our own class too.
243
244 if ( 0 < $depth ) {
245 $classes[] = 'premium-sub-menu-item';
246 }
247
248 if ( 'true' == $item_meta->mega_content_enabled ) {
249 $classes[] = 'premium-mega-nav-item menu-item-has-children';
250
251 if ( 'default' === $item_meta->mega_content_pos ) {
252 $classes[] = 'premium-mega-item-static';
253 }
254 }
255
256 /** handling active anchor links which redirects to an id in a page.
257 * make sure we exclude URL with the #/ as it's not a valid ID selector.
258 */
259 $is_anchor = false !== strpos( $menu_item->url, '#' ) && false === strpos( $menu_item->url, '#/' );
260
261 // we can later add other classes here based on the user settings.
262 if ( ! $is_anchor && in_array( 'current-menu-item', $classes, true ) ) {
263 $classes[] = 'premium-active-item';
264 }
265
266 if ( $is_anchor ) { // the active class will be added via js.
267 $classes[] = 'premium-item-anchor';
268 }
269
270 // Add badge marker.
271 if ( ! empty( $item_meta->item_badge ) ) {
272 $classes[] = 'has-pa-badge';
273
274 // check for sub item badge effects.
275 $badge_effect = $settings['sub_badge_hv_effects'];
276
277 if ( 0 < $depth && '' !== $badge_effect ) {
278 $classes[] = 'premium-badge-' . $badge_effect;
279 }
280 }
281
282 /**
283 * Filters the arguments for a single nav menu item.
284 *
285 * @since 4.4.0
286 *
287 * @param stdClass $args An object of wp_nav_menu() arguments.
288 * @param WP_Post $menu_item Menu item data object.
289 * @param int $depth Depth of menu item. Used for padding.
290 */
291 $args = apply_filters( 'nav_menu_item_args', $args, $menu_item, $depth ); // default fitler.
292
293 /**
294 * Filters the CSS classes applied to a menu item's list item element.
295 *
296 * @since 3.0.0
297 * @since 4.1.0 The `$depth` parameter was added.
298 *
299 * @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
300 * @param WP_Post $menu_item The current menu item object.
301 * @param stdClass $args An object of wp_nav_menu() arguments.
302 * @param int $depth Depth of menu item. Used for padding.
303 */
304 $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
305 $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
306
307 /**
308 * Filters the ID applied to a menu item's list item element.
309 *
310 * @since 3.0.1
311 * @since 4.1.0 The `$depth` parameter was added.
312 *
313 * @param string $menu_id The ID that is applied to the menu item's `<li>` element.
314 * @param WP_Post $menu_item The current menu item.
315 * @param stdClass $args An object of wp_nav_menu() arguments.
316 * @param int $depth Depth of menu item. Used for padding.
317 */
318 $id = apply_filters( 'nav_menu_item_id', 'premium-nav-menu-item-' . $menu_item->ID, $menu_item, $args, $depth ); // change the default id.
319 $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
320
321 $full_width = 'true' == $item_meta->full_width_mega_content ? ' data-full-width="true"' : '';
322
323 $output .= $indent . '<li' . $id . $class_names . $full_width . '>';
324 // link attributes.
325 $atts = array();
326 $atts['title'] = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : '';
327 $atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
328
329 if ( '_blank' === $menu_item->target && empty( $menu_item->xfn ) ) {
330
331 $atts['rel'] = 'noopener';
332 } else {
333
334 $atts['rel'] = $menu_item->xfn;
335 }
336
337 $atts['href'] = ! empty( $menu_item->url ) ? $menu_item->url : '';
338 $atts['aria-current'] = $menu_item->current ? 'page' : '';
339
340 /**
341 * Page-Transition Experiment Fix.
342 * add elementor's custom attribute to Toggle menu links
343 * && if the element has sub|mega menu.
344 */
345 $is_parent = in_array( 'menu-item-has-children', $classes, true ) || 'true' == $item_meta->mega_content_enabled;
346 $is_toggle = in_array( $settings['pa_nav_menu_layout'], array( 'dropdown', 'slide' ), true ) || wp_is_mobile();
347
348 if ( $is_toggle && $is_parent ) {
349 $atts['data-e-disable-page-transition'] = 'true';
350 }
351
352 /**
353 * Filters the HTML attributes applied to a menu item's anchor element.
354 *
355 * @since 3.6.0
356 * @since 4.1.0 The `$depth` parameter was added.
357 *
358 * @param array $atts {
359 * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
360 *
361 * @type string $title Title attribute.
362 * @type string $target Target attribute.
363 * @type string $rel The rel attribute.
364 * @type string $href The href attribute.
365 * @type string $aria-current The aria-current attribute.
366 * }
367 * @param WP_Post $menu_item The current menu item object.
368 * @param stdClass $args An object of wp_nav_menu() arguments.
369 * @param int $depth Depth of menu item. Used for padding.
370 */
371 $atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
372
373 // add our own class.
374 if ( empty( $atts['class'] ) ) {
375 $atts['class'] = 'premium-menu-link';
376 } else {
377 $atts['class'] .= ' premium-menu-link';
378 }
379
380 if ( 0 == $depth ) {
381
382 $atts['class'] .= ' premium-menu-link-parent';
383 $atts['class'] .= ' premium-lq__' . $settings['item_lq_effect'];
384 }
385
386 $dropdown_icon = '';
387
388 $dropdown_icon_class = '';
389 $item_icon = '';
390 $item_badge = '';
391 $icon_class = 0 < $depth ? ' premium-sub-item-icon' : ' premium-item-icon';
392 $badge_class = 0 < $depth ? 'premium-sub-item-badge' : 'premium-item-badge';
393
394 if ( in_array( 'menu-item-has-children', $classes, true ) || 'true' == $item_meta->mega_content_enabled ) {
395
396 // $dropdown_icon_class = 0 === $depth ? $settings['submenu_icon']['value'] : $this->get_default_submenu_icon();
397
398 // submenu_item_icon.
399 if ( 0 === $depth ) {
400 $dropdown_icon_class = $settings['submenu_icon']['value'];
401 } else {
402 $dropdown_icon_class = ! empty( $settings['submenu_item_icon']['value'] ) ? $settings['submenu_item_icon']['value'] : $this->get_default_submenu_icon();
403 }
404
405 if ( ! empty( $dropdown_icon_class ) ) {
406
407 $dropdown_icon_class .= ' premium-dropdown-icon';
408 $dropdown_icon = sprintf( '<i class="%1$s"></i>', esc_attr( $dropdown_icon_class ) );
409
410 }
411 }
412
413 // add item icon.
414 if ( 'icon' === $item_meta->item_icon_type && ! empty( $item_meta->item_icon ) ) {
415 $item_icon = sprintf( '<i class="%1$s" style="color:%2$s"></i>', esc_attr( $item_meta->item_icon . $icon_class ), esc_attr( $item_meta->item_icon_color ) );
416 } elseif ( 'lottie' === $item_meta->item_icon_type && ! empty( $item_meta->item_lottie_url ) ) {
417 $item_icon = sprintf( '<div class="%1$s" data-lottie-url="%2$s" data-lottie-loop="true"></div>', esc_attr( $icon_class ) . ' premium-lottie-animation', esc_url( $item_meta->item_lottie_url ) );
418 }
419
420 // add item badge.
421 if ( ! empty( $item_meta->item_badge ) ) {
422 $item_badge = sprintf( '<span class="%1$s" style="color:%2$s; background-color:%3$s;">%4$s</span>', esc_attr( $badge_class ), esc_attr( $item_meta->item_badge_color ), esc_attr( $item_meta->item_badge_bg ), esc_attr( $item_meta->item_badge ) );
423 }
424
425 if ( 0 < $depth ) {
426 $atts['class'] .= ' premium-sub-menu-link';
427 }
428
429 $attributes = '';
430 foreach ( $atts as $attr => $value ) {
431 if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
432 $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
433 $attributes .= ' ' . $attr . '="' . $value . '"';
434 }
435 }
436
437 /** This filter is documented in wp-includes/post-template.php */
438 $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
439
440 /**
441 * Filters a menu item's title.
442 *
443 * @since 4.4.0
444 *
445 * @param string $title The menu item's title.
446 * @param WP_Post $menu_item The current menu item object.
447 * @param stdClass $args An object of wp_nav_menu() arguments.
448 * @param int $depth Depth of menu item. Used for padding.
449 */
450 $title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );
451
452 $item_output = $args->before;
453 $item_output .= '<a' . $attributes . '>';
454 $item_output .= $args->link_before . $item_icon . $title . $dropdown_icon . $item_badge . $args->link_after;
455 $item_output .= '</a>';
456 $item_output .= $args->after;
457
458 /**
459 * Filters a menu item's starting output.
460 *
461 * The menu item's starting output only includes `$args->before`, the opening `<a>`,
462 * the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
463 * no filter for modifying the opening and closing `<li>` for a menu item.
464 *
465 * @since 3.0.0
466 *
467 * @param string $item_output The menu item's starting HTML output.
468 * @param WP_Post $menu_item Menu item data object.
469 * @param int $depth Depth of menu item. Used for padding.
470 * @param stdClass $args An object of wp_nav_menu() arguments.
471 */
472 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );
473 }
474
475 /**
476 * Ends the element output, if needed.
477 *
478 * @since 3.0.0
479 * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
480 *
481 * @see Walker::end_el()
482 *
483 * @param string $output Used to append additional content (passed by reference).
484 * @param WP_Post $data_object Menu item data object. Not used.
485 * @param int $depth Depth of page. Not Used.
486 * @param stdClass $args An object of wp_nav_menu() arguments.
487 */
488 public function end_el( &$output, $data_object, $depth = 0, $args = null ) {
489
490 /**
491 * Add mega content to main nav menu items only.
492 */
493 if ( 0 === $depth ) {
494
495 $item_meta = $this->get_item_postmeta( $data_object->ID );
496
497 if ( 'true' == $item_meta->mega_content_enabled && class_exists( 'Elementor\Plugin' ) ) {
498
499 $temp_id = $this->get_mega_content_id( $data_object->ID );
500 $content = Helper_Functions::render_elementor_template( $temp_id, true );
501 $style = 'width:' . $item_meta->mega_content_width;
502 $output .= sprintf( '<div id="premium-mega-content-%1$s" class="premium-mega-content-container" style="%2$s">%3$s</div>', $data_object->ID, $style, $content );
503 }
504 }
505
506 if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
507 $t = '';
508 $n = '';
509 } else {
510 $t = "\t";
511 $n = "\n";
512 }
513
514 $output .= "</li>{$n}";
515 }
516 }
517