Adding JS functionality to the Publish button in wp-admin/post.php

Solved it by using a modal box instead of metabox, forcing the users to finish editing the plugin data, before submitting the regular changes to WP.

    //add_action( 'add_meta_boxes', array( $this, 'add_custom_metabox' ) );
    add_action( 'media_buttons_context', array($this, 'add_custom_media_buttons' ) );

    add_action( 'admin_footer', array($this, 'add_esm_edit' ) );

These were the lines that were added to the __construct(). Commented out the old one.

The code itself is a simple link and when clicking it, it brings up the <div> hiding in the admin_footer.