Skip to content

Commit

Permalink
add filter to delay saving post
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Jun 28, 2024
1 parent 2181f61 commit 46f900e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion assets/js/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class ConvertToBlocksEditorSupport {
return null;
}

client.save();
setTimeout(() => {
client.save();
}, config.agent.save_delay);

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', 500, $post_id )
],
]
);
Expand Down

0 comments on commit 46f900e

Please sign in to comment.