On this page
normalize_whitespace( string $str ): string
Normalizes EOL characters and strips duplicate whitespace.
Parameters
$strstring Required-
The string to normalize.
Return
string The normalized string.
Source
File: wp-includes/formatting.php. View all references
function normalize_whitespace( $str ) {
$str = trim( $str );
$str = str_replace( "\r", "\n", $str );
$str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
return $str;
}
Related
Used By
| Used By | Description |
|---|---|
| WP_REST_Autosaves_Controller::create_post_autosave() wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php | Creates autosave for the specified post. |
| wp_create_post_autosave() wp-admin/includes/post.php | Creates autosave data for the specified post from |
| wp_text_diff() wp-includes/pluggable.php | Displays a human readable HTML representation of the difference between two strings. |
| wp_save_post_revision() wp-includes/revision.php | Creates a revision for the current version of a post. |
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/normalize_whitespace