This tool uses a fast queue-based system to find all posts, pages, and reusable block patterns that contain Adaire Blocks
and re-save them with the current block structure. This is useful when you've made changes to block
code that cause validation errors.
What this does:
Finds all posts/pages and patterns with Adaire Blocks
Processes each item one at a time in a queue
Automatically recovers and fixes validation errors
Re-saves each item with the current block structure
Preserves all block settings and content
Cleans up resources after each item for optimal performance
⚠️ Important:
Faster than previous version - processes posts sequentially with optimized timeouts
It's recommended to backup your database first
Do not close this page while migration is running
You can cancel at any time - already processed posts will remain migrated
Status:Preparing...
Queue: Initializing...
Progress:0/0
✅ 0 | ❌ 0
✅ Migration completed!
Note: This tool will process both posts/pages and reusable block patterns (wp_block) that contain Adaire Blocks.
'Unauthorized']);
}
$items_to_migrate = [];
$posts_count = 0;
$patterns_count = 0;
// Get all posts and pages that might contain blocks
$args = [
'post_type' => ['post', 'page'],
'post_status' => ['publish', 'draft', 'pending', 'private'],
'posts_per_page' => -1,
'fields' => 'ids',
];
$all_posts = get_posts($args);
$posts_checked = count($all_posts);
// Filter posts that contain Adaire Blocks
foreach ($all_posts as $post_id) {
$content = get_post_field('post_content', $post_id);
// Check if post contains any Adaire Blocks
if (has_blocks($content)) {
$blocks = parse_blocks($content);
if (adaire_has_adaire_blocks($blocks)) {
$post = get_post($post_id);
$items_to_migrate[] = [
'id' => $post_id,
'title' => $post->post_title,
'type' => 'post',
];
$posts_count++;
}
}
}
// Get all reusable blocks/patterns (wp_block post type)
$pattern_args = [
'post_type' => 'wp_block',
'post_status' => ['publish', 'draft', 'pending', 'private'],
'posts_per_page' => -1,
'fields' => 'ids',
];
$all_patterns = get_posts($pattern_args);
$patterns_checked = count($all_patterns);
// Filter patterns that contain Adaire Blocks
foreach ($all_patterns as $pattern_id) {
$content = get_post_field('post_content', $pattern_id);
// Check if pattern contains any Adaire Blocks
if (has_blocks($content)) {
$blocks = parse_blocks($content);
if (adaire_has_adaire_blocks($blocks)) {
$pattern = get_post($pattern_id);
$items_to_migrate[] = [
'id' => $pattern_id,
'title' => $pattern->post_title ? $pattern->post_title : 'Untitled Pattern',
'type' => 'pattern',
];
$patterns_count++;
}
}
}
wp_send_json_success([
'items' => $items_to_migrate,
'posts_count' => $posts_count,
'patterns_count' => $patterns_count,
'posts_checked' => $posts_checked,
'patterns_checked' => $patterns_checked,
]);
}
add_action('wp_ajax_adaire_get_posts_to_migrate', 'adaire_get_posts_to_migrate');
/**
* Check if blocks array contains any Adaire Blocks
*/
function adaire_has_adaire_blocks($blocks) {
foreach ($blocks as $block) {
// Check if it's an Adaire Block (starts with 'create-block/')
if (isset($block['blockName']) && strpos($block['blockName'], 'create-block/') === 0) {
return true;
}
// Check inner blocks recursively
if (!empty($block['innerBlocks'])) {
if (adaire_has_adaire_blocks($block['innerBlocks'])) {
return true;
}
}
}
return false;
}
// Note: Migration now happens via JavaScript in hidden iframes
// Each post is loaded in the editor context where auto-recovery runs
// This ensures blocks are actually recovered using the current save.js