Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/10/2011 06:09:46 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Add sanity check to bp_core_set_uri_globals() to prevent debug notices with partial uri matches and canonical redirects. Also improve inline docs in bp_core_set_uri_globals().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-catchuri.php

    r3947 r4091  
    117117    $bp_unfiltered_uri = $bp_uri;
    118118
    119     // Find a match within registered BuddyPress controlled WP pages (check members first)
    120     foreach ( (array)$bp->pages as $page_key => $bp_page ) {
    121         if ( in_array( $bp_page->name, (array)$bp_uri ) ) {
     119    // Loop through each page in the global
     120    foreach ( (array) $bp->pages as $page_key => $bp_page ) {
     121
     122        // Look for a match (check members first)
     123        if ( in_array( $bp_page->name, (array) $bp_uri ) ) {
     124
    122125            // Match found, now match the slug to make sure.
    123126            $uri_chunks = explode( '/', $bp_page->slug );
    124127
    125             foreach ( (array)$uri_chunks as $key => $uri_chunk ) {
    126                 if ( $bp_uri[$key] == $uri_chunk ) {
     128            // Loop through uri_chunks
     129            foreach ( (array) $uri_chunks as $key => $uri_chunk ) {
     130
     131                // Make sure chunk is in the correct position
     132                if ( !empty( $bp_uri[$key] ) && ( $bp_uri[$key] == $uri_chunk ) ) {
    127133                    $matches[] = 1;
     134
     135                // No match
    128136                } else {
    129137                    $matches[] = 0;
     
    131139            }
    132140
     141            // Have a match
    133142            if ( !in_array( 0, (array) $matches ) ) {
    134143                $match      = $bp_page;
     
    137146            };
    138147
     148            // Unset matches
    139149            unset( $matches );
    140150        }
    141151
     152        // Unset uri chunks
    142153        unset( $uri_chunks );
    143154    }
Note: See TracChangeset for help on using the changeset viewer.