PluginProbe ʕ •ᴥ•ʔ
Ocean Extra / 2.5.3
Ocean Extra v2.5.3
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.4.1 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.0.1 1.2.1 1.2.1.1 1.2.1.2 1.2.10 1.2.2 1.2.2.1 1.2.2.2 1.2.2.3 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 1.4.17 1.4.18 1.4.19 1.4.2 1.4.20 1.4.21 1.4.22 1.4.23 1.4.24 1.4.25 1.4.26 1.4.27 1.4.28 1.4.29 1.4.3 1.4.30 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.20 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6
ocean-extra / includes / walker.php
ocean-extra / includes Last commit date
admin-bar 1 year ago client-migration 6 months ago compatibility 1 year ago customizer 1 year ago freemius 8 months ago menu-icons 1 year ago metabox 1 year ago onboarding 3 months ago panel 9 months ago post-settings 6 months ago preloader 1 year ago shortcodes 1 year ago themepanel 1 year ago widgets 8 months ago wizard 3 years ago adobe-font.php 1 year ago custom-code.php 8 months ago dashboard.php 1 year ago image-resizer.php 1 year ago jshrink.php 3 years ago ocean-extra-strings.php 3 years ago plugins-tab.php 1 year ago update-message.php 1 year ago utils.php 1 year ago walker.php 4 years ago
walker.php
190 lines
1 <?php
2 /**
3 * Custom wp_nav_menu walker for the Custom Menu widget.
4 *
5 * @package Ocean_Extra
6 * @category Core
7 * @author OceanWP
8 */
9
10 if ( ! class_exists( 'Ocean_Extra_Nav_Walker' ) ) {
11
12 class Ocean_Extra_Nav_Walker extends Walker_Nav_Menu {
13
14 /**
15 * Middle logo menu breaking point
16 *
17 * @access private
18 * @var init
19 */
20 private $break_point = null;
21
22 /**
23 * Middle logo menu number of top level items displayed
24 *
25 * @access private
26 * @var init
27 */
28 private $displayed = 0;
29
30 /**
31 * Starts the list before the elements are added.
32 *
33 * @param string $output Passed by reference. Used to append additional content.
34 * @param int $depth Depth of menu item. Used for padding.
35 * @param array $args An array of arguments. @see wp_nav_menu()
36 */
37 public function start_lvl( &$output, $depth = 0, $args = array() ) {
38 $indent = str_repeat( "\t", $depth );
39
40 $output .= "\n$indent<ul class=\"sub-menu\">\n";
41 }
42
43 /**
44 * Modified the menu output.
45 *
46 * @param string $output Passed by reference. Used to append additional content.
47 * @param object $item Menu item data object.
48 * @param int $depth Depth of menu item. Used for padding.
49 * @param array $args An array of arguments. @see wp_nav_menu()
50 * @param int $id Current item ID.
51 */
52 public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
53 global $wp_query;
54 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
55
56 // Set up empty variable.
57 $class_names = '';
58
59 $classes = empty( $item->classes ) ? array() : (array) $item->classes;
60 $classes[] = 'menu-item-' . $item->ID;
61
62 // Nav no click
63 if ( $item->nolink != '' ) {
64 $classes[] = 'nav-no-click';
65 }
66
67 /**
68 * Filter the CSS class(es) applied to a menu item's <li>.
69 *
70 * @param array $classes The CSS classes that are applied to the menu item's <li>.
71 * @param object $item The current menu item.
72 * @param array $args An array of wp_nav_menu() arguments.
73 */
74 $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
75 $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
76
77 /**
78 * Filter the ID applied to a menu item's <li>.
79 *
80 * @param string $menu_id The ID that is applied to the menu item's <li>.
81 * @param object $item The current menu item.
82 * @param array $args An array of wp_nav_menu() arguments.
83 */
84 $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args );
85 $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
86
87 // <li> output.
88 $output .= $indent . '<li ' . $id . $class_names . '>';
89
90 // link attributes
91 $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) . '"' : '';
92 $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) . '"' : '';
93 $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) . '"' : '';
94 $attributes .= ! empty( $item->url ) ? ' href="' . esc_url( $item->url ) . '"' : '';
95
96 // Icon.
97 $icon = '';
98 if ( $item->icon != '' ) {
99 $icon = '<i class="' . $item->icon . '"></i>';
100 }
101
102 // Description
103 $description = '';
104 if ( $item->description != '' ) {
105 $description = '<span class="nav-content">' . $item->description . '</span>';
106 }
107
108 // Text before and after
109 $text_before = '';
110 $text_after = '';
111 if ( $item->icon != '' ) {
112 $text_before = '<span class="menu-text">';
113 $text_after = '</span>';
114 }
115
116 // Output
117 $item_output = $args->before;
118
119 $item_output .= '<a' . $attributes . ' class="menu-link">';
120
121 $item_output .= $args->link_before . $icon . $text_before . apply_filters( 'the_title', $item->title, $item->ID ) . $text_after . $args->link_after;
122
123 if ( $depth !== 0 ) {
124 $item_output .= $description;
125 }
126
127 $item_output .= '</a>';
128
129 $item_output .= $args->after;
130
131 // Build html
132 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
133
134 }
135
136 /**
137 * Ends the list of after the elements are added.
138 *
139 * @param string $output Passed by reference. Used to append additional content.
140 * @param int $depth Depth of menu item. Used for padding.
141 * @param array $args An array of arguments. @see wp_nav_menu()
142 */
143 public function end_lvl( &$output, $depth = 0, $args = array() ) {
144 $indent = str_repeat( "\t", $depth );
145 $output .= "$indent</ul>\n";
146 }
147
148 /**
149 * Icon if sub menu.
150 */
151 public function display_element( $element, &$children_elements = array(), $max_depth = 0, $depth = 0, $args = array(), &$output = '' ) {
152
153 // Define vars
154 $id_field = $this->db_fields['id'];
155 $header_style = oceanwp_header_style();
156
157 if ( is_object( $args[0] ) ) {
158 $args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
159 }
160
161 // Down Arrows
162 if ( ! empty( $children_elements[ $element->$id_field ] ) && ( $depth == 0 )
163 || $element->category_post != '' && $element->object == 'category' ) {
164 $element->classes[] = 'dropdown';
165 if ( true == get_theme_mod( 'ocean_menu_arrow_down', true ) ) {
166 $element->title .= ' <span class="nav-arrow fa fa-angle-down"></span>';
167 }
168 }
169
170 // Right/Left Arrows
171 if ( ! empty( $children_elements[ $element->$id_field ] ) && ( $depth > 0 ) ) {
172 $element->classes[] = 'dropdown';
173 if ( true == get_theme_mod( 'ocean_menu_arrow_side', true ) ) {
174 if ( is_rtl() ) {
175 $element->title .= '<span class="nav-arrow fa fa-angle-left"></span>';
176 } else {
177 $element->title .= '<span class="nav-arrow fa fa-angle-right"></span>';
178 }
179 }
180 }
181
182 // Define walker
183 Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
184
185 }
186
187 }
188
189 }
190