好的,所以比我想要的更黑客的解决方案,但它工作了。。。
这里是从我的代码中稍微简化和抽象的方法,以防任何人需要这样做(我相信不久的将来会有更多的插件)
var reload_check = false; var publish_button_click = false;
jQuery(document).ready(function($) {
add_publish_button_click = setInterval(function() {
$publish_button = jQuery(\'.edit-post-header__settings .editor-post-publish-button\');
if ($publish_button && !publish_button_click) {
publish_button_click = true;
$publish_button.on(\'click\', function() {
var reloader = setInterval(function() {
if (reload_check) {return;} else {reload_check = true;}
postsaving = wp.data.select(\'core/editor\').isSavingPost();
autosaving = wp.data.select(\'core/editor\').isAutosavingPost();
success = wp.data.select(\'core/editor\').didPostSaveRequestSucceed();
console.log(\'Saving: \'+postsaving+\' - Autosaving: \'+autosaving+\' - Success: \'+success);
if (postsaving || autosaving || !success) {classic_reload_check = false; return;}
clearInterval(reloader);
value = document.getElementById(\'metabox_input_id\').value;
if (value == \'trigger_value\') {
if (confirm(\'Page reload required. Refresh the page now?\')) {
window.location.href = window.location.href+\'&refreshed=1\';
}
}
}, 1000);
});
}
}, 500);
});
。。。只是需要改变一下
metabox_input_id
和
trigger_value
根据需要匹配。:-)