File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1018,9 +1018,14 @@ private function get_user_id_from_request( $request ) {
10181018 * @return string The normalized content.
10191019 */
10201020 private function normalize_whitespace ( $ post_content ) {
1021- $ post_content = preg_replace ( '#<!-- /?wp:paragraph -->\s*<!-- /?wp:paragraph --># ' , PHP_EOL , $ post_content );
1022- $ post_content = preg_replace ( '#\n\s*\n+# ' , PHP_EOL , $ post_content );
1023- $ post_content = str_replace ( '' ' , "' " , $ post_content );
1021+ // First remove any Gutenberg tags with whitespace between them.
1022+ $ post_content = preg_replace ( '#<!-- /?wp:paragraph -->\s*<!-- /?wp:paragraph --># ' , '' , $ post_content );
1023+ // Then remove *all* remaining Gutenberg tags.
1024+ $ post_content = preg_replace ( '#<!-- /?wp:[a-zA-Z]+? --># ' , '' , $ post_content );
1025+ // Now remove any line breaks with whitespaces between them.
1026+ $ post_content = preg_replace ( '# ' . PHP_EOL . '\s* ' . PHP_EOL . '+# ' , '' , $ post_content );
1027+ // Finally remove all remaining line breaks.
1028+ $ post_content = str_replace ( PHP_EOL , '' , $ post_content );
10241029
10251030 return trim ( $ post_content );
10261031 }
You can’t perform that action at this time.
0 commit comments