Changeset 13441 for trunk/src/bp-core/classes/class-bp-core-nav.php
- Timestamp:
- 03/23/2023 07:35:38 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-core-nav.php
r13108 r13441 36 36 37 37 /** 38 * The component ID. 39 * 40 * @since 12.0.0 41 * @var string 42 */ 43 private $component_id; 44 45 /** 38 46 * Initializes the Nav belonging to the specified object. 39 47 * … … 42 50 * @param int $object_id The item ID to build the nav for. Default is the displayed user ID. 43 51 */ 44 public function __construct( $object_id = 0 ) { 45 if ( empty( $object_id ) ) { 52 public function __construct( $object_id = 0, $component_id = 'members' ) { 53 if ( bp_is_active( $component_id ) ) { 54 $this->component_id = $component_id; 55 } 56 57 if ( empty( $object_id ) && 'members' === $this->component_id ) { 46 58 $this->object_id = (int) bp_displayed_user_id(); 47 59 } else { … … 136 148 } 137 149 150 $path_chunks = array( 151 'component_id' => $this->component_id, 152 ); 153 138 154 // We have a child and the parent exists. 139 155 if ( ! empty( $args['parent_slug'] ) ) { 140 $slug = $args['parent_slug'] . '/' . $args['slug']; 141 $args['secondary'] = true; 156 $slug = $args['parent_slug'] . '/' . $args['slug']; 157 $path_chunks['single_item_component'] = $args['parent_slug']; 158 $path_chunks['single_item_action'] = $args['slug']; 159 $args['secondary'] = true; 142 160 143 161 // This is a parent. 144 162 } else { 145 $slug = $args['slug']; 146 $args['primary'] = true; 163 $slug = $args['slug']; 164 $path_chunks['single_item_component'] = $slug; 165 $args['primary'] = true; 166 } 167 168 /* 169 * This is where we set links using BP Rewrites. 170 * 171 * @since 12.0.0 172 */ 173 if ( ! isset( $args['link'] ) || ! $args['link'] ) { 174 if ( 'groups' === $this->component_id ) { 175 if ( isset( $path_chunks['single_item_component'] ) ) { 176 $path_chunks['single_item'] = str_replace( '_manage', '', $path_chunks['single_item_component'] ); 177 } else { 178 $path_chunks['single_item'] = groups_get_slug( $this->object_id ); 179 } 180 181 $chunk = 'single_item_action'; 182 if ( $path_chunks['single_item'] . '_manage' === $path_chunks['single_item_component'] ) { 183 $chunk = 'single_item_action_variables'; 184 $path_chunks[ $chunk ] = $path_chunks['single_item_action']; 185 $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ); 186 $group_screens = bp_get_group_screens( 'manage' ); 187 } else { 188 $group_screens = bp_get_group_screens( 'read' ); 189 } 190 191 if ( isset( $group_screens[ $args['slug'] ] ) ) { 192 $args['rewrite_id'] = $group_screens[ $args['slug'] ]['rewrite_id']; 193 $path_chunks[ $chunk ] = bp_rewrites_get_slug( 'groups', $args['rewrite_id'], $args['slug'] ); 194 195 if ( 'single_item_action_variables' === $chunk ) { 196 $path_chunks[ $chunk ] = array( $path_chunks[ $chunk ] ); 197 } 198 } 199 200 unset( $path_chunks['single_item_component'] ); 201 $args['link'] = bp_rewrites_get_url( $path_chunks ); 202 } else { 203 $path_chunks['single_item_component'] = bp_rewrites_get_slug( 'members', 'member_' . $path_chunks['single_item_component'], $path_chunks['single_item_component'] ); 204 205 if ( isset( $path_chunks['single_item_action'] ) && ! is_numeric( $path_chunks['single_item_action'] ) ) { 206 $path_chunks['single_item_action'] = bp_rewrites_get_slug( 207 'members', 208 'member_' . $path_chunks['single_item_component'] . '_' . $path_chunks['single_item_action'], 209 $path_chunks['single_item_action'] 210 ); 211 } 212 213 $args['link'] = bp_members_get_user_url( $this->object_id, $path_chunks ); 214 } 147 215 } 148 216
Note: See TracChangeset
for help on using the changeset viewer.