Make WordPress Core

Changeset 29176


Ignore:
Timestamp:
07/15/2014 09:50:41 PM (10 years ago)
Author:
wonderboymusic
Message:

Make audio and video URLs/embed handlers work in <iframe>-sandbox'd MCE views.

Introduce:
get_editor_stylesheets()
wp_media_mce_styles().

See #28905.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r29151 r29176  
    26532653    }
    26542654
    2655     // TODO: needed?
    2656     $parsed = do_shortcode( $parsed );
     2655    if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) {
     2656        $styles = '';
     2657        $mce_styles = wp_media_mce_styles();
     2658        foreach ( $mce_styles as $style ) {
     2659            $styles .= sprintf( '<link rel="stylesheet" href="%s"/>', $style );
     2660        }
     2661
     2662        $html = do_shortcode( $parsed );
     2663
     2664        global $wp_scripts;
     2665        if ( ! empty( $wp_scripts ) ) {
     2666            $wp_scripts->done = array();
     2667        }
     2668        ob_start();
     2669        wp_print_scripts( 'wp-mediaelement' );
     2670        $scripts = ob_get_clean();
     2671
     2672        $parsed = $styles . $html . $scripts;
     2673    }
     2674
    26572675
    26582676    if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) ||
  • trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

    r29049 r29176  
    194194    display: -moz-inline-stack;
    195195    display: inline-block;
    196     max-width: 100%;
    197196}
    198197
  • trunk/src/wp-includes/media.php

    r29164 r29176  
    32573257    }
    32583258}
     3259
     3260/**
     3261 * Return the URls for CSS files used in an <iframe>-sandbox'd TinyMCE media view
     3262 *
     3263 * @since 4.0.0
     3264 *
     3265 * @global $wp_version
     3266 * @return array The relevant CSS file URLs.
     3267 */
     3268function wp_media_mce_styles() {
     3269    $version = 'ver=' . $GLOBALS['wp_version'];
     3270    $tinymce = includes_url( "js/tinymce/skins/lightgray/content.min.css?$version" );
     3271    $dashicons = includes_url( "css/dashicons.css?$version" );
     3272    $skin = includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" );
     3273    $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" );
     3274    $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );
     3275
     3276    $mce_styles = array( $tinymce, $dashicons, $skin, $mediaelement, $wpmediaelement );
     3277    $editor_styles = get_editor_stylesheets();
     3278    if ( ! empty( $editor_styles ) ) {
     3279        foreach ( $editor_styles as $style ) {
     3280            $mce_styles[] = $style;
     3281        }
     3282    }
     3283    return $mce_styles;
     3284}
  • trunk/src/wp-includes/theme.php

    r29163 r29176  
    13961396
    13971397/**
     1398 * Retrieve any registered editor stylesheets
     1399 *
     1400 * @since 4.0.0
     1401 *
     1402 * @global $editor_styles Registered editor stylesheets
     1403 *
     1404 * @return array If registered, a list of editor stylesheet URLs.
     1405 */
     1406function get_editor_stylesheets() {
     1407    $stylesheets = array();
     1408    // load editor_style.css if the current theme supports it
     1409    if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) {
     1410        $editor_styles = $GLOBALS['editor_styles'];
     1411
     1412        $editor_styles = array_unique( array_filter( $editor_styles ) );
     1413        $style_uri = get_stylesheet_directory_uri();
     1414        $style_dir = get_stylesheet_directory();
     1415
     1416        // Support externally referenced styles (like, say, fonts).
     1417        foreach ( $editor_styles as $key => $file ) {
     1418            if ( preg_match( '~^(https?:)?//~', $file ) ) {
     1419                $stylesheets[] = esc_url_raw( $file );
     1420                unset( $editor_styles[ $key ] );
     1421            }
     1422        }
     1423
     1424        // Look in a parent theme first, that way child theme CSS overrides.
     1425        if ( is_child_theme() ) {
     1426            $template_uri = get_template_directory_uri();
     1427            $template_dir = get_template_directory();
     1428
     1429            foreach ( $editor_styles as $key => $file ) {
     1430                if ( $file && file_exists( "$template_dir/$file" ) ) {
     1431                    $stylesheets[] = "$template_uri/$file";
     1432                }
     1433            }
     1434        }
     1435
     1436        foreach ( $editor_styles as $file ) {
     1437            if ( $file && file_exists( "$style_dir/$file" ) ) {
     1438                $stylesheets[] = "$style_uri/$file";
     1439            }
     1440        }
     1441    }
     1442    return $stylesheets;
     1443}
     1444
     1445/**
    13981446 * Allows a theme to register its support of a certain feature
    13991447 *
Note: See TracChangeset for help on using the changeset viewer.