Changeset 13455 for trunk/src/bp-core/bp-core-rewrites.php
- Timestamp:
- 04/20/2023 02:30:11 AM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-rewrites.php
r13452 r13455 116 116 117 117 return $slug; 118 } 119 120 /** 121 * Returns the rewrite ID of a customized slug. 122 * 123 * @since 12.0.0 124 * 125 * @param string $component_id The component ID (eg: `activity` for the BP Activity component). 126 * @param string $slug The customized slug. 127 * @param string $context The context for the customized slug, useful when the same slug is used 128 * for more than one rewrite ID of the same component. 129 * @return string The rewrite ID matching the customized slug. 130 */ 131 function bp_rewrites_get_custom_slug_rewrite_id( $component_id = '', $slug = '', $context = '' ) { 132 $directory_pages = bp_core_get_directory_pages(); 133 134 if ( ! isset( $directory_pages->{$component_id}->custom_slugs ) || ! $slug ) { 135 return null; 136 } 137 138 $custom_slugs = (array) $directory_pages->{$component_id}->custom_slugs; 139 $rewrite_ids = array_keys( $custom_slugs, $slug, true ); 140 141 if ( 1 < count( $rewrite_ids ) && isset( $context ) && $context ) { 142 foreach ( $rewrite_ids as $rewrite_id_key => $rewrite_id ) { 143 if ( false !== strpos( $rewrite_id, $context ) ) { 144 continue; 145 } 146 147 unset( $rewrite_ids[ $rewrite_id_key ] ); 148 } 149 } 150 151 // Always return the first match. 152 return reset( $rewrite_ids ); 118 153 } 119 154 … … 284 319 return apply_filters( 'bp_rewrites_get_root_url', $url ); 285 320 } 321 322 /** 323 * Get needed data to find a member single item from the requested URL. 324 * 325 * @since 12.0.0 326 * 327 * @param string $request The request used during parsing. 328 * @return array Data to use to find a member single item from the request. 329 */ 330 function bp_rewrites_get_member_data( $request = '' ) { 331 $member_data = array( 'field' => 'slug' ); 332 333 if ( bp_is_username_compatibility_mode() ) { 334 $member_data = array( 'field' => 'login' ); 335 } 336 337 if ( bp_core_enable_root_profiles() ) { 338 if ( ! $request ) { 339 $request = $GLOBALS['wp']->request; 340 } 341 342 $request_chunks = explode( '/', ltrim( $request, '/' ) ); 343 $member_chunk = reset( $request_chunks ); 344 345 // Try to get an existing member to eventually reset the WP Query. 346 $member_data['object'] = get_user_by( $member_data['field'], $member_chunk ); 347 } 348 349 return $member_data; 350 }
Note: See TracChangeset
for help on using the changeset viewer.