<?php
/*
* Plugin-Name: Product Designer App
* Plugin-URI: https://productdesignerapp.com
* Author: productdesignerapp
* Config
* NOTE: All your configuration in this file will not be updated. So, You don't need to worry when upgrading.
*/
if (!defined('ABSPATH'))
{
    exit;
}

global $wpdb;

/*
* Plugin
* Developer mode, Platform
* NOTE: Set dev mode to 'true' if you are developing or debug (All error in code can show and style, script loading from file unminify)
*/
if (!defined('PDAPP_DEV_MODE'))
{
    define('PDAPP_DEV_MODE', false);
}

if (!defined('PDAPP_PLATFORM'))
{
    define('PDAPP_PLATFORM', 'wp');
}

/*
* Security
* Nonce key, Print/design prefix name
* NOTE: Change nonce key with high request security
* NOTE: Change prefix with high security resource folder and files (Need change before add any data of resources)
*/
if (!defined('PDAPP_ADMIN_NONCE'))
{
    define('PDAPP_ADMIN_NONCE', 'pdapp-admin-nonce');
}

if (!defined('PDAPP_FRONT_NONCE'))
{
    define('PDAPP_FRONT_NONCE', 'pdapp-front-nonce');
}

if (!defined('PDAPP_PREFIX'))
{
    define('PDAPP_PREFIX', 'prefix_');
}

/*
* Path dir, Folder, Chmod
* System
*/
if (!defined('PDAPP_BASE_NAME'))
{
    define('PDAPP_BASE_NAME', plugin_basename(PDAPP_PLUGIN_FILE));
}

if (!defined('PDAPP_ADMIN_PLUGIN_DIR'))
{
    define('PDAPP_ADMIN_PLUGIN_DIR', PDAPP_PLUGIN_DIR . 'admin/');
}

if (!defined('PDAPP_UPLOAD_DIR'))	
{
    define('PDAPP_UPLOAD_DIR', trailingslashit(wp_upload_dir()['basedir']) . dirname(PDAPP_BASE_NAME) . '/');
}
    
if (!defined('PDAPP_CHMOD'))
{
    define('PDAPP_CHMOD', 0755);
}
	
/*
* URL, Slug
* System
*/
if (!defined('PDAPP_SITE_URL'))
{
    define('PDAPP_SITE_URL', site_url());
}
	
if (!defined('PDAPP_ADMIN_URL'))
{
    define('PDAPP_ADMIN_URL', admin_url());
}

if (!defined('PDAPP_UPLOAD_URL'))	
{
    $pdappUploadURL = trailingslashit(wp_upload_dir()['baseurl']) . dirname(PDAPP_BASE_NAME) . '/';
    if(strpos($pdappUploadURL, PDAPP_SITE_URL) === false)
    {
        $pdappFixURL = explode('://', PDAPP_SITE_URL);
        $pdappFixUploadURL = explode('://', $pdappUploadURL);
        $pdappUploadURL = isset($pdappFixURL[0]) && isset($pdappFixUploadURL[1]) ? $pdappFixURL[0] .'://'. $pdappFixUploadURL[1] : $pdappUploadURL;
    }

    define('PDAPP_UPLOAD_URL', $pdappUploadURL);
}

if (!defined('PDAPP_PLUGIN_SLUG'))
{
    define('PDAPP_PLUGIN_SLUG', 'product-designer-app');
}

/*
* Plugin capabilities
*/
if (!defined('PDAPP_CAP_ACCESS'))
{
    define('PDAPP_CAP_ACCESS', PDAPP_PLUGIN_SLUG);
}

if (!defined('PDAPP_CAP_ORDERS'))
{
    define('PDAPP_CAP_ORDERS', PDAPP_PLUGIN_SLUG. '-orders');
}

if (!defined('PDAPP_CAP_QUOTES'))
{
    define('PDAPP_CAP_QUOTES', PDAPP_PLUGIN_SLUG. '-quotes');
}

if (!defined('PDAPP_CAP_PRODUCTS'))
{
    define('PDAPP_CAP_PRODUCTS', PDAPP_PLUGIN_SLUG. '-products');
}

if (!defined('PDAPP_CAP_ARTS'))
{
    define('PDAPP_CAP_ARTS', PDAPP_PLUGIN_SLUG. '-arts');
}

if (!defined('PDAPP_CAP_TEMPLATES'))
{
    define('PDAPP_CAP_TEMPLATES', PDAPP_PLUGIN_SLUG. '-templates');
}

if (!defined('PDAPP_CAP_PRINTINGS'))
{
    define('PDAPP_CAP_PRINTINGS', PDAPP_PLUGIN_SLUG. '-printings');
}

if (!defined('PDAPP_CAP_THEMES'))
{
    define('PDAPP_CAP_THEMES', PDAPP_PLUGIN_SLUG. '-themes');
}

if (!defined('PDAPP_CAP_UPGRADE'))
{
    define('PDAPP_CAP_UPGRADE', PDAPP_PLUGIN_SLUG. '-upgrade');
}

if (!defined('PDAPP_CAP_SETTINGS'))
{
    define('PDAPP_CAP_SETTINGS', PDAPP_PLUGIN_SLUG. '-settings');
}

/*
* Plugin database
*/
if (!defined('PDAPP_DB_PRODUCTS'))
{
    define('PDAPP_DB_PRODUCTS', $wpdb->prefix . 'pdapp_products');
}

if (!defined('PDAPP_DB_ARTWORKS'))
{
    define('PDAPP_DB_ARTWORKS', $wpdb->prefix . 'pdapp_artworks');
}

if (!defined('PDAPP_DB_TEMPLATES'))
{
    define('PDAPP_DB_TEMPLATES', $wpdb->prefix . 'pdapp_templates');
}

if (!defined('PDAPP_DB_PRINTS'))
{
    define('PDAPP_DB_PRINTS', $wpdb->prefix . 'pdapp_prints');
}

if (!defined('PDAPP_DB_SETTINGS'))
{
    define('PDAPP_DB_SETTINGS', $wpdb->prefix . 'pdapp_settings');
}

if (!defined('PDAPP_DB_VALUES'))
{
    define('PDAPP_DB_VALUES', $wpdb->prefix . 'pdapp_values');
}

if (!defined('PDAPP_DB_DESIGNS'))
{
    define('PDAPP_DB_DESIGNS', $wpdb->prefix . 'pdapp_designs');
}

if (!defined('PDAPP_DB_WOO_PRODUCTS'))
{
    define('PDAPP_DB_WOO_PRODUCTS', $wpdb->prefix . 'pdapp_woo_products');
}

if (!defined('PDAPP_DB_ORDERS'))
{
    define('PDAPP_DB_ORDERS', $wpdb->prefix . 'pdapp_orders');
}

if (!defined('PDAPP_DB_ORDER_DETAIL'))
{
    define('PDAPP_DB_ORDER_DETAIL', $wpdb->prefix . 'pdapp_order_detail');
}

/*
* Configs
*/
/* Expired token design after 10 days */
if (!defined('PDAPP_TOKEN_DATE'))
{
    define('PDAPP_TOKEN_DATE', 10);
}

/* Allow remove cart upload */
if (!defined('PDAPP_CLEAN_CART'))
{
    define('PDAPP_CLEAN_CART', false);
}

require_once(PDAPP_PLUGIN_DIR .'config-update.php');
?>