Last active
March 14, 2017 06:59
-
-
Save pranali333/3ec55040c9ead9c1a2dbdb13761f8036 to your computer and use it in GitHub Desktop.
Custom code to keep media description open while uploading media using rtMedia uploader
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
// Check if function does not exist. | |
if ( ! function_exists( 'rtmedia_wp_footer_open_title_and_desc_callback' ) ) { | |
/** | |
* Add script in the wp_footer that fire just after the media is added in the rtMedia up-loader | |
* By default it will open the title and description box of the media | |
*/ | |
function rtmedia_wp_footer_open_title_and_desc_callback() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
rtMediaHook.register( 'rtmedia_js_file_added', function( args ) { | |
if( typeof args == 'object' && typeof args[1] != 'undefined' && typeof args[1].id != 'undefined' ) { | |
var id = args[1].id; | |
var button_click = '#label_' + id; | |
setTimeout( function() { | |
if( jQuery( button_click ).length > 0 ){ | |
jQuery( button_click ).trigger( 'click' ); | |
} | |
}, 250 ); | |
} | |
return true; | |
} ); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'wp_footer', 'rtmedia_wp_footer_open_title_and_desc_callback' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment