Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#30389 closed defect (bug) (duplicate)

Scheduled posts delete iframes (filter HTML) on publish

Reported by: uplink3r's profile uplink3r Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Posts, Post Types Keywords: 2nd-opinion reporter-feedback
Focuses: Cc:


This is a follow-up to #22944. I have noticed this bug in WordPress 4.0, it's identical to the one in the mentioned ticket.

Change History (4)

#1 @uplink3r
10 years ago

I discovered it's being caused by a plugin that I wrote but here is the code for the plugin (slightly refactored). Obviously this code should do almost nothing as presented here.

Also it's important to note this bug ONLY happens on scheduled posts going to published, because this happens in wp_cron where the unfiltered_html permission doesn't exist for the guest user running the task.

function do_the_save( $post_id ){
	$content = get_post_field('post_content', $post_id);
	remove_action('save_post', __METHOD__);
	wp_update_post( array('ID' => $post_id, 'post_content' => $content) );
	add_action('save_post', __METHOD__);
add_action('save_post', 'do_the_save');
Last edited 10 years ago by uplink3r (previous) (diff)

#2 follow-up: @collinsinternet
10 years ago

  • Keywords 2nd-opinion reporter-feedback added

While I was able to duplicate your issue with your code, I do not feel that this is a WP Core issue.

The disconnect happens at wp_update_post() in your code where content gets sanitized. You could remove the 'content_save_pre' filter prior to wp_update_post() to resolve your issue.

remove_filter('content_save_pre', 'wp_filter_post_kses');
wp_update_post( array('ID' => $post_id, 'post_content' => $content) );
add_filter('content_save_pre', 'wp_filter_post_kses');

#3 @DrewAPicture
10 years ago

  • Component changed from General to Posts, Post Types

#4 in reply to: ↑ 2 @johnbillion
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Replying to collinsinternet:

While I was able to duplicate your issue with your code, I do not feel that this is a WP Core issue.

This is definitely a core issue.

This is a duplicate of #19373.

In addition, the tests added in [1174/tests] aren't adequate because the current user object is present, unlike when scheduled posts are published via WP-Cron.

Note: See TracTickets for help on using tickets.