Make WordPress Core

Ticket #23282: 23282.diff

File 23282.diff, 4.5 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 682ffbb..11e4c61 100644
    function gallery_shortcode($attr) { 
    803803}
    804804
    805805/**
     806 * Retrieve all attachment posts with mime-type
     807 *
     808 */
     809function wp_get_attached_audio() {
     810
     811}
     812
     813/**
     814 * The Audio shortcode.
     815 *
     816 * This implements the functionality of the Audio Shortcode for displaying
     817 * WordPress mp3s in a post.
     818 *
     819 * @since 3.6.0
     820 *
     821 * @param array $attr Attributes of the shortcode.
     822 * @return string HTML content to display audio.
     823 */
     824function wp_audio_shortcode( $attr ) {
     825        global $content_width;
     826        $post = get_post();
     827
     828        static $instances = 0;
     829        $instances++;
     830
     831        $audio = null;
     832
     833        extract( shortcode_atts( array( 'src' => '' ), $attr ) );
     834
     835        if ( empty( $src ) ) {
     836                $children = get_children( array(
     837                        'post_parent' => $post->ID,
     838                        'post_type' => 'attachment',
     839                        'post_mime_type' => 'audio',
     840                        'posts_per_page' => 1
     841                ) );
     842
     843                if ( empty( $children ) )
     844                        return;
     845
     846                $audio = reset( $children );
     847                $src = wp_get_attachment_url( $audio->ID );
     848                if ( empty( $src ) )
     849                        return;
     850        }
     851
     852        wp_enqueue_style( 'wp-mediaelement' );
     853        wp_enqueue_script( 'wp-mediaelement' );
     854
     855        $html = sprintf( '<audio class="%s" id="%s" src="%s" type="audio/mp3" controls="controls"></audio>',
     856                apply_filters( 'audio_shortcode_class', 'wp-audio-shortcode' ),
     857                sprintf( 'audio-%d-%d', $post->ID, $instances ),
     858                esc_url( $src )
     859        );
     860
     861        return apply_filters( 'audio_shortcode', $html, $src, $audio, $post );
     862}
     863add_shortcode( 'audio', 'wp_audio_shortcode' );
     864
     865/**
     866 * The Video shortcode.
     867 *
     868 * This implements the functionality of the Video Shortcode for displaying
     869 * WordPress mp4s in a post.
     870 *
     871 * @since 3.6.0
     872 *
     873 * @param array $attr Attributes of the shortcode.
     874 * @return string HTML content to display video.
     875 */
     876function wp_video_shortcode( $attr ) {
     877        global $content_width;
     878        $post = get_post();
     879
     880        static $instances = 0;
     881        $instances++;
     882
     883        $video = null;
     884
     885        extract( shortcode_atts( array(
     886                'src' => '',
     887                'width' => empty( $content_width ) ? 640 : $content_width,
     888                'height' => 360
     889        ), $attr ) );
     890
     891        if ( empty( $src ) ) {
     892                $children = get_children( array(
     893                        'post_parent' => $post->ID,
     894                        'post_type' => 'attachment',
     895                        'post_mime_type' => 'video',
     896                        'posts_per_page' => 1
     897                ) );
     898
     899                if ( empty( $children ) )
     900                        return;
     901
     902                $video = reset( $children );
     903                $src = wp_get_attachment_url( $video->ID );
     904                if ( empty( $src ) )
     905                        return;
     906        }
     907
     908        wp_enqueue_style( 'wp-mediaelement' );
     909        wp_enqueue_script( 'wp-mediaelement' );
     910
     911        $html = sprintf( '<video class="%s" id="%s" width="%d" height="%d" src="%s" type="video/mp4" controls="controls" preload="none"></video>',
     912                apply_filters( 'video_shortcode_class', 'wp-video-shortcode' ),
     913                sprintf( 'video-%d-%d', $post->ID, $instances ),
     914                $width,
     915                $height,
     916                esc_url( $src )
     917        );
     918
     919        return apply_filters( 'video_shortcode', $html, $src, $video, $post );
     920}
     921add_shortcode( 'video', 'wp_video_shortcode' );
     922
     923/**
    806924 * Display previous image link that has the same post parent.
    807925 *
    808926 * @since 2.5.0
  • wp-includes/script-loader.php

    diff --git wp-includes/script-loader.php wp-includes/script-loader.php
    index c8aa410..05bbb62 100644
    function wp_default_scripts( &$scripts ) { 
    269269
    270270        $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 );
    271271
     272        $scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array('jquery'), '2.10.1', 1 );
     273        $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.js", array('mediaelement'), false, 1 );
     274
    272275        $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), false, 1 );
    273276        did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
    274277                'empty' => __('Strength indicator'),
    function wp_default_styles( &$styles ) { 
    533536        $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) );
    534537        $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" );
    535538
     539        $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer$suffix.css" );
     540        $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.css", array( 'mediaelement' ) );
     541
    536542        foreach ( $rtl_styles as $rtl_style ) {
    537543                $styles->add_data( $rtl_style, 'rtl', true );
    538544                if ( $suffix && ! in_array( $rtl_style, $no_suffix ) )