Skip to:
Content

BuddyPress.org

Ticket #6457: 6457.02.patch

File 6457.02.patch, 5.0 KB (added by johnjamesjacoby, 10 years ago)
  • bp-loader.php

     
    3030// Load from source if no build exists
    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';
     33
     34        // We are loading from source
     35        if ( ! defined( 'BP_LOAD_SOURCE' ) ) {
     36                define( 'BP_LOAD_SOURCE', true );
     37        }
    3638}
    3739
    38 // Set source subdirectory
    39 define( 'BP_SOURCE_SUBDIRECTORY', $subdir );
    40 
    41 // Define overrides - only applicable to those running trunk
     40// Directory & URL Overrides - necessary when developing BuddyPress
    4241if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
    4342        define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    4443}
    4544if ( ! defined( 'BP_PLUGIN_URL' ) ) {
    46         // Be nice to symlinked directories
    4745        define( 'BP_PLUGIN_URL', plugins_url( trailingslashit( basename( constant( 'BP_PLUGIN_DIR' ) ) ) ) );
    4846}
    4947
  • src/bp-loader.php

     
    242242                        define( 'BP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    243243                }
    244244
    245                 // Only applicable to those running trunk
    246                 if ( ! defined( 'BP_SOURCE_SUBDIRECTORY' ) ) {
    247                         define( 'BP_SOURCE_SUBDIRECTORY', '' );
    248                 }
    249 
    250245                // Define on which blog ID BuddyPress should run
    251246                if ( ! defined( 'BP_ROOT_BLOG' ) ) {
    252247
     
    379374
    380375                /** Paths**************************************************************/
    381376
     377                // Assume BuddyPress is not running in a sub-directory
     378                $sub_directory = '';
     379
     380                // Are we currently developing BuddyPress
     381                if ( defined( 'BP_LOAD_SOURCE' ) ) {
     382                        if ( true === constant( 'BP_LOAD_SOURCE' ) ) {
     383                                $sub_directory = 'src';
     384                        } else {
     385                                $sub_directory = 'build';
     386                        }
     387                }
     388
    382389                // BuddyPress root directory
    383390                $this->file           = constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php';
    384391                $this->basename       = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
    385                 $this->plugin_dir     = trailingslashit( constant( 'BP_PLUGIN_DIR' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
    386                 $this->plugin_url     = trailingslashit( constant( 'BP_PLUGIN_URL' ) . constant( 'BP_SOURCE_SUBDIRECTORY' ) );
     392                $this->plugin_dir     = trailingslashit( constant( 'BP_PLUGIN_DIR' ) . $sub_directory );
     393                $this->plugin_url     = trailingslashit( constant( 'BP_PLUGIN_URL' ) . $sub_directory );
    387394
    388395                // Languages
    389396                $this->lang_dir       = $this->plugin_dir . 'bp-languages';
  • src/bp-templates/bp-legacy/buddypress-functions.php

     
    381381         *   asset)
    382382         */
    383383        private function locate_asset_in_stack( $file, $type = 'css', $script_handle = '' ) {
    384                 $locations = array();
     384                $locations = $subdirs = $retval = array();
    385385
    386                 // Ensure the assets can be located when running from /src/.
    387                 if ( defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src' ) {
    388                         $file = str_replace( '.min', '', $file );
     386                // Assets in /src/ are not minified
     387                if ( defined( 'BP_LOAD_SOURCE' ) ) {
     388                        $raw_file = str_replace( '.min', '', $file );
     389                } else {
     390                        $raw_file = $file;
    389391                }
    390392
    391393                // No need to check child if template == stylesheet
     
    393395                        $locations['bp-child'] = array(
    394396                                'dir'  => get_stylesheet_directory(),
    395397                                'uri'  => get_stylesheet_directory_uri(),
    396                                 'file' => $file,
     398                                'file' => $raw_file
    397399                        );
    398400                }
    399401
    400402                $locations['bp-parent'] = array(
    401403                        'dir'  => get_template_directory(),
    402404                        'uri'  => get_template_directory_uri(),
    403                         'file' => $file,
     405                        'file' => $raw_file
    404406                );
    405407
    406408                $locations['bp-legacy'] = array(
    407409                        'dir'  => bp_get_theme_compat_dir(),
    408410                        'uri'  => bp_get_theme_compat_url(),
    409                         'file' => $file,
     411                        'file' => $raw_file
    410412                );
    411413
    412                 // Subdirectories within the top-level $locations directories
    413                 $subdirs = array(
    414                         'buddypress/' . $type,
    415                         'community/' . $type,
    416                         $type,
    417                 );
     414                // Look for minified versions
     415                if ( $raw_file !== $file ) {
    418416
    419                 $retval = array();
     417                        // Define new locations array
     418                        $new_locations = array();
    420419
     420                        // Loop through existing locations and add minified versions
     421                        foreach ( $locations as $location_type => $location_data ) {
     422
     423                                // Repopulate current location
     424                                $new_locations[ $location_type ] = $location_data;
     425
     426                                // Populate minified location
     427                                $location_key = $location_type . '-min';
     428                                $new_locations[ $location_key ] = $location_data;
     429                                $new_locations[ $location_key ]['file'] = $file;
     430                        }
     431
     432                        // Set locations to new locations
     433                        $locations = $new_locations;
     434                }
     435
     436                // Subdirectories within top-level $locations directories
     437                $asset_locations = bp_get_template_locations();
     438                foreach ( $asset_locations as $asset_location ) {
     439                        if ( ! empty( $asset_location ) ) {
     440                                $subdirs[] = "{$asset_location}/{$type}";
     441                        } else {
     442                                $subdirs[] = $type;
     443                        }
     444                }
     445
     446                // Look for assets
    421447                foreach ( $locations as $location_type => $location ) {
    422448                        foreach ( $subdirs as $subdir ) {
    423449                                if ( file_exists( trailingslashit( $location['dir'] ) . trailingslashit( $subdir ) . $location['file'] ) ) {