diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/admin/class-zoho-admin.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/admin/class-zoho-admin.php index 6e3bfc7e..c898bc40 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/admin/class-zoho-admin.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/admin/class-zoho-admin.php @@ -48,9 +48,9 @@ class HVAC_Zoho_Admin { wp_enqueue_script( 'hvac-zoho-admin', - HVAC_PLUGIN_URL . 'assets/js/zoho-admin.js', + HVAC_CE_PLUGIN_URL . 'assets/js/zoho-admin.js', array('jquery'), - HVAC_VERSION, + HVAC_CE_VERSION, true ); @@ -61,9 +61,9 @@ class HVAC_Zoho_Admin { wp_enqueue_style( 'hvac-zoho-admin', - HVAC_PLUGIN_URL . 'assets/css/zoho-admin.css', + HVAC_CE_PLUGIN_URL . 'assets/css/zoho-admin.css', array(), - HVAC_VERSION + HVAC_CE_VERSION ); } @@ -71,7 +71,7 @@ class HVAC_Zoho_Admin { * Render admin page */ public function render_admin_page() { - $config_file = HVAC_PLUGIN_DIR . 'includes/zoho/zoho-config.php'; + $config_file = HVAC_CE_PLUGIN_DIR . 'includes/zoho/zoho-config.php'; $is_configured = file_exists($config_file); $site_url = get_site_url(); $is_staging = strpos($site_url, 'upskillhvac.com') === false; @@ -161,11 +161,11 @@ class HVAC_Zoho_Admin { } try { - require_once HVAC_PLUGIN_DIR . 'includes/zoho/class-zoho-crm-auth.php'; + require_once HVAC_CE_PLUGIN_DIR . 'includes/zoho/class-zoho-crm-auth.php'; $auth = new HVAC_Zoho_CRM_Auth(); // Test API call - $response = $auth->make_api_request('GET', '/crm/v2/settings/modules'); + $response = $auth->make_api_request('/settings/modules', 'GET'); if ($response && !isset($response['error'])) { wp_send_json_success(array( @@ -199,7 +199,7 @@ class HVAC_Zoho_Admin { $type = sanitize_text_field($_POST['type']); try { - require_once HVAC_PLUGIN_DIR . 'includes/zoho/class-zoho-sync.php'; + require_once HVAC_CE_PLUGIN_DIR . 'includes/zoho/class-zoho-sync.php'; $sync = new HVAC_Zoho_Sync(); switch ($type) { @@ -225,7 +225,4 @@ class HVAC_Zoho_Admin { } } } - -// Initialize the admin interface -new HVAC_Zoho_Admin(); ?> \ No newline at end of file diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-crm-auth.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-crm-auth.php index b8ba9e83..3ca6c86a 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-crm-auth.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-crm-auth.php @@ -27,10 +27,10 @@ class HVAC_Zoho_CRM_Auth { if (file_exists($config_file)) { require_once $config_file; - $this->client_id = ZOHO_CLIENT_ID; - $this->client_secret = ZOHO_CLIENT_SECRET; - $this->refresh_token = ZOHO_REFRESH_TOKEN; - $this->redirect_uri = ZOHO_REDIRECT_URI; + $this->client_id = defined('ZOHO_CLIENT_ID') ? ZOHO_CLIENT_ID : ''; + $this->client_secret = defined('ZOHO_CLIENT_SECRET') ? ZOHO_CLIENT_SECRET : ''; + $this->refresh_token = defined('ZOHO_REFRESH_TOKEN') ? ZOHO_REFRESH_TOKEN : ''; + $this->redirect_uri = defined('ZOHO_REDIRECT_URI') ? ZOHO_REDIRECT_URI : 'http://localhost:8080/callback'; } // Load stored access token from WordPress options @@ -42,7 +42,7 @@ class HVAC_Zoho_CRM_Auth { */ public function get_authorization_url() { $params = array( - 'scope' => ZOHO_SCOPES, + 'scope' => defined('ZOHO_SCOPES') ? ZOHO_SCOPES : 'ZohoCRM.settings.all,ZohoCRM.modules.all,ZohoCRM.users.all,ZohoCRM.org.all', 'client_id' => $this->client_id, 'response_type' => 'code', 'access_type' => 'offline', @@ -50,14 +50,16 @@ class HVAC_Zoho_CRM_Auth { 'prompt' => 'consent' ); - return ZOHO_ACCOUNTS_URL . '/oauth/v2/auth?' . http_build_query($params); + $accounts_url = defined('ZOHO_ACCOUNTS_URL') ? ZOHO_ACCOUNTS_URL : 'https://accounts.zoho.com'; + return $accounts_url . '/oauth/v2/auth?' . http_build_query($params); } /** * Exchange authorization code for tokens */ public function exchange_code_for_tokens($auth_code) { - $url = ZOHO_ACCOUNTS_URL . '/oauth/v2/token'; + $accounts_url = defined('ZOHO_ACCOUNTS_URL') ? ZOHO_ACCOUNTS_URL : 'https://accounts.zoho.com'; + $url = $accounts_url . '/oauth/v2/token'; $params = array( 'grant_type' => 'authorization_code', @@ -113,7 +115,8 @@ class HVAC_Zoho_CRM_Auth { * Refresh access token using refresh token */ private function refresh_access_token() { - $url = ZOHO_ACCOUNTS_URL . '/oauth/v2/token'; + $accounts_url = defined('ZOHO_ACCOUNTS_URL') ? ZOHO_ACCOUNTS_URL : 'https://accounts.zoho.com'; + $url = $accounts_url . '/oauth/v2/token'; $params = array( 'refresh_token' => $this->refresh_token, @@ -181,7 +184,8 @@ class HVAC_Zoho_CRM_Auth { return new WP_Error('no_token', 'No valid access token available'); } - $url = ZOHO_API_BASE_URL . $endpoint; + $api_base_url = defined('ZOHO_API_BASE_URL') ? ZOHO_API_BASE_URL : 'https://www.zohoapis.com/crm/v2'; + $url = $api_base_url . $endpoint; $args = array( 'method' => $method, diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-sync.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-sync.php index 8523d543..7a4a4bb0 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-sync.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/zoho/class-zoho-sync.php @@ -32,7 +32,7 @@ class HVAC_Zoho_Sync { * Constructor */ public function __construct() { - require_once HVAC_PLUGIN_DIR . 'includes/zoho/class-zoho-crm-auth.php'; + require_once HVAC_CE_PLUGIN_DIR . 'includes/zoho/class-zoho-crm-auth.php'; $this->auth = new HVAC_Zoho_CRM_Auth(); // Determine if we're in staging mode