Skip to:
Content

BuddyPress.org

Changeset 10613


Ignore:
Timestamp:
02/18/2016 11:10:33 AM (9 years ago)
Author:
djpaul
Message:

Fix script/style enqueue path when using BP dev. repo. with release build of WP, and SCRIPT_DEBUG=false.

If you have a WordPress release build (that is, not the dev SVN with its src folder) with a BuddyPress dev build (with its src folder), and set SCRIPT_DEBUG=false, BuddyPress will try to load the minified versions of its CSS and JS assets. As these minified assets only exist in our release builds, this causes 404 errors in this particular set of circumstances.

Fixes #6920

Location:
trunk/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-admin.php

    r10516 r10613  
    202202    global $bp_activity_list_table;
    203203
    204     $bp = buddypress();
    205 
    206     // Decide whether to load the dev version of the CSS and JavaScript.
    207     $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : 'min.';
    208 
     204    $bp       = buddypress();
    209205    $doaction = bp_admin_list_table_current_bulk_action();
     206    $min      = bp_core_get_minified_asset_suffix();
    210207
    211208    /**
     
    309306
    310307    // Enqueue CSS and JavaScript.
    311     wp_enqueue_script( 'bp_activity_admin_js', $bp->plugin_url . "bp-activity/admin/js/admin.{$min}js",   array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true );
     308    wp_enqueue_script( 'bp_activity_admin_js', $bp->plugin_url . "bp-activity/admin/js/admin{$min}.js",   array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true );
    312309    wp_localize_script( 'bp_activity_admin_js', 'bp_activity_admin_vars', array(
    313310        'page' => get_current_screen()->id
    314311    ) );
    315     wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin.{$min}css", array(),                               bp_get_version()       );
     312    wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin{$min}.css", array(),                               bp_get_version()       );
    316313
    317314    wp_style_add_data( 'bp_activity_admin_css', 'rtl', true );
  • trunk/src/bp-activity/bp-activity-cssjs.php

    r10417 r10613  
    3232
    3333
    34     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     34    $min = bp_core_get_minified_asset_suffix();
    3535
    3636    wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
  • trunk/src/bp-core/bp-core-cssjs.php

    r10497 r10613  
    1717 */
    1818function bp_core_register_common_scripts() {
    19     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     19    $min = bp_core_get_minified_asset_suffix();
    2020    $url = buddypress()->plugin_url . 'bp-core/js/';
    2121
     
    6464 */
    6565function bp_core_register_common_styles() {
    66     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     66    $min = bp_core_get_minified_asset_suffix();
    6767    $url = buddypress()->plugin_url . 'bp-core/css/';
    6868
  • trunk/src/bp-core/bp-core-customizer-email.php

    r10608 r10613  
    7979         */
    8080        $bp  = buddypress();
    81         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     81        $min = bp_core_get_minified_asset_suffix();
    8282
    8383        wp_enqueue_script(
  • trunk/src/bp-core/bp-core-functions.php

    r10608 r10613  
    23142314}
    23152315
     2316/**
     2317 * Get the correct filename suffix for minified assets.
     2318 *
     2319 * @since 2.5.0
     2320 *
     2321 * @return string
     2322 */
     2323function bp_core_get_minified_asset_suffix() {
     2324    $ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
     2325
     2326    // Ensure the assets can be located when running from /src/.
     2327    if ( defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src' ) {
     2328        $ext = str_replace( '.min', '', $ext );
     2329    }
     2330
     2331    return $ext;
     2332}
     2333
    23162334/** Nav Menu ******************************************************************/
    23172335
  • trunk/src/bp-core/classes/class-bp-admin.php

    r10612 r10613  
    963963     */
    964964    public function admin_register_styles() {
    965         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     965        $min = bp_core_get_minified_asset_suffix();
    966966        $url = $this->css_url;
    967967
     
    10151015     */
    10161016    public function admin_register_scripts() {
    1017         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     1017        $min = bp_core_get_minified_asset_suffix();
    10181018        $url = $this->js_url;
    10191019
  • trunk/src/bp-core/deprecated/2.1.php

    r10487 r10613  
    325325    }
    326326
    327     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     327    $min = bp_core_get_minified_asset_suffix();
    328328
    329329    if ( file_exists( get_stylesheet_directory() . '/_inc/css/adminbar.css' ) ) { // Backwards compatibility
  • trunk/src/bp-friends/classes/class-bp-core-friends-widget.php

    r10587 r10613  
    4949        }
    5050
    51         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     51        $min = bp_core_get_minified_asset_suffix();
    5252        wp_enqueue_script( 'bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() );
    5353
  • trunk/src/bp-groups/bp-groups-admin.php

    r10569 r10613  
    7979    $redirect_to = remove_query_arg( array( 'action', 'action2', 'gid', 'deleted', 'error', 'updated', 'success_new', 'error_new', 'success_modified', 'error_modified' ), $_SERVER['REQUEST_URI'] );
    8080
    81     // Decide whether to load the dev version of the CSS and JavaScript.
    82     $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : 'min.';
    83 
    84     $doaction = bp_admin_list_table_current_bulk_action();
     81    $doaction   = bp_admin_list_table_current_bulk_action();
     82    $min        = bp_core_get_minified_asset_suffix();
    8583
    8684    /**
     
    188186
    189187    // Enqueue CSS and JavaScript.
    190     wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin.{$min}js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true );
     188    wp_enqueue_script( 'bp_groups_admin_js', $bp->plugin_url . "bp-groups/admin/js/admin{$min}.js", array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), bp_get_version(), true );
    191189    wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array(
    192190        'add_member_placeholder' => __( 'Start typing a username to add a new member.', 'buddypress' ),
    193191        'warn_on_leave'          => __( 'If you leave this page, you will lose any unsaved changes you have made to the group.', 'buddypress' ),
    194192    ) );
    195     wp_enqueue_style( 'bp_groups_admin_css', $bp->plugin_url . "bp-groups/admin/css/admin.{$min}css", array(), bp_get_version() );
     193    wp_enqueue_style( 'bp_groups_admin_css', $bp->plugin_url . "bp-groups/admin/css/admin{$min}.css", array(), bp_get_version() );
    196194
    197195    wp_style_add_data( 'bp_groups_admin_css', 'rtl', true );
  • trunk/src/bp-groups/classes/class-bp-groups-widget.php

    r10553 r10613  
    3131
    3232        if ( is_active_widget( false, false, $this->id_base ) && ! is_admin() && ! is_network_admin() ) {
    33             $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     33            $min = bp_core_get_minified_asset_suffix();
    3434            wp_enqueue_script( 'groups_widget_groups_list-js', buddypress()->plugin_url . "bp-groups/js/widget-groups{$min}.js", array( 'jquery' ), bp_get_version() );
    3535        }
  • trunk/src/bp-members/classes/class-bp-members-admin.php

    r10579 r10613  
    557557        }
    558558
    559         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     559        $min = bp_core_get_minified_asset_suffix();
    560560        $css = $this->css_url . "admin{$min}.css";
    561561
  • trunk/src/bp-messages/bp-messages-cssjs.php

    r10446 r10613  
    2020        add_action( 'wp_head', 'messages_autocomplete_init_jsblock' );
    2121
    22         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     22        $min = bp_core_get_minified_asset_suffix();
    2323        $url = buddypress()->plugin_url . 'bp-messages/js/';
    2424
     
    3838function messages_add_autocomplete_css() {
    3939    if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) {
    40         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     40        $min = bp_core_get_minified_asset_suffix();
    4141        $url = buddypress()->plugin_url . 'bp-messages/css/';
    4242
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r10487 r10613  
    215215     */
    216216    public function enqueue_styles() {
    217         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     217        $min = bp_core_get_minified_asset_suffix();
    218218
    219219        // Locate the BP stylesheet.
     
    276276     */
    277277    public function enqueue_scripts() {
    278         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     278        $min = bp_core_get_minified_asset_suffix();
    279279
    280280        // Locate the BP JS file.
  • trunk/src/bp-xprofile/bp-xprofile-cssjs.php

    r10557 r10613  
    1818function xprofile_add_admin_css() {
    1919    if ( !empty( $_GET['page'] ) && strpos( $_GET['page'], 'bp-profile-setup' ) !== false ) {
    20         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     20        $min = bp_core_get_minified_asset_suffix();
    2121
    2222        wp_enqueue_style( 'xprofile-admin-css', buddypress()->plugin_url . "bp-xprofile/admin/css/admin{$min}.css", array(), bp_get_version() );
     
    4444        wp_enqueue_script( 'jquery-ui-sortable'  );
    4545
    46         $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     46        $min = bp_core_get_minified_asset_suffix();
    4747        wp_enqueue_script( 'xprofile-admin-js', buddypress()->plugin_url . "bp-xprofile/admin/js/admin{$min}.js", array( 'jquery', 'jquery-ui-sortable' ), bp_get_version() );
    4848
Note: See TracChangeset for help on using the changeset viewer.