table_builder_block_migrate_old_blocks(); set_transient('table_builder_block_migrate', TABLE_BUILDER_BLOCK_PLUGIN_VERSION); } } } } } /** * Migrate old blocks to new format. * * @return void */ public function table_builder_block_migrate_old_blocks() { global $wpdb; $posts = $wpdb->get_results(" SELECT ID, post_content FROM {$wpdb->posts} WHERE post_type IN ('post', 'page', 'your_custom_post_type') AND post_status IN ('publish', 'draft', 'pending', 'private') AND post_content LIKE '%gutenkit/%' "); foreach ($posts as $post) { $updated_content = str_replace( [ 'wp:gutenkit/table-builder', 'wp:gutenkit/table-builder-row', 'wp:gutenkit/table-builder-item', 'gutenkit/table-builder', 'gutenkit/table-builder-row', 'gutenkit/table-builder-item', ], [ 'wp:tablebuilder/table-builder', 'wp:tablebuilder/table-builder-row', 'wp:tablebuilder/table-builder-item', 'tablebuilder/table-builder', 'tablebuilder/table-builder-row', 'tablebuilder/table-builder-item', ], $post->post_content ); if ($updated_content !== $post->post_content) { wp_update_post([ 'ID' => $post->ID, 'post_content' => $updated_content, ]); } } } }