<?php

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
    exit( 'Direct script access denied.' );
}

function la_zumma_get_demo_array($dir_url, $dir_path){

    $demo_items = array(
        '01-fashion-classic' => array(
            'link' => 'https://zumma.la-studioweb.com/',
            'title' => '01 Fashion Classic',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-02' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-02' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-01.zip',
        ),
        '02-fashion-classic' => array(
            'link' => 'https://zumma.la-studioweb.com/02-fashion-classic/',
            'title' => '02 Fashion Classic',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-02' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '03-fashion-modern' => array(
            'link' => 'https://zumma.la-studioweb.com/03-fashion-modern/',
            'title' => '03 Fashion Modern',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-01' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-03.zip',
        ),
        '04-fashion-trend' => array(
            'link' => 'https://zumma.la-studioweb.com/04-fashion-trend/',
            'title' => '04 Fashion Trend',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-03' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-04' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-04.zip',
        ),
        '05-fashion-trend-02' => array(
            'link' => 'https://zumma.la-studioweb.com/05-fashion-trend-02/',
            'title' => '05 Fashion Trend 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-04' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-05.zip',
        ),
        '06-fashion-modern-02' => array(
            'link' => 'https://zumma.la-studioweb.com/06-fashion-modern-02/',
            'title' => '06 Fashion Modern 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-06.zip',
        ),
        '07-fashion-parallax' => array(
            'link' => 'https://zumma.la-studioweb.com/07-fashion-parallax/',
            'title' => '07 Fashion Parallax',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-04' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '08-fashion-simple-01' => array(
            'link' => 'https://zumma.la-studioweb.com/08-fashion-simple-01/',
            'title' => '08 Fashion Simple 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-06' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '09-fashion-simple-02' => array(
            'link' => 'https://zumma.la-studioweb.com/09-fashion-simple-02/',
            'title' => '09 Fashion Simple 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '10-fashion-mega' => array(
            'link' => 'https://zumma.la-studioweb.com/10-fashion-mega/',
            'title' => '10 Fashion Mega',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '11-cosmetic-01' => array(
            'link' => 'https://zumma.la-studioweb.com/11-cosmetic-01/',
            'title' => '11 Cosmetic 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-05' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-11.zip',
        ),
        '12-cosmetic-02' => array(
            'link' => 'https://zumma.la-studioweb.com/12-cosmetic-02/',
            'title' => '12 Cosmetic 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-05' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-02' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '13-candles-01' => array(
            'link' => 'https://zumma.la-studioweb.com/13-candles-01/',
            'title' => '13 Candles 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-06' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '14-wines-01' => array(
            'link' => 'https://zumma.la-studioweb.com/14-wines-01/',
            'title' => '14 Wines 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-05' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-12' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '15-baby-store' => array(
            'link' => 'https://zumma.la-studioweb.com/15-baby-store/',
            'title' => '15 Baby Store',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-07' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-07' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '16-cake' => array(
            'link' => 'https://zumma.la-studioweb.com/16-cake/',
            'title' => '16 Cake',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-08' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '17-burger-store' => array(
            'link' => 'https://zumma.la-studioweb.com/17-burger-store/',
            'title' => '17 Burger Store',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-09' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '18-fashion-modern-03' => array(
            'link' => 'https://zumma.la-studioweb.com/18-fashion-modern-03/',
            'title' => '18 Fashion Modern 03',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-18.zip',
        ),
        '19-fashion-big-size' => array(
            'link' => 'https://zumma.la-studioweb.com/19-fashion-big-size/',
            'title' => '19 Fashion Big Size',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-01' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-08' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '20-furniture-01' => array(
            'link' => 'https://zumma.la-studioweb.com/20-furniture-01/',
            'title' => '20 Furniture 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-10' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '21-furniture-02' => array(
            'link' => 'https://zumma.la-studioweb.com/21-furniture-02/',
            'title' => '21 Furniture 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-12' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-03' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-21.zip',
        ),
        '22-furniture-03' => array(
            'link' => 'https://zumma.la-studioweb.com/22-furniture-03/',
            'title' => '22 Furniture 03',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-11' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-09' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '23-plant-01' => array(
            'link' => 'https://zumma.la-studioweb.com/23-plant-01/',
            'title' => '23 Plant 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-13' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-08' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-23.zip',
        ),
        '24-plant-02' => array(
            'link' => 'https://zumma.la-studioweb.com/24-plant-02/',
            'title' => '24 Plant 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-14' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-08' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
        '25-organic-01' => array(
            'link' => 'https://zumma.la-studioweb.com/25-organic-01/',
            'title' => '25 Organic 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-15' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-10' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-25.zip',
        ),
        '26-organic-02' => array(
            'link' => 'https://zumma.la-studioweb.com/26-organic-02/',
            'title' => '26 Organic 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-16' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-10' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-26.zip',
        ),
        '27-watch-01' => array(
            'link' => 'https://zumma.la-studioweb.com/27-watch-01/',
            'title' => '27 Watch 01',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-17' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-11' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-27.zip',
        ),
        '28-watch-02' => array(
            'link' => 'https://zumma.la-studioweb.com/28-watch-02/',
            'title' => '28 Watch 02',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-17' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-05' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
            'data_slider' => 'main-28.zip',
        ),
        '29-watch-03' => array(
            'link' => 'https://zumma.la-studioweb.com/29-watch-03/',
            'title' => '29 Watch 03',
            'data_elementor' => array(
                'header' => array(
                    'location' => 'header',
                    'value' => array(
                        'zumma-header-18' => 'include/general',
                    ),
                ),
                'footer' => array(
                    'location' => 'footer',
                    'value' => array(
                        'zumma-footer-02' => 'include/general',
                    ),
                ),
            ),
            'category' => array(
                0 => 'Demo',
            ),
        ),
    );

    $default_image_setting = array(
        'woocommerce_single_image_width' => 1000,
        'woocommerce_thumbnail_image_width' => 600,
        'woocommerce_thumbnail_cropping' => 'custom',
        'woocommerce_thumbnail_cropping_custom_width' => 10,
        'woocommerce_thumbnail_cropping_custom_height' => 12,
        'thumbnail_size_w' => 0,
        'thumbnail_size_h' => 0,
        'medium_size_w' => 0,
        'medium_size_h' => 0,
        'medium_large_size_w' => 0,
        'medium_large_size_h' => 0,
        'large_size_w' => 0,
        'large_size_h' => 0,
    );

    $default_menu = array(
        'main-nav'              => 'Zumma Primary Menu'
    );

    $default_page = array(
        'page_for_posts' 	            => 'Blog',
        'woocommerce_shop_page_id'      => 'Shop',
        'woocommerce_cart_page_id'      => 'Cart',
        'woocommerce_checkout_page_id'  => 'Checkout',
        'woocommerce_myaccount_page_id' => 'My Account'
    );

    $slider = $dir_path . 'Slider/';
    $content = $dir_path . 'Content/';
    $product = $dir_path . 'Product/';
    $widget = $dir_path . 'Widget/';
    $setting = $dir_path . 'Setting/';
    $preview = $dir_url;

    $default_elementor = [
        'single-post'       => [
            'location' => 'single',
            'value' => [
                'zumma-single-post-01' => 'include/singular/post',
            ],
        ],
        'single-page'       => [
            'location' => 'single',
            'value' => '',
            'default' => [
                'zumma-woopages' => [
                    'include/singular/page/wishlist',
                    'include/singular/page/compare',
                    'include/singular/page/cart',
                    'include/singular/page/checkout'
                ],
            ]
        ],
        'archive'           => [
            'location' => 'archive',
            'value' => [
                'zumma-blog-right-sidebar' => 'include/archive'
            ]
        ],
        'search-results'    => [
            'location' => 'archive',
            'value'    => '',
            'default' => [
                'name' => 'include/archive/search'
            ],
        ],
        'error-404'         => [
            'location' => 'single',
            'value' => [
	            'zumma-404' => 'include/archive/search'
            ],
        ],
        'product'           => [
            'location' => 'single',
            'value' => [
                'zumma-product-template-01' => 'include/product'
            ]
        ],
        'product-archive'   => [
            'location' => 'archive',
            'value' => [
                'zumma-shop-fullwidth' => 'include/product_archive'
            ]
        ],
    ];

    $elementor_kit_settings = json_decode( file_get_contents( $setting . 'settings.json' ), true );

    $data_return = array();

    foreach ($demo_items as $demo_key => $demo_detail){
	    $value = array();

	    $value['title']             = $demo_detail['title'];
	    $value['category']          = !empty($demo_detail['category']) ? $demo_detail['category'] : array('Demo');
	    $value['demo_preset']       = $demo_key;
	    $value['demo_url']          = $demo_detail['link'];
	    $value['preview']           = !empty($demo_detail['preview']) ? $demo_detail['preview'] : ($preview . $demo_key . '.jpg');
	    $value['option']            = $setting . $demo_key . '.json';
	    $value['content']           = !empty($demo_detail['data_sample']) ? $content . $demo_detail['data_sample'] : $content . 'demo-data.json';
	    $value['product']           = !empty($demo_detail['data_product']) ? $product . $demo_detail['data_product'] : $product . 'products.csv';
	    $value['widget']            = !empty($demo_detail['data_widget']) ? $widget . $demo_detail['data_widget'] : $widget . 'widgets.json';
	    $value['pages']             = array_merge( $default_page, array( 'page_on_front' => $demo_detail['title'] ));
	    $value['menu-locations']    = array_merge( $default_menu, isset($demo_detail['menu-locations']) ? $demo_detail['menu-locations'] : array());
	    $value['other_setting']     = array_merge( $default_image_setting, isset($demo_detail['other_setting']) ? $demo_detail['other_setting'] : array());
	    if(!empty($demo_detail['data_slider'])){
		    $value['slider'] = $slider . $demo_detail['data_slider'];
	    }
        $value['elementor']         = array_merge( $default_elementor, isset($demo_detail['data_elementor']) ? $demo_detail['data_elementor'] : array());
        $value['elementor_kit_settings']         = array_merge( $elementor_kit_settings, isset($demo_detail['elementor_kit_settings']) ? $demo_detail['elementor_kit_settings'] : array());
	    $data_return[$demo_key] = $value;
    }

    return $data_return;
}