diff --git a/src/wp-admin/includes/class-wp-press-this.php b/src/wp-admin/includes/class-wp-press-this.php index 51b5104e32..b276eb31b7 100644 --- a/src/wp-admin/includes/class-wp-press-this.php +++ b/src/wp-admin/includes/class-wp-press-this.php @@ -444,6 +444,9 @@ class WP_Press_This { private function _limit_embed( $src ) { $src = $this->_limit_url( $src ); + if ( empty( $src ) ) + return ''; + if ( preg_match( '/\/\/(m|www)\.youtube\.com\/(embed|v)\/([^\?]+)\?.+$/', $src, $src_matches ) ) { // Embedded Youtube videos (www or mobile) $src = 'https://www.youtube.com/watch?v=' . $src_matches[3]; @@ -459,14 +462,13 @@ class WP_Press_This { } else if ( preg_match( '/\/\/(www\.)?dailymotion\.com\/embed\/video\/([^\/\?]+)([\/\?]{1}.+)?/', $src, $src_matches ) ) { // Embedded Daily Motion videos $src = 'https://www.dailymotion.com/video/' . $src_matches[2]; - } else if ( ! preg_match( '/\/\/(m|www)\.youtube\.com\/watch\?/', $src ) // Youtube video page (www or mobile) - && ! preg_match( '/\/youtu\.be\/.+$/', $src ) // Youtu.be video page - && ! preg_match( '/\/\/vimeo\.com\/[\d]+$/', $src ) // Vimeo video page - && ! preg_match( '/\/\/(www\.)?dailymotion\.com\/video\/.+$/', $src ) // Daily Motion video page - && ! preg_match( '/\/\/soundcloud\.com\/.+$/', $src ) // SoundCloud audio page - && ! preg_match( '/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/', $src ) // Twitter status page - && ! preg_match( '/\/\/vine\.co\/v\/[^\/]+/', $src ) ) { // Vine video page - $src = ''; + } else { + require_once( ABSPATH . WPINC . '/class-oembed.php' ); + $oembed = _wp_oembed_get_object(); + + if ( ! $oembed->get_provider( $src, array( 'discover' => false ) ) ) { + $src = ''; + } } return $src; @@ -933,6 +935,11 @@ class WP_Press_This { public function get_embeds( $data ) { $selected_embeds = array(); + // Make sure to add the Pressed page if it's a valid oembed itself + if ( ! empty ( $data['u'] ) && $this->_limit_embed( $data['u'] ) ) { + $data['_embeds'][] = $data['u']; + } + if ( ! empty( $data['_embeds'] ) ) { foreach( $data['_embeds'] as $src ) { $prot_relative_src = preg_replace( '/^https?:/', '', $src ); @@ -1097,10 +1104,7 @@ class WP_Press_This { $default_html = array( 'quote' => '', 'link' => '', 'embed' => '' ); - require_once( ABSPATH . WPINC . '/class-oembed.php' ); - $oembed = _wp_oembed_get_object(); - - if ( ! empty( $data['u'] ) && $oembed->get_provider( $data['u'], array( 'discover' => false ) ) ) { + if ( $this->_limit_embed( $data['u'] ) ) { $default_html['embed'] = '
[embed]' . $data['u'] . '[/embed]
'; if ( ! empty( $data['s'] ) ) { diff --git a/src/wp-admin/js/bookmarklet.js b/src/wp-admin/js/bookmarklet.js index a1ac930f11..fe8e74a0c2 100644 --- a/src/wp-admin/js/bookmarklet.js +++ b/src/wp-admin/js/bookmarklet.js @@ -66,16 +66,6 @@ form.appendChild( input ); } - if ( href.match( /\/\/(www|m)\.youtube\.com\/watch/ ) || - href.match( /\/\/vimeo\.com\/(.+\/)?([\d]+)$/ ) || - href.match( /\/\/(www\.)?dailymotion\.com\/video\/.+$/ ) || - href.match( /\/\/soundcloud\.com\/.+$/ ) || - href.match( /\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/ ) || - href.match( /\/\/vine\.co\/v\/[^\/]+/ ) ) { - - add( '_embeds[]', href ); - } - metas = head.getElementsByTagName( 'meta' ) || []; for ( var m = 0; m < metas.length; m++ ) { diff --git a/src/wp-admin/js/bookmarklet.min.js b/src/wp-admin/js/bookmarklet.min.js index 4e9d0a7c3f..7f0a3d21f0 100644 --- a/src/wp-admin/js/bookmarklet.min.js +++ b/src/wp-admin/js/bookmarklet.min.js @@ -1 +1 @@ -(function(a,b,c,d){function e(a,c){if("undefined"!=typeof c){var d=b.createElement("input");d.name=a,d.value=c,d.type="hidden",p.appendChild(d)}}var f,g,h,i,j,k,l,m,n,o=a.encodeURIComponent,p=b.createElement("form"),q=b.getElementsByTagName("head")[0],r="_press_this_app",s=!0;if(d){if(!c.match(/^https?:/))return void(top.location.href=d);if(d+="&u="+o(c),c.match(/^https:/)&&d.match(/^http:/)&&(s=!1),a.getSelection?h=a.getSelection()+"":b.getSelection?h=b.getSelection()+"":b.selection&&(h=b.selection.createRange().text||""),d+="&buster="+(new Date).getTime(),s||(b.title&&(d+="&t="+o(b.title.substr(0,256))),h&&(d+="&s="+o(h.substr(0,512)))),f=a.outerWidth||b.documentElement.clientWidth||600,g=a.outerHeight||b.documentElement.clientHeight||700,f=800>f||f>5e3?600:.7*f,g=800>g||g>3e3?700:.9*g,!s)return void a.open(d,r,"location,resizable,scrollbars,width="+f+",height="+g);(c.match(/\/\/(www|m)\.youtube\.com\/watch/)||c.match(/\/\/vimeo\.com\/(.+\/)?([\d]+)$/)||c.match(/\/\/(www\.)?dailymotion\.com\/video\/.+$/)||c.match(/\/\/soundcloud\.com\/.+$/)||c.match(/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/)||c.match(/\/\/vine\.co\/v\/[^\/]+/))&&e("_embeds[]",c),i=q.getElementsByTagName("meta")||[];for(var t=0;t