WordPress.org

Forums

How to make "Open link in new window" be ON by default in editing format button? (5 posts)

  1. qpqpqp
    Member
    Posted 1 year ago #

    Above the "text area" editing box of any "Add New Post" page, if one clicks on the "link" formatting button, a small pop-up window appears into which one can paste the URL and link-text to create a link in one's post.

    In this pop-up window, there is an option check-box that says

    "Open link in new window/tab"

    which you can click if you want ' target="_blank" ' to be added to the href code.

    Currently, no matter which theme I choose, that check-box option is by default always turned OFF (i.e. is unchecked), such that if I want to have the link I'm creating open in a new window, I have to click the box. If I forget or neglect to do it, then ' target="_blank" ' is not inserted, and the link does not open in a new window.

    The thing is, I ALWAYS want EVERY link in all my posts to open in a new window. So I have to click that option box every single time.

    I'd much rather save myself a bunch of constant effort (and save myself the trouble of always remembering) by having that option box be checked ON by default, rather than be OFF by default.

    Is there any way to change the default state of this option?

    I'm not afraid to manually edit a php or css file, if that's what it takes. I just don't know which one to edit!

    Alternately, if there is some easy "setting" that can be changed within the Dashboard itself, obviously I'd do it that way -- except I can't find any such setting.

    So my question is:

    Is there any built-in easy way to make links "open in a new window" by default when using the edit box's style/formatting buttons? And if not, is there a "hard way" to change the default status, by editing some php or css or tinymce or whatever file? If so: Which file?

  2. qpqpqp
    Member
    Posted 1 year ago #

    I've been poking around in various files trying to find the way to fix this, and stumbled on "wp-langs-en.js" in wp-includes/js/tinymce/langs/wp-langs-en.js which does seem to refer to relevant attributes of this exact issue.

    In particular, there is a part of "wp-langs-en.js" which says:

    link_title:"Insert/edit link",
    link_url:"Link URL",
    link_target:"Target",
    link_target_same:"Open link in the same window",
    link_target_blank:"Open link in a new window",

    What would happen if I changed that to say

    link_title:"Insert/edit link",
    link_url:"Link URL",
    link_target_blank:"Target",
    link_target_blank:"Open link in the same window",
    link_target_blank:"Open link in a new window",

    ...that is, make ALL options be "target_blank."

    I could save a pristine copy of the file, then alter the code, upload the altered file, and see if it worked -- and if it didn't, delete the altered file from the server and re-upload the pristine copy with no harm done -- right?

    Or am I on the completely wrong track? Any other suggestions?

  3. qpqpqp
    Member
    Posted 1 year ago #

    OK, I just experimented altering the "wp-langs-en.js" file as described above -- and it had no effect.

    I also experimented similarly with the adjacent "wp-langs.php" file, also to no effect.

    I then restored the untouched pristine versions of the files, just to get back to where I started.

    So, that didn't work. Back now I'm back to square one. Any other suggestions? I know this should be not very difficult.

  4. qpqpqp
    Member
    Posted 1 year ago #

    Is this issue theme-dependent, or is it part of the underlying WordPress style?

  5. cbhmmd
    Member
    Posted 6 months ago #

    Is this problem solved? I have the same problem, and I can't figure out how to solve it..

Topic Closed

This topic has been closed to new replies.

About this Topic