tried a fix on redirection without real page, by using template-redirection hook instead of init
This commit is contained in:
@@ -65,56 +65,59 @@ function redirection_profil_CIPF(){
|
||||
|
||||
|
||||
/*
|
||||
* version 1:
|
||||
* redirects when on the page with slug defined in SLUG_PAGE_REDIRECTION
|
||||
*
|
||||
*/
|
||||
function redirection_page_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
if (!is_page($slug_page_redirection))
|
||||
return;
|
||||
|
||||
redirection_profil_CIPF();
|
||||
}
|
||||
add_action('template_redirect', 'redirection_page_CIPF');
|
||||
//function redirection_page_CIPF(){
|
||||
// PLGNTLS_class::debug_infos();
|
||||
// $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
//
|
||||
// if (!is_page($slug_page_redirection))
|
||||
// return;
|
||||
//
|
||||
// redirection_profil_CIPF();
|
||||
//}
|
||||
//add_action('template_redirect', 'redirection_page_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* version 2:
|
||||
* 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() {
|
||||
// PLGNTLS_class::debug_infos();
|
||||
// $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
//
|
||||
//
|
||||
// if (!isset($_GET['q']))
|
||||
// return;
|
||||
//
|
||||
// /*
|
||||
// * check the request /path/
|
||||
// * for url : https://url.com/path/to/file/?query=value
|
||||
// * -> $_GET: {"q":"/path/to/file/","query":"value"}
|
||||
// *
|
||||
// */
|
||||
// $get_path = trim($_GET['q'], '/');
|
||||
// if ($get_path !== $slug_page_redirection)
|
||||
// return;
|
||||
//
|
||||
// /*
|
||||
// * check the request ?query
|
||||
// *
|
||||
// if(!isset($_GET['query']))
|
||||
// return;
|
||||
// */
|
||||
//
|
||||
// redirection_profil_CIPF();
|
||||
//}
|
||||
function redirection_query_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
|
||||
if (!isset($_GET['q']))
|
||||
return;
|
||||
|
||||
/*
|
||||
* check the request /path/
|
||||
* for url : https://url.com/path/to/file/?query=value
|
||||
* -> $_GET: {"q":"/path/to/file/","query":"value"}
|
||||
*
|
||||
*/
|
||||
$get_path = trim($_GET['q'], '/');
|
||||
if ($get_path !== $slug_page_redirection)
|
||||
return;
|
||||
|
||||
/*
|
||||
* check the request ?query
|
||||
*
|
||||
if(!isset($_GET['query']))
|
||||
return;
|
||||
*/
|
||||
|
||||
redirection_profil_CIPF();
|
||||
}
|
||||
add_action('template_redirect', 'redirection_query_CIPF');
|
||||
//add_action('init', 'redirection_query_CIPF');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user