Last active
December 12, 2019 06:09
-
-
Save gsgoraya/79a3ff70d9cdd2e76cac97e1486668cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// insert the code inside this block | |
$('a#ct-edit-template-builder, a#ct-edit-template-builder-parent').on('click', function(e) { | |
....... | |
....... | |
....... | |
....... | |
// following is the code to be inserted at the end of this block. | |
// if it is a newly created post, still in draft mode, then have it published before the oxygenbuilder opens | |
if(wp.data.select('core/editor').getCurrentPost().status === 'auto-draft') { | |
e.preventDefault(); | |
var unsubscribe = wp.data.use(() => {})['stores']['core/edit-post'].store.subscribe(function(e) { | |
if(wp.data.use(() => {})['stores']['core/edit-post'].store.getState().metaBoxes.isSaving === false) { | |
location.href = me.attr('href'); | |
unsubscribe(); | |
} | |
}); | |
// trigger the post update | |
wp.data.dispatch('core/editor').savePost(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment