From a29835d6fc2d3ff3638e0bae1241e1e9ac489334 Mon Sep 17 00:00:00 2001 From: max-baranikov Date: Mon, 29 Mar 2021 13:38:03 +0300 Subject: [PATCH] Improved module customization --- src/include/api/class-wc-retailcrm-client-v4.php | 4 ++-- src/include/api/class-wc-retailcrm-client-v5.php | 4 ++-- src/include/api/class-wc-retailcrm-proxy.php | 2 +- src/include/api/class-wc-retailcrm-request.php | 4 ++-- src/include/api/class-wc-retailcrm-response.php | 2 +- src/include/class-wc-retailcrm-base.php | 4 ++-- src/include/class-wc-retailcrm-plugin.php | 4 ++-- .../components/class-wc-retailcrm-history-assembler.php | 5 +---- src/retailcrm.php | 2 +- 9 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/include/api/class-wc-retailcrm-client-v4.php b/src/include/api/class-wc-retailcrm-client-v4.php index 1cce88f..8004102 100644 --- a/src/include/api/class-wc-retailcrm-client-v4.php +++ b/src/include/api/class-wc-retailcrm-client-v4.php @@ -13,11 +13,11 @@ */ if ( ! class_exists( 'WC_Retailcrm_Request' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-request.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-request.php')); } if ( ! class_exists( 'WC_Retailcrm_Response' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-response.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php')); } class WC_Retailcrm_Client_V4 diff --git a/src/include/api/class-wc-retailcrm-client-v5.php b/src/include/api/class-wc-retailcrm-client-v5.php index 3ec37cd..3deeba8 100644 --- a/src/include/api/class-wc-retailcrm-client-v5.php +++ b/src/include/api/class-wc-retailcrm-client-v5.php @@ -13,11 +13,11 @@ */ if ( ! class_exists( 'WC_Retailcrm_Request' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-request.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-request.php')); } if ( ! class_exists( 'WC_Retailcrm_Response' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-response.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php')); } class WC_Retailcrm_Client_V5 diff --git a/src/include/api/class-wc-retailcrm-proxy.php b/src/include/api/class-wc-retailcrm-proxy.php index c109639..2db32e2 100644 --- a/src/include/api/class-wc-retailcrm-proxy.php +++ b/src/include/api/class-wc-retailcrm-proxy.php @@ -22,7 +22,7 @@ if ( ! class_exists( 'WC_Retailcrm_Proxy' ) ) : $this->corporateEnabled = $corporateEnabled; if ( ! class_exists( 'WC_Retailcrm_Client_V5' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-client-v5.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-client-v5.php')); } $this->retailcrm = new WC_Retailcrm_Client_V5($api_url, $api_key, 'v5'); diff --git a/src/include/api/class-wc-retailcrm-request.php b/src/include/api/class-wc-retailcrm-request.php index a70420c..44290a9 100644 --- a/src/include/api/class-wc-retailcrm-request.php +++ b/src/include/api/class-wc-retailcrm-request.php @@ -12,11 +12,11 @@ */ if ( ! class_exists( 'WC_Retailcrm_Exception_Curl' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-exception-curl.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-exception-curl.php')); } if ( ! class_exists( 'WC_Retailcrm_Response' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-response.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-response.php')); } class WC_Retailcrm_Request diff --git a/src/include/api/class-wc-retailcrm-response.php b/src/include/api/class-wc-retailcrm-response.php index b5f4bff..5073976 100644 --- a/src/include/api/class-wc-retailcrm-response.php +++ b/src/include/api/class-wc-retailcrm-response.php @@ -12,7 +12,7 @@ */ if ( ! class_exists( 'WC_Retailcrm_Exception_Json' ) ) { - include_once( __DIR__ . '/class-wc-retailcrm-exception-json.php' ); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-exception-json.php')); } diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index f11be28..fa1572e 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -9,7 +9,7 @@ if (!class_exists('WC_Retailcrm_Base')) { if (!class_exists('WC_Retailcrm_Abstracts_Settings')) { - include_once 'abstracts/class-wc-retailcrm-abstracts-settings.php'; + include_once(WC_Integration_Retailcrm::checkCustomFile('include/abstracts/class-wc-retailcrm-abstracts-settings.php')); } /** @@ -46,7 +46,7 @@ if (!class_exists('WC_Retailcrm_Base')) { parent::__construct(); if (!class_exists( 'WC_Retailcrm_Proxy')) { - include_once(__DIR__ . '/api/class-wc-retailcrm-proxy.php'); + include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-proxy.php')); } if ($retailcrm === false) { diff --git a/src/include/class-wc-retailcrm-plugin.php b/src/include/class-wc-retailcrm-plugin.php index cedf936..908fe54 100644 --- a/src/include/class-wc-retailcrm-plugin.php +++ b/src/include/class-wc-retailcrm-plugin.php @@ -60,11 +60,11 @@ class WC_Retailcrm_Plugin { } if (!class_exists('WC_Retailcrm_Icml')) { - require_once (dirname(__FILE__) . '/class-wc-retailcrm-icml.php'); + require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-icml.php')); } if (!class_exists('WC_Retailcrm_Base')) { - require_once (dirname(__FILE__) . '/class-wc-retailcrm-base.php'); + require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-base.php')); } $retailcrm_icml = new WC_Retailcrm_Icml(); diff --git a/src/include/components/class-wc-retailcrm-history-assembler.php b/src/include/components/class-wc-retailcrm-history-assembler.php index 0b5ace7..70993b7 100644 --- a/src/include/components/class-wc-retailcrm-history-assembler.php +++ b/src/include/components/class-wc-retailcrm-history-assembler.php @@ -271,10 +271,7 @@ class WC_Retailcrm_History_Assembler private static function getMappingValues($groupFilter = array()) { $fields = array(); - $mappingFile = realpath(implode( - DIRECTORY_SEPARATOR, - array(__DIR__, '..', '..', 'config', 'objects.xml') - )); + $mappingFile = realpath(WC_Integration_Retailcrm::checkCustomFile('config/objects.xml')); if (file_exists($mappingFile)) { $objects = simplexml_load_file($mappingFile); diff --git a/src/retailcrm.php b/src/retailcrm.php index 00ef262..25366bf 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -195,7 +195,7 @@ if (!class_exists( 'WC_Integration_Retailcrm')) : } if (!class_exists('WC_Retailcrm_Plugin')) { - require_once (dirname(__FILE__) . '/include/class-wc-retailcrm-plugin.php'); + require_once(WC_Integration_Retailcrm::checkCustomFile('include/class-wc-retailcrm-plugin.php')); } $plugin = WC_Retailcrm_Plugin::getInstance(__FILE__);