<!DOCTYPE html>
<?php
    include_once('filesHelper.php');
    include_once('editorHelper.php');

    $project = getThemeProject(get_template_directory());
    $domain = isset($project['domain']) ? $project['domain'] : '';
    $project_data = isset($project['project_data']) ? $project['project_data'] : '';

    $base_template_name = get_template();
    $template_name .= $base_template_name . '_preview';

    $theme_download_url = get_bloginfo('template_url', 'display') . '/export/getThemeUrl.php?_wpnonce=';

    $user = wp_get_current_user();
    $uid = (int) $user->ID;
    $buildTime = round(microtime(true));
?>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <script>
        var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
        document.defaultView.templateInfo = <?php echo json_encode(array(
            'login_page' => wp_login_url('wp-admin/themes.php?page=theme_editor'),
            'user' => $uid,
            'nonce' => wp_create_nonce('theme_template_export'),
            'template_url' => get_bloginfo('template_url', 'display'),
            'admin_url' => admin_url(),
            'home_url' => get_option('home'),
            'cms_version' => getThemeVersions(),
            'base_template_name' => $base_template_name,
            'template_name' => $template_name,
            'templates' => getThemeTemplates(),
            'cssJsSources' => getThemeCache(get_template_directory()),
            'md5Hashes' => getThemeHashes(get_template_directory()),
            'projectData' => $project_data,
            'woocommerce_enabled' => theme_woocommerce_enabled(),
            'themeDownloadUrl' => $theme_download_url
        )); ?>;
    </script>
    <script type="text/javascript" src="<?php echo get_bloginfo('template_url', 'display'); ?>/export/DataProvider.js?version=<?php echo $buildTime; ?>"></script>
    <script type="text/javascript" src="<?php echo $domain; ?>/loader/start.js?version=<?php echo $buildTime; ?>"></script>
</head>
<body>
<div id="theme_editor"></div>
</body>
</html>
