From e8b6f11a8db95db84dc0a24506ad3c3cf18aa41c Mon Sep 17 00:00:00 2001 From: Enrico Battocchi Date: Wed, 15 Dec 2021 11:57:17 +0100 Subject: [PATCH 1/2] Remove kses filters on scheduled republish --- src/post-republisher.php | 2 ++ tests/post-republisher-test.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/post-republisher.php b/src/post-republisher.php index 40e2a188a..fef6b5437 100644 --- a/src/post-republisher.php +++ b/src/post-republisher.php @@ -199,7 +199,9 @@ public function republish_scheduled_post( $copy ) { return; } + \kses_remove_filters(); $this->republish( $copy, $original_post ); + \kses_init_filters(); $this->delete_copy( $copy->ID, $original_post->ID ); } diff --git a/tests/post-republisher-test.php b/tests/post-republisher-test.php index 649a5950c..6d6542668 100644 --- a/tests/post-republisher-test.php +++ b/tests/post-republisher-test.php @@ -255,6 +255,9 @@ public function test_republish_scheduled_post() { ->once() ->andReturn( $original ); + Monkey\Functions\expect( 'kses_remove_filters' ); + Monkey\Functions\expect( 'kses_init_filters' ); + $this->instance->expects( 'republish' )->with( $copy, $original )->once(); $this->instance->expects( 'delete_copy' )->with( $copy->ID, $original->ID )->once(); From 36005a0bdeec5dae4201fdaf4aa01ee36d4ea047 Mon Sep 17 00:00:00 2001 From: Enrico Battocchi Date: Wed, 15 Dec 2021 11:57:44 +0100 Subject: [PATCH 2/2] Remove unnecessary `wp_slash` --- src/post-republisher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/post-republisher.php b/src/post-republisher.php index fef6b5437..eca6ee3c3 100644 --- a/src/post-republisher.php +++ b/src/post-republisher.php @@ -326,7 +326,7 @@ protected function republish_post_elements( $post, $original_post ) { $_POST['ID'] = $original_post->ID; // Republish the original post. - $rewritten_post_id = \wp_update_post( \wp_slash( $post_to_be_rewritten ) ); + $rewritten_post_id = \wp_update_post( $post_to_be_rewritten ); if ( $rewritten_post_id === 0 ) { \wp_die( \esc_html__( 'An error occurred while republishing the post.', 'duplicate-post' ) );