Support » Plugins » Getting WP to prompt you for the “title” of link

  • carthik

    (@carthik)


    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Anonymous

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

    Anonymous

    Works 100% perfect.

    Beel

    (@beel)

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

    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”

    cheers

    Mark (podz)

    (@podz)

    Support Maven

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

    Note: Remove this space:

    < a href=

    <a href=

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Getting WP to prompt you for the “title” of link’ is closed to new replies.