如何在文本字段中调用新的Wordpress内联链接对话框?

时间:2016-11-14 11:22:28

标签: javascript jquery wordpress

我们使用以下JS打开标准的Wordpress链接对话框:

jQuery(document).ready(function($){

    $('#acf-field-online_lesen').on('click', function(event) {
        wpActiveEditor = true;// override  var as link dialogue expects wp_editor
        wpLink.open();// Open the link popup
    return false;
    });

$('#wp-link-submit').on('click', function(event) {
    var linkAtts = wpLink.getAttrs();// link attr (href, target) in object(wpLink.getAttrs())
    $('#acf-field-online_lesen').val(linkAtts.href);// Get href attr, add to textfield
    wpLink.textarea = $('.cmb_text_link');// fake textarea in order to close link dialogue
        wpLink.close();// Close the dialogue
        event.preventDefault ? event.preventDefault() : event.returnValue = false;
        event.stopPropagation();
        return false;
    });

$('#wp-link-cancel, #wp-link-close').on('click', function(event) {
    wpLink.textarea = $('.cmb_text_link');
    wpLink.close();
    event.preventDefault ? event.preventDefault() : event.returnValue = false;
    event.stopPropagation();
    return false;
    });

});

我们如何调整它以调用新的Wordpress内联链接对话框:

enter image description here

而不是旧的:

enter image description here

提前感谢您的帮助!

0 个答案:

没有答案