diff --git src/wp-includes/js/customize-selective-refresh.js src/wp-includes/js/customize-selective-refresh.js
index b1169eb277..a3d71f76d1 100644
|
|
wp.customize.selectiveRefresh = ( function( $, api ) { |
488 | 488 | wp.mediaelement.initialize(); |
489 | 489 | } |
490 | 490 | |
| 491 | if ( wp.playlist ) { |
| 492 | wp.playlist.initialize(); |
| 493 | } |
| 494 | |
491 | 495 | /** |
492 | 496 | * Announce when a partial's placement has been rendered so that dynamic elements can be re-built. |
493 | 497 | */ |
diff --git src/wp-includes/js/mediaelement/wp-playlist.js src/wp-includes/js/mediaelement/wp-playlist.js
index 19cab125ba..7d46b201e0 100644
|
|
|
3 | 3 | (function ($, _, Backbone) { |
4 | 4 | 'use strict'; |
5 | 5 | |
| 6 | window.wp = window.wp || {}; |
| 7 | |
6 | 8 | var WPPlaylistView = Backbone.View.extend(/** @lends WPPlaylistView.prototype */{ |
7 | 9 | /** |
8 | 10 | * @constructs |
… |
… |
|
168 | 170 | } |
169 | 171 | }); |
170 | 172 | |
171 | | $(document).ready(function () { |
172 | | $('.wp-playlist').each( function() { |
173 | | return new WPPlaylistView({ el: this }); |
| 173 | function initialize() { |
| 174 | // Only initialize new playlists |
| 175 | $( '.wp-playlist:not(:has(.mejs-container))' ).each( function() { |
| 176 | new WPPlaylistView( { el: this } ); |
174 | 177 | } ); |
175 | | }); |
| 178 | } |
| 179 | |
| 180 | window.wp.playlist = { |
| 181 | initialize: initialize |
| 182 | }; |
| 183 | |
| 184 | $(document).ready( initialize ); |
176 | 185 | |
177 | 186 | window.WPPlaylistView = WPPlaylistView; |
178 | 187 | |
diff --git src/wp-includes/widgets/class-wp-widget-text.php src/wp-includes/widgets/class-wp-widget-text.php
index dc94978cd4..f42b0ca20e 100644
|
|
class WP_Widget_Text extends WP_Widget { |
57 | 57 | |
58 | 58 | wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) ); |
59 | 59 | |
| 60 | if ( $this->is_preview() ) { |
| 61 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); |
| 62 | } |
| 63 | |
60 | 64 | // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). |
61 | 65 | add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); |
62 | 66 | |
… |
… |
class WP_Widget_Text extends WP_Widget { |
393 | 397 | return $instance; |
394 | 398 | } |
395 | 399 | |
| 400 | /** |
| 401 | * Enqueue preview scripts. |
| 402 | * |
| 403 | * These scripts normally are enqueued just-in-time when a playlist shortcode is used. |
| 404 | * However, in the customizer, a playlist shortcode may be used in a text widget and |
| 405 | * dynamically added via selective refresh, so it is important to unconditionally enqueue them. |
| 406 | * |
| 407 | * @since 4.9.2 |
| 408 | */ |
| 409 | public function enqueue_preview_scripts() { |
| 410 | require_once( dirname( dirname( __FILE__ ) ) . '/media.php' ); |
| 411 | |
| 412 | wp_playlist_scripts( 'audio' ); |
| 413 | wp_playlist_scripts( 'video' ); |
| 414 | } |
| 415 | |
396 | 416 | /** |
397 | 417 | * Loads the required scripts and styles for the widget control. |
398 | 418 | * |