From 7738ad1863b6eaf72fe25c854285a2ffbe451348 Mon Sep 17 00:00:00 2001 From: asus Date: Sat, 2 Mar 2024 16:14:36 +0100 Subject: [PATCH] - added role at registration with xootix - cleaned folder --- plugins/fipfcard_plugin/css/example_style.css | 7 - .../css/partenaires/partenaires.css | 1 - plugins/fipfcard_plugin/fipfcard_plugin.php | 11 +- .../fipfcard_plugin/html/example_index.html | 70 ------ .../fipfcard_plugin/html/example_index2.html | 22 -- .../fipfcard_plugin/html/image_editor.html | 3 - .../html/templates/example_presentation.html | 2 - .../html/templates/print_meta.html | 4 - plugins/fipfcard_plugin/js/example_init.js | 20 -- plugins/fipfcard_plugin/js/example_script2.js | 3 - plugins/fipfcard_plugin/js/example_script3.js | 3 - .../js/partenaires/switch_offers.js | 2 - .../php/partenaires/partenaires.php | 225 ------------------ .../php/register/partenaires.php | 15 ++ plugins/fipfcard_plugin/php/test_cache.php | 33 --- .../fipfcard_plugin/php/test_class_tools.php | 74 ------ .../php/utils/add_to_front.php | 163 ------------- .../fipfcard_plugin/php/utils/create_html.php | 46 ---- .../{php => }/utils/console_log.php | 0 .../{php => }/utils/globals.php | 0 plugins/fipfcard_plugin/utils/plugin_ajax.js | 117 --------- private | 2 +- 22 files changed, 19 insertions(+), 804 deletions(-) delete mode 100644 plugins/fipfcard_plugin/css/example_style.css delete mode 100644 plugins/fipfcard_plugin/css/partenaires/partenaires.css delete mode 100644 plugins/fipfcard_plugin/html/example_index.html delete mode 100644 plugins/fipfcard_plugin/html/example_index2.html delete mode 100644 plugins/fipfcard_plugin/html/image_editor.html delete mode 100644 plugins/fipfcard_plugin/html/templates/example_presentation.html delete mode 100644 plugins/fipfcard_plugin/html/templates/print_meta.html delete mode 100644 plugins/fipfcard_plugin/js/example_init.js delete mode 100644 plugins/fipfcard_plugin/js/example_script2.js delete mode 100644 plugins/fipfcard_plugin/js/example_script3.js delete mode 100644 plugins/fipfcard_plugin/js/partenaires/switch_offers.js delete mode 100644 plugins/fipfcard_plugin/php/partenaires/partenaires.php create mode 100644 plugins/fipfcard_plugin/php/register/partenaires.php delete mode 100644 plugins/fipfcard_plugin/php/test_cache.php delete mode 100644 plugins/fipfcard_plugin/php/test_class_tools.php delete mode 100644 plugins/fipfcard_plugin/php/utils/add_to_front.php delete mode 100644 plugins/fipfcard_plugin/php/utils/create_html.php rename plugins/fipfcard_plugin/{php => }/utils/console_log.php (100%) rename plugins/fipfcard_plugin/{php => }/utils/globals.php (100%) delete mode 100644 plugins/fipfcard_plugin/utils/plugin_ajax.js diff --git a/plugins/fipfcard_plugin/css/example_style.css b/plugins/fipfcard_plugin/css/example_style.css deleted file mode 100644 index bf327c8..0000000 --- a/plugins/fipfcard_plugin/css/example_style.css +++ /dev/null @@ -1,7 +0,0 @@ -.first_el_to_change { - border: 1px solid red; -} -#model_plugin_shortcode { - border: 1px solid blue; - padding: 10px; -} diff --git a/plugins/fipfcard_plugin/css/partenaires/partenaires.css b/plugins/fipfcard_plugin/css/partenaires/partenaires.css deleted file mode 100644 index 3cfda82..0000000 --- a/plugins/fipfcard_plugin/css/partenaires/partenaires.css +++ /dev/null @@ -1 +0,0 @@ -div {} diff --git a/plugins/fipfcard_plugin/fipfcard_plugin.php b/plugins/fipfcard_plugin/fipfcard_plugin.php index d7def9d..0bdba3b 100644 --- a/plugins/fipfcard_plugin/fipfcard_plugin.php +++ b/plugins/fipfcard_plugin/fipfcard_plugin.php @@ -27,17 +27,12 @@ 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'); +include_once(PLGNTLS_class::get_path() . '/utils/globals.php'); +include_once(PLGNTLS_class::get_path() . '/utils/console_log.php'); include_once(PLGNTLS_class::get_path() . '/php/paypal/paypal.php'); -include_once(PLGNTLS_class::get_path() . '/php/partenaires/partenaires.php'); +include_once(PLGNTLS_class::get_path() . '/php/register/partenaires.php'); diff --git a/plugins/fipfcard_plugin/html/example_index.html b/plugins/fipfcard_plugin/html/example_index.html deleted file mode 100644 index 7ecb008..0000000 --- a/plugins/fipfcard_plugin/html/example_index.html +++ /dev/null @@ -1,70 +0,0 @@ -
-
    -

    list get_metadata('post') :

    - $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-
    -

    list get_post_meta() :

    - $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-
    -

    list get_metadata('user') :

    - $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-
    -

    list get_user_meta() :

    - $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-
    -

    list get_userdata() :

    - $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-
    -

    list wp_get_current_user() :

    - $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-
    -

    list wp_get_current_user()->data :

    - data as $meta_key => $meta_value) { - include($plgn_dir."html/templates/print_meta.html"); - } - ?> -
