Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/05/2024 03:40:26 AM (6 months ago)
Author:
imath
Message:

Make sure a BP directory used as home can be previewed in customizer

Introduce the bp_is_site_home() function to check requested URL is the same than site's home one even into the customizer.

Props vapvarun

See #9056 (trunk)
Closes https://github.com/buddypress/buddypress/pull/212

File:
1 edited

Legend:

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

    r13493 r13689  
    19241924     */
    19251925    return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
     1926}
     1927
     1928/**
     1929 * Checks whether the requested URL is site home's one.
     1930 *
     1931 * @since 12.1.0
     1932 *
     1933 * @return boolean True if the requested URL is site home's one. False otherwise.
     1934 */
     1935function bp_is_site_home() {
     1936    $requested_url = bp_get_requested_url();
     1937    $home_url      = home_url( '/' );
     1938
     1939    if ( is_customize_preview() ) {
     1940        $requested_url = wp_parse_url( $requested_url, PHP_URL_PATH );
     1941        $home_url      = wp_parse_url( $home_url, PHP_URL_PATH );
     1942    }
     1943
     1944    return $home_url === $requested_url;
    19261945}
    19271946
Note: See TracChangeset for help on using the changeset viewer.