$link_text =
trim( wp_unslash( $_POST['link_text'
] ) );
if ( !
$link_text ) { $link_text =
wp_basename( $src );
} $post =
get_post( isset( $_POST['post_id'
] ) ?
$_POST['post_id'
] : 0
);
// Ping WordPress for an embed.
$check_embed =
$wp_embed->
run_shortcode( '[embed]' .
$src . '[/embed]'
);
// Fallback that WordPress creates when no oEmbed was found.
$fallback =
$wp_embed->
maybe_make_link( $src );
if ( $check_embed !==
$fallback ) { // TinyMCE view for [embed] will parse this.
$html = '[embed]' .
$src . '[/embed]';
} elseif ( $link_text ) { $html = '<a href="' .
esc_url( $src ) . '">' .
$link_text . '</a>';
} else { $html = '';
} // Figure out what filter to run: