Skip to:
Content

BuddyPress.org

Ticket #5158: bp-core-template.php2.patch

File bp-core-template.php2.patch, 4.7 KB (added by megainfo, 13 years ago)

first patch

  • bp-core-template.php

     
    814814
    815815        $is_current_component = false;
    816816
    817         // Backward compatibility: 'xprofile' should be read as 'profile'
    818         if ( 'xprofile' == $component )
    819                 $component = 'profile';
     817        if ( !empty( $component ) ) {
    820818
    821         if ( !empty( $bp->current_component ) ) {
     819                // Backward compatibility: 'xprofile' should be read as 'profile'
     820                if ( 'xprofile' == $component )
     821                        $component = 'profile';
    822822
    823                 // First, check to see whether $component_name and the current
    824                 // component are a simple match
    825                 if ( $bp->current_component == $component ) {
    826                         $is_current_component = true;
     823                if ( !empty( $bp->current_component ) ) {
    827824
    828                 // Since the current component is based on the visible URL slug let's
    829                 // check the component being passed and see if its root_slug matches
    830                 } elseif ( isset( $bp->{$component}->root_slug ) && $bp->{$component}->root_slug == $bp->current_component ) {
    831                         $is_current_component = true;
     825                        // First, check to see whether $component_name and the current
     826                        // component are a simple match
     827                        if ( $bp->current_component == $component ) {
     828                                $is_current_component = true;
    832829
    833                 // Because slugs can differ from root_slugs, we should check them too
    834                 } elseif ( isset( $bp->{$component}->slug ) && $bp->{$component}->slug == $bp->current_component ) {
    835                         $is_current_component = true;
     830                        // Since the current component is based on the visible URL slug let's
     831                        // check the component being passed and see if its root_slug matches
     832                        } elseif ( isset( $bp->{$component}->root_slug ) && $bp->{$component}->root_slug == $bp->current_component ) {
     833                                $is_current_component = true;
    836834
    837                 // Next, check to see whether $component is a canonical,
    838                 // non-translatable component name. If so, we can return its
    839                 // corresponding slug from $bp->active_components.
    840                 } else if ( $key = array_search( $component, $bp->active_components ) ) {
    841                         if ( strstr( $bp->current_component, $key ) ) {
     835                        // Because slugs can differ from root_slugs, we should check them too
     836                        } elseif ( isset( $bp->{$component}->slug ) && $bp->{$component}->slug == $bp->current_component ) {
    842837                                $is_current_component = true;
    843                         }
    844838
    845                 // If we haven't found a match yet, check against the root_slugs
    846                 // created by $bp->pages, as well as the regular slugs
    847                 } else {
    848                         foreach ( $bp->active_components as $id ) {
    849                                 // If the $component parameter does not match the current_component,
    850                                 // then move along, these are not the droids you are looking for
    851                                 if ( empty( $bp->{$id}->root_slug ) || $bp->{$id}->root_slug != $bp->current_component ) {
    852                                         continue;
     839                        // Next, check to see whether $component is a canonical,
     840                        // non-translatable component name. If so, we can return its
     841                        // corresponding slug from $bp->active_components.
     842                        } else if ( $key = array_search( $component, $bp->active_components ) ) {
     843                                if ( strstr( $bp->current_component, $key ) ) {
     844                                        $is_current_component = true;
    853845                                }
    854846
    855                                 if ( $id == $component ) {
    856                                         $is_current_component = true;
    857                                         break;
     847                        // If we haven't found a match yet, check against the root_slugs
     848                        // created by $bp->pages, as well as the regular slugs
     849                        } else {
     850                                foreach ( $bp->active_components as $id ) {
     851                                        // If the $component parameter does not match the current_component,
     852                                        // then move along, these are not the droids you are looking for
     853                                        if ( empty( $bp->{$id}->root_slug ) || $bp->{$id}->root_slug != $bp->current_component ) {
     854                                                continue;
     855                                        }
     856
     857                                        if ( $id == $component ) {
     858                                                $is_current_component = true;
     859                                                break;
     860                                        }
    858861                                }
    859862                        }
    860                 }
    861863
    862         // Page template fallback check if $bp->current_component is empty
    863         } elseif ( !is_admin() && is_page() ) {
    864                 global $wp_query;
    865                 $page          = $wp_query->get_queried_object();
    866                 $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
    867                 $page_template = $custom_fields[0];
     864                // Page template fallback check if $bp->current_component is empty
     865                } elseif ( !is_admin() && is_page() ) {
     866                        global $wp_query;
     867                        $page          = $wp_query->get_queried_object();
     868                        $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
     869                        $page_template = $custom_fields[0];
    868870
    869                 // Component name is in the page template name
    870                 if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
    871                         $is_current_component = true;
     871                        // Component name is in the page template name
     872                        if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
     873                                $is_current_component = true;
     874                        }
    872875                }
    873876        }
    874877