<?php
/**
 * Skin Demo importer
 *
 * @package TOURIMO
 * @since TOURIMO 1.76.0
 */


// Theme storage
//-------------------------------------------------------------------------

tourimo_storage_set( 'theme_demo_url', '//machu-picchu.tourimo.ancorathemes.com' );


//------------------------------------------------------------------------
// One-click import support
//------------------------------------------------------------------------

// Set theme specific importer options
if ( ! function_exists( 'tourimo_skin_importer_set_options' ) ) {
	add_filter('trx_addons_filter_importer_options', 'tourimo_skin_importer_set_options', 9);
	function tourimo_skin_importer_set_options($options = array()) {
		if ( is_array( $options ) ) {
			$options['demo_type']                      = 'machu-picchu';                               // 'machu-picchu' is a skin slug
			$options['files']['machu-picchu']                = $options['files']['default'];           // Need if skin slug not equal to 'default'
			$options['files']['machu-picchu']['title']       = esc_html__('Machu Picchu Demo', 'tourimo');   // Skin title
			$options['files']['machu-picchu']['domain_dev']  = esc_url( tourimo_get_protocol() . '://machu-picchu.tourimo.ancorathemes.com' );  // Developers domain
			$options['files']['machu-picchu']['domain_demo'] = esc_url( tourimo_get_protocol() . '://machu-picchu.tourimo.ancorathemes.com' );  // Demo-site domain
			unset($options['files']['default']);                                                 // Need if skin slug not equal to 'default'
		}
		return $options;
	}
}


//------------------------------------------------------------------------
// OCDI support
//------------------------------------------------------------------------

// Set theme specific OCDI options
if ( ! function_exists( 'tourimo_skin_ocdi_set_options' ) ) {
	add_filter( 'trx_addons_filter_ocdi_options', 'tourimo_skin_ocdi_set_options', 9 );
	function tourimo_skin_ocdi_set_options( $options = array() ) {
		if ( is_array( $options ) ) {
			// Demo-site domain
			$options['files']['ocdi']['title']       = esc_html__( 'Tourimo OCDI Demo', 'tourimo' );
			$options['files']['ocdi']['domain_demo'] = tourimo_storage_get( 'theme_demo_url' );
			if ( substr( $options['files']['ocdi']['domain_demo'], 0, 2 ) === '//' ) {
				$options['files']['ocdi']['domain_demo'] = tourimo_get_protocol() . ':' . $options['files']['ocdi']['domain_demo'];
			}
			// If theme need more demo - just copy 'default' and change required parameters
		}
		return $options;
	}
}
