wip trying to modify html before it is rendered
This commit is contained in:
@@ -56,40 +56,6 @@ function custom_frontend_posting_form() {
|
||||
}
|
||||
add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form');
|
||||
|
||||
// function author_shortode_test($field) {
|
||||
// // global $authordata;
|
||||
// // $user_id = $authordata->ID;
|
||||
//
|
||||
// $author_username = get_query_var('author_name');
|
||||
// $author = get_user_by('slug', $author_username);
|
||||
// $user_id = $author->ID;
|
||||
//
|
||||
// $acf_field = $field['field'];
|
||||
// $acf_post_id = "user_{$user_id}";
|
||||
//
|
||||
// $acf_shortcode = "[acf field='" . $acf_field . "' post_id='" . $acf_post_id . "']";
|
||||
//
|
||||
// error_log("---");
|
||||
// error_log("acf_shortcode:");
|
||||
// error_log($acf_shortcode);
|
||||
// // error_log("get_userdata:");
|
||||
// // error_log(json_encode(get_userdata($user_id)->data->user_email));
|
||||
// error_log("get_fields($acf_post_id):");
|
||||
// error_log(json_encode(get_fields($acf_post_id)));
|
||||
// error_log("get_field($acf_field, $acf_post_id):");
|
||||
// error_log(json_encode(get_field($acf_field, $acf_post_id)));
|
||||
//
|
||||
// //$shortcode = "[acf field=" . $field['field'] . "]";
|
||||
// wp_reset_query();
|
||||
// $acf_return = do_shortcode($acf_shortcode);
|
||||
// // error_log("acf_return:");
|
||||
// // error_log(json_encode($acf_return));
|
||||
// return $acf_return;
|
||||
// // regarder option repeter de diviengine
|
||||
// // peutetre plugin gratuit ?
|
||||
// // plugin menu avec conditions
|
||||
// }
|
||||
// add_shortcode('fipf_acf', 'author_shortode_test', 10, 1);
|
||||
|
||||
|
||||
|
||||
@@ -102,158 +68,18 @@ add_shortcode('fipf_paypal_shortcode', 'fipf_paypal_shortcode_content');
|
||||
|
||||
|
||||
|
||||
//function my_custom_url_handler($query)
|
||||
//{
|
||||
// if ($_SERVER['REQUEST_METHOD'] !== 'POST' )
|
||||
// return ;
|
||||
// if ($_SERVER['QUERY_STRING'] !== 'update_profile_acf' )
|
||||
// return ;
|
||||
// // ! add verification that user can do this edit !
|
||||
//
|
||||
// foreach($_POST['field_name'] as $field)
|
||||
// {
|
||||
// error_log("_POST[$field]");
|
||||
// error_log($_POST[$field]);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
add_action('init', 'custom_action_handler');
|
||||
function custom_action_handler() {
|
||||
error_log("inside init :)");
|
||||
if ( isset( $_GET['custom_action'] ) && $_GET['custom_action'] === 'do_something' ) {
|
||||
error_log("GET :)");
|
||||
}
|
||||
if ( isset( $_POST['custom_action'] ) && $_POST['custom_action'] === 'do_something' ) {
|
||||
error_log("POST :)");
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
error_log("REQUEST_METHOD === GET");
|
||||
error_log("_GET");
|
||||
error_log(json_encode($_GET));
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['submit'])) {
|
||||
error_log("REQUEST_METHOD === GET && GET[SUBMIT]");
|
||||
}
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['QUERY_STRING'] === 'custom_action=do_something' ) {
|
||||
error_log("_POST['de_fb_ville']");
|
||||
error_log(json_encode($_POST['de_fb_ville']));
|
||||
}
|
||||
*/
|
||||
// custom-form-handler.php
|
||||
/*
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit'])) {
|
||||
error_log("REQUEST_METHOD === POST && POST[SUBMIT]");
|
||||
error_log("_POST");
|
||||
error_log(json_encode($_POST));
|
||||
// Form submitted, handle the submission
|
||||
$name = sanitize_text_field($_POST['name']);
|
||||
$email = sanitize_email($_POST['email']);
|
||||
|
||||
// Perform validation
|
||||
$errors = array();
|
||||
|
||||
if (empty($name)) {
|
||||
$errors['name'] = 'Name is required';
|
||||
}
|
||||
|
||||
if (!is_email($email)) {
|
||||
$errors['email'] = 'Invalid email address';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
// Form data is valid, process the submission
|
||||
// For example, save data to the database or send an email
|
||||
// Redirect the user or display a success message
|
||||
} else {
|
||||
// Form data is not valid, display errors
|
||||
// You might re-render the form with error messages here
|
||||
}
|
||||
}
|
||||
function PLGNTLS_conditional_print_offers() {
|
||||
error_log("---");
|
||||
error_log("inside PLGNTLS_print_offers_conditionnal");
|
||||
}
|
||||
add_action('et_after_main_content', 'PLGNTLS_conditional_print_offers');
|
||||
*/
|
||||
//add_action('et_head_meta', 'PLGNTLS_conditional_print_offers');
|
||||
//add_action('et_before_main_content', 'PLGNTLS_conditional_print_offers');
|
||||
|
||||
|
||||
/*
|
||||
[17-Feb-2024 17:54:21 UTC]
|
||||
{
|
||||
"SERVER_SOFTWARE":"nginx\/1.20.2",
|
||||
"REQUEST_URI":"\/?custom_action=do_something",
|
||||
"USER":"www-data",
|
||||
"HOME":"\/home\/www-data",
|
||||
"HTTP_SEC_GPC":"1",
|
||||
"HTTP_SEC_FETCH_USER":"?1",
|
||||
"HTTP_SEC_FETCH_SITE":"same-origin",
|
||||
"HTTP_SEC_FETCH_MODE":"navigate",
|
||||
"HTTP_SEC_FETCH_DEST":"document",
|
||||
"HTTP_UPGRADE_INSECURE_REQUESTS":"1",
|
||||
"HTTP_COOKIE":"wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_f31a945e73c53ab9af191e34eb33fa88=hugo%7C1708332197%7CbJvy7kRZ3UWJ2C0ZOaSuhpLCz11vHL8CA68sQv9U1ne%7C927c46e3b46a2716df0fcce98d7ccda0e158be0aad0593b2dc233de4ccad9e27; wp-settings-time-11=1708187741; mjx.menu=renderer%3ANativeMML%26%3Bsemantics%3Atrue%26%3Bcontext%3ABrowser%26%3Bzoom%3ANone",
|
||||
"HTTP_REFERER":"https:\/\/local_fipfcard_plugin.com\/modif_profile\/",
|
||||
"HTTP_CONNECTION":"keep-alive",
|
||||
"HTTP_DNT":"1",
|
||||
"HTTP_ORIGIN":"https:\/\/local_fipfcard_plugin.com",
|
||||
"HTTP_CONTENT_LENGTH":"2310",
|
||||
"HTTP_CONTENT_TYPE":"multipart\/form-data; boundary=---------------------------92033335430820533424009149678",
|
||||
"HTTP_ACCEPT_ENCODING":"gzip, deflate, br",
|
||||
"HTTP_ACCEPT_LANGUAGE":"en-US,en;q=0.5",
|
||||
"HTTP_ACCEPT":"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/avif,image\/webp,*\/*;q=0.8",
|
||||
"HTTP_USER_AGENT":"Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko\/20100101 Firefox\/122.0",
|
||||
"HTTP_HOST":"local_fipfcard_plugin.com",
|
||||
"REDIRECT_STATUS":"200",
|
||||
"SERVER_NAME":"local_fipfcard_plugin.com",
|
||||
"SERVER_PORT":"443",
|
||||
"SERVER_ADDR":"172.18.0.4",
|
||||
"REMOTE_PORT":"47220",
|
||||
"REMOTE_ADDR":"172.18.0.1",
|
||||
"GATEWAY_INTERFACE":"CGI\/1.1",
|
||||
"HTTPS":"on",
|
||||
"REQUEST_SCHEME":"https",
|
||||
"SERVER_PROTOCOL":"HTTP\/1.1",
|
||||
"DOCUMENT_ROOT":"\/var\/www\/html",
|
||||
"DOCUMENT_URI":"\/index.php",
|
||||
"SCRIPT_NAME":"\/index.php",
|
||||
"CONTENT_LENGTH":"2310",
|
||||
"CONTENT_TYPE":"multipart\/form-data; boundary=---------------------------92033335430820533424009149678",
|
||||
"REQUEST_METHOD":"POST",
|
||||
"QUERY_STRING":"custom_action=do_something",
|
||||
"SCRIPT_FILENAME":"\/var\/www\/html\/index.php",
|
||||
"FCGI_ROLE":"RESPONDER",
|
||||
"PHP_SELF":"\/index.php",
|
||||
"REQUEST_TIME_FLOAT":1708192460.934234,
|
||||
"REQUEST_TIME":1708192460
|
||||
}
|
||||
$_POST
|
||||
{
|
||||
"field_title":["ville_title","nom","pedagogie"],
|
||||
"field_name":["de_fb_ville","de_fb_nom","de_fb_pedagogie"],
|
||||
"field_id":["de_fb_ville_id","de_fb_nom","de_fb_pedagogie"],
|
||||
"de_fb_ville":"gut",
|
||||
"de_fb_nom":"gut",
|
||||
"de_fb_pedagogie":"gut",
|
||||
"form_key":"33420-0",
|
||||
"unique_id":"d2564b14-290e-4865-b740-7932ae770d43",
|
||||
"form_type":"custom",
|
||||
"divi-form-submit":"yes",
|
||||
"form_id":"modif_profile",
|
||||
"form_type_confirm":""
|
||||
}
|
||||
*/
|
||||
// add_action('parse_request', 'my_custom_url_handler');
|
||||
// function my_custom_url_handler($query)
|
||||
// {
|
||||
// if ($_SERVER['REQUEST_METHOD'] !== 'POST' )
|
||||
// return ;
|
||||
// if ($_SERVER['QUERY_STRING'] !== 'update_profile_acf' )
|
||||
// return ;
|
||||
// // ! add verification that user can do this edit !
|
||||
//
|
||||
// foreach($_POST['field_name'] as $field)
|
||||
// {
|
||||
// error_log("_POST[$field]");
|
||||
// error_log($_POST[$field]);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
@@ -271,64 +97,187 @@ $_POST
|
||||
* - https://developer.wordpress.org/reference/functions/is_user_logged_in/
|
||||
* - https://stackoverflow.com/questions/19802492/check-if-current-user-is-administrator-in-wordpress
|
||||
* - https://developer.wordpress.org/reference/functions/current_user_can/
|
||||
function PLGNTLS_df_before_process_handler($form_id, $post_array, $form_type)
|
||||
{
|
||||
error_log("---");
|
||||
error_log("in PLGNTLS_df_before_process_handler");
|
||||
error_log("form_id");
|
||||
error_log($form_id);
|
||||
error_log("post_array");
|
||||
error_log(json_encode($post_array));
|
||||
error_log("form_type");
|
||||
error_log($form_type);
|
||||
}
|
||||
add_action( 'df_before_process', 'PLGNTLS_df_before_process_handler', 10, 3 );
|
||||
function PLGNTLS_df_after_insert_post_handler($form_id, $post_id, $post_array)
|
||||
{
|
||||
error_log("---");
|
||||
error_log("in PLGNTLS_df_after_insert_post_handler");
|
||||
error_log("form_id");
|
||||
error_log($form_id);
|
||||
error_log("post_id");
|
||||
error_log($post_id);
|
||||
error_log("post_array");
|
||||
error_log(json_encode($post_array));
|
||||
}
|
||||
add_action( 'df_after_insert_post', 'PLGNTLS_df_after_insert_post_handler', 10, 3 );
|
||||
*/
|
||||
// function PLGNTLS_my_custom_df_form_handler($form_id, $post_array, $form_type)
|
||||
// {
|
||||
// error_log("in my_custom_df_form_handler");
|
||||
// error_log("form_id");
|
||||
// error_log($form_id);
|
||||
// error_log("post_array");
|
||||
// error_log(json_encode($post_array));
|
||||
// error_log("form_type");
|
||||
// error_log($form_type);
|
||||
// }
|
||||
// add_action ('df_before_process', 'PLGNTLS_my_custom_df_form_handler', 10, 3);
|
||||
/*
|
||||
in my_custom_df_form_handler
|
||||
|
||||
form_id
|
||||
crea_partenaire
|
||||
|
||||
post_array
|
||||
{
|
||||
"post_status":"publish",
|
||||
"field_title":
|
||||
[
|
||||
"Nom commercial",
|
||||
"Votre site Internet",
|
||||
"Dans quelle rubrique devez-vous para\u00eetre ? ",
|
||||
"L\\'accroche en t\u00eate de page",
|
||||
"Pr\u00e9sentez-vous",
|
||||
"Votre logo ",
|
||||
"Image principale",
|
||||
"Titre",
|
||||
"Texte de l\\'offre",
|
||||
"Image (facultatif)",
|
||||
"Voulez-vous ajouter une offre ?",
|
||||
"Voulez-vous afficher cette offre ?",
|
||||
"Titre",
|
||||
"Texte de l\\'offre",
|
||||
"Image (facultatif)",
|
||||
"Voulez-vous ajouter une offre ?",
|
||||
"Voulez-vous afficher l\\'offre ?",
|
||||
"Titre",
|
||||
"Texte de l\\'offre",
|
||||
"Image (facultatif)"
|
||||
],
|
||||
"post_title":"test",
|
||||
"meta_input":
|
||||
[
|
||||
"de_fb_url_partenaire",
|
||||
"de_fb_logo_partenaire",
|
||||
"de_fb_offre_1_titre",
|
||||
"de_fb_offre_1_txt",
|
||||
"de_fb_offre_1_image",
|
||||
"de_fb_ajouter_offre_2",
|
||||
"de_fb_afficher_offre_2",
|
||||
"de_fb_offre_2_titre",
|
||||
"de_fb_offre_2_txt",
|
||||
"de_fb_offre_2_image",
|
||||
"de_fb_ajouter_offre_3",
|
||||
"de_fb_afficher_offre_3",
|
||||
"de_fb_offre_3_titre",
|
||||
"de_fb_offre_3_txt",
|
||||
"de_fb_offre_3_image"
|
||||
],
|
||||
"url_partenaire":"",
|
||||
"tax_input":["de_fb_project_category"],
|
||||
"project_category":"hebergement",
|
||||
"post_excerpt":"test",
|
||||
"post_content":"test",
|
||||
"_ajax_linking_nonce":"0e855ae1a9",
|
||||
"logo_partenaire":"38157",
|
||||
"post_thumbnail":"38156",
|
||||
"offre_1_titre":"test",
|
||||
"offre_1_txt":"test",
|
||||
"offre_1_image":"",
|
||||
"ajouter_offre_2":"Oui",
|
||||
"afficher_offre_2":"Masquer",
|
||||
"offre_2_titre":"test",
|
||||
"offre_2_txt":"test",
|
||||
"offre_2_image":"",
|
||||
"ajouter_offre_3":"Non",
|
||||
"offre_3_image":"",
|
||||
"ID":"38158",
|
||||
"form_type_confirm":""
|
||||
}
|
||||
|
||||
form_type
|
||||
project
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Hook into the 'acf/save_post' action
|
||||
*/
|
||||
// add_action('acf/save_post', 'handle_acf_form_submission', 5); // 20 is the priority, you can adjust it as needed
|
||||
// function handle_acf_form_submission($post_id)
|
||||
// {
|
||||
// error_log("in acf/save_post");
|
||||
// if ($_SERVER['REQUEST_METHOD'] === 'POST' )
|
||||
// {
|
||||
// error_log("_SERVER['REQUEST_URI']");
|
||||
// error_log(json_encode($_SERVER['REQUEST_URI']));
|
||||
// error_log("_SERVER['QUERY_STRING']");
|
||||
// error_log(json_encode($_SERVER['QUERY_STRING']));
|
||||
// error_log("_POST['de_fb_ville']");
|
||||
// error_log(json_encode($_POST['de_fb_ville']));
|
||||
// }
|
||||
// // Check if the request is coming from the specific URL
|
||||
// if ($_SERVER['QUERY_STRING'] !== '/') {
|
||||
// return; // Exit if the request is not from the specific URL
|
||||
// }
|
||||
//
|
||||
// // Check if this is an autosave
|
||||
// if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Check if this is a revision
|
||||
// if (wp_is_post_revision($post_id)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Check if the current user has permission to edit the post
|
||||
// if (!current_user_can('edit_post', $post_id)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Your ACF form submission handling logic goes here
|
||||
// // For example, you can retrieve form data using $_POST and update ACF fields accordingly
|
||||
// if (isset($_POST['your_acf_field_name'])) {
|
||||
// $field_value = sanitize_text_field($_POST['your_acf_field_name']);
|
||||
// update_field('your_acf_field_name', $field_value, $post_id);
|
||||
// }
|
||||
// }
|
||||
-------------
|
||||
|
||||
in PLGNTLS_df_after_insert_post_handler
|
||||
|
||||
form_id
|
||||
crea_partenaire
|
||||
|
||||
post_id
|
||||
38158
|
||||
|
||||
post_array
|
||||
{
|
||||
"post_status":"publish",
|
||||
"field_title":
|
||||
[
|
||||
1. "Nom commercial",
|
||||
2. "Votre site Internet",
|
||||
3. "Dans quelle rubrique devez-vous para\u00eetre ? ",
|
||||
4. "L\\'accroche en t\u00eate de page",
|
||||
5. "Pr\u00e9sentez-vous",
|
||||
6. "Votre logo ",
|
||||
7. "Image principale",
|
||||
8. "Titre",
|
||||
9. "Texte de l\\'offre",
|
||||
10. "Image (facultatif)",
|
||||
11. "Voulez-vous ajouter une offre ?",
|
||||
12. "Voulez-vous afficher cette offre ?",
|
||||
13. "Titre","Texte de l\\'offre",
|
||||
14. "Image (facultatif)",
|
||||
15. "Voulez-vous ajouter une offre ?",
|
||||
16. "Voulez-vous afficher l\\'offre ?",
|
||||
17. "Titre",
|
||||
18. "Texte de l\\'offre",
|
||||
19. "Image (facultatif)"
|
||||
],
|
||||
"post_title":"test",
|
||||
"meta_input":
|
||||
{
|
||||
1. "url_partenaire":"",
|
||||
2. "_url_partenaire":"field_65cb83096d020",
|
||||
3. "logo_partenaire":"38157",
|
||||
4. "_logo_partenaire":"field_65cb79150ac4f",
|
||||
5. "offre_1_titre":"test",
|
||||
6. "_offre_1_titre":"field_65d8bbf6b4651",
|
||||
7. "offre_1_txt":"test",
|
||||
8. "_offre_1_txt":"field_65d8bc395bf88",
|
||||
9. "offre_1_image":"",
|
||||
10. "_offre_1_image":"field_65d8bc5d5bf8b",
|
||||
11. "ajouter_offre_2":"Oui",
|
||||
12. "_ajouter_offre_2":"field_65d8c834e1ac9",
|
||||
13. "afficher_offre_2":"Masquer",
|
||||
14. "_afficher_offre_2":"field_65d8cf09395a5",
|
||||
15. "offre_2_titre":"test",
|
||||
16. "_offre_2_titre":"field_65d8bc201740b",
|
||||
17. "offre_2_txt":"test",
|
||||
18. "_offre_2_txt":"field_65d8bc4c5bf89",
|
||||
19. "offre_2_image":"",
|
||||
20. "_offre_2_image":"field_65d8bc6e5bf8c",
|
||||
21. "ajouter_offre_3":"Non",
|
||||
22. "_ajouter_offre_3":"field_65d8c880fb783",
|
||||
23. "afficher_offre_3":[],
|
||||
24. "offre_3_titre":[],
|
||||
25. "offre_3_txt":[],
|
||||
26. "offre_3_image":"",
|
||||
27. "_offre_3_image":"field_65d8bc8c5bf8e"
|
||||
},
|
||||
"tax_input":{"project_category":[39]},
|
||||
"post_excerpt":"test",
|
||||
"post_content":"test",
|
||||
"_ajax_linking_nonce":"0e855ae1a9",
|
||||
"post_thumbnail":"38156",
|
||||
"ID":"38158",
|
||||
"form_type_confirm":"",
|
||||
"post_type":"project",
|
||||
"post_date":"2024-02-28 18:57:20"
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2
private
2
private
Submodule private updated: 987b3a522f...7bb12740a9
Submodule wordpress_docker updated: 426e412a8f...f45db59f8b
Reference in New Issue
Block a user