ID, '_suiko_update_of', true ); if ( ! $of || 'draft' !== $post->post_status || ! current_user_can( 'edit_post', $of ) ) { return; } $data = array( /* translators: %s: title of the live article */ 'message' => sprintf( __( 'This draft is an update proposed by Suiko for "%s". Review it, then apply it to the live article.', 'suiko' ), get_post_field( 'post_title', $of ) ), 'action' => __( 'Apply this Suiko update', 'suiko' ), 'confirm' => __( 'Replace the live article with this Suiko update?', 'suiko' ), 'url' => suiko_apply_url( $post->ID ), ); wp_register_script( 'suiko-editor', false, array( 'wp-data', 'wp-notices' ), SUIKO_VERSION, true ); wp_enqueue_script( 'suiko-editor' ); wp_add_inline_script( 'suiko-editor', '(function(){var d=' . wp_json_encode( $data ) . ';function go(){if(!window.wp||!wp.data||!wp.data.dispatch){return setTimeout(go,300);}' . 'wp.data.dispatch("core/notices").createNotice("info",d.message,{id:"suiko-update",isDismissible:false,actions:[{label:d.action,onClick:function(){if(window.confirm(d.confirm)){window.location.href=d.url;}}}]});}go();})();' ); } );