New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trac 32417: Media widget #215

Closed
wants to merge 22 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+831 −1
Diff settings

Always

Just for now

@@ -346,6 +346,11 @@ body.adding-widget #customize-preview {
#available-widgets [class*="event"] .widget-title:before,
#available-widgets [class*="calendar"] .widget-title:before { content: "\f145"; top: -4px;}
/* media */
#available-widgets [class*="media"] .widget-title:before {
content: "\f104";
}
/* format-image */
#available-widgets [class*="image"] .widget-title:before,
#available-widgets [class*="photo"] .widget-title:before,
@@ -1807,6 +1807,12 @@ public function customize_preview_settings() {
'stylesheet' => $this->get_stylesheet(),
'active' => $this->is_theme_active(),
),
'media' => array(
/** This filter is documented in wp-includes/media.php */
'audioLibrary' => apply_filters( 'wp_audio_shortcode_library', 'mediaelement' ),
/** This filter is documented in wp-includes/media.php */
'videoLibrary' => apply_filters( 'wp_video_shortcode_library', 'mediaelement' ),
),
'url' => array(
'self' => $self_url,
'allowed' => array_map( 'esc_url_raw', $this->get_allowed_urls() ),
@@ -0,0 +1,19 @@
.media-widget-preview .button {
text-align: center
}
.media-widget-preview .wp-caption {
max-width: 100%;
margin: 0;
}
.media-widget-preview .image {
height: auto;
max-width: 100%;
}
.media-widget-preview .aligncenter {
display: block;
margin: 0 auto;
text-align: center
}
@@ -45,3 +45,6 @@
/** WP_Nav_Menu_Widget class */
require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' );
/** WP_Widget_Media class */
require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-media.php' );
@@ -398,7 +398,7 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
* @returns {boolean} Whether the rendering was successful and the fallback was not invoked.
*/
renderContent: function( placement ) {
var partial = this, content, newContainerElement;
var partial = this, content, mediaSettings = api.settings.media, newContainerElement;
if ( ! placement.container ) {
partial.fallback( new Error( 'no_container' ), [ placement ] );
return false;
@@ -452,6 +452,13 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
placement.container.html( content );
}
// Auto-initialize media elements when they are contained in the placement
if ( $( 'audio, video', placement.container ).length > 0 ) {
if ( wp.mediaelement && wp.mediaelement.initialize && _.contains( [ mediaSettings.audioLibrary, mediaSettings.videoLibrary ], 'mediaelement' ) ) {
wp.mediaelement.initialize();
}
}
placement.container.removeClass( 'customize-render-content-error' );
} catch ( error ) {
if ( 'undefined' !== typeof console && console.error ) {
@@ -1028,6 +1035,14 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
} );
} );
api.preview.bind( 'refresh-partial', function receiveRefreshPartialMessage( partialId ) {
var partial = self.partial( partialId );
if ( partial ) {
partial.refresh();
} else {
api.preview.send( 'refresh' );
}
} );
} );
return self;
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.