Changeset 3219
- Timestamp:
- 08/26/2010 11:14:46 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/bp-core/bp-core-catchuri.php
r3192 r3219 33 33 global $bp, $current_blog; 34 34 35 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && bp_core_is_multisite() ) {36 /* Only catch URI's on the root blog if we are not running BP on multiple blogs */35 // Only catch URI's on the root blog if we are not running BP on multiple blogs 36 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && bp_core_is_multisite() ) 37 37 if ( BP_ROOT_BLOG != (int) $current_blog->blog_id ) 38 38 return false; 39 } 40 39 40 // Ajax or not? 41 41 if ( strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) ) 42 42 $path = bp_core_referrer(); … … 46 46 $path = apply_filters( 'bp_uri', $path ); 47 47 48 // Firstly, take GET variables off the URL to avoid problems,49 // they are still registered in the global $_GET variable */48 // Take GET variables off the URL to avoid problems, 49 // they are still registered in the global $_GET variable 50 50 $noget = substr( $path, 0, strpos( $path, '?' ) ); 51 if ( $noget != '' ) $path = $noget; 52 53 /* Fetch the current URI and explode each part separated by '/' into an array */ 54 $bp_uri = explode( "/", $path ); 55 56 /* Loop and remove empties */ 51 if ( $noget != '' ) 52 $path = $noget; 53 54 // Fetch the current URI and explode each part separated by '/' into an array 55 $bp_uri = explode( '/', $path ); 56 57 // Loop and remove empties 57 58 foreach ( (array)$bp_uri as $key => $uri_chunk ) 58 59 if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] ); 59 60 61 // Running off blog other than root 60 62 if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) { 61 /* If we are running BuddyPress on any blog, not just a root blog, we need to first 62 shift off the blog name if we are running a subdirectory install of WPMU. */ 63 if ( $current_blog->path != '/' ) 64 array_shift( $bp_uri ); 65 } 66 67 /* Set the indexes, these are incresed by one if we are not on a VHOST install */ 63 64 // Any subdirectory names must be removed from $bp_uri. 65 // This includes two cases: (1) when WP is installed in a subdirectory, 66 // and (2) when BP is running on secondary blog of a subdirectory 67 // multisite installation. Phew! 68 if ( $chunks = explode( '/', $current_blog->path ) ) { 69 foreach( $chunks as $key => $chunk ) { 70 $bkey = array_search( $chunk, $bp_uri ); 71 72 if ( $bkey !== false ) 73 unset( $bp_uri[$bkey] ); 74 75 $bp_uri = array_values( $bp_uri ); 76 } 77 } 78 } 79 80 // Set the indexes, these are incresed by one if we are not on a VHOST install 68 81 $component_index = 0; 69 $action_index = $component_index + 1;82 $action_index = $component_index + 1; 70 83 71 84 // If this is a WordPress page, return from the function. … … 73 86 return false; 74 87 75 / * Get site path items */88 // Get site path items 76 89 $paths = explode( '/', bp_core_get_site_path() ); 77 90 78 / * Take empties off the end of path */91 // Take empties off the end of path 79 92 if ( empty( $paths[count($paths) - 1] ) ) 80 93 array_pop( $paths ); 81 94 82 / * Take empties off the start of path */95 // Take empties off the start of path 83 96 if ( empty( $paths[0] ) ) 84 97 array_shift( $paths ); 85 98 86 foreach ( (array)$bp_uri as $key => $uri_chunk ) {87 if ( in_array( $uri_chunk, $paths )) {99 foreach ( (array)$bp_uri as $key => $uri_chunk ) 100 if ( in_array( $uri_chunk, $paths )) 88 101 unset( $bp_uri[$key] ); 89 } 90 } 91 92 /* Reset the keys by merging with an empty array */ 93 $bp_uri = array_merge( array(), $bp_uri ); 102 103 // Reset the keys by merging with an empty array 104 $bp_uri = array_merge( array(), $bp_uri ); 94 105 $bp_unfiltered_uri = $bp_uri; 95 106 96 / * If we are under anything with a members slug, set the correct globals */107 // If we are under anything with a members slug, set the correct globals 97 108 if ( $bp_uri[0] == BP_MEMBERS_SLUG ) { 98 $is_member_page = true;109 $is_member_page = true; 99 110 $is_root_component = true; 100 111 } 101 112 102 / * Catch a member page and set the current member ID */113 // Catch a member page and set the current member ID 103 114 if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) { 104 115 if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) { … … 112 123 unset($bp_uri[1]); 113 124 114 / * Reset the keys by merging with an empty array */125 // Reset the keys by merging with an empty array 115 126 $bp_uri = array_merge( array(), $bp_uri ); 116 127 } 117 128 } else { 118 129 if ( get_userdatabylogin( $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) { 119 $is_member_page = true;130 $is_member_page = true; 120 131 $is_root_component = true; 121 132 … … 128 139 unset($bp_uri[0]); 129 140 130 / * Reset the keys by merging with an empty array */141 // Reset the keys by merging with an empty array 131 142 $bp_uri = array_merge( array(), $bp_uri ); 132 143 } 133 144 } 134 145 135 if ( !isset( $is_root_component) )146 if ( !isset( $is_root_component ) ) 136 147 $is_root_component = in_array( $bp_uri[0], $bp->root_components ); 137 148 … … 141 152 } 142 153 143 / * Set the current component */154 // Set the current component 144 155 $current_component = $bp_uri[$component_index]; 145 156 146 / * Set the current action */147 $current_action = $bp_uri[$action_index];148 149 / * Set the entire URI as the action variables, we will unset the current_component and action in a second */150 $action_variables = $bp_uri;151 152 / * Unset the current_component and action from action_variables */153 unset( $action_variables[$component_index]);154 unset( $action_variables[$action_index]);155 156 / * Remove the username from action variables if this is not a VHOST install */157 // Set the current action 158 $current_action = $bp_uri[$action_index]; 159 160 // Set the entire URI as the action variables, we will unset the current_component and action in a second 161 $action_variables = $bp_uri; 162 163 // Unset the current_component and action from action_variables 164 unset( $action_variables[$component_index] ); 165 unset( $action_variables[$action_index] ); 166 167 // Remove the username from action variables if this is not a VHOST install 157 168 if ( !is_subdomain_install() && !$is_root_component ) 158 array_shift( $action_variables);159 160 / * Reset the keys by merging with an empty array */169 array_shift( $action_variables ); 170 171 // Reset the keys by merging with an empty array 161 172 $action_variables = array_merge( array(), $action_variables ); 162 173 }
Note: See TracChangeset
for help on using the changeset viewer.