Skip to:
Content

BuddyPress.org

Changeset 8740


Ignore:
Timestamp:
07/30/2014 08:40:27 PM (10 years ago)
Author:
r-a-y
Message:

Streamline internal path and plugin directory properties.

Due to the introduction of Grunt (#5160), a few issues have popped up with
BP's internal properties (file, basename, plugin_dir, and plugin_url) being
incorrect for those running trunk.

To address this:

In the stub bp-loader.php file:

  • We introduce a new constant - BP_SOURCE_DIRECTORY - to determine what source folder is being run from trunk.
  • BP_PLUGIN_DIR and BP_PLUGIN_URL are defined so these constants take precedence over the ones in the main bp-loader.php file.
  • BP_PLUGIN_URL uses a slightly different algorithm to be nice to symlinked directories as plugin_dir_url() does not work properly in these instances.

In the main `bp-loader.php file:

  • BP_SOURCE_DIRECTORY is set to a blank string.
  • The file and basename are calculated based off the BP_PLUGIN_DIR constant
  • plugin_dir and plugin_url are set to whatever build is running

Fixes #5652.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-loader.php

    r8523 r8740  
    3131if ( ! file_exists( $bp_loader ) || defined( 'BP_LOAD_SOURCE' ) ) {
    3232    $bp_loader = dirname( __FILE__ ) . '/src/bp-loader.php';
     33    $subdir = 'src';
     34} else {
     35    $subdir = 'build';
     36}
     37
     38// Set source subdirectory
     39define( 'BP_SOURCE_SUBDIRECTORY', $subdir );
     40
     41// Define overrides - only applicable to those running trunk
     42if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
     43    define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
     44}
     45if ( ! defined( 'BP_PLUGIN_URL' ) ) {
     46    // Be nice to symlinked directories
     47    define( 'BP_PLUGIN_URL', plugins_url( trailingslashit( basename( constant( 'BP_PLUGIN_DIR' ) ) ) ) );
    3348}
    3449
  • trunk/src/bp-loader.php

    r8626 r8740  
    228228        // Path and URL
    229229        if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
    230             define( 'BP_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
     230            define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    231231        }
    232232
    233233        if ( ! defined( 'BP_PLUGIN_URL' ) ) {
    234             $plugin_url = plugin_dir_url( __FILE__ );
    235 
    236             // If we're using https, update the protocol. Workaround for WP13941, WP15928, WP19037.
    237             if ( is_ssl() )
    238                 $plugin_url = str_replace( 'http://', 'https://', $plugin_url );
    239 
    240             define( 'BP_PLUGIN_URL', $plugin_url );
     234            define( 'BP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     235        }
     236
     237        // Only applicable to those running trunk
     238        if ( ! defined( 'BP_SOURCE_SUBDIRECTORY' ) ) {
     239            define( 'BP_SOURCE_SUBDIRECTORY', '' );
    241240        }
    242241
     
    261260
    262261                    // basename
    263                     $basename = str_replace( array( 'build/', 'src/' ), '', plugin_basename( constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php' ) );
     262                    $basename = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
    264263
    265264                    // plugin is network-activated; use main site ID instead
     
    359358
    360359        // BuddyPress root directory
    361         $this->file           = __FILE__;
    362         $this->basename       = str_replace( array( 'build/', 'src/' ), '', plugin_basename( $this->file ) );
    363         $this->plugin_dir     = BP_PLUGIN_DIR;
    364         $this->plugin_url     = BP_PLUGIN_URL;
     360        $this->file           = constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php';
     361        $this->basename       = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
     362        $this->plugin_dir     = trailingslashit( constant( 'BP_PLUGIN_DIR' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
     363        $this->plugin_url     = trailingslashit( constant( 'BP_PLUGIN_URL' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
    365364
    366365        // Languages
Note: See TracChangeset for help on using the changeset viewer.