PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 19.1 All 128 releases
wordpress-seo / src / helpers / string-helper.php

string-helper.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/helpers/string-helper.php

46 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Helpers;
4
5 /**
6 * A helper object for string operations.
7 */
8 class String_Helper {
9
10 /**
11 * Strips all HTML tags including script and style.
12 *
13 * @param string $text The text to strip the tags from.
14 *
15 * @return string The processed string.
16 */
17 public function strip_all_tags( $text ) {
18 return \wp_strip_all_tags( $text );
19 }
20
21 /**
22 * Standardize whitespace in a string.
23 *
24 * Replace line breaks, carriage returns, tabs with a space, then remove double spaces.
25 *
26 * @param string $text Text input to standardize.
27 *
28 * @return string
29 */
30 public function standardize_whitespace( $text ) {
31 return \trim( \str_replace( ' ', ' ', \str_replace( [ "\t", "\n", "\r", "\f" ], ' ', $text ) ) );
32 }
33
34 /**
35 * First strip out registered and enclosing shortcodes using native WordPress strip_shortcodes function.
36 * Then strip out the shortcodes with a filthy regex, because people don't properly register their shortcodes.
37 *
38 * @param string $text Input string that might contain shortcodes.
39 *
40 * @return string String without shortcodes.
41 */
42 public function strip_shortcode( $text ) {
43 return \preg_replace( '`\[[^\]]+\]`s', '', \strip_shortcodes( $text ) );
44 }
45 }
46