Skip to content

Commit

Permalink
Merge pull request #173 from 10up/fix/170v2
Browse files Browse the repository at this point in the history
fix/170v2: add filter to delay post saving.
  • Loading branch information
jeffpaul authored Jul 5, 2024
2 parents 9b04f60 + 352d73a commit c310258
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion assets/js/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion includes/ConvertToBlocks/MigrationAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
],
]
);
Expand Down

0 comments on commit c310258

Please sign in to comment.