From 5891a3e4187f8b52a38361aaf0e646eb10a6d388 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Fri, 13 Sep 2024 14:27:34 +0200 Subject: [PATCH] tweaking api to handle stats from deployed pro frontEnd --- includes/api.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/includes/api.php b/includes/api.php index 32b4802..7a96031 100644 --- a/includes/api.php +++ b/includes/api.php @@ -49,10 +49,12 @@ function lhoist_datas_permission_callback( $origin = $request->get_header('origin'); $referer = $request->get_header('referer'); - $isLocalHost = $origin === 'http://localhost:3000' && $referer === 'http://localhost:3000/'; - $isVercelApp = $origin === 'https://lhoist-stay-safe.vercel.app' && $referer === 'https://lhoist-stay-safe.vercel.app/'; + // $isLocalHost = $origin === 'http://localhost:3000' && $referer === 'http://localhost:3000/'; + // $isVercelApp = $origin === 'https://lhoist-stay-safe.vercel.app' && $referer === 'https://lhoist-stay-safe.vercel.app/'; + $isFrontEndApp = $origin === 'https://stay-safe-lhoist.com' && $referer === 'https://stay-safe-lhoist.com/'; - if ($isVercelApp || $isLocalHost) { + + if ($isFrontEndApp) { return true; } return false; @@ -65,6 +67,12 @@ function get_latest_game_datas($request) { // $language = sanitize_text_field($request['language']); $currentLanguage = strtolower($request->get_param('current-language')) ?? 'fr'; + if ($currentLanguage === "my") { + $currentLanguage = "ms"; + } + if ($currentLanguage === "pt") { + $currentLanguage = "pt-pt"; + } // SWITCH TO CURRENT REQUEST LANGUAGE do_action('wpml_switch_language', $currentLanguage); @@ -115,6 +123,12 @@ function get_game_datas($request) { $id = $request->get_param('id'); $currentLanguage = strtolower($request->get_param('current-language')) ?? 'fr'; + if ($currentLanguage === "my") { + $currentLanguage = "ms"; + } + if ($currentLanguage === "pt") { + $currentLanguage = "pt-pt"; + } // SWITCH TO CURRENT REQUEST LANGUAGE do_action('wpml_switch_language', $currentLanguage); @@ -156,7 +170,12 @@ function get_all_games_datas($request) $currentLanguage = strtolower($request->get_param('current-language')) ?? 'fr'; - + if ($currentLanguage === "my") { + $currentLanguage = "ms"; + } + if ($currentLanguage === "pt") { + $currentLanguage = "pt-pt"; + } // SWITCH TO CURRENT REQUEST LANGUAGE do_action('wpml_switch_language', $currentLanguage); add_filter('acf/settings/current_language', 'acf_set_language'); @@ -171,7 +190,6 @@ function get_all_games_datas($request) if (!$searchAndFindsQuery->post) { do_action('wpml_switch_language', "fr"); $searchAndFindsQuery = new WP_Query($args); - write_log("passed"); } $gamesDatas = array();