How set defaults on wpLink()

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

<?php
/**
 * 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' )
                    return;

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

}

1 thought on “How set defaults on wpLink()”

  1. Hi! I’ve been following your weblog for a while now and finally got the bravery to
    go ahsad and give you a shouyt out from Atascocita Tx!

    Just wanted to tell you keep up the fantastic work!

    Reply

Leave a Comment