我创建了一个tinymce插件,添加了YouTube短码功能和tinymce自定义字段 .

插件代码(onsubmit函数):

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 + '"]');

        }

WordPress php短代码:

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;
    }
}

问题是当我手动编写短代码代码时,短代码输出有效,但是当我使用tinymce插件时,我得到引号问题并得到这个输出:

[youtube link=”https://www.youtube.com/watch?v=w9n-t9tazFY” title=”vide title”]

你对此有何建议?

注意:当我更新到最新的WordPress版本时,我遇到了这个问题