Last active
February 24, 2017 12:09
-
-
Save raftaar1191/a2273a3e15e2f76a046c76a9fb92c966 to your computer and use it in GitHub Desktop.
Open media on the same tab when user click on edit media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 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($) { | |
// Event will fire when someone click on edit button of media. | |
jQuery( 'body' ).on( 'click', '.rtmedia-gallery-item-actions a',function(){ | |
var target = jQuery( this ).attr( 'target' ); | |
// Checked for the target attribute if it exists or not and is also set to blank. | |
if ( target != 'undefined' && target == '_blank' ) { | |
// Replace the blank target attribute to self target attribute. | |
jQuery( this ).attr( 'target', '_self' ); | |
} | |
}); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'wp_footer', 'rtmedia_wp_footer_add_js_callback', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment