Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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