I created a tinymce plugin that adds YouTube shortcode function with tinymce custom fields.
Plugin code (onsubmit function):
onsubmit: function( e ) {
var videourl = e.data.video_url;
var videotitle = e.data.video_title;
var jw7_videodescription = e.data.video_description;
var jw7_videoimage = e.data.video_image;
if(videourl === '') { editor.windowManager.alert('Media URL is Required'); return false; }
if(videotitle === '') {jw7_videotitle = 'untitled';}
if(jw7_videodescription === '') {jw7_videodescription = '';}
editor.insertContent('[youtube ' + 'link="' + videourl +'" title="' + videotitle + '"]');
}
The WordPress php shortcode code:
function shortcode_youtube( $atts ) {
$a = shortcode_atts( array(
'link' => '',
'title' => '',
), $atts );
return youtube_outp( $a['link'] , $a['title']);
}
add_shortcode( 'youtube', 'shortcode_youtube' );
function youtube_outp($link , $title){
if (!empty( $link ) ) {
$outp = '<p>Watch <a href="'.$link.'"></a> '.$title.'</p><br><iframe width="420" height="315" src="'.$link.'" frameborder="0" allowfullscreen></iframe>';
return $outp;
}
}
The problem is that when I write the shortcode code to tinymce manually the shortcode output works, but when I use the tinymce plugin, I get quotes problems and get this output :
[youtube link=âhttps://www.youtube.com/watch?v=w9n-t9tazFYâ title=âvide titleâ]
What is your advice about this?
note : I get this problem just when I update to latest WordPress
version