Passed
Push — master ( e51c9a...41921a )
by Chris
04:16
created

includes/nav-navwalker.php (21 issues)

1
<?php
2
/**
3
 * LSX functions and definitions - Navigation Walker.
4
 *
5
 * @package    lsx
6
 * @subpackage navigation
7
 * @category   bootstrap-walker
8
 */
9
10
if ( ! defined( 'ABSPATH' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
11
	exit;
12
}
13
14
add_filter( 'nav_menu_item_id', '__return_null' );
15
16
if ( ! function_exists( 'lsx_nav_menu_css_class' ) ) :
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
17
18
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$classes" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$item" missing
Loading history...
19
	 * Remove the id="" on nav menu items.
20
	 * Return 'menu-slug' for nav menu classes.
21
	 *
22
	 * @package    lsx
23
	 * @subpackage navigation
24
	 * @category   bootstrap-walker
25
	 */
26
	function lsx_nav_menu_css_class( $classes, $item ) {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
27
		$slug    = sanitize_title( $item->title );
28
		$classes = preg_replace( '/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes );
29
		$classes = preg_replace( '/^((menu|page)[-_\w+]+)+/', '', $classes );
30
31
		$classes[] = 'menu-' . $slug;
32
		$classes   = array_unique( $classes );
33
34
		return array_filter( $classes, 'lsx_is_element_empty' );
35
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
36
37
endif;
38
39
add_filter( 'nav_menu_css_class', 'lsx_nav_menu_css_class', 10, 2 );
40
41
if ( ! function_exists( 'lsx_nav_menu_args' ) ) :
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
42
43
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$args" missing
Loading history...
44
	 * Clean up wp_nav_menu_args.
45
	 *
46
	 * Remove the container.
47
	 * Use LSX_Nav_Walker() by default.
48
	 *
49
	 * @package    lsx
50
	 * @subpackage navigation
51
	 * @category   bootstrap-walker
52
	 */
53
	function lsx_nav_menu_args( $args = '' ) {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
54
		$roots_nav_menu_args['container'] = false;
55
56
		if ( ! $args['items_wrap'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
57
			$roots_nav_menu_args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
58
		}
59
60
		if ( current_theme_supports( 'bootstrap-top-navbar' ) && ! $args['depth'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
61
			$roots_nav_menu_args['depth'] = 2;
62
		}
63
64
		if ( ! $args['walker'] ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
65
			$roots_nav_menu_args['walker'] = new LSX_Nav_Walker();
66
		}
67
68
		return array_merge( $args, $roots_nav_menu_args );
69
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
70
71
endif;
72
73
add_filter( 'wp_nav_menu_args', 'lsx_nav_menu_args' );
74