diff --git a/includes/classes/sync/push.php b/includes/classes/sync/push.php index 97d1be6c..3d82ffdd 100644 --- a/includes/classes/sync/push.php +++ b/includes/classes/sync/push.php @@ -253,6 +253,10 @@ public function maybe_do_item_update( $update ) { ); } + if ($result === false) { + wp_send_json_error( 'Failed to push content to Content Workflow' ); + } + return $result; } @@ -556,7 +560,12 @@ protected function set_post_field_value( $post_column ) { case 'post_excerpt': $el_value = wp_kses_post( $this->get_element_value() ); if ( 'post_content' === $post_column ) { - $value = apply_filters( 'the_content', $value ); + $value = $this->ensureShortcodesAreNotConvertedToHtml( + function ($value) { + return apply_filters( 'the_content', $value ); + }, + $value + ); } // There are super minor encoding issues we want to ignore. @@ -577,6 +586,41 @@ protected function set_post_field_value( $post_column ) { return $updated; } + private function ensureShortcodesAreNotConvertedToHtml(callable $callback, string $value): string + { + preg_match_all( + '/\[[\w\W]+?\]/', + $value, + $matches + ); + + foreach ($matches[0] as $match) { + $value = str_replace( + $match, + '' . base64_encode($match) . '', + $value + ); + } + + $value = $callback($value); + + preg_match_all( + '/([\w\W])+?<\/shortcode>/', + $value, + $matches + ); + + foreach ($matches[0] as $match) { + $value = str_replace( + $match, + base64_decode(strip_tags($match)), + $value + ); + } + + return $value; + } + /** * Sets the item config element value for WP taxonomy terms, * if it is determeined that the value changed.