creation of the repo fbpatch
This commit is contained in:
316
php/fbpatch_class.php
Normal file
316
php/fbpatch_class.php
Normal file
@@ -0,0 +1,316 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
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'];
|
||||
const ADMIN_POST_PATCH_CHOICE = 'add_patches';
|
||||
const ACF_DATE_CLASS = 'dfb_date';
|
||||
|
||||
/*
|
||||
* get path an url from plugin root
|
||||
*
|
||||
*/
|
||||
public static function root_path() {
|
||||
return plugin_dir_path(__DIR__);
|
||||
}
|
||||
public static function root_url() {
|
||||
return plugin_dir_url(__DIR__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------------
|
||||
* OPTIONS
|
||||
* these functions are used to select which patch is applied
|
||||
*
|
||||
*/
|
||||
|
||||
private static $_patches = [
|
||||
'_name'=>'fbpatch_list_of_patches',
|
||||
'dates' => ['checked'=>true, 'title'=>'dates', 'description'=>"gerer des dates pour acf dans n'importe quels formats (fonctionne bien pour divi, pas certain pour d'autres plugins)"],
|
||||
'calculations'=> ['checked'=>true, 'title'=>'calculations', 'description'=>"afficher le total des calculs dès l'ouverture des formulaires"],
|
||||
'hide_show' => ['checked'=>true, 'title'=>'masquer les offres', 'description'=>"permettre de masquer les offres en editant un formulaire, sans les supprimer"],
|
||||
'modals' => ['checked'=>false, 'title'=>'modals', 'description'=>"permettre plusieurs modals sur une meme page"],
|
||||
'urls' => ['checked'=>false, 'title'=>'urls', 'description'=>"permettre de rentrer des urls sans 'http://'"],
|
||||
];
|
||||
|
||||
private static function set_option_patches() {
|
||||
/*
|
||||
* get the list of patches in option
|
||||
* create option if needed
|
||||
*
|
||||
*/
|
||||
$raw_patches_option = get_option(self::$_patches['_name']);
|
||||
if (false === $raw_patches_option) {
|
||||
add_option(self::$_patches['_name'], '', '', 'no');
|
||||
}
|
||||
$patches_option = unserialize($raw_patches_option);
|
||||
if (empty($patches_option)) {
|
||||
$patches_option = array();
|
||||
}
|
||||
|
||||
/*
|
||||
* if the option miss patches, add them
|
||||
*
|
||||
*/
|
||||
foreach (self::$_patches as $patch => $data) {
|
||||
if ($patch === '_name') {
|
||||
continue;
|
||||
}
|
||||
if (isset($patches_option[$patch])) {
|
||||
// updates the title and the description
|
||||
$patches_option[$patch]['title'] = $data['title'];
|
||||
$patches_option[$patch]['description'] = $data['description'];
|
||||
}
|
||||
else {
|
||||
// add the option
|
||||
$patches_option[$patch] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if the option has additional patches, delete them
|
||||
*
|
||||
*/
|
||||
foreach ($patches_option as $patch => $data) {
|
||||
if (isset(self::$_patches[$patch])) {
|
||||
continue;
|
||||
}
|
||||
unset($patches_option[$patch]);
|
||||
}
|
||||
|
||||
/*
|
||||
* change the option list with the update patches
|
||||
*
|
||||
*/
|
||||
ksort($patches_option);
|
||||
$serialize_patches_option = serialize($patches_option);
|
||||
update_option(self::$_patches['_name'], $serialize_patches_option);
|
||||
}
|
||||
public static function get_patches() {
|
||||
self::set_option_patches();
|
||||
$patches = get_option(self::$_patches['_name']);
|
||||
return unserialize($patches);
|
||||
}
|
||||
public static function set_patches($patches_on) {
|
||||
/*
|
||||
* loop through the option list and update occording to the received list
|
||||
*
|
||||
*/
|
||||
$raw_patches = get_option(self::$_patches['_name']);
|
||||
$patches_option = unserialize($raw_patches);
|
||||
foreach($patches_option as $patch => $data) {
|
||||
if (in_array($patch, $patches_on)) {
|
||||
$patches_option[$patch]['checked'] = true;
|
||||
}
|
||||
else {
|
||||
$patches_option[$patch]['checked'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* change the option list with the update patches
|
||||
*
|
||||
*/
|
||||
ksort($patches_option);
|
||||
$serialize_patches_option = serialize($patches_option);
|
||||
update_option(self::$_patches['_name'], $serialize_patches_option);
|
||||
}
|
||||
|
||||
/*
|
||||
* this function will include the files of the different patches if they are set in the options
|
||||
*
|
||||
*/
|
||||
public static function init_hook() {
|
||||
$patches = Fbpatch::get_patches();
|
||||
foreach($patches as $patch => $data) {
|
||||
if ($data['checked'] === true) {
|
||||
include_once(self::root_path() . '/php/patches/'.$patch.'.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------------
|
||||
* HIDE SHOW
|
||||
* to hide the chosen elements of the form without deleting the data in acf fields
|
||||
*
|
||||
*/
|
||||
|
||||
private static $_post_id = 0;
|
||||
private static $_has_elements_to_skip = false;
|
||||
private static $_skip_elements = array();
|
||||
|
||||
public static function is_post_id($id) {
|
||||
return self::$_post_id == $id;
|
||||
}
|
||||
public static function is_to_skip($key) {
|
||||
return in_array($key, self::$_skip_elements);
|
||||
}
|
||||
|
||||
/*
|
||||
* create an array of the elements to forget
|
||||
*
|
||||
*/
|
||||
public static function set_post_elements_to_forget($id, $is_to_skip, $skip_array) {
|
||||
self::$_post_id = $id;
|
||||
self::$_has_elements_to_skip = $is_to_skip;
|
||||
self::$_skip_elements = $skip_array;
|
||||
}
|
||||
|
||||
/*
|
||||
* if there is elements to skip, add the filter
|
||||
*
|
||||
*/
|
||||
public static function init_skip_hook() {
|
||||
if (true === self::$_has_elements_to_skip) {
|
||||
add_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip', 10, 5);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* after insertion finished, removes filter and reset variables
|
||||
*
|
||||
*/
|
||||
public static function end_skip_hook() {
|
||||
if (true === self::$_has_elements_to_skip) {
|
||||
remove_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip');
|
||||
}
|
||||
self::$_post_id = 0;
|
||||
self::$_has_elements_to_skip = false;
|
||||
self::$_skip_elements = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------------
|
||||
* DATES
|
||||
* stores the real dates in the database
|
||||
*
|
||||
*/
|
||||
private static $dates_option = 'dfb_acf_dates_option';
|
||||
|
||||
/*
|
||||
* stores acf dates by post_id
|
||||
*
|
||||
*/
|
||||
public static function update_acf_date($post_id, $acf_key, $acf_date) {
|
||||
if (empty($acf_date)) {
|
||||
return;
|
||||
}
|
||||
$dates = get_option(self::$dates_option);
|
||||
|
||||
/*
|
||||
* if option does not exists, add it with its first value
|
||||
*
|
||||
*/
|
||||
if ($dates === false) {
|
||||
$dates[$post_id] = array($acf_key => $acf_date);
|
||||
add_option(self::$dates_option, $dates, '', false);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the option does not contains key for this post_id, add it
|
||||
*
|
||||
*/
|
||||
if (!isset($dates[$post_id])) {
|
||||
$dates[$post_id] = array($acf_key => $acf_date);
|
||||
update_option(self::$dates_option, $dates, false);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the post_id dont contains this acf field yet just add it
|
||||
*
|
||||
*/
|
||||
if (!isset($dates[$post_id][$acf_key])) {
|
||||
$dates[$post_id][$acf_key] = $acf_date;
|
||||
update_option(self::$dates_option, $dates, false);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the acf_key already exists,
|
||||
* only update option if it is different
|
||||
*
|
||||
*/
|
||||
if ($dates[$post_id][$acf_key] !== $acf_date) {
|
||||
$dates[$post_id][$acf_key] = $acf_date;
|
||||
update_option(self::$dates_option, $dates, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if acf_date exists for this acf field, use it instead of the value
|
||||
* return the date in acf format 'Ymd' or false if doesnt exists
|
||||
*
|
||||
*/
|
||||
public static function get_acf_date($post_id, $acf_key) {
|
||||
$dates = get_option(self::$dates_option);
|
||||
|
||||
if ($dates === false) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($dates[$post_id])) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($dates[$post_id][$acf_key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the date, or false if is empty
|
||||
*
|
||||
*/
|
||||
$date = $dates[$post_id][$acf_key];
|
||||
if (empty($date)) {
|
||||
return false;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
27
php/patches/calculations.php
Normal file
27
php/patches/calculations.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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 add_form_builder_calculations_patch() {
|
||||
$handle = 'form_builder_calculations_patch';
|
||||
$url = Fbpatch::root_url() . '/js/calculations.js';
|
||||
$dependencies = array('de_fb_calc');
|
||||
$version = null;
|
||||
$defer = true;
|
||||
wp_enqueue_script($handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_form_builder_calculations_patch', 22);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
184
php/patches/dates.php
Normal file
184
php/patches/dates.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* what I did :
|
||||
* - in front, keep the acf date input with text date,
|
||||
* but add a second hidden field with acf format date 'Ymd'
|
||||
* - in back, saving the text date in the acf field,
|
||||
* but keeping the acf date 'Ymd' in an option
|
||||
* - in the same time, adding a class to the field group
|
||||
* (available to all instances of this field)
|
||||
* to maek it as using a text field
|
||||
* - this way, if accessed the date with metadata,
|
||||
* we get the text date
|
||||
* - then, filter the value when loading,
|
||||
* to use the acf format date 'Ymd' instead of the text date
|
||||
* - and finally filter the format step
|
||||
* (which is not triggered by admin output)
|
||||
* to prevent formating if accessed by divi
|
||||
* (so it will print the metadata instead)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 1. this function will replace the date value by the one in acf format
|
||||
* for dates created by divi form builder
|
||||
*
|
||||
* 118 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/advanced-custom-fields/includes/acf-value-functions.php
|
||||
*
|
||||
* we can either use filter 'acf/load_value' or 'acf/pre_load_value'
|
||||
* - 'acf/pre_load_value' :
|
||||
* it fires first, and will short-circuit the function to get the value
|
||||
* it is useful to force the acf_date value to be always the same,
|
||||
* otherwise acf uses some kind of cach system,
|
||||
* so the value would be evaluated once then it would always be the same on the page : maybe it's alright ?
|
||||
* - 'acf/load_value' :
|
||||
* using this filter, the value is cached, as explained above
|
||||
* - note : the first argument '$value' is actually a little misleading :
|
||||
* - in case of the second filter, 'acf/load_value',
|
||||
* it is indeed tha value that has already been retrieve and that we can override
|
||||
* - but for the first filter, 'acf/pre_load_value', it is actually 'null',
|
||||
* and if returned it will let the function go on to try to retrieve the value
|
||||
*
|
||||
*/
|
||||
//function try_get_acf_date($value, $post_id, $field) {
|
||||
// $acf_date_class = Fbpatch::ACF_DATE_CLASS;
|
||||
// if ($field['type'] !== 'date_picker') {
|
||||
// return $value;
|
||||
// }
|
||||
// if (!str_contains($field['wrapper']['class'], $acf_date_class)) {
|
||||
// return $value;
|
||||
// }
|
||||
//
|
||||
// $acf_date = Fbpatch::get_acf_date($post_id, $field['key']);
|
||||
// if ($acf_date === false) {
|
||||
// return $value;
|
||||
// }
|
||||
//
|
||||
// return $acf_date;
|
||||
//}
|
||||
//add_filter('acf/load_value', __NAMESPACE__.'\try_get_acf_date', 10, 3);
|
||||
////add_filter('acf/pre_load_value', __NAMESPACE__.'\try_get_acf_date', 10, 3);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* load a jquery script to create a hidden field with the acf 'Ymd' date format
|
||||
* jquery date picker :
|
||||
* 7509 : ../../../../wordpress_docker/volumes/wp-volumes/wp-content/plugins/divi-form-builder/includes/modules/FormField/FormField.php
|
||||
*
|
||||
*/
|
||||
function add_form_builder_dates_patch() {
|
||||
$handle = 'form_builder_dates_patch';
|
||||
$url = Fbpatch::root_url() . '/js/dates.js';
|
||||
$dependencies = array('jquery-ui-datepicker');
|
||||
$version = null;
|
||||
$defer = false;
|
||||
wp_enqueue_script($handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_form_builder_dates_patch', 22);
|
||||
|
||||
function view_date_post($form_id, $post_array) {
|
||||
error_log("post_array: " . json_encode($post_array));
|
||||
}
|
||||
add_action('df_before_insert_post', __NAMESPACE__.'\view_date_post', 10, 2);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* action about the submited post before inserting (we cannot modify it unfortunately)
|
||||
* - find any datepicker
|
||||
* - add class to their object to identify they are used by form builder
|
||||
* - save the date in acf format 'Ymd' in the options
|
||||
*
|
||||
* -> the date is output in edit form - 7505 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/modules/FormField/FormField.php
|
||||
* -> 845 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
|
||||
*
|
||||
*/
|
||||
//function process_form_acf_dates($form_id, $post_array) {
|
||||
// $acf_field_start = 'acf_date_hidden_for_';
|
||||
// $acf_date_fields = \FBPATCH\array_has_keys_starting_with($acf_field_start, $post_array);
|
||||
// if (empty($acf_date_fields)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// foreach ($acf_date_fields as $field) {
|
||||
// $acf_date = $post_array[$field];
|
||||
// $acf_field = substr($field, strlen($acf_field_start));
|
||||
// $new_date_text = $post_array['meta_input'][$acf_field];
|
||||
// $acf_key = $post_array['meta_input']['_'.$acf_field];
|
||||
// \FBPATCH\add_date_to_acf_object_class($acf_key, $acf_date);
|
||||
// Fbpatch::update_acf_date($post_array['ID'], $acf_key, $acf_date);
|
||||
// }
|
||||
//}
|
||||
//add_action('df_before_insert_post', __NAMESPACE__.'\process_form_acf_dates', 10, 2);
|
||||
//
|
||||
//
|
||||
///*
|
||||
//* to update a field object (so, globally)
|
||||
//* using `acf_update_field`
|
||||
//* -> 980 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/advanced-custom-fields/includes/acf-field-functions.php
|
||||
//*
|
||||
//*/
|
||||
//function add_date_to_acf_object_class($acf_id) {
|
||||
// $field = get_field_object($acf_id);
|
||||
// $field_class = $field['wrapper']['class'];
|
||||
// $field_classes = explode(' ', $field_class);
|
||||
// $class = Fbpatch::ACF_DATE_CLASS;
|
||||
//
|
||||
// $field_classes = array_filter($field_classes, function($value) {
|
||||
// $class = Fbpatch::ACF_DATE_CLASS;
|
||||
// if (strpos($value, $class) !== 0) {
|
||||
// return $value;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// $field_classes[] = $class;
|
||||
// $implode_class = implode(' ', $field_classes);
|
||||
// $field['wrapper']['class'] = $implode_class;
|
||||
// acf_update_field($field);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
///*
|
||||
//* here i use it to check if there are hidden field for acf dates
|
||||
//*
|
||||
//*/
|
||||
//function array_has_keys_starting_with($needle, &$haystack) {
|
||||
// $keys = array();
|
||||
// foreach ($haystack as $key => $value) {
|
||||
// if (strpos($key, $needle) === 0) {
|
||||
// $keys[] = $key;
|
||||
// }
|
||||
// }
|
||||
// return $keys;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
125
php/patches/hide_show.php
Normal file
125
php/patches/hide_show.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* prevents the meta data to be updated directly in the meta_post_update filter
|
||||
* because nor form_builder nor wp provides filters to modify post_array
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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("post_array: " . json_encode($post_array));
|
||||
|
||||
if (empty($post_array)) {
|
||||
//nothing to overwrite
|
||||
return Fbpatch::set_post_elements_to_forget(0, false, array());
|
||||
}
|
||||
if (!isset($post_array['meta_input']) || empty($post_array['meta_input'])) {
|
||||
//nothing to overwrite
|
||||
return Fbpatch::set_post_elements_to_forget(0, false, array());
|
||||
}
|
||||
// if post creation there will not be an ID
|
||||
if (!isset($post_array['ID']) || empty($post_array['ID'])) {
|
||||
//nothing to overwrite
|
||||
return Fbpatch::set_post_elements_to_forget(0, false, array());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* creating a meta_input list without the prefix
|
||||
*
|
||||
*/
|
||||
$raw_meta_input = $post_array['meta_input'];
|
||||
$meta_input = array();
|
||||
$prefix = 'de_fb_';
|
||||
foreach($raw_meta_input as $meta) {
|
||||
if (substr($meta, 0, strlen($prefix)) === $prefix) {
|
||||
$meta_input[] = substr($meta, strlen($prefix));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if there is meta to skip, init the variables
|
||||
*
|
||||
*/
|
||||
$to_skip = array();
|
||||
foreach($meta_input as $meta) {
|
||||
if (!isset($post_array[$meta])) {
|
||||
$to_skip[] = $meta;
|
||||
}
|
||||
}
|
||||
if (empty($to_skip)) {
|
||||
//nothing to overwrite
|
||||
return Fbpatch::set_post_elements_to_forget(0, false, array());
|
||||
}
|
||||
return Fbpatch::set_post_elements_to_forget($post_array["ID"], true, $to_skip);
|
||||
|
||||
}
|
||||
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));
|
||||
|
||||
Fbpatch::init_skip_hook();
|
||||
}
|
||||
add_action('df_before_insert_post', __NAMESPACE__.'\form_partner_before_insert', 10, 2);
|
||||
|
||||
/*
|
||||
* 235 : ../../../../wordpress_docker/volumes/wp_volume/wp-includes/meta.php
|
||||
* $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
|
||||
* "Returning a non-null value will effectively short-circuit the function."
|
||||
* filter is added in Fbpatch class
|
||||
*
|
||||
*/
|
||||
function filter_elements_to_skip($null, $object_id, $meta_key, $meta_value, $prev_value) {
|
||||
if (false === Fbpatch::is_post_id($object_id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (false === Fbpatch::is_to_skip($meta_key)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* 558 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
|
||||
* do_action( 'df_after_insert_post', $form_id, $post_id, $post_array );
|
||||
*
|
||||
*/
|
||||
function after_form_inserted($form_id, $post_id, $post_array) {
|
||||
//error_log("--form_id : " . json_encode($form_id));
|
||||
//error_log("post_id: " . json_encode($post_id));
|
||||
//error_log("post_array: " . json_encode($post_array));
|
||||
Fbpatch::end_skip_hook();
|
||||
}
|
||||
add_action('df_after_insert_post', __NAMESPACE__.'\after_form_inserted', 10, 3);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
25
php/patches/modals.php
Normal file
25
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
php/patches/urls.php
Normal file
30
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