Files
2024_WEBSITE_fipf/plugins/fipfcard_plugin/fipfcard_plugin.php

306 lines
7.6 KiB
PHP

<?php
/*
Plugin Name: fipfcard_plugin
Plugin URI:
Description:
Author: hugogogo
Version: 1.1.0
Author URI:
*/
/**
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/**
* plugin dir root
*/
include_once( plugin_dir_path(__FILE__) . '/utils/plgntls_class.php');
PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
/**
* general inclusions
*/
include_once(PLGNTLS_class::get_path() . '/php/utils/globals.php');
include_once(PLGNTLS_class::get_path() . '/php/utils/console_log.php');
//include_once(PLGNTLS_class::get_path() . '/php/images/image_edit_shortcode.php');
//include_once(PLGNTLS_class::get_path() . '/php/images/image-edit.php');
//include_once(PLGNTLS_class::get_path() . '/php/test_cache.php');
/**
* test the class PLGNTLS
*/
add_shortcode('fipfcard_plugin', 'fipfcard_test_class_tools');
/**
*
*/
function custom_frontend_posting_form() {
$my_image = the_field('image_ratio');
error_log("my_image");
error_log(json_encode($my_image));
return $my_image;
}
add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form');
/**
* call to paypal_shortcode_content()
*/
include_once(PLGNTLS_class::get_path() . '/php/paypal/paypal.php');
add_shortcode('fipf_paypal_shortcode', 'fipf_paypal_shortcode_content');
/*
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');
/**
* do_action( 'df_before_process', string $form_id, Array $post_array, String $form_type )
* Description: Fires after form is submitted and captcha checking is ok.
* Parameters:
* - $form_id: (String) Form ID from Form setting.
* - $post_array: (Array) Submitted fields from the form. Keys are mapped field names or custom field names (in case of Field Mapping Type is Custom).
* - $form_type : (String) Form Type
*
* wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php|298 col 18-35| do_action( 'df_before_process', $form_id, $post_array, $form_type );
* wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/ajaxcalls/post_ajax.php|254 col 16-33| do_action( 'df_before_process', $form_id, $post_array, $form_type );
*
* check user rights :
* - 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 );
*/
/*
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
-------------
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"
}
*/
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
menu plugin
*/
include_once(PLGNTLS_class::get_path() . '/php/menu/example_menu.php');
function fipfcard_plugin_menu()
{
add_menu_page
(
'fipf_card', // webpage title
'fipf_card', // menu title
'manage_options', // capability
'fipfcard-plugin', // menu_slug
'fipfcard_plugin_content' // callback function to display page content
);
}
add_action('admin_menu', 'fipfcard_plugin_menu');
?>