-

get_field('user_email') :

-

- -

- -

i am a new p

-

to change

- - diff --git a/plugins/fipfcard_plugin/html/example_index2.html b/plugins/fipfcard_plugin/html/example_index2.html deleted file mode 100644 index 3a1a691..0000000 --- a/plugins/fipfcard_plugin/html/example_index2.html +++ /dev/null @@ -1,22 +0,0 @@ - -

age

- -

to change

-

aaaaaand this is the end

-
- - - - -
-
- - - - -
-
diff --git a/plugins/fipfcard_plugin/html/image_editor.html b/plugins/fipfcard_plugin/html/image_editor.html deleted file mode 100644 index ac3d300..0000000 --- a/plugins/fipfcard_plugin/html/image_editor.html +++ /dev/null @@ -1,3 +0,0 @@ - - -
diff --git a/plugins/fipfcard_plugin/html/templates/example_presentation.html b/plugins/fipfcard_plugin/html/templates/example_presentation.html deleted file mode 100644 index 7584962..0000000 --- a/plugins/fipfcard_plugin/html/templates/example_presentation.html +++ /dev/null @@ -1,2 +0,0 @@ -

hello

-

to change

diff --git a/plugins/fipfcard_plugin/html/templates/print_meta.html b/plugins/fipfcard_plugin/html/templates/print_meta.html deleted file mode 100644 index 67f95ae..0000000 --- a/plugins/fipfcard_plugin/html/templates/print_meta.html +++ /dev/null @@ -1,4 +0,0 @@ -
  • - "" : - -
  • diff --git a/plugins/fipfcard_plugin/js/example_init.js b/plugins/fipfcard_plugin/js/example_init.js deleted file mode 100644 index b003818..0000000 --- a/plugins/fipfcard_plugin/js/example_init.js +++ /dev/null @@ -1,20 +0,0 @@ -console.log("PLGNTLS_data:"); -console.log(PLGNTLS_data); - -const title = document.querySelector(".first_el_to_change"); -title.innerHTML = "--- coucou ;) " + PLGNTLS_data.myvar_1; - -const ajax_button_1 = document.querySelector("#test_ajax_1"); -ajax_button_1.addEventListener('click', () => { - PLGNTLS_data.ajax(ajax_button_1, 'get_data') - .then((response) => response.json()) - .then((data) => { - console.log("datou: "); - console.log(data); - }) - .catch((error) => { - console.log("error: "); - console.log(error); - }) - ; -}); diff --git a/plugins/fipfcard_plugin/js/example_script2.js b/plugins/fipfcard_plugin/js/example_script2.js deleted file mode 100644 index b21c8a6..0000000 --- a/plugins/fipfcard_plugin/js/example_script2.js +++ /dev/null @@ -1,3 +0,0 @@ - -const title2 = document.querySelector(".second_el_to_change"); -title2.innerHTML = "--- ho boy !"; diff --git a/plugins/fipfcard_plugin/js/example_script3.js b/plugins/fipfcard_plugin/js/example_script3.js deleted file mode 100644 index a463e1f..0000000 --- a/plugins/fipfcard_plugin/js/example_script3.js +++ /dev/null @@ -1,3 +0,0 @@ - -const title3 = document.querySelector(".third_el_to_change"); -title3.innerHTML = "--- bye bye, " + PLGNTLS_data.myvar_2; diff --git a/plugins/fipfcard_plugin/js/partenaires/switch_offers.js b/plugins/fipfcard_plugin/js/partenaires/switch_offers.js deleted file mode 100644 index f3996de..0000000 --- a/plugins/fipfcard_plugin/js/partenaires/switch_offers.js +++ /dev/null @@ -1,2 +0,0 @@ -console.log("PLGNTLS_data.output :"); -console.log(PLGNTLS_data.output); diff --git a/plugins/fipfcard_plugin/php/partenaires/partenaires.php b/plugins/fipfcard_plugin/php/partenaires/partenaires.php deleted file mode 100644 index b970ff3..0000000 --- a/plugins/fipfcard_plugin/php/partenaires/partenaires.php +++ /dev/null @@ -1,225 +0,0 @@ - Masquer / * -* - offre_x* (image, titre, txt) -*/ -function my_custom_js_function_PLGNTLS() { - if (!is_singular("project")) - return ; - error_log("------"); - - // list all acf fields of the current post - $acf_group_fields = get_fields(); - // list offers to mask - $offers_to_mask = array_filter($acf_group_fields, function($value, $key){ - if (!str_starts_with($key, "afficher_offre_")) - return false; - if ($value === "Masquer") - return true; - }, ARRAY_FILTER_USE_BOTH); - foreach($offers_to_mask as $key => $value){ - $needle = str_replace( "afficher_", "",$key); - } - error_log("needle"); - error_log($needle); - $to_mask = array_filter($acf_group_fields, function($value, $key){ - if (str_starts_with($key, $needle)) - return true; - }, ARRAY_FILTER_USE_BOTH); - // select only the acf fields "afficher_offre_*" -// $acf_offers = array_filter($acf_group_fields, function($field){ -// $field_name = $field['name']; -// return str_starts_with($field_name, "afficher_offre_"); -// }); - // list of "afficher_offre_" for current post that are on "Masquer" -// error_log("---"); -// $to_mask = array(); -// foreach($acf_offers as $offer){ -// $key = $offer['key']; -// error_log("key:"); -// error_log($key); -// $field_value = get_field($key); -// error_log("field_value:"); -// error_log($field_value); -// if ($field_value === 'Masquer') { -// $to_mask[] = $offer; -// } -// } - - $output = $to_mask; - $fipfcard_project = new PLGNTLS_class(); - return $fipfcard_project->add_to_front( - array( - "css/partenaires/partenaires.css", - "js/partenaires/switch_offers.js", - ), - compact( - "output", - ) - ); -} -add_action('wp_footer', 'my_custom_js_function_PLGNTLS'); - - -/* -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" -} -*/ - -?> diff --git a/plugins/fipfcard_plugin/php/register/partenaires.php b/plugins/fipfcard_plugin/php/register/partenaires.php new file mode 100644 index 0000000..ef0db84 --- /dev/null +++ b/plugins/fipfcard_plugin/php/register/partenaires.php @@ -0,0 +1,15 @@ + diff --git a/plugins/fipfcard_plugin/php/test_cache.php b/plugins/fipfcard_plugin/php/test_cache.php deleted file mode 100644 index 62c931e..0000000 --- a/plugins/fipfcard_plugin/php/test_cache.php +++ /dev/null @@ -1,33 +0,0 @@ -'; - echo ''; - echo ''; -} -add_action('wp_head', 'add_custom_meta_tags'); - - -?> diff --git a/plugins/fipfcard_plugin/php/test_class_tools.php b/plugins/fipfcard_plugin/php/test_class_tools.php deleted file mode 100644 index 62ae6a8..0000000 --- a/plugins/fipfcard_plugin/php/test_class_tools.php +++ /dev/null @@ -1,74 +0,0 @@ -data; -$data = $data->user_email; -//error_log("data->data"); -//error_log($data); -//delete_post_meta(get_the_ID(), "_data_user_email"); -//delete_post_meta(get_the_ID(), "_data"); -//add_post_meta(get_the_ID(), "data_user_email", $data); - - $post_metadata = get_metadata( 'post', get_the_ID() ); - $post_meta = get_post_meta( get_the_ID() ); - - $user_metadata = get_metadata( 'user', get_current_user_id() ); - $user_meta = get_user_meta( get_current_user_id() ); - $acf_get_fields = get_fields( get_the_ID() ); - $user_data = get_userdata( get_current_user_id() ); - $current_user = wp_get_current_user(); - $user_email = get_field('user_email', 'MarieM'); - - - return $fipfcard_tools->add_to_front - ( - array - ( - "css/example_style.css", - "js/example_init.js", - "js/example_script2.js", - "js/example_script3.js", - "html/example_index.html", - "html/example_index2.html", - ), - compact - ( - "myvar_1", - "myvar_2", - "post_metadata", - "post_meta", - "user_metadata", - "user_meta", - "acf_get_fields", - "user_data", - "current_user", - "user_email", - "names", - "ages", - ) - ); - -} - - -?> diff --git a/plugins/fipfcard_plugin/php/utils/add_to_front.php b/plugins/fipfcard_plugin/php/utils/add_to_front.php deleted file mode 100644 index 39829e1..0000000 --- a/plugins/fipfcard_plugin/php/utils/add_to_front.php +++ /dev/null @@ -1,163 +0,0 @@ -handle, $wp_scripts->queue); -// if ($already_enqueued !== false) -// return ; - - $fipfcard_first_script = $file->handle; - wp_enqueue_script( $file->handle, $file->url, '', $file->version, true); - - $_url = admin_url( 'admin-ajax.php' ); - $_nonce = wp_create_nonce( 'wp-pageviews-nonce' ); - $vars = compact("_url","_nonce",); -// add_var_to_front($vars); - $object_name = "fipfcard_ajax"; - wp_localize_script($file->handle, $object_name, $vars); - -} - - - - -/* - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -@param string : name of the file, with its path from its extension directory - - from js/ root for .js files - - from css/ root for .css files -@return object / null : - - null if file is not js or css - - or an object with all the necessary infos : - - ext : name.js -> "js" - - basename : name.js -> "name" - - handle : name.js -> "name_js" - - url : url to file in wordpress - - path : path to file in server - - version : used to avoid browser caching -*/ -function fipfcard_init_file($file_name) { - $file = (object)[]; - - $file->ext = pathinfo($file_name, PATHINFO_EXTENSION); - if ($file->ext === "js") - $dir_path = 'js/'; - else if ($file->ext === "css") - $dir_path = 'css/'; - else - return null; - - $file->basename = pathinfo($file_name, PATHINFO_FILENAME); - $file->handle = str_replace(".", "_", $file_name); - - $file->url = FIPFCARD_PLUGIN_URL.$dir_path.$file_name; - $file->path = FIPFCARD_PLUGIN_DIR.$dir_path.$file_name; - $file->version = date("ymd-Gis", filemtime($file->path)); - - return $file; -} - - - -/* - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -@param array : list of files : - - with their path from root of their type of file (ex: from js/ to .js files) - - and with their extension -@param boolean - - to add ajax script and variables - - default to true -*/ -function fipfcard_add_files_to_front($files_arr, $add_ajax = true) { - //wp_enqueue_script(, /url/to/file, [depends on], version, defer? ); - //wp_enqueue_style( , /url/to/file, [depends on], version, media ); - global $fipfcard_first_script; - - if ($add_ajax === true) - fipfcard_add_ajax_post(); - - $previous_css_basename = ''; - $previous_js_basename = ''; - foreach ($files_arr as $file_name) { - $file = fipfcard_init_file($file_name); - if ($file->ext === "js") { - if (is_null($fipfcard_first_script)) - $fipfcard_first_script = $file->handle; - wp_enqueue_script( $file->handle, $file->url, $previous_js_basename, $file->version, true); - $previous_js_basename = $file->basename; - } - else if ($file->ext === "css") { - wp_enqueue_style( $file->handle, $file->url, $previous_css_basename, $file->version, ''); - $previous_css_basename = $file->basename; - } - } -} - - - -/* - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -pass variables to js front as global variables -@param array : list of key => value - with the key being name of the variable, like this : - 'my_var' => 'value', - simpler way to do it is to use compact when calling the function : - add_var_to_front(compact("var1", "var2", "var3")); -@param string (optionnal) : name of first embended script that need these variables - (it will be available to this script and all followings) - this name is the filename + "_" + extension : - init.js -> init_js -*/ -function fipfcard_add_var_to_front($vars, $handle = null) { - if (is_null($handle)) { - global $fipfcard_first_script; - $handle = $fipfcard_first_script; - } - - extract($vars); - foreach ($vars as $key => $var) - { - $js_var = 'let '.$key.' = '.json_encode($var).';'; - wp_add_inline_script($handle, $js_var, 'before'); - } - -// the other way with localize has multiple incidences : -// - it creates an object from wich you can access the variables -// - so if you call it again wiht the same name, it will overwrite the previous -// { -// $handle = pathinfo($handle, PATHINFO_FILENAME); -// $object_name = "php_data"; -// -// wp_localize_script($handle, $object_name, $vars); -// } -} - -?> diff --git a/plugins/fipfcard_plugin/php/utils/create_html.php b/plugins/fipfcard_plugin/php/utils/create_html.php deleted file mode 100644 index fa5505b..0000000 --- a/plugins/fipfcard_plugin/php/utils/create_html.php +++ /dev/null @@ -1,46 +0,0 @@ - val - - recommanded to do it with compact() -ex: create_html( "file.html", compact("var1","var2",) ); -ex: create_html( array("file1.html", "file2.html"), array("var1"=>"value") ); -@return a string of html code - -using ob_start() and ob_get_clean() -allows to have php expansion inside the html loaded -in opposition to the methode file_get_contents() - -https://stackoverflow.com/a/4402045/9497573 -*/ -function fipfcard_create_html($files, $vars = null) { - $files = (array)$files; - $html_dir = FIPFCARD_PLUGIN_DIR.'html/'; - if (!is_null($vars)) - extract($vars); - - ob_start(); - foreach($files as $file) { - include($html_dir.$file); - } - $html = ob_get_clean(); - - return $html; -} - -?> diff --git a/plugins/fipfcard_plugin/php/utils/console_log.php b/plugins/fipfcard_plugin/utils/console_log.php similarity index 100% rename from plugins/fipfcard_plugin/php/utils/console_log.php rename to plugins/fipfcard_plugin/utils/console_log.php diff --git a/plugins/fipfcard_plugin/php/utils/globals.php b/plugins/fipfcard_plugin/utils/globals.php similarity index 100% rename from plugins/fipfcard_plugin/php/utils/globals.php rename to plugins/fipfcard_plugin/utils/globals.php diff --git a/plugins/fipfcard_plugin/utils/plugin_ajax.js b/plugins/fipfcard_plugin/utils/plugin_ajax.js deleted file mode 100644 index e6a272f..0000000 --- a/plugins/fipfcard_plugin/utils/plugin_ajax.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * function that create an ajax post action - * - PLGNTLS_data.ajax_nonce and PLGNTLS_data.ajax_url - * are passed from the class PLGNTLS_class - */ - -/* -// OLD VERSION -console.log("PLGNTLS_data"); -console.log(PLGNTLS_data); -*/ -function PLGNTLS_ajax(action, data_obj) { - const data = new FormData(); - data.append("action", action); - data.append("_ajax_nonce", PLGNTLS_data.ajax_nonce); -// for (const key in data_obj) -// { -// data.append(key, data_obj[key]); -// } -// console.log("data:", data); - data.append(data_obj); - - return fetch(PLGNTLS_data.ajax_url, { - method: "POST", - credentials: "same-origin", - hedears: {"Content-Type": "application/json"}, - body: JSON.stringify(data), - }); -} - -// https://stackoverflow.com/q/52657814/9497573 -function is_plain_object(obj) -{ - if (!obj) - return false; - if (obj.constructor !== Object) - return false; - if (Object.getPrototypeOf(obj) !== Object.prototype) - return false; - return true; -} - -/* -function PLGNTLS_fetch(src = null, options = null) -{ - if (src === null) - return null; - if (options === null) - { - const data = new FormData(); - data.append('action', src); - data.append('_ajax_nonce', PLGNTLS_data.ajax_nonce); - - options = { - method: 'POST', - credentials: 'same-origin', - body: data, - }; - } - else if (is_plain_object(options)) - { - // check for method, default POST - if (!Object.hasOwn(options, 'method')) - options.method = 'POST'; - // check for credentials, default same-origin - if (!Object.hasOwn(options, 'credentials')) - options.credentials = 'same-origin'; - - // check for body, default contains action and nonce - if (!Object.hasOwn(options, 'body')) - options.body = new FormData(); - // add action and nonce in options.body - if (options.body instanceof FormData) - { - // dont check if action and nonce already exist, need new anyway - options.body.set('action', src); - options.body.set('_ajax_nonce', PLGNTLS_data.ajax_nonce); - } - else - { - // should think a better strategy : https://stackoverflow.com/q/20295080/9497573 - // const data = {}; - // if (is_plain_object(options.body)) - // { - // for (const key in options.body) - // data[key] = options.body[key]; - // } - // else - // data.data = options.body; - // data.action = src; - // data._ajax_nonce = PLGNTLS_data.ajax_nonce; - // options.body = JSON.stringify(data); - - // cannot work if fetch use : - // headers: {"Content-Type": "application/json"}, - const data = new FormData( ); - data.append( 'action', src ); - data.append( '_ajax_nonce', PLGNTLS_data.ajax_nonce ); - if ( is_plain_object( options.body ) ) - { - for ( const key in options.body ) - data.append( key, JSON.stringify(options.body[key]) ); - } - // is string : https://stackoverflow.com/q/4059147/9497573 - else if ( typeof options.body === 'string' || options.body instanceof String ) - data.append( 'data', options.body ); - else - data.append('data', JSON.stringify(options.body)); - options.body = data; - } - } - else - throw new Error('options not plain object or formData'); - - return fetch(PLGNTLS_data.ajax_url, options); -} -*/ diff --git a/private b/private index 8bb03bf..8b8c17b 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 8bb03bf5187533d9f7da27a57b0f1b96f3b0400b +Subproject commit 8b8c17b979efca681d3592e9e8038f1008891250