Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/25/2016 05:36:41 PM (8 years ago)
Author:
r-a-y
Message:

Widgets: Enqueue JS on 'bp_enqueue_scripts' action.

Previously, we were enqueuing our JS too early resulting in our JS being
loaded on embed pages.

Fixes #7087.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/classes/class-bp-core-friends-widget.php

    r10793 r10809  
    3131        parent::__construct( false, $name = _x( '(BuddyPress) Friends', 'widget name', 'buddypress' ), $widget_ops );
    3232
    33         if ( is_customize_preview() || is_active_widget( false, false, $this->id_base ) && ! is_admin() && ! is_network_admin() ) {
    34             $min = bp_core_get_minified_asset_suffix();
    35             wp_enqueue_script( 'bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() );
     33        if ( is_customize_preview() || is_active_widget( false, false, $this->id_base ) ) {
     34            add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    3635        }
    37 
     36    }
     37
     38    /**
     39     * Enqueue scripts.
     40     *
     41     * @since 2.6.0
     42     */
     43    public function enqueue_scripts() {
     44        $min = bp_core_get_minified_asset_suffix();
     45        wp_enqueue_script( 'bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() );
    3846    }
    3947
Note: See TracChangeset for help on using the changeset viewer.