serving pages content
This commit is contained in:
parent
ba1159f3c3
commit
7ca346a869
|
|
@ -12,6 +12,11 @@ add_action('rest_api_init', function () {
|
||||||
'callback' => 'get_interface_play_screen_datas',
|
'callback' => 'get_interface_play_screen_datas',
|
||||||
'permission_callback' => '__return_true',
|
'permission_callback' => '__return_true',
|
||||||
));
|
));
|
||||||
|
register_rest_route('lhoist-datas/page', '/(?P<id>\d+)', array(
|
||||||
|
'methods' => 'GET',
|
||||||
|
'callback' => 'get_interface_page_screen',
|
||||||
|
'permission_callback' => '__return_true',
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
register_rest_route('lhoist-datas/statistics', '/post', array(
|
register_rest_route('lhoist-datas/statistics', '/post', array(
|
||||||
|
|
@ -28,7 +33,6 @@ add_action('rest_api_init', function () {
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function lhoist_datas_permission_callback(
|
function lhoist_datas_permission_callback(
|
||||||
WP_REST_Request $request
|
WP_REST_Request $request
|
||||||
) {
|
) {
|
||||||
|
|
@ -97,6 +101,25 @@ function get_interface_play_screen_datas($request)
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
function get_interface_page_screen($request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$id = $request->get_param('id');
|
||||||
|
$currentLanguage = strtolower($request->get_param('current-language')) ?? 'fr';
|
||||||
|
|
||||||
|
// SWITCH TO CURRENT REQUEST LANGUAGE
|
||||||
|
do_action('wpml_switch_language', $currentLanguage);
|
||||||
|
|
||||||
|
$pageTranslatedID = apply_filters('wpml_object_id', $id, 'post', true);
|
||||||
|
$pageContent = get_post($pageTranslatedID);
|
||||||
|
|
||||||
|
$responseDatas = $pageContent;
|
||||||
|
|
||||||
|
$response = new WP_REST_Response($responseDatas);
|
||||||
|
$response->set_status(200);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
// ################ POST GAME STATISTICS ################
|
// ################ POST GAME STATISTICS ################
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user