Changeset 13887 for trunk/src/bp-core/classes/class-bp-walker-nav-menu.php
- Timestamp:
- 06/01/2024 10:19:51 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-walker-nav-menu.php
r12552 r13887 21 21 * 22 22 * @since 1.7.0 23 * 23 24 * @var array 24 25 */ 25 var $db_fields = array( 'id' => 'css_id', 'parent' => 'parent' ); 26 public $db_fields = array( 27 'id' => 'css_id', 28 'parent' => 'parent', 29 ); 26 30 27 31 /** … … 29 33 * 30 34 * @since 1.7.0 35 * 31 36 * @var string 32 37 */ 33 var$tree_type = array();38 public $tree_type = array(); 34 39 35 40 /** … … 59 64 $output = ''; 60 65 61 if ( $max_depth < -1 ) // Invalid parameter.66 if ( $max_depth < -1 ) { // Invalid parameter. 62 67 return $output; 63 64 if ( empty( $elements ) ) // Nothing to walk. 68 } 69 70 if ( empty( $elements ) ) { // Nothing to walk. 65 71 return $output; 72 } 66 73 67 74 $parent_field = $this->db_fields['parent']; 68 75 69 76 // Flat display. 70 if ( -1 == $max_depth ) {77 if ( -1 === $max_depth ) { 71 78 72 79 $empty_array = array(); 73 foreach ( $elements as $e ) 80 foreach ( $elements as $e ) { 74 81 $this->display_element( $e, $empty_array, 1, 0, $args, $output ); 82 } 75 83 76 84 return $output; … … 88 96 foreach ( $elements as $e ) { 89 97 // BuddyPress: changed '==' to '==='. This is the only change from version in Walker::walk(). 90 if ( 0 === $e->$parent_field ) 98 if ( 0 === $e->$parent_field ) { 91 99 $top_level_elements[] = $e; 92 else 93 $children_elements[$e->$parent_field][] = $e; 100 } else { 101 $children_elements[ $e->$parent_field ][] = $e; 102 } 94 103 } 95 104 … … 106 115 107 116 foreach ( $elements as $e ) { 108 if ( $root->$parent_field == $e->$parent_field )117 if ( $root->$parent_field === $e->$parent_field ) { 109 118 $top_level_elements[] = $e; 110 else 111 $children_elements[$e->$parent_field][] = $e; 112 } 113 } 114 115 foreach ( $top_level_elements as $e ) 119 } else { 120 $children_elements[ $e->$parent_field ][] = $e; 121 } 122 } 123 } 124 125 foreach ( $top_level_elements as $e ) { 116 126 $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); 127 } 117 128 118 129 /* … … 120 131 * then we got orphans, which should be displayed regardless. 121 132 */ 122 if ( ( $max_depth == 0) && count( $children_elements ) > 0 ) {133 if ( ( 0 === $max_depth ) && count( $children_elements ) > 0 ) { 123 134 $empty_array = array(); 124 135 125 foreach ( $children_elements as $orphans ) 126 foreach ( $orphans as $op ) 136 foreach ( $children_elements as $orphans ) { 137 foreach ( $orphans as $op ) { 127 138 $this->display_element( $op, $empty_array, 1, 0, $args, $output ); 128 } 129 130 return $output; 139 } 140 } 141 } 142 143 return $output; 131 144 } 132 145 … … 152 165 * @since 1.7.0 153 166 * 154 * @param string $output Passed by reference. Used to append155 * additional content.156 * @param object $item Menu item data object.157 * @param int $depth Depth of menu item. Used for padding. Optional,158 * defaults to 0.159 * @param array$args Optional. See {@link Walker::start_el()}.160 * @param int $id Menu item ID. Optional.167 * @param string $output Passed by reference. Used to append 168 * dditional content. 169 * @param object $item Menu item data object. 170 * @param int $depth Optional. Depth of menu item. Used for padding. 171 * Defaults to 0. 172 * @param stdClass $args Optional. See {@link Walker::start_el()}. 173 * @param int $id Menu item ID. Optional. 161 174 */ 162 175 public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { … … 169 182 * @since 1.7.0 170 183 * 171 * @param array $value Array of classes to be added.172 * @param object $item Menu item data object.173 * @param array $args Array of arguments for the item.184 * @param array $value Array of classes to be added. 185 * @param object $item Menu item data object. 186 * @param stdClass $args An object of wp_nav_menu() arguments. 174 187 */ 175 188 $class_names = join( ' ', apply_filters( 'bp_nav_menu_css_class', array_filter( $item->class ), $item, $args ) ); 176 189 $class_names = ! empty( $class_names ) ? ' class="' . esc_attr( $class_names ) . '"' : ''; 177 190 178 // Add HTML ID 191 // Add HTML ID. 179 192 $id = sanitize_html_class( $item->css_id . '-personal-li' ); // Backpat with BP pre-1.7. 180 193 … … 184 197 * @since 1.7.0 185 198 * 186 * @param string $id ID attribute to be added to the menu item.187 * @param object $item Menu item data object.188 * @param array $args Array of arguments for the item.199 * @param string $id ID attribute to be added to the menu item. 200 * @param object $item Menu item data object. 201 * @param stdClass $args An object of wp_nav_menu() arguments. 189 202 */ 190 203 $id = apply_filters( 'bp_nav_menu_item_id', $id, $item, $args ); … … 198 211 199 212 // Construct the link. 200 $item_output = $args->before;213 $item_output = $args->before; 201 214 $item_output .= '<a' . $attributes . '>'; 202 215 … … 206 219 * @since 1.7.0 207 220 * 208 * @param string $name Item text to be applied. 209 * @param int $value Post ID the title is for. 210 */ 211 $item_output .= $args->link_before . apply_filters( 'the_title', $item->name, 0 ) . $args->link_after; 221 * @param string $name Item text to be applied. 222 * @param int $post_id Post ID the title is for. 223 */ 224 $link_text = apply_filters( 'the_title', $item->name, 0 ); 225 226 $item_output .= $args->link_before . $link_text . $args->link_after; 212 227 $item_output .= '</a>'; 213 228 $item_output .= $args->after; … … 218 233 * @since 1.7.0 219 234 * 220 * @param string $item_output Constructed output for the menu item to append to output.221 * @param object $item Menu item data object.222 * @param int $depth Depth of menu item. Used for padding.223 * @param array $args Array of arguments for the item.235 * @param string $item_output Constructed output for the menu item to append to output. 236 * @param object $item Menu item data object. 237 * @param int $depth Depth of menu item. Used for padding. 238 * @param stdClass $args An object of wp_nav_menu() arguments. 224 239 */ 225 240 $output .= apply_filters( 'bp_walker_nav_menu_start_el', $item_output, $item, $depth, $args );
Note: See TracChangeset
for help on using the changeset viewer.