<?php
namespace Phox\import\demo;

/**
 * Super Demo
 * This is third demo for the theme
 * the primary color #29156b
 *
 * @package Phox
 * @author WHMCSdes
 * @link https://whmcsdes.com
 */

class Super_Demo extends Demo {


	public function config() {

		return [
			'demo_id'                  => 'super-demo',
			'demo_num'                 => '4',
			'import_file_name'         => 'Super Demo',
            'import_zip_url'           => $this->build_demo_url('super'),
            'preview_url'              => 'https://phox.whmcsdes.com/demos/super',
			'import_preview_image_url' => 'https://cdn.wdes.org/phox/demo/tPIAgH4gdSzzNbvSa5HaocOQpu4tH22VyPKvuE49.jpg',
			'update_media_url'         => true
		];

	}

	public function theme_option() {

		$theme_options_json = wp_remote_retrieve_body( wp_remote_get( 'https://whmcsdes.com/phoxdemo/super/super_demo-2021-07-08.json' ) );

		return json_decode( $theme_options_json, true );
	}

	/**
	 * Before Widget Import
	 * check all links in widget and replace it
	 *
	 * @since 1.5.7
	 * @param $import_files
	 * @return mixed
	 */
	public function widgets_import($import_files){
        // check if footer-widget-4 is exist
        if(!isset($import_files->{'footer-widget-4'})){
            return $import_files;
        }
        $site_url = get_site_url();

        $replace_wie_url = str_replace('https://phox.whmcsdes.com/demos/super', $site_url, $import_files->{'footer-widget-4'}->{'widget_wdes_about-1'}->{'image'});
        $replace_wie_url = str_replace('wp-content/uploads/sites/4','wp-content/uploads', $replace_wie_url);
        $import_files->{'footer-widget-4'}->{'widget_wdes_about-1'}->{'image'} = $replace_wie_url;
        return $import_files ;

	}

}







