I almost always select “Open link in new window” when creating an URL/HREF. Is there any way to default this choice.
Even if it requires a small source code change, I think it would be worthwhile (if someone can tell me where that might be.)
I almost always select “Open link in new window” when creating an URL/HREF. Is there any way to default this choice.
Even if it requires a small source code change, I think it would be worthwhile (if someone can tell me where that might be.)
You must be logged in to post a comment.
It seems TinyMCE provides no easy setting to select a default value. But there is another backdoor: the
external_link_list_url
option of TinyMCE can point to an extra Javascript file that will be loaded in the link editor window. You can use it to populate a dropdown of frequent link destinations, but since it is a regular Javascript file we can also drop other content in it. Like code that will change the selected value of the target list dropdown if we are not editing an existing link:You can create a WordPress plugin for this, so it will survive WP updates. Create a new directory under
wp-content/plugins/
(call it whatever you like, so you can find it later). Create a PHP file in it (also called whatever you like), with the following contents. You can change the contents of the comment, this will define what you see in the Plugins administration area.Now also create a Javascript file in that plugin directory, next to the PHP file. I called it
wpse-7785.js
, you can choose something else, but be sure to update the name in theplugins_url()
call above. Place the contents of the first block in that Javascript file.Activate the plugin and go to your editor. When you go to the post editor and click the “Edit link” button, the correct value should be set for the “Target” dropdown.
I followed your instructions and was not working at all, because wordpress changed a bit the id of the link. I fixed myself and I created a plugin.
If someone want my solution it is here working: https://github.com/eballo/DefaultCheckedLink/
UPDATE: Plugin created and published: http://www.wordpress.org/plugins/default-new-window-link-opener
This worked for me…
I stuck this in a PHP file in the wp-content/mu-plugins directory (which you need to create if it doesn’t exist).
You can create a filter for the hook
edit_tag_link
and munge the link to taste. This is one of a huge number of undocumented (or under documented) hooks in WP.I would try something like (warning: untested):
I tried the Plugin Name: WPSE 7785 idea above – the Plugin installed successfully but didn’t change the default setting for “Open link in a new window/tab” – which I believe is the intention of the original request.
I did a bit more searching/testing and found that the control for this is actually in the following WordPress file:
/wp-admin/includes/internal-linking.php
Around line 85 is the following:
I simply added “checked” to the input:
The drawback is that this file is overwritten when WordPress is updated but for now I have a “readme.txt” file in my WP folder for future reference/reminder. I’m sure there is a way to create a hook outside of the admin folder that could be used to control this and not be affected by updates but I’m not at that level of WP skill yet.