From 8aeef1dca828bd1fdfc43e08fc5465d407748995 Mon Sep 17 00:00:00 2001 From: asus Date: Fri, 1 Mar 2024 17:21:03 +0100 Subject: [PATCH] added inline code to plugin tools --- plugins/fipfcard_plugin/css/menu/menu.css | 6 + .../fipfcard_plugin/php/menu/example_menu.php | 10 ++ .../php/partenaires/partenaires.php | 158 +++++++++++++++++- .../fipfcard_plugin/utils/plgntls_class.php | 139 ++++++++++----- private | 2 +- 5 files changed, 269 insertions(+), 46 deletions(-) create mode 100644 plugins/fipfcard_plugin/css/menu/menu.css diff --git a/plugins/fipfcard_plugin/css/menu/menu.css b/plugins/fipfcard_plugin/css/menu/menu.css new file mode 100644 index 0000000..6792b1e --- /dev/null +++ b/plugins/fipfcard_plugin/css/menu/menu.css @@ -0,0 +1,6 @@ +#mytext { + border: 1px solid blue; +} +#mytext_2 { + border: 1px solid green; +} diff --git a/plugins/fipfcard_plugin/php/menu/example_menu.php b/plugins/fipfcard_plugin/php/menu/example_menu.php index ea2ec37..2e50968 100644 --- a/plugins/fipfcard_plugin/php/menu/example_menu.php +++ b/plugins/fipfcard_plugin/php/menu/example_menu.php @@ -10,8 +10,18 @@ if (!defined('ABSPATH')) { function fipfcard_plugin_content() { $fipfcard = new PLGNTLS_class(); + $my_css = ' + #mytext { + background-color: lightblue; + } + #mytext_2 { + background-color: lightgreen; + } + '; echo $fipfcard->add_to_front( array( array("js/menu/example_menu.js", 'type'=>'module'), + "css/menu/menu.css", + "PLGNTLS_menu_css" => array('css'=>$my_css), "js/menu/example_menu_2.js", "html/menu/example_menu.html", )); diff --git a/plugins/fipfcard_plugin/php/partenaires/partenaires.php b/plugins/fipfcard_plugin/php/partenaires/partenaires.php index 14a3461..b970ff3 100644 --- a/plugins/fipfcard_plugin/php/partenaires/partenaires.php +++ b/plugins/fipfcard_plugin/php/partenaires/partenaires.php @@ -7,6 +7,7 @@ * - afficher_offre_* * - -> Masquer / * * - offre_x* (image, titre, txt) +*/ function my_custom_js_function_PLGNTLS() { if (!is_singular("project")) return ; @@ -63,7 +64,162 @@ function my_custom_js_function_PLGNTLS() { ); } 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/utils/plgntls_class.php b/plugins/fipfcard_plugin/utils/plgntls_class.php index 6425dc4..13c5b8f 100644 --- a/plugins/fipfcard_plugin/utils/plgntls_class.php +++ b/plugins/fipfcard_plugin/utils/plgntls_class.php @@ -8,6 +8,9 @@ * * PLGNTLS means PLUGIN TOOLS * + * .add_to_front() : this method is made to add files and codes all at once + * otherwise use the wp functions (wp_enqueue_*, wp_add_inline_*, etc) + * * * ex: * @@ -16,34 +19,31 @@ * $var_2 = 'value_2'; * $var_3 = 'value_3'; * return $my_plugin_class->add_to_front( - * array( - * 'path/to/style.css' // those files are added to front - * 'path/to/script.js' // in the order you put them - * 'http://my_url.com' // it can be urls - * 'path/to/file.html' // html are just rendered then returned + * array( // files added in order by types + * 'path/to/style1.css', // + * 'path/to/script1.js', // + * 'path/to/style2.css', // -> depends on style1.css + * 'http://my_url1.com', // + * 'path/to/script2.js', // -> depends on script1.js + * 'path/to/file1.html', // | will be returned + * 'path/to/file2.html', // -> | as expanded html + * 'path/to/file3.html', // | in the order included + * 'handle_name' => 'path/to/script3.js', // -> depends on the script with handle 'handle_name' + * array( // + * 'path/to/script4.js', // | add a script with attributes + * 'attribute_1' => 'value_1', // -> | first element of array must be + * 'attribute_2' => 'value_2', // | the script, without explicit key + * ), // + * array( 'js' => 'var_js' ), // -> add inline js, only first element will be used + * array( 'css' => 'var_css' ), // -> add inline css, only first element will be used * ), * compact( // these variables are added to html and js files - * 'var_1', // in html files you can access them directly - * 'var_2', // in js files they are properties of object PLGNTLS_data - * 'var_3', // like PLGNTLS_data.var_1; + * 'var_1', // - in html files you can access them directly + * 'var_2', // - in js files they are properties of object PLGNTLS_data + * 'var_3', // like PLGNTLS_data.var_1; * ) * ); * - * complete syntax to include js scripts : - * - * key => value - * 1: 'src' - * 2: 'dependence' => 'src' - * 3: array( 'src', 'attr_1' => 'value_1', ... ) - * 4: 'dependence' => array( 'src', 'attr_1' => 'value_1', ... ) - * - * -> 'src' is required - * -> 'dependence' is optional - * explicit key is always a dependence - * -> value can be a string 'src', or an array('srcs', ...) - * if value is array, first element is 'src' and following - * are attributes for