Skip to:
Content

BuddyPress.org

Changeset 10809


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.

Location:
trunk/src
Files:
3 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
  • 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
  • trunk/src/bp-members/classes/class-bp-core-members-widget.php

    r10793 r10809  
    3636        ) );
    3737
    38         // Maybe enqueue JS for widget.
    39         if ( is_customize_preview() || is_active_widget( false, false, $this->id_base ) && ! is_admin() && ! is_network_admin() ) {
    40             wp_enqueue_script( 'bp-widget-members' );
     38        if ( is_customize_preview() || is_active_widget( false, false, $this->id_base ) ) {
     39            add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    4140        }
     41    }
     42
     43    /**
     44     * Enqueue scripts.
     45     *
     46     * @since 2.6.0
     47     */
     48    public function enqueue_scripts() {
     49        wp_enqueue_script( 'bp-widget-members' );
    4250    }
    4351
Note: See TracChangeset for help on using the changeset viewer.