From 76f2e8ba00c3b40b39f7055b6ab126ac4755c373 Mon Sep 17 00:00:00 2001 From: asus Date: Thu, 14 Mar 2024 12:31:31 +0100 Subject: [PATCH 1/3] wip debug redirections --- plugins/cipf_plugin/fipfcard_plugin.php | 4 +- .../php/admin_menu/example_menu.php | 19 +++---- plugins/cipf_plugin/php/admin_modif_prof.php | 41 ++++++++++++- .../cipf_plugin/php/author_restriction.php | 11 ++++ .../form_builder_patch/form_calculation.php | 1 + .../form_builder_patch/multiple_modals.php | 1 + .../php/form_builder_patch/url_validation.php | 4 +- plugins/cipf_plugin/php/hide_admin.php | 8 +++ plugins/cipf_plugin/php/prof_check_page.php | 8 +++ plugins/cipf_plugin/php/redirections.php | 57 ++++++++++++++++++- plugins/cipf_plugin/php/renew_card.php | 30 +++++++++- plugins/cipf_plugin/utils/console_log.php | 1 + plugins/cipf_plugin/utils/plgntls_class.php | 7 ++- private | 2 +- 14 files changed, 165 insertions(+), 29 deletions(-) diff --git a/plugins/cipf_plugin/fipfcard_plugin.php b/plugins/cipf_plugin/fipfcard_plugin.php index 85e09bf..645fc58 100644 --- a/plugins/cipf_plugin/fipfcard_plugin.php +++ b/plugins/cipf_plugin/fipfcard_plugin.php @@ -37,7 +37,7 @@ include_once(PLGNTLS_class::root_path() . 'php/admin_menu/example_menu.php'); include_once(PLGNTLS_class::root_path() . 'php/paypal/paypal.php'); include_once(PLGNTLS_class::root_path() . '/php/user_infos.php'); -include_once(PLGNTLS_class::root_path() . '/php/hide_admin.php'); +//include_once(PLGNTLS_class::root_path() . '/php/hide_admin.php'); //include_once(PLGNTLS_class::root_path() . '/php/menus.php'); include_once(PLGNTLS_class::root_path() . 'php/register_partenaires.php'); include_once(PLGNTLS_class::root_path() . 'php/redirections.php'); @@ -55,8 +55,8 @@ include_once(PLGNTLS_class::root_path() . 'php/admin_modif_prof.php'); /* include_once(PLGNTLS_class::root_path() . 'php/form_builder_patch/url_validation.php'); include_once(PLGNTLS_class::root_path() . 'php/form_builder_patch/multiple_modals.php'); -*/ include_once(PLGNTLS_class::root_path() . 'php/form_builder_patch/form_calculation.php'); +*/ diff --git a/plugins/cipf_plugin/php/admin_menu/example_menu.php b/plugins/cipf_plugin/php/admin_menu/example_menu.php index 5238c84..36c1ab0 100644 --- a/plugins/cipf_plugin/php/admin_menu/example_menu.php +++ b/plugins/cipf_plugin/php/admin_menu/example_menu.php @@ -13,8 +13,8 @@ if (!defined('ABSPATH')) { /* * menu plugin */ -function cipfcard_plugin_menu() -{ +function cipfcard_plugin_menu() { + PLGNTLS_class::debug_infos(); add_menu_page ( 'cipf_card', // webpage title @@ -28,14 +28,9 @@ add_action('admin_menu', 'cipfcard_plugin_menu'); -/** - * it means someone outside wp is accessing the file, in this case kill it. - */ -if (!defined('ABSPATH')) { - die('You can not access this file!'); -} function cipfcard_plugin_content() { + PLGNTLS_class::debug_infos(); $cipfcard = new PLGNTLS_class(); $my_css = ' @@ -66,12 +61,12 @@ ajax - to access the content of the data object properties of the ajax call : use $_POST['property_name'] */ -function cipfcard_menu_fetch_handler() -{ +function cipfcard_menu_fetch_handler() { + PLGNTLS_class::debug_infos(); return new WP_REST_Response('hello', 200); } -function cipfcard_menu_endpoint() -{ +function cipfcard_menu_endpoint() { + PLGNTLS_class::debug_infos(); register_rest_route('plgntls', '/get_data', array( 'methods' => 'POST', 'callback' => 'cipfcard_menu_fetch_handler', diff --git a/plugins/cipf_plugin/php/admin_modif_prof.php b/plugins/cipf_plugin/php/admin_modif_prof.php index 8a72447..67c80bb 100644 --- a/plugins/cipf_plugin/php/admin_modif_prof.php +++ b/plugins/cipf_plugin/php/admin_modif_prof.php @@ -10,13 +10,28 @@ if (!defined('ABSPATH')) { + + /* * custom action in php on custom form submission * custom forms are not processed by divi form builder * so they don't change between hooks before and after process * */ -function admin_validate_prof_CIPF($form_id, $post_array, $form_type) { +function admin_validate_prof_CIPF() { + PLGNTLS_class::debug_infos(); + +} + + + + + +/* +* calling the action to validate from the FormBuilder hook +* +*/ +function custom_form_admin_validate_prof_CIPF($form_id, $post_array, $form_type) { PLGNTLS_class::debug_infos(); $admin_validate_prof_field = PLGNTLS_class::ADMIN_VALIDATE_PROF_FIELD; @@ -36,9 +51,29 @@ function admin_validate_prof_CIPF($form_id, $post_array, $form_type) { if ($contains_id === false) return; - /* custom action */ + admin_validate_prof_CIPF(); } -add_action('df_before_process', 'admin_validate_prof_CIPF', 10, 3); +add_action('df_before_process', 'custom_form_admin_validate_prof_CIPF', 10, 3); + + +/* +* calling the action to validate from the +* +function custom_link_intercept() { + PLGNTLS_class::debug_infos(); + $query_page_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL; + + // Check if the request contains ?QUERY_REDIRECTION_PROFIL + if(isset($_GET[$query_page_redirection])) { + admin_validate_prof_CIPF(); + } +} +add_action('init', 'custom_link_intercept'); +*/ + + + + /* diff --git a/plugins/cipf_plugin/php/author_restriction.php b/plugins/cipf_plugin/php/author_restriction.php index 73b87a3..e8de433 100644 --- a/plugins/cipf_plugin/php/author_restriction.php +++ b/plugins/cipf_plugin/php/author_restriction.php @@ -15,8 +15,17 @@ function restrict_author_page_CIPF() { $role_fipf = PLGNTLS_class::ROLE_FIPF; $role_admin = PLGNTLS_class::ROLE_ADMIN; + $slug = get_post_field( 'post_name', get_post() ); + error_log("slug"); + error_log($slug); +// error_log("request"); +// error_log(json_encode($_REQUEST)); +// error_log("server"); +// error_log(json_encode($_SERVER)); + if (!is_author()) return; +PLGNTLS_class::debug_infos(); $current_user = wp_get_current_user(); @@ -29,6 +38,7 @@ function restrict_author_page_CIPF() { $allowed_roles = array($role_admin, $role_fipf); if (array_intersect($allowed_roles, $current_user->roles)) return; +PLGNTLS_class::debug_infos(); /* * get_queried_object_id() would work too @@ -46,6 +56,7 @@ function restrict_author_page_CIPF() { wp_redirect(home_url(), 301); exit; } +PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'restrict_author_page_CIPF', 10); diff --git a/plugins/cipf_plugin/php/form_builder_patch/form_calculation.php b/plugins/cipf_plugin/php/form_builder_patch/form_calculation.php index 5add040..03b7970 100644 --- a/plugins/cipf_plugin/php/form_builder_patch/form_calculation.php +++ b/plugins/cipf_plugin/php/form_builder_patch/form_calculation.php @@ -12,6 +12,7 @@ if (!defined('ABSPATH')) { /* */ function add_form_calculation_patch_CIPF() { + PLGNTLS_class::debug_infos(); $handle = 'form_calculation_patch'; $url = PLGNTLS_class::root_url() . 'js/form_builder_patch/form_calculation.js'; $dependencies = array('de_fb_calc'); diff --git a/plugins/cipf_plugin/php/form_builder_patch/multiple_modals.php b/plugins/cipf_plugin/php/form_builder_patch/multiple_modals.php index 41df4e3..f13278e 100644 --- a/plugins/cipf_plugin/php/form_builder_patch/multiple_modals.php +++ b/plugins/cipf_plugin/php/form_builder_patch/multiple_modals.php @@ -10,6 +10,7 @@ if (!defined('ABSPATH')) { function test_modal_PLGNTLS() { + PLGNTLS_class::debug_infos(); $cipf_modal = new PLGNTLS_class(); $cipf_modal->add_to_front( array( diff --git a/plugins/cipf_plugin/php/form_builder_patch/url_validation.php b/plugins/cipf_plugin/php/form_builder_patch/url_validation.php index 48d6f33..cd7a98a 100644 --- a/plugins/cipf_plugin/php/form_builder_patch/url_validation.php +++ b/plugins/cipf_plugin/php/form_builder_patch/url_validation.php @@ -15,8 +15,8 @@ if (!defined('ABSPATH')) { * - Undefined variable: min_length in /var/www/html/wp-content/plugins/divi-form-builder/includes/modules/FormField/FormField.php on line 5933 * - Undefined variable: use_icon in /var/www/html/wp-content/plugins/divi-form-builder/includes/modules/FormField/FormField.php on line 5984 */ -function add_my_jquery_patch() -{ +function add_my_jquery_patch() { + PLGNTLS_class::debug_infos(); $handle = 'jquery_validator_url_patch'; $url = PLGNTLS_class::root_url() . 'js/form_builder_patch/url_validation.js'; $dependencies = array('de_fb_validate'); diff --git a/plugins/cipf_plugin/php/hide_admin.php b/plugins/cipf_plugin/php/hide_admin.php index b0731d1..13bd27f 100644 --- a/plugins/cipf_plugin/php/hide_admin.php +++ b/plugins/cipf_plugin/php/hide_admin.php @@ -18,6 +18,14 @@ function hide_admin_bar_CIPF() { PLGNTLS_class::debug_infos(); $role_admin = PLGNTLS_class::ROLE_ADMIN; + $slug = get_post_field( 'post_name', get_post() ); + error_log("slug"); + error_log($slug); +// error_log("request"); +// error_log(json_encode($_REQUEST)); +// error_log("server"); +// error_log(json_encode($_SERVER)); + if (!current_user_can($role_admin) && !is_admin()) { show_admin_bar(false); } diff --git a/plugins/cipf_plugin/php/prof_check_page.php b/plugins/cipf_plugin/php/prof_check_page.php index 86c1b14..1ebc2a4 100644 --- a/plugins/cipf_plugin/php/prof_check_page.php +++ b/plugins/cipf_plugin/php/prof_check_page.php @@ -114,16 +114,24 @@ function show_prof_paiement_messages_CIPF($user_id) { */ function check_prof_page_CIPF() { PLGNTLS_class::debug_infos(); + + $slug = get_post_field( 'post_name', get_post() ); + error_log("slug"); + error_log($slug); + // is an author page if (!is_author()) return; +PLGNTLS_class::debug_infos(); // the way to find the id of the author of an author_page $author_id = get_queried_object_id(); handle_prof_is_activ_CIPF($author_id); +PLGNTLS_class::debug_infos(); show_prof_paiement_messages_CIPF($author_id); +PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'check_prof_page_CIPF', 11); diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index cfa79a0..780c25e 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -77,18 +77,69 @@ function redirection_profil_page_CIPF(){ function redirection_page_CIPF(){ PLGNTLS_class::debug_infos(); $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; - $role_prof = PLGNTLS_class::ROLE_PROF; - $role_partner = PLGNTLS_class::ROLE_PARTNER; + + $slug = get_post_field( 'post_name', get_post() ); + error_log("slug"); + error_log($slug); +// error_log("request"); +// error_log(json_encode($_REQUEST)); +// error_log("server"); +// error_log(json_encode($_SERVER)); if (!is_page($slug_page_redirection)) return; +PLGNTLS_class::debug_infos(); redirection_profil_page_CIPF(); +PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'redirection_page_CIPF'); +/* + +[ ] -debug: function 'hide_admin_bar_CIPF' (in /home/www-data/cipf_plugin/php/hide_admin.php, line 18) + slug + +[ ] -debug: function 'redirection_page_CIPF' (in /home/www-data/cipf_plugin/php/redirections.php, line 78) + slug + home +[ ] -debug: function 'restrict_author_page_CIPF' (in /home/www-data/cipf_plugin/php/author_restriction.php, line 14) + slug + home +[ ] -debug: function 'renew_page_restrictions_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 26) + slug + home +[ ] -debug: function 'check_prof_page_CIPF' (in /home/www-data/cipf_plugin/php/prof_check_page.php, line 116) + slug + home +[ ] -debug: function 'renew_page_filter_message_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 109) + slug + home +[ ] -debug: function 'hide_admin_bar_CIPF' (in /home/www-data/cipf_plugin/php/hide_admin.php, line 18) + slug + +[ ] -debug: function 'redirection_page_CIPF' (in /home/www-data/cipf_plugin/php/redirections.php, line 78) + slug + calculations +[ ] -debug: function 'restrict_author_page_CIPF' (in /home/www-data/cipf_plugin/php/author_restriction.php, line 14) + slug + calculations +[ ] -debug: function 'renew_page_restrictions_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 26) + slug + calculations +[ ] -debug: function 'check_prof_page_CIPF' (in /home/www-data/cipf_plugin/php/prof_check_page.php, line 116) + slug + calculations +[ ] -debug: function 'renew_page_filter_message_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 109) + slug + calculations + + +*/ + + /* @@ -118,7 +169,6 @@ add_action('rest_api_init', 'endpoint_for_redirection_CIPF'); /* * * -*/ function custom_link_intercept() { PLGNTLS_class::debug_infos(); $query_page_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL; @@ -129,6 +179,7 @@ function custom_link_intercept() { } } add_action('init', 'custom_link_intercept'); +*/ diff --git a/plugins/cipf_plugin/php/renew_card.php b/plugins/cipf_plugin/php/renew_card.php index b592ed0..5334fb7 100644 --- a/plugins/cipf_plugin/php/renew_card.php +++ b/plugins/cipf_plugin/php/renew_card.php @@ -32,15 +32,32 @@ function renew_page_restrictions_CIPF(){ $base_url = home_url(); - if (!is_page($slug_renew_card)) - return; + wp_reset_query(); + $slug = get_post_field( 'post_name', get_post() ); + error_log("slug"); + error_log($slug); +// error_log("request"); +// error_log(json_encode($_REQUEST)); +// error_log("server"); +// error_log(json_encode($_SERVER)); + + + if (!is_page('commande')) + return; +PLGNTLS_class::debug_infos(); + + /* + * is it good ? + * -> dont' redirect if user not logged in, because new users need to acces this page + * if (!is_user_logged_in()) { // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes nocache_headers(); wp_redirect($base_url, 301); exit; } + */ $current_user_id = get_current_user_id(); $current_user = wp_get_current_user(); @@ -51,10 +68,10 @@ function renew_page_restrictions_CIPF(){ * check multiple user roles * https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083 * - */ $allowed_roles = array($role_admin, $role_fipf, $role_prof); if (!array_intersect($allowed_roles, $current_user->roles)) return; + */ /* * if prof, check card state @@ -93,8 +110,15 @@ function renew_page_filter_message_CIPF(){ $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD; $acf_card_state = PLGNTLS_class::ACF_CARD_STATE; + $slug = get_post_field( 'post_name', get_post() ); + error_log("slug"); + error_log($slug); + + /* if (!is_page($slug_renew_card)) return; + */ +PLGNTLS_class::debug_infos(); $user_id = get_current_user_id(); $acf_id = 'user_'.$user_id; diff --git a/plugins/cipf_plugin/utils/console_log.php b/plugins/cipf_plugin/utils/console_log.php index 8e6bb0b..9e11203 100644 --- a/plugins/cipf_plugin/utils/console_log.php +++ b/plugins/cipf_plugin/utils/console_log.php @@ -12,6 +12,7 @@ if (!defined('ABSPATH')) { https://stackify.com/how-to-log-to-console-in-php/ */ function console_log(...$outputs) { + PLGNTLS_class::debug_infos(); if (CIPF_CONSOLE_OFF) return; foreach($outputs as $output) diff --git a/plugins/cipf_plugin/utils/plgntls_class.php b/plugins/cipf_plugin/utils/plgntls_class.php index 66833d2..e83be2c 100644 --- a/plugins/cipf_plugin/utils/plgntls_class.php +++ b/plugins/cipf_plugin/utils/plgntls_class.php @@ -86,6 +86,7 @@ class PLGNTLS_class const SLUG_PAYPAL_REDIRECTION_FAILURE = '?'.self::QUERY_REDIRECTION_PROFIL; const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php const QUERY_REDIRECTION_PROFIL = 'redirection_cipf'; + const QUERY_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php // PAYPAL const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl"; @@ -104,11 +105,11 @@ class PLGNTLS_class const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days') const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php) - const ADMIN_VALIDATE_PROF_FIELD = 'cipf_admin_activate_prof'; // for admin_modif_prof.php + const ADMIN_VALIDATE_PROF_FIELD = 'admin_activate_prof_cipf'; // for admin_modif_prof.php - private static $_DEBUG_INFOS = false; + private static $_DEBUG_INFOS = true; private static $_plugin_dir_path; private static $_plugin_name; private static $_file_dir_path; @@ -196,7 +197,7 @@ class PLGNTLS_class $function = $trace[1]['function']; $file = $trace[0]['file']; $line = $trace[0]['line']; - error_log("-debug: function '".$function."' (in ".$file.", line ".$line); + error_log("-debug: function '".$function."' (in ".$file.", line ".$line .')'); } diff --git a/private b/private index de5ea3a..e9929b6 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit de5ea3a591024f68dbf54d635908e28c1ec8cb46 +Subproject commit e9929b6f8fdd2f1f8aeb8daea27507785e8c77d1 From e14acfb739df7f365205085bd4de6ab18c6274b4 Mon Sep 17 00:00:00 2001 From: asus Date: Thu, 14 Mar 2024 13:10:05 +0100 Subject: [PATCH 2/3] wip i broke everyhting :p --- .../cipf_plugin/php/author_restriction.php | 11 --- plugins/cipf_plugin/php/hide_admin.php | 8 -- plugins/cipf_plugin/php/prof_check_page.php | 7 -- plugins/cipf_plugin/php/redirections.php | 92 ++++--------------- plugins/cipf_plugin/php/renew_card.php | 17 ---- plugins/cipf_plugin/utils/plgntls_class.php | 2 +- private | 2 +- 7 files changed, 18 insertions(+), 121 deletions(-) diff --git a/plugins/cipf_plugin/php/author_restriction.php b/plugins/cipf_plugin/php/author_restriction.php index e8de433..73b87a3 100644 --- a/plugins/cipf_plugin/php/author_restriction.php +++ b/plugins/cipf_plugin/php/author_restriction.php @@ -15,17 +15,8 @@ function restrict_author_page_CIPF() { $role_fipf = PLGNTLS_class::ROLE_FIPF; $role_admin = PLGNTLS_class::ROLE_ADMIN; - $slug = get_post_field( 'post_name', get_post() ); - error_log("slug"); - error_log($slug); -// error_log("request"); -// error_log(json_encode($_REQUEST)); -// error_log("server"); -// error_log(json_encode($_SERVER)); - if (!is_author()) return; -PLGNTLS_class::debug_infos(); $current_user = wp_get_current_user(); @@ -38,7 +29,6 @@ PLGNTLS_class::debug_infos(); $allowed_roles = array($role_admin, $role_fipf); if (array_intersect($allowed_roles, $current_user->roles)) return; -PLGNTLS_class::debug_infos(); /* * get_queried_object_id() would work too @@ -56,7 +46,6 @@ PLGNTLS_class::debug_infos(); wp_redirect(home_url(), 301); exit; } -PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'restrict_author_page_CIPF', 10); diff --git a/plugins/cipf_plugin/php/hide_admin.php b/plugins/cipf_plugin/php/hide_admin.php index 13bd27f..b0731d1 100644 --- a/plugins/cipf_plugin/php/hide_admin.php +++ b/plugins/cipf_plugin/php/hide_admin.php @@ -18,14 +18,6 @@ function hide_admin_bar_CIPF() { PLGNTLS_class::debug_infos(); $role_admin = PLGNTLS_class::ROLE_ADMIN; - $slug = get_post_field( 'post_name', get_post() ); - error_log("slug"); - error_log($slug); -// error_log("request"); -// error_log(json_encode($_REQUEST)); -// error_log("server"); -// error_log(json_encode($_SERVER)); - if (!current_user_can($role_admin) && !is_admin()) { show_admin_bar(false); } diff --git a/plugins/cipf_plugin/php/prof_check_page.php b/plugins/cipf_plugin/php/prof_check_page.php index 1ebc2a4..2ff01b5 100644 --- a/plugins/cipf_plugin/php/prof_check_page.php +++ b/plugins/cipf_plugin/php/prof_check_page.php @@ -115,23 +115,16 @@ function show_prof_paiement_messages_CIPF($user_id) { function check_prof_page_CIPF() { PLGNTLS_class::debug_infos(); - $slug = get_post_field( 'post_name', get_post() ); - error_log("slug"); - error_log($slug); - // is an author page if (!is_author()) return; -PLGNTLS_class::debug_infos(); // the way to find the id of the author of an author_page $author_id = get_queried_object_id(); handle_prof_is_activ_CIPF($author_id); -PLGNTLS_class::debug_infos(); show_prof_paiement_messages_CIPF($author_id); -PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'check_prof_page_CIPF', 11); diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index 780c25e..92654cf 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -21,28 +21,21 @@ function redirection_profil_page_CIPF(){ $base_url = home_url(); $current_user_id = get_current_user_id(); + // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes nocache_headers(); - error_log("--- inside redirection profil page"); if (!is_user_logged_in()) { - foreach ($_COOKIE as $name => $value) { - error_log(json_encode("$name: $value")); - } - - error_log("is not logged in"); wp_redirect($base_url, 301); exit; } if (current_user_can($role_prof)) { - error_log("is prof"); $user_page = get_author_posts_url($current_user_id); wp_redirect($user_page, 301); exit; } else if (current_user_can($role_partner)) { - error_log("is partenaire"); $args = array( 'post_type' => 'post', 'author' => $current_user_id, @@ -60,7 +53,6 @@ function redirection_profil_page_CIPF(){ exit; } else { - error_log("is else"); wp_redirect($base_url, 301); exit; } @@ -76,72 +68,39 @@ function redirection_profil_page_CIPF(){ */ function redirection_page_CIPF(){ PLGNTLS_class::debug_infos(); + error_log("hello"); $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; - $slug = get_post_field( 'post_name', get_post() ); - error_log("slug"); - error_log($slug); -// error_log("request"); -// error_log(json_encode($_REQUEST)); -// error_log("server"); -// error_log(json_encode($_SERVER)); - if (!is_page($slug_page_redirection)) return; -PLGNTLS_class::debug_infos(); redirection_profil_page_CIPF(); -PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'redirection_page_CIPF'); + + /* +* redirects when someone reaches the page with query ?QUERY_REDIRECTION_PROFIL +* +function redirection_query_CIPF() { + PLGNTLS_class::debug_infos(); + $query_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL; -[ ] -debug: function 'hide_admin_bar_CIPF' (in /home/www-data/cipf_plugin/php/hide_admin.php, line 18) - slug - -[ ] -debug: function 'redirection_page_CIPF' (in /home/www-data/cipf_plugin/php/redirections.php, line 78) - slug - home -[ ] -debug: function 'restrict_author_page_CIPF' (in /home/www-data/cipf_plugin/php/author_restriction.php, line 14) - slug - home -[ ] -debug: function 'renew_page_restrictions_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 26) - slug - home -[ ] -debug: function 'check_prof_page_CIPF' (in /home/www-data/cipf_plugin/php/prof_check_page.php, line 116) - slug - home -[ ] -debug: function 'renew_page_filter_message_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 109) - slug - home -[ ] -debug: function 'hide_admin_bar_CIPF' (in /home/www-data/cipf_plugin/php/hide_admin.php, line 18) - slug - -[ ] -debug: function 'redirection_page_CIPF' (in /home/www-data/cipf_plugin/php/redirections.php, line 78) - slug - calculations -[ ] -debug: function 'restrict_author_page_CIPF' (in /home/www-data/cipf_plugin/php/author_restriction.php, line 14) - slug - calculations -[ ] -debug: function 'renew_page_restrictions_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 26) - slug - calculations -[ ] -debug: function 'check_prof_page_CIPF' (in /home/www-data/cipf_plugin/php/prof_check_page.php, line 116) - slug - calculations -[ ] -debug: function 'renew_page_filter_message_CIPF' (in /home/www-data/cipf_plugin/php/renew_card.php, line 109) - slug - calculations - - + // Check if the request contains ?QUERY_REDIRECTION_PROFIL + if(isset($_GET[$query_redirection])) { + redirection_profil_page_CIPF(); + } +} +add_action('init', 'redirection_query_CIPF'); */ + /* * DOES NOT WORK so far * because to use is_user_logged_in() in redirection_profil_page_CIPF @@ -166,23 +125,4 @@ add_action('rest_api_init', 'endpoint_for_redirection_CIPF'); -/* -* -* -function custom_link_intercept() { - PLGNTLS_class::debug_infos(); - $query_page_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL; - - // Check if the request contains ?QUERY_REDIRECTION_PROFIL - if(isset($_GET[$query_page_redirection])) { - redirection_profil_page_CIPF(); - } -} -add_action('init', 'custom_link_intercept'); -*/ - - - - - ?> diff --git a/plugins/cipf_plugin/php/renew_card.php b/plugins/cipf_plugin/php/renew_card.php index 5334fb7..679d20a 100644 --- a/plugins/cipf_plugin/php/renew_card.php +++ b/plugins/cipf_plugin/php/renew_card.php @@ -34,18 +34,8 @@ function renew_page_restrictions_CIPF(){ wp_reset_query(); - $slug = get_post_field( 'post_name', get_post() ); - error_log("slug"); - error_log($slug); -// error_log("request"); -// error_log(json_encode($_REQUEST)); -// error_log("server"); -// error_log(json_encode($_SERVER)); - - if (!is_page('commande')) return; -PLGNTLS_class::debug_infos(); /* * is it good ? @@ -110,15 +100,8 @@ function renew_page_filter_message_CIPF(){ $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD; $acf_card_state = PLGNTLS_class::ACF_CARD_STATE; - $slug = get_post_field( 'post_name', get_post() ); - error_log("slug"); - error_log($slug); - - /* if (!is_page($slug_renew_card)) return; - */ -PLGNTLS_class::debug_infos(); $user_id = get_current_user_id(); $acf_id = 'user_'.$user_id; diff --git a/plugins/cipf_plugin/utils/plgntls_class.php b/plugins/cipf_plugin/utils/plgntls_class.php index e83be2c..a2b23fe 100644 --- a/plugins/cipf_plugin/utils/plgntls_class.php +++ b/plugins/cipf_plugin/utils/plgntls_class.php @@ -86,7 +86,7 @@ class PLGNTLS_class const SLUG_PAYPAL_REDIRECTION_FAILURE = '?'.self::QUERY_REDIRECTION_PROFIL; const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php const QUERY_REDIRECTION_PROFIL = 'redirection_cipf'; - const QUERY_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php + const QUERY_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php // PAYPAL const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl"; diff --git a/private b/private index e9929b6..a86a33b 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit e9929b6f8fdd2f1f8aeb8daea27507785e8c77d1 +Subproject commit a86a33b46e4b7eb8b9b5efe665a75f043a27869d From d0bfe907157db43e3c4c66b07fc6d6b4d59dde35 Mon Sep 17 00:00:00 2001 From: asus Date: Thu, 14 Mar 2024 13:48:19 +0100 Subject: [PATCH 3/3] nop it wasn't my plugin's fault --- plugins/cipf_plugin/php/redirections.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index 92654cf..15f8cf5 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -68,7 +68,6 @@ function redirection_profil_page_CIPF(){ */ function redirection_page_CIPF(){ PLGNTLS_class::debug_infos(); - error_log("hello"); $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; if (!is_page($slug_page_redirection)) @@ -85,6 +84,7 @@ add_action('template_redirect', 'redirection_page_CIPF'); /* * redirects when someone reaches the page with query ?QUERY_REDIRECTION_PROFIL * +*/ function redirection_query_CIPF() { PLGNTLS_class::debug_infos(); $query_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL; @@ -95,7 +95,6 @@ function redirection_query_CIPF() { } } add_action('init', 'redirection_query_CIPF'); -*/