tried a fix on redirection without real page, by using template-redirection hook instead of init

This commit is contained in:
asus
2024-03-15 09:18:39 +01:00
parent 9ebce56025
commit 6c7b269052

View File

@@ -65,56 +65,59 @@ function redirection_profil_CIPF(){
/* /*
* version 1:
* redirects when on the page with slug defined in SLUG_PAGE_REDIRECTION * redirects when on the page with slug defined in SLUG_PAGE_REDIRECTION
* *
*/ */
function redirection_page_CIPF(){ //function redirection_page_CIPF(){
PLGNTLS_class::debug_infos(); // PLGNTLS_class::debug_infos();
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; // $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
//
if (!is_page($slug_page_redirection)) // if (!is_page($slug_page_redirection))
return; // return;
//
redirection_profil_CIPF(); // redirection_profil_CIPF();
} //}
add_action('template_redirect', 'redirection_page_CIPF'); //add_action('template_redirect', 'redirection_page_CIPF');
/* /*
* version 2:
* redirects when a specific url is requested : SLUG_PAGE_REDIRECTION * redirects when a specific url is requested : SLUG_PAGE_REDIRECTION
* works even if it does not exists * works even if the page actually does not exists
* *
*/ */
//function redirection_query_CIPF() { function redirection_query_CIPF() {
// PLGNTLS_class::debug_infos(); PLGNTLS_class::debug_infos();
// $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
//
//
// if (!isset($_GET['q'])) if (!isset($_GET['q']))
// return; return;
//
// /* /*
// * check the request /path/ * check the request /path/
// * for url : https://url.com/path/to/file/?query=value * for url : https://url.com/path/to/file/?query=value
// * -> $_GET: {"q":"/path/to/file/","query":"value"} * -> $_GET: {"q":"/path/to/file/","query":"value"}
// * *
// */ */
// $get_path = trim($_GET['q'], '/'); $get_path = trim($_GET['q'], '/');
// if ($get_path !== $slug_page_redirection) if ($get_path !== $slug_page_redirection)
// return; return;
//
// /* /*
// * check the request ?query * check the request ?query
// * *
// if(!isset($_GET['query'])) if(!isset($_GET['query']))
// return; return;
// */ */
//
// redirection_profil_CIPF(); redirection_profil_CIPF();
//} }
add_action('template_redirect', 'redirection_query_CIPF');
//add_action('init', 'redirection_query_CIPF'); //add_action('init', 'redirection_query_CIPF');