WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With WP 3.2, WordPress maybe has a new function to add Link-Quicktags to the editor. But I found an function to set defaults for the link-button:

Take a look at wplink.js Line 278.

    setDefaultValues : function() {
        // Set URL and description to defaults.
        // Leave the new tab setting as-is.
        inputs.url.val( 'http://' );
        inputs.title.val( '' );

        // Update save prompt.
        inputs.submit.val( wpLinkL10n.save );

How is it possible to set the values for a custom value?

Is this possible and can you help me?

Thanks for an answer from an JavaScript Expert.

share|improve this question
up vote 3 down vote accepted

Also an small example for change the url in link-button to use the url from installed blog. Use print JS in footer, not an include from js file via wp_enqueue_script() - ist faster vor development, specially for this small requirement, but not so on standard and fine, how the example from the other answer.

enter image description here

enter image description here

 * Plugin Name: Change URL in Link Popup
 * Plugin URI:  http://bueltge.de/
 * Description: Adds a domain link button to the post editing screen.
 * Version:     0.0.1
 * Author:      Frank B&uuml;ltge

if ( ! function_exists( 'fb_add_quicktag_button' ) ) {

    function fb_add_quicktag_button() {
        <script type="text/javascript">
            // change link on Link popup in TinyMCE and quicktag popup
            ( function( $ ) {

                if ( typeof wpLink == 'undefined' )

                wpLink.setDefaultValues = function () { 
                    $('#url-field').val('<?php echo home_url( '/' ); ?>');
            } )( jQuery );
    add_action( 'admin_footer-post-new.php', 'fb_add_quicktag_button', 9999 );
    add_action( 'admin_footer-post.php',     'fb_add_quicktag_button', 9999 );

share|improve this answer
@B&uuml;ltge +1 ;) – kaiser Aug 3 '12 at 9:36
@kaiser: +1 for read my stuff in the deep – bueltge Aug 3 '12 at 12:45

Put the following in your functions.php; better is a custom plugin.

add_action( 'admin_print_scripts-post.php',     'wpse22643_overwrite_wplinks' );
add_action( 'admin_print_scripts-post-new.php', 'wpse22643_overwrite_wplinks' );
 * enqueue script
function wpse22643_overwrite_wplinks( $hook ) {

    // register is important, that other plugins will change or deactivate this
        get_stylesheet_directory_uri() . '/js/overwrite-wplinks.js',
        array( 'jquery' ),
    wp_enqueue_script( 'overwrite-wplinks' );

Check the path to the js file you want to include above. Then place the following code in the above mentioned js file.

( function( $ ) {

    if ( typeof wpLink == 'undefined' )

    wpLink.setDefaultValues = function () { 
        $('#link-title-field').val('This works :)');
        $('#wp-link-submit').val( 'Use this link' );
} )( jQuery );

You can change the default values now.

share|improve this answer
Thanks for your answer. But this is an overwrite of the strings, right? I search for an replace form the default values. BUt for now it is an solution and I will only enhance for translation. – bueltge Aug 2 '12 at 12:21
It is the same way the setDefaultValues sets the defaults. – Joshua Abenazer Aug 2 '12 at 12:27
I have change your solution, only for codex and that other people use an codex conform example. – bueltge Aug 2 '12 at 13:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.