From ee2dafbccc2cdb4f3918fe5ea588d20b82b61e10 Mon Sep 17 00:00:00 2001 From: asus Date: Sun, 18 Feb 2024 02:27:09 +0100 Subject: [PATCH] patch for jquery url validator working --- plugins/fipfcard_plugin/fipfcard_plugin.php | 6 +++--- plugins/fipfcard_plugin/js/example_init.js | 1 - .../js/jquery_validator_patch.js | 20 ------------------- .../js/jquery_validator_url_patch.js | 8 ++++++++ .../php/utils/plugin_tools.php | 5 ----- 5 files changed, 11 insertions(+), 29 deletions(-) delete mode 100644 plugins/fipfcard_plugin/js/jquery_validator_patch.js create mode 100644 plugins/fipfcard_plugin/js/jquery_validator_url_patch.js diff --git a/plugins/fipfcard_plugin/fipfcard_plugin.php b/plugins/fipfcard_plugin/fipfcard_plugin.php index 50d0328..36a75f1 100644 --- a/plugins/fipfcard_plugin/fipfcard_plugin.php +++ b/plugins/fipfcard_plugin/fipfcard_plugin.php @@ -251,8 +251,8 @@ function my_custom_url_handler($query) /** * in `wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php` - * line 1328 : wp_register_script( 'de_fb_validate', DE_FB_URL . '/js/jquery.validation/jquer - * line 1354 : wp_enqueue_script( 'de_fb_validate' ); + * 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() { @@ -261,7 +261,7 @@ function add_my_jquery_patch() ( array ( - 'de_fb_validate' => 'js/jquery_validator_patch.js', + 'de_fb_validate' => 'js/jquery_validator_url_patch.js', ) ); } diff --git a/plugins/fipfcard_plugin/js/example_init.js b/plugins/fipfcard_plugin/js/example_init.js index 28c1c39..b003818 100644 --- a/plugins/fipfcard_plugin/js/example_init.js +++ b/plugins/fipfcard_plugin/js/example_init.js @@ -1,4 +1,3 @@ -console.log("-------------EXAMPLEEEEE----------------- :)"); console.log("PLGNTLS_data:"); console.log(PLGNTLS_data); diff --git a/plugins/fipfcard_plugin/js/jquery_validator_patch.js b/plugins/fipfcard_plugin/js/jquery_validator_patch.js deleted file mode 100644 index 4d3d9a9..0000000 --- a/plugins/fipfcard_plugin/js/jquery_validator_patch.js +++ /dev/null @@ -1,20 +0,0 @@ -console.log("-------------jquery----------------- :)"); -// https://stackoverflow.com/questions/24938890/wordpress-jquery-noconflict -// https://wordpress.stackexchange.com/questions/104510/how-to-add-jquery-script-to-an-individual-page -// https://developer.wordpress.org/reference/functions/wp_enqueue_script/#jQuery_noConflict_Wrappers -//(function($) { -jQuery( document ).ready( function( $ ) { - - $.validator.addMethod - ( - 'validUrl', - function(value, element) - { - var url = $.validator.methods.url.bind(this); - return url(value, element) || url('http://' + value, element); - }, - 'Please enter a valid URL' - ); - -} ); -//})(jQuery); diff --git a/plugins/fipfcard_plugin/js/jquery_validator_url_patch.js b/plugins/fipfcard_plugin/js/jquery_validator_url_patch.js new file mode 100644 index 0000000..f7aeeb1 --- /dev/null +++ b/plugins/fipfcard_plugin/js/jquery_validator_url_patch.js @@ -0,0 +1,8 @@ +// https://stackoverflow.com/questions/12741517/how-to-make-url-validation-without-http-or-add-it-after-validation-passed/44848476#44848476 + +let old_url = jQuery.validator.methods.url; +jQuery.validator.addMethod( 'url', function(value, element) { + let url = old_url.bind(this); + return url(value, element) || url('http://' + value, element); + }, 'Please enter a valid URL' +); diff --git a/plugins/fipfcard_plugin/php/utils/plugin_tools.php b/plugins/fipfcard_plugin/php/utils/plugin_tools.php index aeed203..2b0de1a 100644 --- a/plugins/fipfcard_plugin/php/utils/plugin_tools.php +++ b/plugins/fipfcard_plugin/php/utils/plugin_tools.php @@ -195,10 +195,7 @@ class PLGNTLS_class global $wp_scripts; $already_enqueued = array_search($file->handle, $wp_scripts->queue); if ($already_enqueued !== false) - { - error_log("double !"); return null; - } } else if ($file->ext === "css") { @@ -241,8 +238,6 @@ class PLGNTLS_class $file->basename = pathinfo($file_name, PATHINFO_BASENAME); $file->handle = "PLGNTLS_" . str_replace(".", "_", $file->basename); - error_log("in init file->handle"); - error_log(json_encode($file->handle)); $file->url = $this->get_url().$file_name; $file->path = $this->get_path().$file_name;