You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was facing a really nasty bug. My actions were added correctly but did all receive a "failed fetch action" error. This was due to my arguments not being able to run through json_decode and therefor not being attached to my hook (resulting in a PHP too few arguments error). This is an example of my arguments:
As you can see, starting from the timestamp all the quotes are transformed into their HTML equivalent - this is due to wp_filter_post_kses sanitizing the post_content data.
WP prevents this from happening with their own JSON data (e.g. WP_Embed) by checking and removing the kses filters before inserting/updating the post. I've fixed the error by doing the same in ActionScheduler_wpPostStore method save_post_array:
$has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );
if ( $has_kses ) {
// Prevent KSES from corrupting JSON in post_content.kses_remove_filters();
}
$post_id = wp_insert_post($post_array);
if ( $has_kses ) {
kses_init_filters();
}
I can provide you with a pull request too..
Cheers
The text was updated successfully, but these errors were encountered:
dennisnissle
changed the title
wp_filter_post_kses quotes JSON on save_post_array
wp_filter_post_kses creates invalid JSON on save_post_array
May 30, 2019
Hi,
I was facing a really nasty bug. My actions were added correctly but did all receive a "failed fetch action" error. This was due to my arguments not being able to run through json_decode and therefor not being attached to my hook (resulting in a PHP too few arguments error). This is an example of my arguments:
This is the JSON being created within the post_content DB field (sanitized by WP)
As you can see, starting from the timestamp all the quotes are transformed into their HTML equivalent - this is due to
wp_filter_post_kses
sanitizing the post_content data.WP prevents this from happening with their own JSON data (e.g.
WP_Embed
) by checking and removing the kses filters before inserting/updating the post. I've fixed the error by doing the same inActionScheduler_wpPostStore
methodsave_post_array
:I can provide you with a pull request too..
Cheers
The text was updated successfully, but these errors were encountered: