Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/19/2016 09:21:46 PM (5 years ago)
Author:
r-a-y
Message:

Widgets: Add support for WP Customizer's selective refresh.

This functionality is available as of WordPress 4.5.0.

For more details, view the WP development post:
https://make.wordpress.org/core/2016/03/22/implementing-selective-refresh-support-for-widgets/

Props lakrisgubben.
Fixes #7030.

File:
1 edited

Legend:

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

    r10613 r10793  
    2525    function __construct() {
    2626        $widget_ops = array(
    27             'description' => __( 'A dynamic list of recently active, popular, and newest Friends of the displayed member.  Widget is only shown when viewing a member profile.', 'buddypress' ),
    28             'classname' => 'widget_bp_core_friends_widget buddypress widget',
     27            'description'                 => __( 'A dynamic list of recently active, popular, and newest Friends of the displayed member.  Widget is only shown when viewing a member profile.', 'buddypress' ),
     28            'classname'                   => 'widget_bp_core_friends_widget buddypress widget',
     29            'customize_selective_refresh' => true,
    2930        );
    3031        parent::__construct( false, $name = _x( '(BuddyPress) Friends', 'widget name', 'buddypress' ), $widget_ops );
     32
     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() );
     36        }
    3137
    3238    }
     
    4854            return;
    4955        }
    50 
    51         $min = bp_core_get_minified_asset_suffix();
    52         wp_enqueue_script( 'bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() );
    5356
    5457        $user_id = bp_displayed_user_id();
Note: See TracChangeset for help on using the changeset viewer.