mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Media: Enable selective optout for video and audio shortcodes.
Make the JavaScript selectors for audio and video shortcodes aware of the state of the `wp_video_shortcode_library` and `wp_audio_shortcode_library` filters. Allow extenders to replace the library for either media shortcode. Props westonruter, joedolson, rudlinkon, obayedmamur. Fixes #40144. git-svn-id: https://develop.svn.wordpress.org/trunk@55271 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+13
-1
@@ -19,6 +19,8 @@
|
||||
* @return {void}
|
||||
*/
|
||||
function initialize() {
|
||||
var selectors = [];
|
||||
|
||||
if ( typeof _wpmejsSettings !== 'undefined' ) {
|
||||
settings = $.extend( true, {}, _wpmejsSettings );
|
||||
}
|
||||
@@ -63,8 +65,18 @@
|
||||
}
|
||||
};
|
||||
|
||||
if ( 'undefined' === typeof settings.videoShortcodeLibrary || 'mediaelement' === settings.videoShortcodeLibrary ) {
|
||||
selectors.push( '.wp-video-shortcode' );
|
||||
}
|
||||
if ( 'undefined' === typeof settings.audioShortcodeLibrary || 'mediaelement' === settings.audioShortcodeLibrary ) {
|
||||
selectors.push( '.wp-audio-shortcode' );
|
||||
}
|
||||
if ( ! selectors.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only initialize new media elements.
|
||||
$( '.wp-audio-shortcode, .wp-video-shortcode' )
|
||||
$( selectors.join( ', ' ) )
|
||||
.not( '.mejs-container' )
|
||||
.filter(function () {
|
||||
return ! $( this ).parent().hasClass( 'mejs-mediaelement' );
|
||||
|
||||
@@ -1111,6 +1111,10 @@ function wp_default_scripts( $scripts ) {
|
||||
'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ),
|
||||
'classPrefix' => 'mejs-',
|
||||
'stretching' => 'responsive',
|
||||
/** This filter is documented in wp-includes/media.php */
|
||||
'audioShortcodeLibrary' => apply_filters( 'wp_audio_shortcode_library', 'mediaelement' ),
|
||||
/** This filter is documented in wp-includes/media.php */
|
||||
'videoShortcodeLibrary' => apply_filters( 'wp_video_shortcode_library', 'mediaelement' ),
|
||||
);
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
'mediaelement',
|
||||
|
||||
Reference in New Issue
Block a user