Skip to:
Content

BuddyPress.org

Changeset 8682


Ignore:
Timestamp:
07/23/2014 07:42:14 PM (10 years ago)
Author:
r-a-y
Message:

Theme compatibility: Fix issues with themes using post type conditionals.

Previously, when BP resets a post for theme compatibility, we set the
'post_type' to a post type that does not exist (eg. 'bp_activity'). For
themes doing conditional template loading based on the post type, BP's
theme compatibility would not kick in due to the non-existent post type.

This commit replaces all 'post_type' values in bp_theme_compat_reset_post()
to 'page' to address this problem.

For backward compatibility, this commit also modifies the post class to
emulate the older post classes prior to this commit resulting from the
'page' post type change.

Fixes #5418.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-screens.php

    r8090 r8682  
    386386            'post_date'      => 0,
    387387            'post_content'   => '',
    388             'post_type'      => 'bp_activity',
     388            'post_type'      => 'page',
    389389            'post_status'    => 'publish',
    390390            'is_page'        => true,
     
    439439            'post_date'      => 0,
    440440            'post_content'   => '',
    441             'post_type'      => 'bp_activity',
     441            'post_type'      => 'page',
    442442            'post_status'    => 'publish',
    443443            'is_page'        => true,
  • trunk/src/bp-blogs/bp-blogs-screens.php

    r8090 r8682  
    150150            'post_date'      => 0,
    151151            'post_content'   => '',
    152             'post_type'      => 'bp_blogs',
     152            'post_type'      => 'page',
    153153            'post_status'    => 'publish',
    154154            'is_page'        => true,
     
    213213            'post_date'      => 0,
    214214            'post_content'   => '',
    215             'post_type'      => 'bp_group',
     215            'post_type'      => 'page',
    216216            'post_status'    => 'publish',
    217217            'is_page'        => true,
  • trunk/src/bp-core/bp-core-template.php

    r8677 r8682  
    24622462
    24632463/**
     2464 * Customizes the post CSS class according to BuddyPress content.
     2465 *
     2466 * Hooked to the 'post_class' filter.
     2467 *
     2468 * @since BuddyPress (2.1.0)
     2469 *
     2470 * @param array $wp_classes The post classes coming from WordPress.
     2471 * @return array
     2472 */
     2473function bp_get_the_post_class( $wp_classes = array() ) {
     2474    // don't do anything if we're not on a BP page
     2475    if ( ! is_buddypress() ) {
     2476        return $wp_classes;
     2477    }
     2478
     2479    $bp_classes = array();
     2480
     2481    if ( bp_is_user() || bp_is_single_activity() ) {
     2482        $bp_classes[] = 'bp_members';
     2483
     2484    } elseif ( bp_is_group() ) {
     2485        $bp_classes[] = 'bp_group';
     2486
     2487    } elseif ( bp_is_activity_component() ) {
     2488        $bp_classes[] = 'bp_activity';
     2489
     2490    } elseif ( bp_is_blogs_component() ) {
     2491        $bp_classes[] = 'bp_blogs';
     2492
     2493    } elseif ( bp_is_register_page() ) {
     2494        $bp_classes[] = 'bp_register';
     2495
     2496    } elseif ( bp_is_activation_page() ) {
     2497        $bp_classes[] = 'bp_activate';
     2498
     2499    } elseif ( bp_is_forums_component() && bp_is_directory() ) {
     2500        $bp_classes[] = 'bp_forum';
     2501    }
     2502
     2503    if ( empty( $bp_classes ) ) {
     2504        return $wp_classes;
     2505    }
     2506
     2507    // emulate post type css class
     2508    foreach ( $bp_classes as $bp_class ) {
     2509        $bp_classes[] = "type-{$bp_class}";
     2510    }
     2511
     2512    // removes the 'page' and 'type-page' post classes
     2513    // we need to remove these classes since they did not exist before we switched
     2514    // theme compat to use the 'page' post type
     2515    $page_key      = array_search( 'page',      $wp_classes );
     2516    $page_type_key = array_search( 'type-page', $wp_classes );
     2517    unset( $wp_classes[$page_key], $wp_classes[$page_type_key] );
     2518
     2519    // okay let's merge!
     2520    return array_unique( array_merge( $bp_classes, $wp_classes ) );
     2521}
     2522add_filter( 'post_class', 'bp_get_the_post_class' );
     2523
     2524/**
    24642525 * Sort BuddyPress nav menu items by their position property.
    24652526 *
  • trunk/src/bp-forums/bp-forums-screens.php

    r7736 r8682  
    217217            'post_date'      => 0,
    218218            'post_content'   => '',
    219             'post_type'      => 'bp_forum',
     219            'post_type'      => 'page',
    220220            'post_status'    => 'publish',
    221221            'is_page'        => true,
  • trunk/src/bp-groups/bp-groups-screens.php

    r8678 r8682  
    10721072            'post_date'      => 0,
    10731073            'post_content'   => '',
    1074             'post_type'      => 'bp_group',
     1074            'post_type'      => 'page',
    10751075            'post_status'    => 'publish',
    10761076            'is_page'        => true,
     
    11281128            'post_date'      => 0,
    11291129            'post_content'   => '',
    1130             'post_type'      => 'bp_group',
     1130            'post_type'      => 'page',
    11311131            'post_status'    => 'publish',
    11321132            'is_page'        => true,
     
    11881188            'post_date'      => 0,
    11891189            'post_content'   => '',
    1190             'post_type'      => 'bp_group',
     1190            'post_type'      => 'page',
    11911191            'post_status'    => 'publish',
    11921192            'is_page'        => true,
  • trunk/src/bp-members/bp-members-screens.php

    r8658 r8682  
    359359            'post_date'      => 0,
    360360            'post_content'   => '',
    361             'post_type'      => 'bp_members',
     361            'post_type'      => 'page',
    362362            'post_status'    => 'publish',
    363363            'is_page'        => true,
     
    421421            'post_date'      => 0,
    422422            'post_content'   => '',
    423             'post_type'      => 'bp_members',
     423            'post_type'      => 'page',
    424424            'post_status'    => 'publish',
    425425            'is_page'        => true,
     
    530530        }
    531531
    532         $post_type = bp_is_register_page() ? 'bp_register' : 'bp_activate';
    533 
    534532        bp_theme_compat_reset_post( array(
    535533            'ID'             => 0,
     
    538536            'post_date'      => 0,
    539537            'post_content'   => '',
    540             'post_type'      => $post_type,
     538            'post_type'      => 'page',
    541539            'post_status'    => 'publish',
    542540            'is_page'        => true,
Note: See TracChangeset for help on using the changeset viewer.