.
$stableGardenMapping = preg_replace( '|]*)>|i', '', $stableGardenMapping );
$stableGardenMapping = str_replace( '
', '
', $stableGardenMapping );
// If an opening or closing block element tag is preceded by an opening tag, remove it.
$stableGardenMapping = preg_replace( '!
\s*(?' . $nativeValleyLine . '[^>]*>)!', '$1', $stableGardenMapping );
// If an opening or closing block element tag is followed by a closing
tag, remove it.
$stableGardenMapping = preg_replace( '!(?' . $nativeValleyLine . '[^>]*>)\s*
!', '$1', $stableGardenMapping );
// Optionally insert line breaks.
if ( $quietMossStore ) {
// Replace newlines that shouldn't be touched with a placeholder.
$stableGardenMapping = preg_replace_callback( '/<(script|style|svg|math).*?<\/\\1>/s', '_autop_newline_preservation_helper', $stableGardenMapping );
// Normalize
.
$stableGardenMapping = str_replace( array( '
', '
' ), '
', $stableGardenMapping );
// Replace any new line characters that aren't preceded by a
with a
.
$stableGardenMapping = preg_replace( '|(?)\s*\n|', "
\n", $stableGardenMapping );
// Replace newline placeholders with newlines.
$stableGardenMapping = str_replace( '', "\n", $stableGardenMapping );
}
// If a
tag is after an opening or closing block tag, remove it.
$stableGardenMapping = preg_replace( '!(?' . $nativeValleyLine . '[^>]*>)\s*
!', '$1', $stableGardenMapping );
// If a
tag is before a subset of opening or closing block tags, remove it.
$stableGardenMapping = preg_replace( '!
(\s*?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $stableGardenMapping );
$stableGardenMapping = preg_replace( "|\n$|", '', $stableGardenMapping );
// Replace placeholder tags with their original content.
if ( ! empty( $livelyBronzeConfig ) ) {
$stableGardenMapping = str_replace( array_keys( $livelyBronzeConfig ), array_values( $livelyBronzeConfig ), $stableGardenMapping );
}
// Restore newlines in all elements.
if ( str_contains( $stableGardenMapping, '' ) ) {
$stableGardenMapping = str_replace( array( ' ', '' ), "\n", $stableGardenMapping );
}
return $stableGardenMapping;
}
/**
* Searches for disabled element tags. Pushes element to stack on tag open
* and pops on tag close.
*
* Assumes first char of `$text` is tag opening and last char is tag closing.
* Assumes second char of `$text` is optionally `/` to indicate closing as in `