<?php
/** 
 * @package   	VikRentItems
 * @subpackage 	core
 * @author    	E4J s.r.l.
 * @copyright 	Copyright (C) 2018 E4J s.r.l. All Rights Reserved.
 * @license  	http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link 		https://vikwp.com
 */

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

// Software version
define('VIKRENTITEMS_SOFTWARE_VERSION', '1.2.1');

// Base path
define('VIKRENTITEMS_BASE', dirname(__FILE__));

// Libraries path
define('VIKRENTITEMS_LIBRARIES', VIKRENTITEMS_BASE . DIRECTORY_SEPARATOR . 'libraries');

// Languages path
define('VIKRENTITEMS_LANG', basename(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'languages');
/**
 * The admin and site languages are no more used by the plugin.
 *
 * @deprecated 1.0.0
 */
define('VIKRENTITEMS_SITE_LANG', basename(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'site' . DIRECTORY_SEPARATOR . 'language');
define('VIKRENTITEMS_ADMIN_LANG', basename(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'language');

// Assets URI
define('VIKRENTITEMS_SITE_ASSETS_URI', plugin_dir_url(__FILE__) . 'site/resources/');
define('VIKRENTITEMS_ADMIN_ASSETS_URI', plugin_dir_url(__FILE__) . 'admin/resources/');

// Debug flag
define('VIKRENTITEMS_DEBUG', false);

// URI Constants for admin and site sections (with trailing slash)
defined('VRI_ADMIN_URI') or define('VRI_ADMIN_URI', plugin_dir_url(__FILE__).'admin/');
defined('VRI_SITE_URI') or define('VRI_SITE_URI', plugin_dir_url(__FILE__).'site/');
defined('VRI_BASE_URI') or define('VRI_BASE_URI', plugin_dir_url(__FILE__));
defined('VRI_MODULES_URI') or define('VRI_MODULES_URI', plugin_dir_url(__FILE__));
defined('VRI_ADMIN_URI_REL') or define('VRI_ADMIN_URI_REL', plugin_dir_url(__FILE__).'admin/');
defined('VRI_SITE_URI_REL') or define('VRI_SITE_URI_REL', plugin_dir_url(__FILE__).'site/');

// Path Constants for admin and site sections (with NO trailing directory separator)
defined('VRI_ADMIN_PATH') or define('VRI_ADMIN_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'admin');
defined('VRI_SITE_PATH') or define('VRI_SITE_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'site');

// Other Constants that may not be available in the framework
defined('DS') or define('DS', DIRECTORY_SEPARATOR);

/**
 * We define the base path constant for the upload dir
 * used to upload the customer documents onto the sub-dirs.
 * 
 * @since 	1.2.0
 */
$customer_upload_base_path = VRI_ADMIN_PATH . DIRECTORY_SEPARATOR . 'resources';
$customer_upload_base_uri = VRI_ADMIN_URI . 'resources/';
$media_upload_base_path    = $customer_upload_base_path;
$media_upload_base_uri 	   = $customer_upload_base_uri;
$upload_dir = wp_upload_dir();
if (is_array($upload_dir) && !empty($upload_dir['basedir']) && !empty($upload_dir['baseurl'])) {
	$customer_upload_base_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'vikrentitems';
	$customer_upload_base_uri = rtrim($upload_dir['baseurl'], '/') . '/' . 'vikrentitems' . '/';
	// define proper values for the media directory
	$media_upload_base_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'vikrentitems' . DIRECTORY_SEPARATOR . 'media';
	$media_upload_base_uri 	= rtrim($upload_dir['baseurl'], '/') . '/' . 'vikrentitems' . '/' . 'media' . '/';
}
defined('VRI_CUSTOMERS_PATH') or define('VRI_CUSTOMERS_PATH', $customer_upload_base_path);
defined('VRI_CUSTOMERS_URI') or define('VRI_CUSTOMERS_URI', $customer_upload_base_uri);

/**
 * We define the base path and URI for the media dir.
 * 
 * @since 	1.2.0
 */
defined('VRI_MEDIA_PATH') or define('VRI_MEDIA_PATH', $media_upload_base_path);
defined('VRI_MEDIA_URI') or define('VRI_MEDIA_URI', $media_upload_base_uri);


/**
 * Site pre-process flag.
 * When this flag is enabled, the plugin will try to dispatch the
 * site controller within the "init" action. This is made by 
 * fetching the shortcode assigned to the current URI.
 *
 * By disabling this flag, the site controller will be dispatched 
 * with the headers already sent.
 */
define('VIKRENTITEMS_SITE_PREPROCESS', true);
