diff --git a/assets/js/editor/editor.js b/assets/js/editor/editor.js index 187b6a3..bee0280 100644 --- a/assets/js/editor/editor.js +++ b/assets/js/editor/editor.js @@ -66,7 +66,15 @@ class ConvertToBlocksEditorSupport { return null; } - client.save(); + const saveDelay = config?.agent?.save_delay || 0; + + if (saveDelay > 0) { + setTimeout(() => { + client.save(); + }, saveDelay); + } else { + client.save(); + } return null; }, 500); diff --git a/includes/ConvertToBlocks/MigrationAgent.php b/includes/ConvertToBlocks/MigrationAgent.php index 2aaadbc..a859a31 100644 --- a/includes/ConvertToBlocks/MigrationAgent.php +++ b/includes/ConvertToBlocks/MigrationAgent.php @@ -24,12 +24,18 @@ public function register() { return; } + $posts_to_update = get_option( 'ctb_posts_to_update' ); + $cursor = get_option( 'ctb_cursor' ); + $posts_to_update = is_array( $posts_to_update ) ? $posts_to_update : []; + $post_id = $posts_to_update[ $cursor ] ?? 0; + wp_localize_script( 'convert_to_blocks_editor', 'convert_to_blocks_agent', [ 'agent' => [ - 'next' => $this->next(), + 'next' => $this->next(), + 'save_delay' => apply_filters( 'convert_to_blocks_save_delay', 0, $post_id ) ], ] );