Skip to:
Content

BuddyPress.org

Changeset 8611


Ignore:
Timestamp:
07/12/2014 05:25:27 PM (10 years ago)
Author:
boonebgorges
Message:

More conservative page_template checks in bp_is_current_component()

The page_template checks in bp_is_current_component() should not go through if
the currently queried object is not a single page (ie when a plugin is forcing
it to be a CPT archive). So we check for the presence of the ID property
before attempting to use it.

Fixes #5751

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template.php

    r8498 r8611  
    11071107    } elseif ( !is_admin() && is_a( $wp_query, 'WP_Query' ) && is_page() ) {
    11081108        global $wp_query;
    1109         $page          = $wp_query->get_queried_object();
    1110         $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
    1111         $page_template = $custom_fields[0];
    1112 
    1113         // Component name is in the page template name
    1114         if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
    1115             $is_current_component = true;
     1109
     1110        $page = $wp_query->get_queried_object();
     1111        if ( isset( $page->ID ) ) {
     1112            $custom_fields = get_post_custom_values( '_wp_page_template', $page->ID );
     1113            $page_template = $custom_fields[0];
     1114
     1115            // Component name is in the page template name
     1116            if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
     1117                $is_current_component = true;
     1118            }
    11161119        }
    11171120    }
Note: See TracChangeset for help on using the changeset viewer.