126 lines
3.3 KiB
PHP
126 lines
3.3 KiB
PHP
<?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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|