<?php
/**
 * Updater file to update old options.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

update_option( 'smart_post_show_pro_version', '3.3.0' );
update_option( 'smart_post_show_pro_db_version', '3.3.0' );

$old_options = get_option( 'sp-pcp-blocks-setting-options' );
$old_modules = get_option( 'sp-pcp-blocks-modules-options' );

$new_options = array(
	array(
		'block_name' => 'post-carousel-two',
		'show'       => true,
	),
	array(
		'block_name' => 'smart-image',
		'show'       => true,
	),
	array(
		'block_name' => 'smart-search',
		'show'       => true,
	),
	array(
		'block_name' => 'smart-info-box',
		'show'       => true,
	),
	array(
		'block_name' => 'smart-list',
		'show'       => true,
	),
	array(
		'block_name' => 'smart-lists',
		'show'       => true,
	),
	array(
		'block_name' => 'table-of-content',
		'show'       => true,
	),
	array(
		'block_name' => 'table-of-content',
		'show'       => true,
	),
);

$new_modules = array(
	array(
		'module_name' => 'taxonomy',
		'show'        => $old_modules['taxonomy'] ?? true,
	),
	array(
		'module_name' => 'post-badges',
		'show'        => true,
	),
	array(
		'module_name' => 'image-gallery',
		'show'        => true,
	),
	array(
		'module_name' => 'featured-video',
		'show'        => true,
	),
	array(
		'module_name' => 'back-to-top',
		'show'        => true,
	),
	array(
		'module_name' => 'saved-template',
		'show'        => true,
	),
);

update_option( 'sp-pcp-blocks-setting-options', array_merge( $old_options, $new_options ) );
update_option( 'sp-pcp-blocks-modules-options', $new_modules );
