Changeset 42622
- Timestamp:
- 01/30/2018 02:55:25 PM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
- Property svn:mergeinfo changed
/trunk merged: 42613,42617
- Property svn:mergeinfo changed
-
branches/4.9/src/wp-includes/js/customize-selective-refresh.js
r42037 r42622 487 487 if ( wp.mediaelement ) { 488 488 wp.mediaelement.initialize(); 489 } 490 491 if ( wp.playlist ) { 492 wp.playlist.initialize(); 489 493 } 490 494 -
branches/4.9/src/wp-includes/js/mediaelement/wp-playlist.js
r36783 r42622 3 3 (function ($, _, Backbone) { 4 4 'use strict'; 5 6 /** @namespace wp */ 7 window.wp = window.wp || {}; 5 8 6 9 var WPPlaylistView = Backbone.View.extend({ … … 165 168 }); 166 169 167 $(document).ready(function () { 168 $('.wp-playlist').each( function() { 169 return new WPPlaylistView({ el: this }); 170 /** 171 * Initialize media playlists in the document. 172 * 173 * Only initializes new playlists not previously-initialized. 174 * 175 * @since 4.9.3 176 * @returns {void} 177 */ 178 function initialize() { 179 $( '.wp-playlist:not(:has(.mejs-container))' ).each( function() { 180 new WPPlaylistView( { el: this } ); 170 181 } ); 171 }); 182 } 183 184 /** 185 * Expose the API publicly on window.wp.playlist. 186 * 187 * @namespace wp.playlist 188 * @since 4.9.3 189 * @type {object} 190 */ 191 window.wp.playlist = { 192 initialize: initialize 193 }; 194 195 $( document ).ready( initialize ); 172 196 173 197 window.WPPlaylistView = WPPlaylistView; -
branches/4.9/src/wp-includes/widgets/class-wp-widget-text.php
r42546 r42622 57 57 58 58 wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) ); 59 60 if ( $this->is_preview() ) { 61 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); 62 } 59 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(). … … 388 392 389 393 return $instance; 394 } 395 396 /** 397 * Enqueue preview scripts. 398 * 399 * These scripts normally are enqueued just-in-time when a playlist shortcode is used. 400 * However, in the customizer, a playlist shortcode may be used in a text widget and 401 * dynamically added via selective refresh, so it is important to unconditionally enqueue them. 402 * 403 * @since 4.9.3 404 */ 405 public function enqueue_preview_scripts() { 406 require_once dirname( dirname( __FILE__ ) ) . '/media.php'; 407 408 wp_playlist_scripts( 'audio' ); 409 wp_playlist_scripts( 'video' ); 390 410 } 391 411 -
branches/4.9/tests/phpunit/tests/widgets/text-widget.php
r41361 r42622 30 30 * Clean up global scope. 31 31 * 32 * @global WP_Scripts $wp_scripts 33 * @global WP_Styles $wp_style 32 * @global WP_Scripts $wp_scripts 33 * @global WP_Styles $wp_style 34 * @global WP_Customize_Manager $wp_customize 34 35 */ 35 36 function clean_up_global_scope() { 36 global $wp_scripts, $wp_styles ;37 global $wp_scripts, $wp_styles, $wp_customize; 37 38 parent::clean_up_global_scope(); 38 $wp_scripts = null; 39 $wp_styles = null; 39 $wp_scripts = null; 40 $wp_styles = null; 41 $wp_customize = null; 40 42 } 41 43 … … 67 69 $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) ); 68 70 $this->assertContains( 'wp.textWidgets.idBases.push( "text" );', wp_scripts()->registered['text-widgets']->extra['after'] ); 71 $this->assertFalse( has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); 72 } 73 74 /** 75 * Test register in customize preview. 76 * 77 * @global WP_Customize_Manager $wp_customize 78 * @covers WP_Widget_Text::__construct() 79 * @covers WP_Widget_Text::_register() 80 */ 81 function test__register_in_customize_preview() { 82 global $wp_customize; 83 wp_set_current_user( 84 $this->factory()->user->create( 85 array( 86 'role' => 'administrator', 87 ) 88 ) 89 ); 90 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 91 $wp_customize = new WP_Customize_Manager( 92 array( 93 'changeset_uuid' => wp_generate_uuid4(), 94 ) 95 ); 96 $wp_customize->start_previewing_theme(); 97 98 $widget = new WP_Widget_Text(); 99 $widget->_register(); 100 $this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); 101 } 102 103 /** 104 * Test enqueue_preview_scripts method. 105 * 106 * @global WP_Scripts $wp_scripts 107 * @global WP_Styles $wp_styles 108 * @covers WP_Widget_Text::enqueue_preview_scripts 109 */ 110 function test_enqueue_preview_scripts() { 111 global $wp_scripts, $wp_styles; 112 $wp_scripts = null; 113 $wp_styles = null; 114 $widget = new WP_Widget_Text(); 115 116 $this->assertFalse( wp_style_is( 'wp-mediaelement' ) ); 117 $this->assertFalse( wp_script_is( 'wp-playlist' ) ); 118 119 ob_start(); 120 $widget->enqueue_preview_scripts(); 121 ob_end_clean(); 122 123 $this->assertTrue( wp_style_is( 'wp-mediaelement' ) ); 124 $this->assertTrue( wp_script_is( 'wp-playlist' ) ); 69 125 } 70 126
Note: See TracChangeset
for help on using the changeset viewer.