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-groups/classes/class-bp-groups-widget.php

    r10793 r10809  
    3131        parent::__construct( false, _x( '(BuddyPress) Groups', '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( 'groups_widget_groups_list-js', buddypress()->plugin_url . "bp-groups/js/widget-groups{$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        }
     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( 'groups_widget_groups_list-js', buddypress()->plugin_url . "bp-groups/js/widget-groups{$min}.js", array( 'jquery' ), bp_get_version() );
    3746    }
    3847
Note: See TracChangeset for help on using the changeset viewer.