Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/31/2024 01:26:36 AM (3 months ago)
Author:
imath
Message:

Introduce a function to inform about whether BP was loaded from src

bp_is_running_from_src_subdirectory() informs whether BuddyPress was loaded from the src subdirectory (trunk version). This function exposes the 'bp_is_running_from_src_subdirectory' to let developers tests code that is only available when BuddyPress is built.

Props emaralive, espellcaste.

See #9210
Fixes #9224
Closes https://github.com/buddypress/buddypress/pull/358

File:
1 edited

Legend:

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

    r13998 r14013  
    138138function bp_is_running_wp( $version, $compare = '>=' ) {
    139139    return version_compare( $GLOBALS['wp_version'], $version, $compare );
     140}
     141
     142/**
     143 * Informs whether BuddyPress was loaded from the `src` subdirectory (trunk version).
     144 *
     145 * @since 15.0.0
     146 *
     147 * @return boolean True if BuddyPress was loaded from the `src` subdirectory, false otherwise.
     148 */
     149function bp_is_running_from_src_subdirectory() {
     150    $is_src = defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src';
     151
     152    /**
     153     * Filter here to edit the way BuddyPress was loaded.
     154     *
     155     * @since 15.0.0
     156     *
     157     * @param boolean $is_src True if BuddyPress was loaded from the `src` subdirectory, false otherwise.
     158     */
     159    return apply_filters( 'bp_is_running_from_src_subdirectory', $is_src );
    140160}
    141161
     
    27672787
    27682788    // Ensure the assets can be located when running from /src/.
    2769     if ( defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src' ) {
     2789    if ( bp_is_running_from_src_subdirectory() ) {
    27702790        $ext = str_replace( '.min', '', $ext );
    27712791    }
     
    49815001     * version of BuddyPress do not load deprecated functions.
    49825002     */
    4983     if ( defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src' ) {
     5003    if ( bp_is_running_from_src_subdirectory() ) {
    49845004        return array();
    49855005    }
Note: See TracChangeset for help on using the changeset viewer.