In the WYSIWYG editor of WordPress you get pop up if you want to add a link for a text. Is there a possibility to access this functionality? Because I want to use this pop up for a WordPress widget that I created so that you can add links to a widget if you configure it in the backend.
Here is a screenshot of what I mean:
I tried for a bit and could not get this to work perfectly, but it’s close, it’s hard to extend with the
<form>
for the popup styles being hardcoded, thought possible with more work.To get started you can:
Enqueue the link popup javascript and styles, the main .js file is
wp-includes/wplink.js
. Depending on where you loading this you might need to add more or less scripts/styles since it relies on several (thickbox, jQuery-ui, ui-dialog, etc).Set the translatable variable:
Now you should be able to extend the
wpLink
function using something like:You need a
<form>
element for the pop-up which by defualt is way to long to paste here, you can see the defualt one here: https://gist.github.com/wycks/6402573Now there are major problems with this namely I did not add any closing or submission (or checking) javascript to the function, such as
wpLink.close
orwpLink.textarea
, so seewplink.js
for further info.Sorry this just takes way to long to fiddle with, unless I am missing something basic, but that should get you most of the way.