<?php
/*
* Plugin-Name: Product Designer App
* Plugin-URI: https://productdesignerapp.com
* Author: productdesignerapp
* Template
*/
if (!defined('ABSPATH'))
{
    exit;
}

$pdappScript = 'var pdappAdminUrl = "'. esc_url(PDAPP_ADMIN_URL) .'";';
$pdappScript .= 'var pdappUrl = "'. esc_url(PDAPP_SITE_URL) .'";';
$pdappScript .= 'var pdappPluginUrl = "'. esc_url(PDAPP_PLUGIN_URL) .'";';
$pdappScript .= 'var pdappUploadUrl = "'. esc_url(PDAPP_UPLOAD_URL) .'";';

$pdappPrFormat = str_replace('&nbsp;', '', wp_strip_all_tags(wc_price(0)));
$pdappPriceFormat = strpos($pdappPrFormat, get_woocommerce_currency_symbol()) == 0 ? esc_html(get_woocommerce_currency_symbol().'10') : esc_html('10'.get_woocommerce_currency_symbol());
$pdappScript .= 'var pdappPriceFormat = "'. esc_html($pdappPriceFormat) .'";';

$pdappScript .= 'var pdappToken = "'. esc_html($pdappToken) .'";';
$pdappScript .= 'var pdappNonce = "'. esc_html($pdappNonce) .'";';
$pdappScript .= 'var pdappProductID = "'. esc_html($pdappProductID) .'";';
$pdappScript .= 'var pdappLangDefault = "'. esc_html($pdappLangDefault) .'";';
$pdappScript .= 'var pdappBackUrl = "'. esc_url($pdappBackUrl) .'";';
$pdappScript .= 'var pdappCustomerMail = "'. esc_html($pdappCustomerMail) .'";';
$pdappScript .= 'var pdappPrice = "'. esc_html($pdappPrice) .'";';

$pdappDevScript = PDAPP_DEV_MODE ? '' : 'min.';
$pdappScript .= 'const pdappWorker = (typeof window.Worker == "function" && !!window.Worker) ? new Worker(pdappPluginUrl+"templates/'. esc_html(PDAPP_THEME_FOLDER) .'/assets/js/pdapp-worker.'. $pdappDevScript .'js?ver='. PDAPP_VERSION .'") : false;';

wp_enqueue_script('pdapp-script', PDAPP_PLUGIN_URL . 'assets/js/pdapp-inline.js', ['jquery'], PDAPP_VERSION.'-'. time(), true);
wp_add_inline_script('pdapp-script', $pdappScript, 'before');
?>