Make audio and video URLs/embed handlers work in <iframe>
-sandbox'd MCE views.
Introduce: `get_editor_stylesheets()` `wp_media_mce_styles()`. See #28905. git-svn-id: https://develop.svn.wordpress.org/trunk@29176 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0db107498a
commit
bbfdf38a5b
@ -2652,8 +2652,26 @@ function wp_ajax_parse_embed() {
|
|||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: needed?
|
if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) {
|
||||||
$parsed = do_shortcode( $parsed );
|
$styles = '';
|
||||||
|
$mce_styles = wp_media_mce_styles();
|
||||||
|
foreach ( $mce_styles as $style ) {
|
||||||
|
$styles .= sprintf( '<link rel="stylesheet" href="%s"/>', $style );
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = do_shortcode( $parsed );
|
||||||
|
|
||||||
|
global $wp_scripts;
|
||||||
|
if ( ! empty( $wp_scripts ) ) {
|
||||||
|
$wp_scripts->done = array();
|
||||||
|
}
|
||||||
|
ob_start();
|
||||||
|
wp_print_scripts( 'wp-mediaelement' );
|
||||||
|
$scripts = ob_get_clean();
|
||||||
|
|
||||||
|
$parsed = $styles . $html . $scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) ||
|
if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) ||
|
||||||
preg_match( '%<link [^>]*href="http://%', $parsed ) ) ) ) {
|
preg_match( '%<link [^>]*href="http://%', $parsed ) ) ) ) {
|
||||||
|
@ -193,7 +193,6 @@ video,
|
|||||||
embed {
|
embed {
|
||||||
display: -moz-inline-stack;
|
display: -moz-inline-stack;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
max-width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
audio {
|
audio {
|
||||||
|
@ -3256,3 +3256,29 @@ function attachment_url_to_postid( $url ) {
|
|||||||
return (int) $post_id;
|
return (int) $post_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the URls for CSS files used in an <iframe>-sandbox'd TinyMCE media view
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
*
|
||||||
|
* @global $wp_version
|
||||||
|
* @return array The relevant CSS file URLs.
|
||||||
|
*/
|
||||||
|
function wp_media_mce_styles() {
|
||||||
|
$version = 'ver=' . $GLOBALS['wp_version'];
|
||||||
|
$tinymce = includes_url( "js/tinymce/skins/lightgray/content.min.css?$version" );
|
||||||
|
$dashicons = includes_url( "css/dashicons.css?$version" );
|
||||||
|
$skin = includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" );
|
||||||
|
$mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" );
|
||||||
|
$wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );
|
||||||
|
|
||||||
|
$mce_styles = array( $tinymce, $dashicons, $skin, $mediaelement, $wpmediaelement );
|
||||||
|
$editor_styles = get_editor_stylesheets();
|
||||||
|
if ( ! empty( $editor_styles ) ) {
|
||||||
|
foreach ( $editor_styles as $style ) {
|
||||||
|
$mce_styles[] = $style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $mce_styles;
|
||||||
|
}
|
@ -1394,6 +1394,54 @@ function remove_editor_styles() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve any registered editor stylesheets
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
*
|
||||||
|
* @global $editor_styles Registered editor stylesheets
|
||||||
|
*
|
||||||
|
* @return array If registered, a list of editor stylesheet URLs.
|
||||||
|
*/
|
||||||
|
function get_editor_stylesheets() {
|
||||||
|
$stylesheets = array();
|
||||||
|
// load editor_style.css if the current theme supports it
|
||||||
|
if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) {
|
||||||
|
$editor_styles = $GLOBALS['editor_styles'];
|
||||||
|
|
||||||
|
$editor_styles = array_unique( array_filter( $editor_styles ) );
|
||||||
|
$style_uri = get_stylesheet_directory_uri();
|
||||||
|
$style_dir = get_stylesheet_directory();
|
||||||
|
|
||||||
|
// Support externally referenced styles (like, say, fonts).
|
||||||
|
foreach ( $editor_styles as $key => $file ) {
|
||||||
|
if ( preg_match( '~^(https?:)?//~', $file ) ) {
|
||||||
|
$stylesheets[] = esc_url_raw( $file );
|
||||||
|
unset( $editor_styles[ $key ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look in a parent theme first, that way child theme CSS overrides.
|
||||||
|
if ( is_child_theme() ) {
|
||||||
|
$template_uri = get_template_directory_uri();
|
||||||
|
$template_dir = get_template_directory();
|
||||||
|
|
||||||
|
foreach ( $editor_styles as $key => $file ) {
|
||||||
|
if ( $file && file_exists( "$template_dir/$file" ) ) {
|
||||||
|
$stylesheets[] = "$template_uri/$file";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $editor_styles as $file ) {
|
||||||
|
if ( $file && file_exists( "$style_dir/$file" ) ) {
|
||||||
|
$stylesheets[] = "$style_uri/$file";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $stylesheets;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows a theme to register its support of a certain feature
|
* Allows a theme to register its support of a certain feature
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user