hide show post elements works
This commit is contained in:
@@ -8,6 +8,176 @@ if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------------
|
||||
* strategy 2
|
||||
* prevent 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 (is_null($post_array) || 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());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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."
|
||||
*
|
||||
*/
|
||||
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', '');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------------
|
||||
* strategy 1
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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));
|
||||
// Fbpatch::set_post_array($post_array);
|
||||
//}
|
||||
//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::set_post_identification($post_array);
|
||||
//}
|
||||
//add_action('df_before_insert_post', __NAMESPACE__.'\form_partner_before_insert', 10, 2);
|
||||
|
||||
|
||||
/*
|
||||
* 4179 : ../../../../wordpress_docker/volumes/wp_volume/wp-includes/post.php
|
||||
*
|
||||
*/
|
||||
//function maybe_abort_insert_post($maybe_empty, $postarr) {
|
||||
// error_log("- in filter maybe empty, postarr: " . json_encode($postarr));
|
||||
// $prevent = Fbpatch::should_prevent_insert($postarr);
|
||||
// error_log("prevent: " . json_encode($prevent));
|
||||
// return false;
|
||||
//}
|
||||
//add_filter( 'wp_insert_post_empty_content', __NAMESPACE__.'\maybe_abort_insert_post', 10, 2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------------------
|
||||
* researches
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 4674 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/modules/Form/Form.php
|
||||
*
|
||||
@@ -22,56 +192,13 @@ if (!defined('ABSPATH')) {
|
||||
//}
|
||||
//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("post_array: " . json_encode($post_array));
|
||||
Fbpatch::set_post_array($post_array);
|
||||
}
|
||||
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::set_post_identification($post_array);
|
||||
}
|
||||
add_action('df_before_insert_post', __NAMESPACE__.'\form_partner_before_insert', 10, 2);
|
||||
|
||||
|
||||
/*
|
||||
* 4179 : ../../../../wordpress_docker/volumes/wp_volume/wp-includes/post.php
|
||||
*
|
||||
*/
|
||||
function maybe_abort_insert_post($maybe_empty, $postarr) {
|
||||
error_log("- in filter maybe empty, postarr: " . json_encode($postarr));
|
||||
$prevent = Fbpatch::should_prevent_insert($postarr);
|
||||
error_log("prevent: " . json_encode($prevent));
|
||||
return false;
|
||||
}
|
||||
add_filter( 'wp_insert_post_empty_content', __NAMESPACE__.'\maybe_abort_insert_post', 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 );
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
function test_attachment_filter($data, $postarr, $unsanitized_postarr, $update) {
|
||||
error_log("-- in test_attachment_filter");
|
||||
error_log("data: " . json_encode($data));
|
||||
error_log("postarr: " . json_encode($postarr));
|
||||
error_log("unsanitized_postarr: " . json_encode($unsanitized_postarr));
|
||||
error_log("update: " . json_encode($update));
|
||||
}
|
||||
//function test_attachment_filter($data, $postarr, $unsanitized_postarr, $update) {
|
||||
// error_log("-- in test_attachment_filter");
|
||||
// error_log("data: " . json_encode($data));
|
||||
// error_log("postarr: " . json_encode($postarr));
|
||||
// error_log("unsanitized_postarr: " . json_encode($unsanitized_postarr));
|
||||
// error_log("update: " . json_encode($update));
|
||||
//}
|
||||
//add_filter( 'wp_insert_attachment_data', __NAMESPACE__.'\test_attachment_filter', 10, 4);
|
||||
|
||||
|
||||
@@ -80,17 +207,16 @@ function test_attachment_filter($data, $postarr, $unsanitized_postarr, $update)
|
||||
* $data = apply_filters( 'wp_insert_post_data', $data, $postarr, $unsanitized_postarr, $update );
|
||||
*
|
||||
*/
|
||||
function test_post_filter($data, $postarr, $unsanitized_postarr, $update) {
|
||||
error_log("-- in test_post_filter");
|
||||
error_log("data: " . json_encode($data));
|
||||
error_log("postarr: " . json_encode($postarr));
|
||||
error_log("unsanitized_postarr: " . json_encode($unsanitized_postarr));
|
||||
error_log("update: " . json_encode($update));
|
||||
return $data;
|
||||
}
|
||||
//function test_post_filter($data, $postarr, $unsanitized_postarr, $update) {
|
||||
// error_log("-- in test_post_filter");
|
||||
// error_log("data: " . json_encode($data));
|
||||
// error_log("postarr: " . json_encode($postarr));
|
||||
// error_log("unsanitized_postarr: " . json_encode($unsanitized_postarr));
|
||||
// error_log("update: " . json_encode($update));
|
||||
// return $data;
|
||||
//}
|
||||
//add_filter('wp_insert_post_data', __NAMESPACE__.'\test_post_filter', 10, 4);
|
||||
|
||||
|
||||
/*
|
||||
* 4558 : update_post_meta( $post_id, $field, $value );
|
||||
* 2552 : ../../../../wordpress_docker/volumes/wp_volume/wp-includes/post.php
|
||||
@@ -104,6 +230,15 @@ function test_post_filter($data, $postarr, $unsanitized_postarr, $update) {
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* strategy 2 :
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user