| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | const currentUrl = window.location.href; |
| 15 | 15 | const usesPrettyPermalinks = this.detectPrettyPermalinks(currentUrl); |
| 16 | 16 | |
| 17 | 17 | if (window.yatraConfig?.debug) { |
| 18 | - console.log('Yatra API Helper - Using permalinks:', usesPrettyPermalinks ? 'Pretty' : 'Plain'); | |
| 18 | + window.YATRA_DEBUG && console.log('Yatra API Helper - Using permalinks:', usesPrettyPermalinks ? 'Pretty' : 'Plain'); | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | if (usesPrettyPermalinks) { |
| 22 | 22 | return `/wp-json/yatra/v1${endpoint}`; |
| @@ -35,9 +35,9 @@ | ||
| 35 | 35 | const yatraData = window.yatraTripData || window.yatraBookingData || {}; |
| 36 | 36 | if (yatraData.permalinkStructure !== undefined) { |
| 37 | 37 | const isPlain = yatraData.permalinkStructure === 'plain'; |
| 38 | 38 | if (window.yatraConfig?.debug) { |
| 39 | - console.log('Yatra API Helper - WordPress permalink structure:', yatraData.permalinkStructure, 'isPlain:', isPlain); | |
| 39 | + window.YATRA_DEBUG && console.log('Yatra API Helper - WordPress permalink structure:', yatraData.permalinkStructure, 'isPlain:', isPlain); | |
| 40 | 40 | } |
| 41 | 41 | return !isPlain; // Return true if NOT plain (i.e., pretty) |
| 42 | 42 | } |
| 43 | 43 | |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | if (wpApiSettings.root) { |
| 47 | 47 | // If root ends with /wp-json/, pretty permalinks are working |
| 48 | 48 | const usesPretty = wpApiSettings.root.includes('/wp-json/'); |
| 49 | 49 | if (window.yatraConfig?.debug) { |
| 50 | - console.log('Yatra API Helper - WP API settings root:', wpApiSettings.root, 'usesPretty:', usesPretty); | |
| 50 | + window.YATRA_DEBUG && console.log('Yatra API Helper - WP API settings root:', wpApiSettings.root, 'usesPretty:', usesPretty); | |
| 51 | 51 | } |
| 52 | 52 | return usesPretty; |
| 53 | 53 | } |
| 54 | 54 | |
| @@ -59,14 +59,14 @@ | ||
| 59 | 59 | url.includes('/tag/') || // Tag URLs |
| 60 | 60 | (url.includes('/') && !url.includes('?') && !url.includes('=')); |
| 61 | 61 | |
| 62 | 62 | if (window.yatraConfig?.debug) { |
| 63 | - console.log('Yatra API Helper - URL structure analysis:', hasPrettyStructure); | |
| 63 | + window.YATRA_DEBUG && console.log('Yatra API Helper - URL structure analysis:', hasPrettyStructure); | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Method 4: Default to plain since we know pretty permalinks aren't working |
| 67 | 67 | if (window.yatraConfig?.debug) { |
| 68 | - console.log('Yatra API Helper - Defaulting to plain permalinks (fallback)'); | |
| 68 | + window.YATRA_DEBUG && console.log('Yatra API Helper - Defaulting to plain permalinks (fallback)'); | |
| 69 | 69 | } |
| 70 | 70 | return false; |
| 71 | 71 | }, |
| 72 | 72 | |
| @@ -87,9 +87,9 @@ | ||
| 87 | 87 | // Return the first available nonce |
| 88 | 88 | for (const nonce of sources) { |
| 89 | 89 | if (nonce && nonce !== '') { |
| 90 | 90 | if (window.yatraConfig?.debug) { |
| 91 | - console.log('Yatra API Helper - Using nonce from source:', sources.indexOf(nonce)); | |
| 91 | + window.YATRA_DEBUG && console.log('Yatra API Helper - Using nonce from source:', sources.indexOf(nonce)); | |
| 92 | 92 | } |
| 93 | 93 | return nonce; |
| 94 | 94 | } |
| 95 | 95 | } |
| @@ -144,9 +144,9 @@ | ||
| 144 | 144 | const hasUserData = window.yatraTripData?.userId || window.yatraBookingData?.userId; |
| 145 | 145 | |
| 146 | 146 | const shouldUse = isLoggedIn || hasUserData; |
| 147 | 147 | if (window.yatraConfig?.debug) { |
| 148 | - console.log('Yatra API Helper - User logged in:', shouldUse); | |
| 148 | + window.YATRA_DEBUG && console.log('Yatra API Helper - User logged in:', shouldUse); | |
| 149 | 149 | } |
| 150 | 150 | return shouldUse; |
| 151 | 151 | }, |
| 152 | 152 | |
| @@ -178,9 +178,9 @@ | ||
| 178 | 178 | document.addEventListener('DOMContentLoaded', function() { |
| 179 | 179 | // API Helper is ready for use |
| 180 | 180 | // Debug logging can be enabled by setting window.yatraConfig.debug = true |
| 181 | 181 | if (window.yatraConfig?.debug) { |
| 182 | - console.log('Yatra API Helper - Initialized'); | |
| 182 | + window.YATRA_DEBUG && console.log('Yatra API Helper - Initialized'); | |
| 183 | 183 | const detectedStructure = window.YatraApiHelper.detectPrettyPermalinks(window.location.href); |
| 184 | - console.log('Yatra API Helper - Permalink structure:', detectedStructure ? 'Pretty' : 'Plain'); | |
| 184 | + window.YATRA_DEBUG && console.log('Yatra API Helper - Permalink structure:', detectedStructure ? 'Pretty' : 'Plain'); | |
| 185 | 185 | } |
| 186 | 186 | }); |