Getting WP to prompt you for the "title" of link (7 posts)

  1. carthik
    Posted 10 years ago #

    This modification allows my wordpress to prompt me for the title attribute when I use the quicktags in the post page to add a link.
    Here is what I have in my wp-admin/quicktags.js file, closer to the bottom:

    function edInsertLink(myField, i, defaultValue) {
    if (!defaultValue) {
    defaultValue = 'http://';
    if (!edCheckOpenTags(i)) {
    var URL = prompt('Enter the URL' ,defaultValue);
    if (URL) {
    edButtons[i].tagStart = '< a href=""'<br" />
    + URL
    + '" title="' + prompt('Enter a title for the link', '')
    + '">';
    edInsertTag(myField, i);
    else {
    edInsertTag(myField, i);

    This function replaces the existent edInsertLink(); function in the quicktags.js file

  2. Anonymous
    Posted 10 years ago #

    I was just going to ask for help on getting this feature. Thanks!

  3. Anonymous
    Posted 10 years ago #

    Works 100% perfect.

  4. Beel
    Posted 10 years ago #

    Make sure this gets to Matt as it should be added to quicktags.

  5. drstuey
    Posted 10 years ago #

    yes it does work, but not as written here. Word press has deleted the <a href=" part and turned it into a link which should be obvious from the fact that everything after that in the post is blue and underlined.

    The correct line should be:
    edButtons[i].tagStart = '<a href="

    Someone should edit the post above and change < to &lt; in case anyone else tries to copy the code.

    Yes this would be good in the official release quicktags, but maybe the JavaScript needs another if/else in case there is no title to stop it writing title="null"


  6. Mark (podz)
    Support Maven
    Posted 10 years ago #

    @drstuey - thanks, I have edited the above code.

    Note: Remove this space:

    < a href=

    <a href=

  7. idntical
    Posted 9 years ago #

    I've copy and pasted over the code, and for some reason still cant do it. Is there something special i have to do?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.