Skip to content

Instantly share code, notes, and snippets.

@BhargavBhandari90
Last active May 15, 2017 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BhargavBhandari90/6773522ca54a55c56b945ac050383c69 to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/6773522ca54a55c56b945ac050383c69 to your computer and use it in GitHub Desktop.
Remove target blank from edit link.
<?php
// Add this code to theme's functions.php
// Remove target blank from edit link.
// Check if function doest not exists.
if ( ! function_exists( 'rtmedia_wp_footer_add_js_callback' ) ) {
function rtmedia_wp_footer_add_js_callback() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
function remove_blank_target() {
jQuery( '.rtmedia-list .rtmedia-list-item' ).each( function(){
var target = jQuery( this ).find( '.rtmedia-gallery-item-actions a:first' ).attr( 'target' );
// Checked for the target attribute if it exists or not and is also set to blank.
if ( target != 'undefined' ) {
// Replace the blank target attribute to self target attribute.
jQuery( this ).find( '.rtmedia-gallery-item-actions a:first' ).attr( 'target', '_self' );
}
});
}
// Function for removing target blank
remove_blank_target();
// Remove target blank when new elements are added
jQuery('.rtmedia-list').bind("DOMSubtreeModified",function(){
remove_blank_target();
});
});
</script>
<?php
}
}
add_action( 'wp_footer', 'rtmedia_wp_footer_add_js_callback' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment