Set “Open in New tab” as default option
Question
I would like to set the Open in New tab
as default option. So that when I add a new URL in a text I would like to automatically tick the box to open the link in a new tab.
I am running on Version 5.1.1
. I tried to create the following plugin:
<?php
/*
Plugin Name: New Tab Always
Description: Ensure that the new tab is always clicked.
Plugin URI:
Author:
Author URI:
Version: 0.1
License:
*/
add_action( 'admin_head', function() {
global $pagenow;
if ( $pagenow === 'post.php' ) {
?>
<script>
jQuery(document).ready(function($){
var linkTarget = jQuery( '#wp-link-target' );
if ( linkTarget.length ) {
linkTarget.prop( 'checked', true );
}
});
</script>
<?php
}
});
However, I still get the old behavior of not having the button clicked.
Any suggestions what I am doing wrong?
I appreciate your replies!
0
plugin-development, plugins
3 years
2020-08-21T16:10:48-05:00
2020-08-21T16:10:48-05:00 0 Answers
42 views
0
Leave an answer