moved all aptches from cipf plugin to fbpatch
This commit is contained in:
29
plugins/fbpatch/js/modals.js
Normal file
29
plugins/fbpatch/js/modals.js
Normal file
@@ -0,0 +1,29 @@
|
||||
let modal_wrapper_CIPF = document.querySelector('#de-fb-modal-wrapper-');
|
||||
|
||||
// create an observer on first #de-fb-modal-wrapper- to check if child nodes are added
|
||||
const observer_CIPF = new MutationObserver(wait_for_close_button_CIPF);
|
||||
observer_CIPF.observe(modal_wrapper_CIPF, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
|
||||
// observe mutations to see if they include the creation of the button .modal-close
|
||||
// if the button is created, add an eventListener to it
|
||||
function wait_for_close_button_CIPF(mutationsList) {
|
||||
mutationsList.forEach((mutation) => {
|
||||
// check if nodes were added
|
||||
if (mutation.type !== 'childList')
|
||||
return;
|
||||
// check if added nodes includes the button .modal-close
|
||||
let modal_close = document.querySelector('#de-fb-modal-wrapper- .modal-close');
|
||||
if (modal_close !== null) {
|
||||
modal_close.addEventListener("click", delete_modal_CIPF);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// when triggered, the .modal-close button will remove all childs from #de-fb-modal-wrapper-
|
||||
function delete_modal_CIPF() {
|
||||
modal_wrapper_CIPF.innerHTML = '';
|
||||
}
|
||||
|
||||
9
plugins/fbpatch/js/urls.js
Normal file
9
plugins/fbpatch/js/urls.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// 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'
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ function plugin_content() {
|
||||
$nonce = Fbpatch::NONCE;
|
||||
$admin_post_patches = Fbpatch::ADMIN_POST_PATCH_CHOICE;
|
||||
ob_start();
|
||||
include(plugin_dir_path(__DIR__) . '/html/menu.html');
|
||||
include(Fbpatch::root_path() . '/html/menu.html');
|
||||
$html = ob_get_clean();
|
||||
|
||||
echo $html;
|
||||
|
||||
@@ -16,7 +16,6 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
class Fbpatch {
|
||||
|
||||
const SLUG_TOOGLE_ADMIN_MENU = ['_name'=>'toogle_admin_menu_url_fbpatch', 'toggle'=>'toggle', 'show'=>'show', 'hide'=>'hide'];
|
||||
const OPTION_TOGGLE_MENU = ['_name'=>'toggle_admin_menu_option_fbpatch', 'show'=>'show', 'hide'=>'hide'];
|
||||
const NONCE = ['_name'=>'nonce_name', '_action'=>'action_name'];
|
||||
@@ -24,12 +23,22 @@ class Fbpatch {
|
||||
|
||||
private static $_patches = [
|
||||
'_name'=>'fbpatch_list_of_patches',
|
||||
'calculations'=>['checked'=>false, 'title'=>'calculations title', 'description'=>'calculation description'],
|
||||
'hide_show' =>['checked'=>false, 'title'=>'hide/show title', 'description'=>'hide/show description'],
|
||||
'calculations'=>['checked'=>true, 'title'=>'calculations title', 'description'=>'calculation description'],
|
||||
'hide_show' =>['checked'=>true, 'title'=>'hide/show title', 'description'=>'hide/show description'],
|
||||
'modals' =>['checked'=>false, 'title'=>'modals title', 'description'=>'modals description'],
|
||||
'urls' =>['checked'=>false, 'title'=>'urls title', 'description'=>'urls description'],
|
||||
];
|
||||
//private static $_patches = ['_name'=>'fbpatch_list_of_patches', 'hide_show'];
|
||||
//private static $_patches = ['_name'=>'fbpatch_list_of_patches'];
|
||||
|
||||
public static function root_path() {
|
||||
return plugin_dir_path(__DIR__);
|
||||
}
|
||||
public static function root_url() {
|
||||
return plugin_dir_url(__DIR__);
|
||||
}
|
||||
|
||||
|
||||
private static function set_option_patches() {
|
||||
/*
|
||||
* get the list of patches in option
|
||||
@@ -116,7 +125,7 @@ class Fbpatch {
|
||||
$patches = Fbpatch::get_patches();
|
||||
foreach($patches as $patch => $data) {
|
||||
if ($data['checked'] === true) {
|
||||
include_once(plugin_dir_path(__DIR__) . '/php/'.$patch.'.php');
|
||||
include_once(self::root_path() . '/php/patches/'.$patch.'.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ if (!defined('ABSPATH')) {
|
||||
*/
|
||||
function add_form_builder_calculations_patch() {
|
||||
$handle = 'form_builder_calculations_patch';
|
||||
$url = plugin_dir_url(__DIR__) . '/js/calculations.js';
|
||||
$url = Fbpatch::root_url() . '/js/calculations.js';
|
||||
$dependencies = array('de_fb_calc');
|
||||
$version = null;
|
||||
$defer = true;
|
||||
52
plugins/fbpatch/php/patches/hide_show.php
Normal file
52
plugins/fbpatch/php/patches/hide_show.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FBPATCH;
|
||||
|
||||
/*
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
/*
|
||||
* 4674 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/modules/Form/Form.php
|
||||
*
|
||||
*/
|
||||
//function form_partner_before_render_CIPF() {
|
||||
// PLGNTLS_class::debug_infos();
|
||||
//
|
||||
// $cipf_form_partner = new PLGNTLS_class();
|
||||
// $cipf_form_partner->add_to_front(array(
|
||||
// 'css/hide_show_form_elements.css',
|
||||
// ));
|
||||
//}
|
||||
//add_action('de_fb_before_form_render', 'form_partner_before_render_CIPF');
|
||||
|
||||
|
||||
/*
|
||||
* 305 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
|
||||
*
|
||||
*/
|
||||
function form_partner_before_process($form_id, $post_array, $form_type) {
|
||||
error_log("form_id: " . json_encode($form_id));
|
||||
error_log("post_array: " . json_encode($post_array));
|
||||
error_log("form_type: " . json_encode($form_type));
|
||||
}
|
||||
add_action('df_before_process', __NAMESPACE__.'\form_partner_before_process', 10, 3);
|
||||
|
||||
/*
|
||||
* 506 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
|
||||
*
|
||||
*/
|
||||
function form_partner_before_insert($form_id, $post_array) {
|
||||
error_log("form_id: " . json_encode($form_id));
|
||||
error_log("post_array: " . json_encode($post_array));
|
||||
}
|
||||
add_action('df_before_insert_post', __NAMESPACE__.'\form_partner_before_insert', 10, 2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
25
plugins/fbpatch/php/patches/modals.php
Normal file
25
plugins/fbpatch/php/patches/modals.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace FBPATCH;
|
||||
|
||||
/**
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function test_modal() {
|
||||
$handle = 'form_builder_modals_patch';
|
||||
$url = Fbpatch::root_url() . '/js/modals.js';
|
||||
$dependencies = array();
|
||||
$version = null;
|
||||
$defer = true;
|
||||
wp_enqueue_script($handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_shortcode('test_modal', __NAMESPACE__.'\test_modal');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
30
plugins/fbpatch/php/patches/urls.php
Normal file
30
plugins/fbpatch/php/patches/urls.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace FBPATCH;
|
||||
|
||||
/**
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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 = Fbpatch::root_url() . 'js/urls.js';
|
||||
$dependencies = array('de_fb_validate');
|
||||
$version = null;
|
||||
$defer = true;
|
||||
wp_enqueue_script( $handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_my_jquery_patch');
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user