<?php
/*
* Plugin-Name: Product Designer App
* Plugin-URI: https://productdesignerapp.com
* Author: productdesignerapp
* Page: Components
*/

if (!defined('ABSPATH'))
{
    exit;
}

$pdappNonce = wp_create_nonce(PDAPP_ADMIN_NONCE);
$pdappLangDefault = pdapp_lang_code();
$pdappUrl = site_url();
$pdappAdminUrl = admin_url();

$pdappDomain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$editPage = pdapp_get('edit');
$pdappDetailPage = pdapp_get('detail');
$pdappItemID = pdapp_get('item');

$pdappScript = 'var pdappNonce = "'. esc_html($pdappNonce) .'";';
$pdappScript .= 'var pdappAdminUrl = "'. esc_url($pdappAdminUrl) .'";';
$pdappScript .= 'var pdappUrl = "'. esc_url($pdappUrl) .'";';
$pdappScript .= 'var pdappUploadUrl = "'. esc_url(PDAPP_UPLOAD_URL) .'";';
$pdappScript .= 'var pdappPluginUrl = "'. esc_url(PDAPP_PLUGIN_URL) .'";';
$pdappScript .= 'var pdappHomeUrl = "'. esc_url(PDAPP_HOME_URL) .'";';
$pdappScript .= 'var pdappAPIUrl = "'. esc_url(PDAPP_API_URL) .'";';
$pdappScript .= 'var pdappPlatform = "'. esc_html(PDAPP_PLATFORM) .'";';
$pdappScript .= 'var pdappPackage = "'. esc_html(PDAPP_PACKAGE) .'";';
$pdappScript .= 'var pdappDomain = "'. sanitize_text_field($pdappDomain) .'";';
$pdappScript .= 'var pdappEditPage = "'. esc_html($editPage) .'";';
$pdappScript .= 'var pdappDetailPage = "'. esc_html($pdappDetailPage) .'";';
$pdappScript .= 'var pdappItemID = "'. esc_html($pdappItemID) .'";';
$pdappScript .= 'var pdappLangDefault = "'. esc_html($pdappLangDefault) .'";';
$pdappScript .= 'var pdappPluginSlug = "'. esc_html(PDAPP_PLUGIN_SLUG) .'";';
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');
?>