Support

Account

Home Forums Bug Reports Attachment Taxonomy Multi-Select not saving Reply To: Attachment Taxonomy Multi-Select not saving

  • This code fixes the WordPress save function. I have also submitted this as a bug so hopefully they fix it.

    add_action( 'admin_print_footer_scripts', 'mediaArrayFix', 11 );
    	function mediaArrayFix() {
    		// Make sure the media-views script has been enqueued.
    		if(!did_action( 'wp_enqueue_media' ) ){ return; }
    		?>
    		<script>
    		wp.media.view.AttachmentCompat.prototype.save = function( event ) {
    			var data = {};
    			if ( event ) { event.preventDefault(); }
    			_.each( this.$el.serializeArray(), function( pair ) {
    				if ( /\[\]$/.test( pair.name ) ) {
    					if ( undefined === data[ pair.name ] ) { data[ pair.name ] = []; }
    					data[ pair.name ].push( pair.value );
    				}else{ data[ pair.name ] = pair.value; }
    			});
    			this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
    			this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
    		};
    		</script>
    		<?php
    	}