<?php

update_option('domain_for_sale_pro_version', '3.4.1');
update_option('domain_for_sale_pro_db_version', '3.4.1');

function domain_for_sale_recover_domain_name_3_4_1() {
    $query = new \WP_Query(array(
        'post_type'      => 'dfs_template',
        'posts_per_page' => 900,
        'post_status'    => 'any',
    ));
    foreach ($query->posts as $post) {
        $template_options = get_post_meta($post->ID, 'dfs_template_options', true);
        if (!is_array($template_options)) $template_options = [];
        if (empty($template_options['domain_name']) && !empty($post->post_title)) {
            $template_options['domain_name'] = $post->post_title;
            update_post_meta($post->ID, 'dfs_template_options', $template_options);
        }
    }
}
domain_for_sale_recover_domain_name_3_4_1();
