WordPress.org

Make WordPress Core

Ticket #11556: 11556.patch

File 11556.patch, 1.3 KB (added by Viper007Bond, 8 years ago)
  • wp-includes/media.php

     
    954954
    955955                // After a post is saved, cache oEmbed items via AJAX
    956956                add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') );
     957
     958                // Convert YouTu.be URLs to normal ones
     959                add_filter( 'embed_pre_url', array(&$this, 'youtube_url_expander') );
    957960        }
    958961
    959962        /**
     
    10671070                $rawattr = $attr;
    10681071                $attr = wp_parse_args( $attr, wp_embed_defaults() );
    10691072
     1073                $url = apply_filters( 'embed_pre_url', $url );
     1074
    10701075                // Look for known internal handlers
    10711076                ksort( $this->handlers );
    10721077                foreach ( $this->handlers as $priority => $handlers ) {
     
    11941199                $output = ( $this->linkifunknown ) ? '<a href="' . esc_attr($url) . '">' . esc_html($url) . '</a>' : $url;
    11951200                return apply_filters( 'embed_maybe_make_link', $output, $url );
    11961201        }
     1202
     1203        /**
     1204         * Convert YouTu.be URLs into their full length counterparts
     1205         *
     1206         * @param string $url A URL, maybe with youtu.be in it
     1207         * @return string A URL, with any YouTube URL expanded
     1208         */
     1209        function youtube_url_expander( $url ) {
     1210                return str_replace( 'http://youtu.be/', 'http://www.youtube.com/watch?v=', $url );
     1211        }
    11971212}
    11981213$wp_embed = new WP_Embed();
    11991214