@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param string $arg it can be menu id, slug or full name |
26 | 26 | */ |
27 | - public function __construct( $arg = null ) { |
|
27 | + public function __construct($arg = null) { |
|
28 | 28 | |
29 | - if ( is_numeric( $arg ) && 0 !== absint( $arg ) ) { |
|
29 | + if (is_numeric($arg) && 0 !== absint($arg)) { |
|
30 | 30 | |
31 | - $menu_id = $this->check_menu_id( $arg ); |
|
31 | + $menu_id = $this->check_menu_id($arg); |
|
32 | 32 | |
33 | - } elseif ( is_string( $arg ) ) { |
|
33 | + } elseif (is_string($arg)) { |
|
34 | 34 | |
35 | - $menu_id = $this->get_menu_id_by_name( $arg ); |
|
35 | + $menu_id = $this->get_menu_id_by_name($arg); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | - if ( ! isset( $menu_id ) ) { |
|
39 | + if (!isset($menu_id)) { |
|
40 | 40 | |
41 | 41 | $menu_id = $this->get_first_menu_id(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | - if ( $menu_id ) { |
|
45 | + if ($menu_id) { |
|
46 | 46 | |
47 | 47 | $this->ID = $menu_id; |
48 | 48 | |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $_return = array(); |
63 | 63 | |
64 | - $items = wp_get_nav_menu_items( $this->ID ); |
|
64 | + $items = wp_get_nav_menu_items($this->ID); |
|
65 | 65 | |
66 | - foreach ( $items as $item ) { |
|
66 | + foreach ($items as $item) { |
|
67 | 67 | |
68 | - $_return[ $item->ID ] = new Menu_Item( $item ); |
|
68 | + $_return[$item->ID] = new Menu_Item($item); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Apply nesting |
72 | 72 | |
73 | - foreach ( $_return as $item_id => $item ) { |
|
73 | + foreach ($_return as $item_id => $item) { |
|
74 | 74 | |
75 | - if ( isset( $item->menu_item_parent ) && $item->menu_item_parent && isset( $_return[ $item->menu_item_parent ] ) ) { |
|
75 | + if (isset($item->menu_item_parent) && $item->menu_item_parent && isset($_return[$item->menu_item_parent])) { |
|
76 | 76 | |
77 | - $_return[ $item->menu_item_parent ]->add_child( $item ); |
|
77 | + $_return[$item->menu_item_parent]->add_child($item); |
|
78 | 78 | |
79 | - unset( $_return[ $item_id ] ); |
|
79 | + unset($_return[$item_id]); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | } |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function get_first_menu_id() { |
94 | 94 | |
95 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
95 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
96 | 96 | |
97 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
97 | + if (is_array($menus) && count($menus)) { |
|
98 | 98 | |
99 | - if ( isset( $menus[0]->term_id ) ) { |
|
99 | + if (isset($menus[0]->term_id)) { |
|
100 | 100 | |
101 | 101 | return $menus[0]->term_id; |
102 | 102 | |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * @param int $menu_id |
114 | 114 | * @return int|boolean |
115 | 115 | */ |
116 | - protected function check_menu_id( $menu_id ) { |
|
116 | + protected function check_menu_id($menu_id) { |
|
117 | 117 | |
118 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
118 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
119 | 119 | |
120 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
120 | + if (is_array($menus) && count($menus)) { |
|
121 | 121 | |
122 | - foreach ( $menus as $menu ) { |
|
122 | + foreach ($menus as $menu) { |
|
123 | 123 | |
124 | - if ( absint( $menu->term_id ) === absint( $menu_id ) ) { |
|
124 | + if (absint($menu->term_id) === absint($menu_id)) { |
|
125 | 125 | |
126 | 126 | return $menu_id; |
127 | 127 | |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | * @param string $slug |
140 | 140 | * @return int |
141 | 141 | */ |
142 | - protected function get_menu_id_by_name( $slug = null ) { |
|
142 | + protected function get_menu_id_by_name($slug = null) { |
|
143 | 143 | |
144 | - if ( $slug && is_string( $slug ) ) { |
|
144 | + if ($slug && is_string($slug)) { |
|
145 | 145 | |
146 | - $menu_id = get_term_by( 'slug', $slug, 'nav_menu' ); |
|
146 | + $menu_id = get_term_by('slug', $slug, 'nav_menu'); |
|
147 | 147 | |
148 | - if ( $menu_id ) { return $menu_id; } |
|
148 | + if ($menu_id) { return $menu_id; } |
|
149 | 149 | |
150 | - $menu_id = get_term_by( 'name', $slug, 'nav_menu' ); |
|
150 | + $menu_id = get_term_by('name', $slug, 'nav_menu'); |
|
151 | 151 | |
152 | - if ( $menu_id ) { return $menu_id; } |
|
152 | + if ($menu_id) { return $menu_id; } |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return false; |
@@ -26,21 +26,21 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return array |
28 | 28 | */ |
29 | - public static function get_scope( $view_name = null ) { |
|
29 | + public static function get_scope($view_name = null) { |
|
30 | 30 | |
31 | 31 | $scope = self::get_common_scope(); |
32 | 32 | |
33 | - if ( is_string( $view_name ) ) { |
|
33 | + if (is_string($view_name)) { |
|
34 | 34 | |
35 | - $scope = self::extend_scope( $scope, $view_name ); |
|
35 | + $scope = self::extend_scope($scope, $view_name); |
|
36 | 36 | |
37 | 37 | } else { |
38 | 38 | |
39 | 39 | $request = Hierarchy::get_current_request(); |
40 | 40 | |
41 | - $file = Hierarchy::get_available_file( 'scope', $request ); |
|
41 | + $file = Hierarchy::get_available_file('scope', $request); |
|
42 | 42 | |
43 | - $scope = self::extend_scope( $scope, $file ); |
|
43 | + $scope = self::extend_scope($scope, $file); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public static function extend_scope( $scope, $view_name ) { |
|
59 | + public static function extend_scope($scope, $view_name) { |
|
60 | 60 | |
61 | - $scope = array_merge( $scope, self::require_scope( $view_name ) ); |
|
61 | + $scope = array_merge($scope, self::require_scope($view_name)); |
|
62 | 62 | |
63 | 63 | return $scope; |
64 | 64 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function get_common_scope() { |
73 | 73 | |
74 | - if ( null === self::$common ) { |
|
74 | + if (null === self::$common) { |
|
75 | 75 | |
76 | - self::$common = self::require_scope( 'common' ); |
|
76 | + self::$common = self::require_scope('common'); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return array |
90 | 90 | */ |
91 | - public static function require_scope( $filename ) { |
|
91 | + public static function require_scope($filename) { |
|
92 | 92 | |
93 | 93 | $_return = array(); |
94 | 94 | |
95 | - $file = Hierarchy::get_file_path( 'scope', $filename ); |
|
95 | + $file = Hierarchy::get_file_path('scope', $filename); |
|
96 | 96 | |
97 | - if ( file_exists( $file ) ) { |
|
97 | + if (file_exists($file)) { |
|
98 | 98 | |
99 | 99 | require $file; |
100 | 100 | |
101 | 101 | } |
102 | 102 | |
103 | - if ( isset( $data ) ) { |
|
103 | + if (isset($data)) { |
|
104 | 104 | |
105 | 105 | $_return = $data; |
106 | 106 |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param \WP_Post $item |
45 | 45 | */ |
46 | - public function __construct( $item ) { |
|
46 | + public function __construct($item) { |
|
47 | 47 | |
48 | - if ( is_a( $item, '\WP_Post' ) ) { |
|
48 | + if (is_a($item, '\WP_Post')) { |
|
49 | 49 | |
50 | - $this->import( $item ); |
|
50 | + $this->import($item); |
|
51 | 51 | $this->filter_classes(); |
52 | 52 | |
53 | 53 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function get_classes() { |
106 | 106 | |
107 | - return implode( ' ', $this->classes ); |
|
107 | + return implode(' ', $this->classes); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @param string $class_name |
115 | 115 | */ |
116 | - public function add_class( $class_name ) { |
|
116 | + public function add_class($class_name) { |
|
117 | 117 | |
118 | 118 | $this->classes[] = $class_name; |
119 | 119 | |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param Menu_Item $item |
126 | 126 | */ |
127 | - public function add_child( $item ) { |
|
127 | + public function add_child($item) { |
|
128 | 128 | |
129 | - if ( ! $this->has_child ) { |
|
130 | - $this->add_class( 'menu-item-has-children' ); |
|
129 | + if (!$this->has_child) { |
|
130 | + $this->add_class('menu-item-has-children'); |
|
131 | 131 | $this->has_child = true; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $this->children[] = $item; |
135 | 135 | $item->level = $this->level + 1; |
136 | 136 | |
137 | - if ( $item->children ) { |
|
137 | + if ($item->children) { |
|
138 | 138 | $this->update_child_levels(); |
139 | 139 | } |
140 | 140 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function filter_classes() { |
149 | 149 | |
150 | - $this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this ); |
|
150 | + $this->classes = apply_filters('nav_menu_css_class', $this->classes, $this); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function update_child_levels() { |
160 | 160 | |
161 | - if ( is_array( $this->children ) ) { |
|
161 | + if (is_array($this->children)) { |
|
162 | 162 | |
163 | - foreach ( $this->children as $child ) { |
|
163 | + foreach ($this->children as $child) { |
|
164 | 164 | $child->level = $this->level + 1; |
165 | 165 | $child->update_child_levels(); |
166 | 166 | } |