public
anonymous / admin.js
Created

  • Download Gist
admin.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
jQuery(function($) {
var called = 0;
$('#wpcontent').ajaxStop(function() {
if ( 0 == called ) {
$('[value="uploaded"]').attr( 'selected', true );
called = 1;
}
});
var oldPost = wp.media.view.MediaFrame.Post;
wp.media.view.MediaFrame.Post = oldPost.extend({
initialize: function() {
oldPost.prototype.initialize.apply( this, arguments );
this.states.get('insert').get('library').props.set('uploadedTo', wp.media.view.settings.post.id);
}
});
});
functions.php
PHP
1 2 3 4
add_action('admin_enqueue_scripts', 'add_admin_js');
function add_admin_js(){
wp_enqueue_script('admin_js', get_bloginfo( 'template_directory' ) . '/javascripts/admin.js');
}

Sorry line 5 is missing the end that triggers the change so dragging is re-enabled.
$('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.