Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/15/2025 02:57:47 AM (6 months ago)
Author:
espellcaste
Message:

The is_home() returns false on BuddyPress pages.

This change addresses an issue where is_home returned true on BuddyPress pages (except if a BuddyPress component was set as the front page).

Props r-a-y.

Fixes #9300 (14.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/14.0/tests/phpunit/testcases/routing/core.php

    r13507 r14144  
    2222    }
    2323
    24     function test_wordpress_page() {
     24    public function test_wordpress_page() {
    2525        $this->set_permalink_structure( '/%postname%/' );
    2626        $this->go_to( '/' );
    2727        $this->assertEmpty( bp_current_component() );
    2828    }
     29
     30    /**
     31     * @ticket BP9300
     32     */
     33    public function test_buddypress_directory_is_home_false() {
     34        $this->set_permalink_structure( '/%postname%/' );
     35
     36        $is_home_value = null;
     37
     38        // Capture the is_home value during pre_get_posts for the main query.
     39        $callback = function ( $query ) use ( &$is_home_value ) {
     40            if ( $query->is_main_query() ) {
     41                $is_home_value = $query->is_home;
     42            }
     43        };
     44
     45        add_action( 'pre_get_posts', $callback );
     46
     47        $this->go_to( bp_get_members_directory_permalink() );
     48
     49        remove_action( 'pre_get_posts', $callback );
     50
     51        $this->assertFalse( $is_home_value, 'is_home should be false for a BuddyPress directory page on the main query.' );
     52    }
    2953}
Note: See TracChangeset for help on using the changeset viewer.