N
N
Nikolai Novosad2017-05-04 13:39:22
TinyMCE
Nikolai Novosad, 2017-05-04 13:39:22

Do you want to open links in a new window by default?

Hello.
I'm using Wordpress 4.7.4 It is
necessary that links open in a new window by default when inserting/editing. Those. to add 'target = _blank'.
How to add checkbox 'Open link in new tab'( https://i.stack.imgur.com/1b8TM.jpg) when you select 'Link options' ( https://i.stack.imgur.com/rpCiq.jpg) I figured it out.

function ahu_after_wp_tiny_mce() {
    if (get_post_type() == 'post') { ?>
    <script>
      jQuery(document).on('wplink-open', function (wrap) {
        if (jQuery('input#wp-link-url').val() <= 0)
          jQuery('input#wp-link-target').prop('checked', true);
      });
    </script>
    <?php
  }
}
add_action( 'after_wp_tiny_mce', 'ahu_after_wp_tiny_mce' );

But if you do not select 'Link options' when inserting/editing a link, then 'targer=_blank' is not added.
Please tell me how to do it.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question