tweaking api to handle stats from deployed pro frontEnd
This commit is contained in:
parent
03697e497c
commit
5891a3e418
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user