Make WordPress Core


Ignore:
Timestamp:
06/18/2015 12:11:30 AM (10 years ago)
Author:
azaozz
Message:

Press This: Check the embeds list against all of the oembed providers.
Props stephdau. Fixes #32069.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-press-this.php

    r32827 r32828  
    445445        $src = $this->_limit_url( $src );
    446446
     447        if ( empty( $src ) )
     448            return '';
     449
    447450        if ( preg_match( '/\/\/(m|www)\.youtube\.com\/(embed|v)\/([^\?]+)\?.+$/', $src, $src_matches ) ) {
    448451            // Embedded Youtube videos (www or mobile)
     
    460463            // Embedded Daily Motion videos
    461464            $src = 'https://www.dailymotion.com/video/' . $src_matches[2];
    462         } else if ( ! preg_match( '/\/\/(m|www)\.youtube\.com\/watch\?/', $src )          // Youtube video page (www or mobile)
    463                     && ! preg_match( '/\/youtu\.be\/.+$/', $src )                         // Youtu.be video page
    464                     && ! preg_match( '/\/\/vimeo\.com\/[\d]+$/', $src )                   // Vimeo video page
    465                     && ! preg_match( '/\/\/(www\.)?dailymotion\.com\/video\/.+$/', $src ) // Daily Motion video page
    466                     && ! preg_match( '/\/\/soundcloud\.com\/.+$/', $src )                 // SoundCloud audio page
    467                     && ! preg_match( '/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/', $src ) // Twitter status page
    468                     && ! preg_match( '/\/\/vine\.co\/v\/[^\/]+/', $src ) ) {              // Vine video page
    469             $src = '';
     465        } else {
     466            require_once( ABSPATH . WPINC . '/class-oembed.php' );
     467            $oembed = _wp_oembed_get_object();
     468
     469            if ( ! $oembed->get_provider( $src, array( 'discover' => false ) ) ) {
     470                $src = '';
     471            }
    470472        }
    471473
     
    934936        $selected_embeds = array();
    935937
     938        // Make sure to add the Pressed page if it's a valid oembed itself
     939        if ( ! empty ( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) {
     940            $data['_embeds'][] = $data['u'];
     941        }
     942
    936943        if ( ! empty( $data['_embeds'] ) ) {
    937944            foreach( $data['_embeds'] as $src ) {
     
    10981105        $default_html = array( 'quote' => '', 'link' => '', 'embed' => '' );
    10991106
    1100         require_once( ABSPATH . WPINC . '/class-oembed.php' );
    1101         $oembed = _wp_oembed_get_object();
    1102 
    1103         if ( ! empty( $data['u'] ) && $oembed->get_provider( $data['u'], array( 'discover' => false ) ) ) {
     1107        if ( $this->_limit_embed( $data['u'] ) ) {
    11041108            $default_html['embed'] = '<p>[embed]' . $data['u'] . '[/embed]</p>';
    11051109
Note: See TracChangeset for help on using the changeset viewer.