How to remove the depreceated target=”_blank” in WordPress TinyMCE?
If you let your users set their Links in WordPress with TinyMCE editor, you might run into some validation Problem, because target=”_blank” is part of the XHTML-Strict Standard.
To remove the Options in TinyMCE you need to edit two Files:
in
wp-includes/js/tinymce/themes/advanced/link.htm remove the Table Row offering the Link Target:
<tr>
<td><label id="targetlistlabel" for="targetlist">{#advanced_dlg.link_target}</label></td>
<td><select id="target_list" name="target_list"></select></td>
</tr>
in
wp-includes/js/tinymce/themes/advanced/js/link.js comment out the the call to
fillTargetList() in the init-function.
If you still want to open external Links in new Windows (or Tabs) you can use this Little Javascript. Links to different Domains will be opened in a new Window.
/** Creating custom :external selector **/
$.expr[':'].external = function(obj){
return !obj.href.match(/^mailto\:/)
&& (obj.hostname != location.hostname);
};
// Add 'external' CSS class to all external links
$('a:external').bind( 'click', function(){
open(this.href);
return false;
});
This entry is filed under Developer Blog, Wordpress.
Responses are currently closed, but you can trackback from your own site.