Site-Wide Checkbox Hide
You can add a simple function to your functions.php
to change its visibility (and will also set the default checked state to false
):
function disable_open_new_window() {
?>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('input#link-target-checkbox').prop('checked', false);
$('#wp-link .link-target').css('visibility', 'hidden');
});
</script>
<?php
}
add_action ('after_wp_tiny_mce', 'disable_open_new_window');
This will change the visibility of that checkbox site-wide, however, as the dialog box is not specific to ACF, and is used a few places in WordPress.
Reference: Prevent WordPress Authors From Setting Links to Open in New Windows
Field-Specific Checkbox Hide
As far as I’m aware, this isn’t possible, since the dialog box isn’t specific to custom fields (or ACF), it’s a WordPress built-in dialog box.
Instead of hiding the checkbox, you can make it functionally useless instead. If you take a look at the documentation, you’ll see you can retrieve a $link['target']
option, which you can choose to use, or set that field to _self
or _blank
or whatever you want it to be.