added url patch as a separate plugin

This commit is contained in:
asus
2024-02-18 11:00:01 +01:00
parent ee2dafbccc
commit 74fc6e3d1b
4 changed files with 50 additions and 13 deletions

View File

@@ -0,0 +1,28 @@
<?php
/*
Plugin Name: formbuilder url patch
Plugin URI:
Description:
Author: hugogogo
Version: 1.1.0
Author URI:
*/
/**
* in `wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php`
* also :
* - 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()
{
$handle = 'jquery_validator_url_patch';
$url = plugin_dir_url(__FILE__) . 'jquery_validator_url_patch.js';
$dependencies = array('de_fb_validate');
$version = '';
$defer = true;
wp_enqueue_script( $handle, $url, $dependencies, $version, $defer);
}
add_action('wp_enqueue_scripts', 'add_my_jquery_patch');
?>

View File

@@ -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'
);