Changeset 3300 for trunk/bp-core/bp-core-catchuri.php
- Timestamp:
- 10/24/2010 09:22:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-catchuri.php
r3234 r3300 43 43 } 44 44 45 // Ajax or not? 45 46 if ( strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) ) 46 47 $path = bp_core_referrer(); 47 48 else 48 $path = clean_url( $_SERVER['REQUEST_URI'] );49 $path = esc_url( $_SERVER['REQUEST_URI'] ); 49 50 50 51 $path = apply_filters( 'bp_uri', $path ); 51 52 52 // Firstly, take GET variables off the URL to avoid problems,53 // they are still registered in the global $_GET variable */53 // Take GET variables off the URL to avoid problems, 54 // they are still registered in the global $_GET variable 54 55 $noget = substr( $path, 0, strpos( $path, '?' ) ); 55 if ( $noget != '' ) $path = $noget; 56 57 /* Fetch the current URI and explode each part separated by '/' into an array */ 56 if ( $noget != '' ) 57 $path = $noget; 58 59 // Fetch the current URI and explode each part separated by '/' into an array 58 60 $bp_uri = explode( "/", $path ); 59 61 60 / * Loop and remove empties */62 // Loop and remove empties 61 63 foreach ( (array)$bp_uri as $key => $uri_chunk ) 62 64 if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] ); 63 65 64 if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) { 65 /* If we are running BuddyPress on any blog, not just a root blog, we need to first 66 shift off the blog name if we are running a subdirectory install of WPMU. */ 67 if ( $current_blog->path != '/' ) 68 array_shift( $bp_uri ); 69 } 70 71 /* Set the indexes, these are incresed by one if we are not on a VHOST install */ 72 $component_index = 0; 73 $action_index = $component_index + 1; 74 75 /* Get site path items */ 66 // Running off blog other than root 67 if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) { 68 69 // Any subdirectory names must be removed from $bp_uri. 70 // This includes two cases: (1) when WP is installed in a subdirectory, 71 // and (2) when BP is running on secondary blog of a subdirectory 72 // multisite installation. Phew! 73 if ( $chunks = explode( '/', $current_blog->path ) ) { 74 foreach( $chunks as $key => $chunk ) { 75 $bkey = array_search( $chunk, $bp_uri ); 76 77 if ( $bkey !== false ) 78 unset( $bp_uri[$bkey] ); 79 80 $bp_uri = array_values( $bp_uri ); 81 } 82 } 83 } 84 85 // Set the indexes, these are incresed by one if we are not on a VHOST install 86 $component_index = 0; 87 $action_index = $component_index + 1; 88 89 // Get site path items 76 90 $paths = explode( '/', bp_core_get_site_path() ); 77 91 78 / * Take empties off the end of path */92 // Take empties off the end of path 79 93 if ( empty( $paths[count($paths) - 1] ) ) 80 94 array_pop( $paths ); 81 95 82 / * Take empties off the start of path */96 // Take empties off the start of path 83 97 if ( empty( $paths[0] ) ) 84 98 array_shift( $paths ); … … 90 104 } 91 105 92 / * Reset the keys by merging with an empty array */93 $bp_uri 94 $bp_unfiltered_uri = $bp_uri;95 96 / * Find a match within registered BuddyPress controlled WP pages (check members first) */106 // Reset the keys by merging with an empty array 107 $bp_uri = array_merge( array(), $bp_uri ); 108 $bp_unfiltered_uri = $bp_uri; 109 110 // Find a match within registered BuddyPress controlled WP pages (check members first) 97 111 foreach ( (array)$bp_pages as $page_key => $bp_page ) { 98 112 if ( in_array( $bp_page->name, (array)$bp_uri ) ) { 99 / * Match found, now match the slug to make sure. */113 // Match found, now match the slug to make sure. 100 114 $uri_chunks = explode( '/', $bp_page->slug ); 101 115 … … 120 134 } 121 135 122 / * This is not a BuddyPress page, so just return. */136 // This is not a BuddyPress page, so just return. 123 137 if ( in_array( 0, (array) $matches ) ) 124 138 return false; 125 139 126 / * Find the offset */140 // Find the offset 127 141 $uri_offset = 0; 128 142 $slug = explode( '/', $match->slug ); … … 133 147 } 134 148 135 / * Global the unfiltered offset to use in bp_core_load_template() */149 // Global the unfiltered offset to use in bp_core_load_template() 136 150 $bp_unfiltered_uri_offset = $uri_offset; 137 151 138 / * This is a members page so lets check if we have a displayed member */152 // This is a members page so lets check if we have a displayed member 139 153 if ( 'members' == $match->key ) { 140 154 if ( !empty( $bp_uri[$uri_offset + 1] ) ) { … … 146 160 $uri_offset = $uri_offset + 2; 147 161 148 / * Remove everything from the URI up to the offset and take it from there. */162 // Remove everything from the URI up to the offset and take it from there. 149 163 for ( $i = 0; $i < $uri_offset; $i++ ) 150 164 unset( $bp_uri[$i] ); … … 154 168 } 155 169 156 / * Reset the keys by merging with an empty array */170 // Reset the keys by merging with an empty array 157 171 $bp_uri = array_merge( array(), $bp_uri ); 158 172 159 / * Set the current component */173 // Set the current component 160 174 if ( empty( $current_component ) ) { 161 175 for ( $i = 0; $i <= $uri_offset; $i++ ) { … … 170 184 $i = 1; 171 185 172 / * Set the current action */186 // Set the current action 173 187 $current_action = $bp_uri[$i]; 174 188 175 / * Unset the current_component and action from action_variables */189 // Unset the current_component and action from action_variables 176 190 for ( $j = 0; $j <= $i; $j++ ) 177 191 unset( $bp_uri[$j] ); 178 192 179 / * Set the entire URI as the action variables, we will unset the current_component and action in a second */193 // Set the entire URI as the action variables, we will unset the current_component and action in a second 180 194 $action_variables = $bp_uri; 181 195 182 / * Remove the username from action variables if this is not a VHOST install */196 // Remove the username from action variables if this is not a VHOST install 183 197 if ( 'no' == VHOST && !$is_root_component ) 184 198 array_shift($bp_uri); 185 199 186 / * Reset the keys by merging with an empty array */200 // Reset the keys by merging with an empty array 187 201 $action_variables = array_merge( array(), $action_variables ); 188 189 //var_dump($current_component, $current_action, $bp_uri);190 202 } 191 add_action( ' plugins_loaded', 'bp_core_set_uri_globals', 3);203 add_action( 'bp_loaded', 'bp_core_set_uri_globals', 4 ); 192 204 193 205 /**
Note: See TracChangeset
for help on using the changeset viewer.