| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Main WordPress Formatting API. 4 * 5 * Handles many functions for formatting output. 6 * 7 * @package WordPress 8 */ 9 10 /** 11 * Replaces common plain text characters with formatted entities. 12 * 13 * Returns given text with transformations of quotes into smart quotes, apostrophes, 14 * dashes, ellipses, the trademark symbol, and the multiplication symbol. 15 * 16 * As an example, 17 * 18 * 'cause today's effort makes it worth tomorrow's "holiday" ... 19 * 20 * Becomes: 21 * 22 * ’cause today’s effort makes it worth tomorrow’s “holiday” … 23 * 24 * Code within certain HTML blocks are skipped. 25 * 26 * Do not use this function before the {@see 'init'} action hook; everything will break. 27 * 28 * @since 0.71 29 * 30 * @global array $wp_cockneyreplace Array of formatted entities for certain common phrases. 31 * @global array $shortcode_tags 32 * 33 * @param string $text The text to be formatted. 34 * @param bool $reset Set to true for unit testing. Translated patterns will reset. 35 * @return string The string replaced with HTML entities. 36 */ 37 function wptexturize( $text, $reset = false ) { 38 global $wp_cockneyreplace, $shortcode_tags; 39 static $static_characters = null, 40 $static_replacements = null, 41 $dynamic_characters = null, 42 $dynamic_replacements = null, 43 $default_no_texturize_tags = null, 44 $default_no_texturize_shortcodes = null, 45 $run_texturize = true, 46 $apos = null, 47 $prime = null, 48 $double_prime = null, 49 $opening_quote = null, 50 $closing_quote = null, 51 $opening_single_quote = null, 52 $closing_single_quote = null, 53 $open_q_flag = '<!--oq-->', 54 $open_sq_flag = '<!--osq-->', 55 $apos_flag = '<!--apos-->'; 56 57 // If there's nothing to do, just stop. 58 if ( empty( $text ) || false === $run_texturize ) { 59 return $text; 60 } 61 62 // Set up static variables. Run once only. 63 if ( $reset || ! isset( $static_characters ) ) { 64 /** 65 * Filters whether to skip running wptexturize(). 66 * 67 * Returning false from the filter will effectively short-circuit wptexturize() 68 * and return the original text passed to the function instead. 69 * 70 * The filter runs only once, the first time wptexturize() is called. 71 * 72 * @since 4.0.0 73 * 74 * @see wptexturize() 75 * 76 * @param bool $run_texturize Whether to short-circuit wptexturize(). 77 */ 78 $run_texturize = apply_filters( 'run_wptexturize', $run_texturize ); 79 if ( false === $run_texturize ) { 80 return $text; 81 } 82 83 /* translators: Opening curly double quote. */ 84 $opening_quote = _x( '“', 'opening curly double quote' ); 85 /* translators: Closing curly double quote. */ 86 $closing_quote = _x( '”', 'closing curly double quote' ); 87 88 /* translators: Apostrophe, for example in 'cause or can't. */ 89 $apos = _x( '’', 'apostrophe' ); 90 91 /* translators: Prime, for example in 9' (nine feet). */ 92 $prime = _x( '′', 'prime' ); 93 /* translators: Double prime, for example in 9" (nine inches). */ 94 $double_prime = _x( '″', 'double prime' ); 95 96 /* translators: Opening curly single quote. */ 97 $opening_single_quote = _x( '‘', 'opening curly single quote' ); 98 /* translators: Closing curly single quote. */ 99 $closing_single_quote = _x( '’', 'closing curly single quote' ); 100 101 /* translators: En dash. */ 102 $en_dash = _x( '–', 'en dash' ); 103 /* translators: Em dash. */ 104 $em_dash = _x( '—', 'em dash' ); 105 106 $default_no_texturize_tags = array( 'pre', 'code', 'kbd', 'style', 'script', 'tt' ); 107 $default_no_texturize_shortcodes = array( 'code' ); 108 109 // If a plugin has provided an autocorrect array, use it. 110 if ( isset( $wp_cockneyreplace ) ) { 111 $cockney = array_keys( $wp_cockneyreplace ); 112 $cockneyreplace = array_values( $wp_cockneyreplace ); 113 } else { 114 /* 115 * translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, 116 * for example... 'We do not have enough words yet'... is a typical quoted phrase. But when we write 117 * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. 118 */ 119 $cockney = explode( 120 ',', 121 _x( 122 "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", 123 'Comma-separated list of words to texturize in your language' 124 ) 125 ); 126 127 $cockneyreplace = explode( 128 ',', 129 _x( 130 '’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', 131 'Comma-separated list of replacement words in your language' 132 ) 133 ); 134 } 135 136 $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); 137 $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 138 139 /* 140 * Pattern-based replacements of characters. 141 * Sort the remaining patterns into several arrays for performance tuning. 142 */ 143 $dynamic_characters = array( 144 'apos' => array(), 145 'quote' => array(), 146 'dash' => array(), 147 ); 148 $dynamic_replacements = array( 149 'apos' => array(), 150 'quote' => array(), 151 'dash' => array(), 152 ); 153 $dynamic = array(); 154 $spaces = wp_spaces_regexp(); 155 156 // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. 157 if ( "'" !== $apos || "'" !== $closing_single_quote ) { 158 $dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote; 159 } 160 if ( "'" !== $apos || '"' !== $closing_quote ) { 161 $dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote; 162 } 163 164 // '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. 165 if ( "'" !== $apos ) { 166 $dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag; 167 } 168 169 // Quoted numbers like '0.42'. 170 if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { 171 $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote; 172 } 173 174 // Single quote at start, or preceded by (, {, <, [, ", -, or spaces. 175 if ( "'" !== $opening_single_quote ) { 176 $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag; 177 } 178 179 // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. 180 if ( "'" !== $apos ) { 181 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag; 182 } 183 184 $dynamic_characters['apos'] = array_keys( $dynamic ); 185 $dynamic_replacements['apos'] = array_values( $dynamic ); 186 $dynamic = array(); 187 188 // Quoted numbers like "42". 189 if ( '"' !== $opening_quote && '"' !== $closing_quote ) { 190 $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote; 191 } 192 193 // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. 194 if ( '"' !== $opening_quote ) { 195 $dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $open_q_flag; 196 } 197 198 $dynamic_characters['quote'] = array_keys( $dynamic ); 199 $dynamic_replacements['quote'] = array_values( $dynamic ); 200 $dynamic = array(); 201 202 // Dashes and spaces. 203 $dynamic['/---/'] = $em_dash; 204 $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash; 205 $dynamic['/(?<!xn)--/'] = $en_dash; 206 $dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash; 207 208 $dynamic_characters['dash'] = array_keys( $dynamic ); 209 $dynamic_replacements['dash'] = array_values( $dynamic ); 210 } 211 212 // Must do this every time in case plugins use these filters in a context sensitive manner. 213 /** 214 * Filters the list of HTML elements not to texturize. 215 * 216 * @since 2.8.0 217 * 218 * @param string[] $default_no_texturize_tags An array of HTML element names. 219 */ 220 $no_texturize_tags = apply_filters( 'no_texturize_tags', $default_no_texturize_tags ); 221 /** 222 * Filters the list of shortcodes not to texturize. 223 * 224 * @since 2.8.0 225 * 226 * @param string[] $default_no_texturize_shortcodes An array of shortcode names. 227 */ 228 $no_texturize_shortcodes = apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes ); 229 230 $no_texturize_tags_stack = array(); 231 $no_texturize_shortcodes_stack = array(); 232 233 // Look for shortcodes and HTML elements. 234 235 preg_match_all( '@\[/?([^<>&/\[\]\x00-\x20=]++)@', $text, $matches ); 236 $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); 237 $found_shortcodes = ! empty( $tagnames ); 238 $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; 239 $regex = _get_wptexturize_split_regex( $shortcode_regex ); 240 241 $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); 242 243 foreach ( $textarr as &$curl ) { 244 // Only call _wptexturize_pushpop_element if $curl is a delimiter. 245 $first = $curl[0]; 246 if ( '<' === $first ) { 247 if ( str_starts_with( $curl, '<!--' ) ) { 248 // This is an HTML comment delimiter. 249 continue; 250 } else { 251 // This is an HTML element delimiter. 252 253 // Replace each & with & unless it already looks like an entity. 254 $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); 255 256 _wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags ); 257 } 258 } elseif ( '' === trim( $curl ) ) { 259 // This is a newline between delimiters. Performance improves when we check this. 260 continue; 261 262 } elseif ( '[' === $first && $found_shortcodes && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) { 263 // This is a shortcode delimiter. 264 265 if ( ! str_starts_with( $curl, '[[' ) && ! str_ends_with( $curl, ']]' ) ) { 266 // Looks like a normal shortcode. 267 _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes ); 268 } else { 269 // Looks like an escaped shortcode. 270 continue; 271 } 272 } elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) { 273 // This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize. 274 275 $curl = str_replace( $static_characters, $static_replacements, $curl ); 276 277 if ( str_contains( $curl, "'" ) ) { 278 $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); 279 $curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote ); 280 $curl = str_replace( $apos_flag, $apos, $curl ); 281 $curl = str_replace( $open_sq_flag, $opening_single_quote, $curl ); 282 } 283 if ( str_contains( $curl, '"' ) ) { 284 $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); 285 $curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote ); 286 $curl = str_replace( $open_q_flag, $opening_quote, $curl ); 287 } 288 if ( str_contains( $curl, '-' ) ) { 289 $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); 290 } 291 292 // 9x9 (times), but never 0x9999. 293 if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) { 294 // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! 295 $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl ); 296 } 297 298 // Replace each & with & unless it already looks like an entity. 299 $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); 300 } 301 } 302 303 return implode( '', $textarr ); 304 } 305 306 /** 307 * Implements a logic tree to determine whether or not "7'." represents seven feet, 308 * then converts the special char into either a prime char or a closing quote char. 309 * 310 * @since 4.3.0 311 * 312 * @param string $haystack The plain text to be searched. 313 * @param string $needle The character to search for such as ' or ". 314 * @param string $prime The prime char to use for replacement. 315 * @param string $open_quote The opening quote char. Opening quote replacement must be 316 * accomplished already. 317 * @param string $close_quote The closing quote char to use for replacement. 318 * @return string The $haystack value after primes and quotes replacements. 319 */ 320 function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) { 321 $spaces = wp_spaces_regexp(); 322 $flag = '<!--wp-prime-or-quote-->'; 323 $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ')/'; 324 $prime_pattern = "/(?<=\\d)$needle/"; 325 $flag_after_digit = "/(?<=\\d)$flag/"; 326 $flag_no_digit = "/(?<!\\d)$flag/"; 327 328 $sentences = explode( $open_quote, $haystack ); 329 330 foreach ( $sentences as $key => &$sentence ) { 331 if ( ! str_contains( $sentence, $needle ) ) { 332 continue; 333 } elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { 334 $sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); 335 if ( $count > 1 ) { 336 // This sentence appears to have multiple closing quotes. Attempt Vulcan logic. 337 $sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 ); 338 if ( 0 === $count2 ) { 339 // Try looking for a quote followed by a period. 340 $count2 = substr_count( $sentence, "$flag." ); 341 if ( $count2 > 0 ) { 342 // Assume the rightmost quote-period match is the end of quotation. 343 $pos = strrpos( $sentence, "$flag." ); 344 } else { 345 /* 346 * When all else fails, make the rightmost candidate a closing quote. 347 * This is most likely to be problematic in the context of bug #18549. 348 */ 349 $pos = strrpos( $sentence, $flag ); 350 } 351 $sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) ); 352 } 353 // Use conventional replacement on any remaining primes and quotes. 354 $sentence = preg_replace( $prime_pattern, $prime, $sentence ); 355 $sentence = preg_replace( $flag_after_digit, $prime, $sentence ); 356 $sentence = str_replace( $flag, $close_quote, $sentence ); 357 } elseif ( 1 === $count ) { 358 // Found only one closing quote candidate, so give it priority over primes. 359 $sentence = str_replace( $flag, $close_quote, $sentence ); 360 $sentence = preg_replace( $prime_pattern, $prime, $sentence ); 361 } else { 362 // No closing quotes found. Just run primes pattern. 363 $sentence = preg_replace( $prime_pattern, $prime, $sentence ); 364 } 365 } else { 366 $sentence = preg_replace( $prime_pattern, $prime, $sentence ); 367 $sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); 368 } 369 if ( '"' === $needle && str_contains( $sentence, '"' ) ) { 370 $sentence = str_replace( '"', $close_quote, $sentence ); 371 } 372 } 373 374 return implode( $open_quote, $sentences ); 375 } 376 377 /** 378 * Searches for disabled element tags. Pushes element to stack on tag open 379 * and pops on tag close. 380 * 381 * Assumes first char of `$text` is tag opening and last char is tag closing. 382 * Assumes second char of `$text` is optionally `/` to indicate closing as in `</html>`. 383 * 384 * @since 2.9.0 385 * @access private 386 * 387 * @param string $text Text to check. Must be a tag like `<html>` or `[shortcode]`. 388 * @param string[] $stack Array of open tag elements. 389 * @param string[] $disabled_elements Array of tag names to match against. Spaces are not allowed in tag names. 390 */ 391 function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { 392 // Is it an opening tag or closing tag? 393 if ( isset( $text[1] ) && '/' !== $text[1] ) { 394 $opening_tag = true; 395 $name_offset = 1; 396 } elseif ( 0 === count( $stack ) ) { 397 // Stack is empty. Just stop. 398 return; 399 } else { 400 $opening_tag = false; 401 $name_offset = 2; 402 } 403 404 // Parse out the tag name. 405 $space = strpos( $text, ' ' ); 406 if ( false === $space ) { 407 $space = -1; 408 } else { 409 $space -= $name_offset; 410 } 411 $tag = substr( $text, $name_offset, $space ); 412 413 // Handle disabled tags. 414 if ( in_array( $tag, $disabled_elements, true ) ) { 415 if ( $opening_tag ) { 416 /* 417 * This disables texturize until we find a closing tag of our type 418 * (e.g. <pre>) even if there was invalid nesting before that. 419 * 420 * Example: in the case <pre>sadsadasd</code>"baba"</pre> 421 * "baba" won't be texturized. 422 */ 423 424 array_push( $stack, $tag ); 425 } elseif ( end( $stack ) === $tag ) { 426 array_pop( $stack ); 427 } 428 } 429 } 430 431 /** 432 * Replaces double line breaks with paragraph elements. 433 * 434 * A group of regex replaces used to identify text formatted with newlines and 435 * replace double line breaks with HTML paragraph tags. The remaining line breaks 436 * after conversion become `<br />` tags, unless `$br` is set to '0' or 'false'. 437 * 438 * @since 0.71 439 * 440 * @param string $text The text which has to be formatted. 441 * @param bool $br Optional. If set, this will convert all remaining line breaks 442 * after paragraphing. Line breaks within `<script>`, `<style>`, 443 * and `<svg>` tags are not affected. Default true. 444 * @return string Text which has been converted into correct paragraph tags. 445 */ 446 function wpautop( $text, $br = true ) { 447 $pre_tags = array(); 448 449 if ( '' === trim( $text ) ) { 450 return ''; 451 } 452 453 // Just to make things a little easier, pad the end. 454 $text = $text . "\n"; 455 456 /* 457 * Pre tags shouldn't be touched by autop. 458 * Replace pre tags with placeholders and bring them back after autop. 459 */ 460 if ( str_contains( $text, '<pre' ) ) { 461 $text_parts = explode( '</pre>', $text ); 462 $last_part = array_pop( $text_parts ); 463 $text = ''; 464 $i = 0; 465 466 foreach ( $text_parts as $text_part ) { 467 $start = strpos( $text_part, '<pre' ); 468 469 // Malformed HTML? 470 if ( false === $start ) { 471 $text .= $text_part; 472 continue; 473 } 474 475 $name = "<pre wp-pre-tag-$i></pre>"; 476 $pre_tags[ $name ] = substr( $text_part, $start ) . '</pre>'; 477 478 $text .= substr( $text_part, 0, $start ) . $name; 479 ++$i; 480 } 481 482 $text .= $last_part; 483 } 484 // Change multiple <br>'s into two line breaks, which will turn into paragraphs. 485 $text = preg_replace( '|<br\s*/?>\s*<br\s*/?>|', "\n\n", $text ); 486 487 $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; 488 489 // Add a double line break above block-level opening tags. 490 $text = preg_replace( '!(<' . $allblocks . '[\s/>])!', "\n\n$1", $text ); 491 492 // Add a double line break below block-level closing tags. 493 $text = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $text ); 494 495 // Add a double line break after hr tags, which are self closing. 496 $text = preg_replace( '!(<hr\s*?/?>)!', "$1\n\n", $text ); 497 498 // Standardize newline characters to "\n". 499 $text = str_replace( array( "\r\n", "\r" ), "\n", $text ); 500 501 // Find newlines in all elements and add placeholders. 502 $text = wp_replace_in_html_tags( $text, array( "\n" => ' <!-- wpnl --> ' ) ); 503 504 // Collapse line breaks before and after <option> elements so they don't get autop'd. 505 if ( str_contains( $text, '<option' ) ) { 506 $text = preg_replace( '|\s*<option|', '<option', $text ); 507 $text = preg_replace( '|</option>\s*|', '</option>', $text ); 508 } 509 510 /* 511 * Collapse line breaks inside <object> elements, before <param> and <embed> elements 512 * so they don't get autop'd. 513 */ 514 if ( str_contains( $text, '</object>' ) ) { 515 $text = preg_replace( '|(<object[^>]*>)\s*|', '$1', $text ); 516 $text = preg_replace( '|\s*</object>|', '</object>', $text ); 517 $text = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $text ); 518 } 519 520 /* 521 * Collapse line breaks inside <audio> and <video> elements, 522 * before and after <source> and <track> elements. 523 */ 524 if ( str_contains( $text, '<source' ) || str_contains( $text, '<track' ) ) { 525 $text = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $text ); 526 $text = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $text ); 527 $text = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $text ); 528 } 529 530 // Collapse line breaks before and after <figcaption> elements. 531 if ( str_contains( $text, '<figcaption' ) ) { 532 $text = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $text ); 533 $text = preg_replace( '|</figcaption>\s*|', '</figcaption>', $text ); 534 } 535 536 // Remove more than two contiguous line breaks. 537 $text = preg_replace( "/\n\n+/", "\n\n", $text ); 538 539 // Split up the contents into an array of strings, separated by double line breaks. 540 $paragraphs = preg_split( '/\n\s*\n/', $text, -1, PREG_SPLIT_NO_EMPTY ); 541 542 // Reset $text prior to rebuilding. 543 $text = ''; 544 545 // Rebuild the content as a string, wrapping every bit with a <p>. 546 foreach ( $paragraphs as $paragraph ) { 547 $text .= '<p>' . trim( $paragraph, "\n" ) . "</p>\n"; 548 } 549 550 // Under certain strange conditions it could create a P of entirely whitespace. 551 $text = preg_replace( '|<p>\s*</p>|', '', $text ); 552 553 // Add a closing <p> inside <div>, <address>, or <form> tag if missing. 554 $text = preg_replace( '!<p>([^<]+)</(div|address|form)>!', '<p>$1</p></$2>', $text ); 555 556 // If an opening or closing block element tag is wrapped in a <p>, unwrap it. 557 $text = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $text ); 558 559 // In some cases <li> may get wrapped in <p>, fix them. 560 $text = preg_replace( '|<p>(<li.+?)</p>|', '$1', $text ); 561 562 // If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>. 563 $text = preg_replace( '!<p><blockquote((?:[^>"\']|"[^"]*"|\'[^\']*\')*)>!i', '<blockquote$1><p>', $text ); 564 $text = str_replace( '</blockquote></p>', '</p></blockquote>', $text ); 565 566 // If an opening or closing block element tag is preceded by an opening <p> tag, remove it. 567 $text = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)!', '$1', $text ); 568 569 // If an opening or closing block element tag is followed by a closing <p> tag, remove it. 570 $text = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*</p>!', '$1', $text ); 571 572 // Optionally insert line breaks. 573 if ( $br ) { 574 // Replace newlines that shouldn't be touched with a placeholder. 575 $text = preg_replace_callback( '/<(script|style|svg|math).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text ); 576 577 // Normalize <br>. 578 $text = str_replace( array( '<br>', '<br/>' ), '<br />', $text ); 579 580 // Replace any new line characters that aren't preceded by a <br /> with a <br />. 581 $text = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $text ); 582 583 // Replace newline placeholders with newlines. 584 $text = str_replace( '<WPPreserveNewline />', "\n", $text ); 585 } 586 587 // If a <br /> tag is after an opening or closing block tag, remove it. 588 $text = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', '$1', $text ); 589 590 // If a <br /> tag is before a subset of opening or closing block tags, remove it. 591 $text = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $text ); 592 $text = preg_replace( "|\n</p>$|", '</p>', $text ); 593 594 // Replace placeholder <pre> tags with their original content. 595 if ( ! empty( $pre_tags ) ) { 596 $text = str_replace( array_keys( $pre_tags ), array_values( $pre_tags ), $text ); 597 } 598 599 // Restore newlines in all elements. 600 if ( str_contains( $text, '<!-- wpnl -->' ) ) { 601 $text = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $text ); 602 } 603 604 return $text; 605 } 606 607 /** 608 * Separates HTML elements and comments from the text. 609 * 610 * @since 4.2.4 611 * 612 * @param string $input The text which has to be formatted. 613 * @return string[] Array of the formatted text. 614 * 615 * @phpstan-return non-empty-list<string> 616 */ 617 function wp_html_split( $input ) { 618 return preg_split( get_html_split_regex(), $input, -1, PREG_SPLIT_DELIM_CAPTURE ); 619 } 620 621 /** 622 * Retrieves the regular expression for an HTML element. 623 * 624 * @since 4.4.0 625 * 626 * @return string The regular expression. 627 * 628 * @phpstan-return non-falsy-string 629 */ 630 function get_html_split_regex() { 631 /** @var non-falsy-string|null $regex */ 632 static $regex; 633 634 if ( ! isset( $regex ) ) { 635 // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation 636 $comments = 637 '!' // Start of comment, after the <. 638 . '(?:' // Unroll the loop: Consume everything until --> is found. 639 . '-(?!->)' // Dash not followed by end of comment. 640 . '[^\-]*+' // Consume non-dashes. 641 . ')*+' // Loop possessively. 642 . '(?:-->)?'; // End of comment. If not found, match all input. 643 644 $cdata = 645 '!\[CDATA\[' // Start of comment, after the <. 646 . '[^\]]*+' // Consume non-]. 647 . '(?:' // Unroll the loop: Consume everything until ]]> is found. 648 . '](?!]>)' // One ] not followed by end of comment. 649 . '[^\]]*+' // Consume non-]. 650 . ')*+' // Loop possessively. 651 . '(?:]]>)?'; // End of comment. If not found, match all input. 652 653 $escaped = 654 '(?=' // Is the element escaped? 655 . '!--' 656 . '|' 657 . '!\[CDATA\[' 658 . ')' 659 . '(?(?=!-)' // If yes, which type? 660 . $comments 661 . '|' 662 . $cdata 663 . ')'; 664 665 $regex = 666 '/(' // Capture the entire match. 667 . '<' // Find start of element. 668 . '(?' // Conditional expression follows. 669 . $escaped // Find end of escaped element. 670 . '|' // ...else... 671 . '[^>]*>?' // Find end of normal element. 672 . ')' 673 . ')/'; 674 // phpcs:enable 675 } 676 677 return $regex; 678 } 679 680 /** 681 * Retrieves the combined regular expression for HTML and shortcodes. 682 * 683 * @access private 684 * @ignore 685 * @internal This function will be removed in 4.5.0 per Shortcode API Roadmap. 686 * @since 4.4.0 687 * 688 * @param string $shortcode_regex Optional. The result from _get_wptexturize_shortcode_regex(). 689 * @return string The regular expression. 690 */ 691 function _get_wptexturize_split_regex( $shortcode_regex = '' ) { 692 static $html_regex; 693 694 if ( ! isset( $html_regex ) ) { 695 // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation 696 $comment_regex = 697 '!' // Start of comment, after the <. 698 . '(?:' // Unroll the loop: Consume everything until --> is found. 699 . '-(?!->)' // Dash not followed by end of comment. 700 . '[^\-]*+' // Consume non-dashes. 701 . ')*+' // Loop possessively. 702 . '(?:-->)?'; // End of comment. If not found, match all input. 703 704 $html_regex = // Needs replaced with wp_html_split() per Shortcode API Roadmap. 705 '<' // Find start of element. 706 . '(?(?=!--)' // Is this a comment? 707 . $comment_regex // Find end of comment. 708 . '|' 709 . '[^>]*>?' // Find end of element. If not found, match all input. 710 . ')'; 711 // phpcs:enable 712 } 713 714 if ( empty( $shortcode_regex ) ) { 715 $regex = '/(' . $html_regex . ')/'; 716 } else { 717 $regex = '/(' . $html_regex . '|' . $shortcode_regex . ')/'; 718 } 719 720 return $regex; 721 } 722 723 /** 724 * Retrieves the regular expression for shortcodes. 725 * 726 * @access private 727 * @ignore 728 * @since 4.4.0 729 * 730 * @param string[] $tagnames Array of shortcodes to find. 731 * @return string The regular expression. 732 */ 733 function _get_wptexturize_shortcode_regex( $tagnames ) { 734 $tagregexp = implode( '|', array_map( 'preg_quote', $tagnames ) ); 735 $tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex(). 736 // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation 737 $regex = 738 '\[' // Find start of shortcode. 739 . '[\/\[]?' // Shortcodes may begin with [/ or [[. 740 . $tagregexp // Only match registered shortcodes, because performance. 741 . '(?:' 742 . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. 743 . '|' 744 . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. 745 . ')*+' // Possessive critical. 746 . '\]' // Find end of shortcode. 747 . '\]?'; // Shortcodes may end with ]]. 748 // phpcs:enable 749 750 return $regex; 751 } 752 753 /** 754 * Replaces characters or phrases within HTML elements only. 755 * 756 * @since 4.2.3 757 * 758 * @param string $haystack The text which has to be formatted. 759 * @param array $replace_pairs In the form array('from' => 'to', ...). 760 * @return string The formatted text. 761 */ 762 function wp_replace_in_html_tags( $haystack, $replace_pairs ) { 763 // Find all elements. 764 $textarr = wp_html_split( $haystack ); 765 $changed = false; 766 767 // Optimize when searching for one item. 768 if ( 1 === count( $replace_pairs ) ) { 769 // Extract $needle and $replace. 770 $needle = array_key_first( $replace_pairs ); 771 $replace = $replace_pairs[ $needle ]; 772 773 // Loop through delimiters (elements) only. 774 for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { 775 if ( str_contains( $textarr[ $i ], $needle ) ) { 776 $textarr[ $i ] = str_replace( $needle, $replace, $textarr[ $i ] ); 777 $changed = true; 778 } 779 } 780 } else { 781 // Extract all $needles. 782 $needles = array_keys( $replace_pairs ); 783 784 // Loop through delimiters (elements) only. 785 for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { 786 foreach ( $needles as $needle ) { 787 if ( str_contains( $textarr[ $i ], $needle ) ) { 788 $textarr[ $i ] = strtr( $textarr[ $i ], $replace_pairs ); 789 $changed = true; 790 // After one strtr() break out of the foreach loop and look at next element. 791 break; 792 } 793 } 794 } 795 } 796 797 if ( $changed ) { 798 $haystack = implode( $textarr ); 799 } 800 801 return $haystack; 802 } 803 804 /** 805 * Newline preservation help function for wpautop(). 806 * 807 * @since 3.1.0 808 * @access private 809 * 810 * @param array $matches preg_replace_callback matches array 811 * @return string Text with newlines replaced with placeholders. 812 */ 813 function _autop_newline_preservation_helper( $matches ) { 814 return str_replace( "\n", '<WPPreserveNewline />', $matches[0] ); 815 } 816 817 /** 818 * Don't auto-p wrap shortcodes that stand alone. 819 * 820 * Ensures that shortcodes are not wrapped in `<p>...</p>`. 821 * 822 * @since 2.9.0 823 * 824 * @global array $shortcode_tags 825 * 826 * @param string $text The content. 827 * @return string The filtered content. 828 */ 829 function shortcode_unautop( $text ) { 830 global $shortcode_tags; 831 832 if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { 833 return $text; 834 } 835 836 $tagregexp = implode( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); 837 $spaces = wp_spaces_regexp(); 838 839 // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound,Universal.WhiteSpace.PrecisionAlignment.Found -- don't remove regex indentation 840 $pattern = 841 '/' 842 . '<p>' // Opening paragraph. 843 . '(?:' . $spaces . ')*+' // Optional leading whitespace. 844 . '(' // 1: The shortcode. 845 . '\\[' // Opening bracket. 846 . "($tagregexp)" // 2: Shortcode name. 847 . '(?![\\w-])' // Not followed by word character or hyphen. 848 // Unroll the loop: Inside the opening shortcode tag. 849 . '[^\\]\\/]*' // Not a closing bracket or forward slash. 850 . '(?:' 851 . '\\/(?!\\])' // A forward slash not followed by a closing bracket. 852 . '[^\\]\\/]*' // Not a closing bracket or forward slash. 853 . ')*?' 854 . '(?:' 855 . '\\/\\]' // Self closing tag and closing bracket. 856 . '|' 857 . '\\]' // Closing bracket. 858 . '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags. 859 . '[^\\[]*+' // Not an opening bracket. 860 . '(?:' 861 . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag. 862 . '[^\\[]*+' // Not an opening bracket. 863 . ')*+' 864 . '\\[\\/\\2\\]' // Closing shortcode tag. 865 . ')?' 866 . ')' 867 . ')' 868 . '(?:' . $spaces . ')*+' // Optional trailing whitespace. 869 . '<\\/p>' // Closing paragraph. 870 . '/'; 871 // phpcs:enable 872 873 return preg_replace( $pattern, '$1', $text ); 874 } 875 876 /** 877 * Checks to see if a string is utf8 encoded. 878 * 879 * NOTE: This function checks for 5-Byte sequences, UTF8 880 * has Bytes Sequences with a maximum length of 4. 881 * 882 * @author bmorel at ssi dot fr (modified) 883 * @since 1.2.1 884 * @deprecated 6.9.0 Use {@see wp_is_valid_utf8()} instead. 885 * 886 * @param string $str The string to be checked. 887 * @return bool True if $str fits a UTF-8 model, false otherwise. 888 */ 889 function seems_utf8( $str ) { 890 _deprecated_function( __FUNCTION__, '6.9.0', 'wp_is_valid_utf8()' ); 891 892 mbstring_binary_safe_encoding(); 893 $length = strlen( $str ); 894 reset_mbstring_encoding(); 895 896 for ( $i = 0; $i < $length; $i++ ) { 897 $c = ord( $str[ $i ] ); 898 899 if ( $c < 0x80 ) { 900 $n = 0; // 0bbbbbbb 901 } elseif ( ( $c & 0xE0 ) === 0xC0 ) { 902 $n = 1; // 110bbbbb 903 } elseif ( ( $c & 0xF0 ) === 0xE0 ) { 904 $n = 2; // 1110bbbb 905 } elseif ( ( $c & 0xF8 ) === 0xF0 ) { 906 $n = 3; // 11110bbb 907 } elseif ( ( $c & 0xFC ) === 0xF8 ) { 908 $n = 4; // 111110bb 909 } elseif ( ( $c & 0xFE ) === 0xFC ) { 910 $n = 5; // 1111110b 911 } else { 912 return false; // Does not match any model. 913 } 914 915 for ( $j = 0; $j < $n; $j++ ) { // n bytes matching 10bbbbbb follow? 916 if ( ( ++$i === $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) !== 0x80 ) ) { 917 return false; 918 } 919 } 920 } 921 922 return true; 923 } 924 925 /** 926 * Converts a number of special characters into their HTML entities. 927 * 928 * Specifically deals with: `&`, `<`, `>`, `"`, and `'`. 929 * 930 * `$quote_style` can be set to ENT_COMPAT to encode `"` to 931 * `"`, or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded. 932 * 933 * @since 1.2.2 934 * @since 5.5.0 `$quote_style` also accepts `ENT_XML1`. 935 * @access private 936 * 937 * @param string $text The text which is to be encoded. 938 * @param int|string $quote_style Optional. Converts double quotes if set to ENT_COMPAT, 939 * both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. 940 * Converts single and double quotes, as well as converting HTML 941 * named entities (that are not also XML named entities) to their 942 * code points if set to ENT_XML1. Also compatible with old values; 943 * converting single quotes if set to 'single', 944 * double if set to 'double' or both if otherwise set. 945 * Default is ENT_NOQUOTES. 946 * @param false|string $charset Optional. The character encoding of the string. Default false. 947 * @param bool $double_encode Optional. Whether to encode existing HTML entities. Default false. 948 * @return string The encoded text with HTML entities. 949 */ 950 function _wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { 951 $text = (string) $text; 952 953 if ( 0 === strlen( $text ) ) { 954 return ''; 955 } 956 957 // Don't bother if there are no specialchars - saves some processing. 958 if ( ! preg_match( '/[&<>"\']/', $text ) ) { 959 return $text; 960 } 961 962 // Account for the previous behavior of the function when the $quote_style is not an accepted value. 963 if ( empty( $quote_style ) ) { 964 $quote_style = ENT_NOQUOTES; 965 } elseif ( ENT_XML1 === $quote_style ) { 966 $quote_style = ENT_QUOTES | ENT_XML1; 967 } elseif ( ! in_array( $quote_style, array( ENT_NOQUOTES, ENT_COMPAT, ENT_QUOTES, 'single', 'double' ), true ) ) { 968 $quote_style = ENT_QUOTES; 969 } 970 971 $charset = _canonical_charset( $charset ? $charset : get_option( 'blog_charset' ) ); 972 973 $_quote_style = $quote_style; 974 975 if ( 'double' === $quote_style ) { 976 $quote_style = ENT_COMPAT; 977 $_quote_style = ENT_COMPAT; 978 } elseif ( 'single' === $quote_style ) { 979 $quote_style = ENT_NOQUOTES; 980 } 981 982 if ( ! $double_encode ) { 983 /* 984 * Guarantee every &entity; is valid, convert &garbage; into &garbage; 985 * This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable. 986 */ 987 $text = wp_kses_normalize_entities( $text, ( $quote_style & ENT_XML1 ) ? 'xml' : 'html' ); 988 } 989 990 $text = htmlspecialchars( $text, $quote_style, $charset, $double_encode ); 991 992 // Back-compat. 993 if ( 'single' === $_quote_style ) { 994 $text = str_replace( "'", ''', $text ); 995 } 996 997 return $text; 998 } 999 1000 /** 1001 * Converts a number of HTML entities into their special characters. 1002 * 1003 * Specifically deals with: `&`, `<`, `>`, `"`, and `'`. 1004 * 1005 * `$quote_style` can be set to ENT_COMPAT to decode `"` entities, 1006 * or ENT_QUOTES to do both `"` and `'`. Default is ENT_NOQUOTES where no quotes are decoded. 1007 * 1008 * @since 2.8.0 1009 * 1010 * @param string $text The text which is to be decoded. 1011 * @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, 1012 * both single and double if set to ENT_QUOTES or 1013 * none if set to ENT_NOQUOTES. 1014 * Also compatible with old _wp_specialchars() values; 1015 * converting single quotes if set to 'single', 1016 * double if set to 'double' or both if otherwise set. 1017 * Default is ENT_NOQUOTES. 1018 * @return string The decoded text without HTML entities. 1019 */ 1020 function wp_specialchars_decode( $text, $quote_style = ENT_NOQUOTES ) { 1021 $text = (string) $text; 1022 1023 if ( 0 === strlen( $text ) ) { 1024 return ''; 1025 } 1026 1027 // Don't bother if there are no entities - saves a lot of processing. 1028 if ( ! str_contains( $text, '&' ) ) { 1029 return $text; 1030 } 1031 1032 // Match the previous behavior of _wp_specialchars() when the $quote_style is not an accepted value. 1033 if ( empty( $quote_style ) ) { 1034 $quote_style = ENT_NOQUOTES; 1035 } elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { 1036 $quote_style = ENT_QUOTES; 1037 } 1038 1039 // More complete than get_html_translation_table( HTML_SPECIALCHARS ). 1040 $single = array( 1041 ''' => '\'', 1042 ''' => '\'', 1043 ); 1044 $single_preg = array( 1045 '/�*39;/' => ''', 1046 '/�*27;/i' => ''', 1047 ); 1048 $double = array( 1049 '"' => '"', 1050 '"' => '"', 1051 '"' => '"', 1052 ); 1053 $double_preg = array( 1054 '/�*34;/' => '"', 1055 '/�*22;/i' => '"', 1056 ); 1057 $others = array( 1058 '<' => '<', 1059 '<' => '<', 1060 '>' => '>', 1061 '>' => '>', 1062 '&' => '&', 1063 '&' => '&', 1064 '&' => '&', 1065 ); 1066 $others_preg = array( 1067 '/�*60;/' => '<', 1068 '/�*62;/' => '>', 1069 '/�*38;/' => '&', 1070 '/�*26;/i' => '&', 1071 ); 1072 1073 if ( ENT_QUOTES === $quote_style ) { 1074 $translation = array_merge( $single, $double, $others ); 1075 $translation_preg = array_merge( $single_preg, $double_preg, $others_preg ); 1076 } elseif ( ENT_COMPAT === $quote_style || 'double' === $quote_style ) { 1077 $translation = array_merge( $double, $others ); 1078 $translation_preg = array_merge( $double_preg, $others_preg ); 1079 } elseif ( 'single' === $quote_style ) { 1080 $translation = array_merge( $single, $others ); 1081 $translation_preg = array_merge( $single_preg, $others_preg ); 1082 } elseif ( ENT_NOQUOTES === $quote_style ) { 1083 $translation = $others; 1084 $translation_preg = $others_preg; 1085 } 1086 1087 // Remove zero padding on numeric entities. 1088 $text = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $text ); 1089 1090 // Replace characters according to translation table. 1091 return strtr( $text, $translation ); 1092 } 1093 1094 /** 1095 * Checks for invalid UTF8 in a string. 1096 * 1097 * Note! This function only performs its work if the `blog_charset` is set 1098 * to UTF-8. For all other values it returns the input text unchanged. 1099 * 1100 * Note! Unless requested, this returns an empty string if the input contains 1101 * any sequences of invalid UTF-8. To replace invalid byte sequences, pass 1102 * `true` as the optional `$strip` parameter. 1103 * 1104 * Consider using {@see wp_scrub_utf8()} instead which does not depend on 1105 * the value of `blog_charset`. 1106 * 1107 * Example: 1108 * 1109 * // The `blog_charset` is `latin1`, so this returns the input unchanged. 1110 * $every_possible_input === wp_check_invalid_utf8( $every_possible_input ); 1111 * 1112 * // Valid strings come through unchanged. 1113 * 'test' === wp_check_invalid_utf8( 'test' ); 1114 * 1115 * $invalid = "the byte \xC0 is never allowed in a UTF-8 string."; 1116 * 1117 * // Invalid strings are rejected outright. 1118 * '' === wp_check_invalid_utf8( $invalid ); 1119 * 1120 * // “Stripping” invalid sequences produces the replacement character instead. 1121 * "the byte \u{FFFD} is never allowed in a UTF-8 string." === wp_check_invalid_utf8( $invalid, true ); 1122 * 'the byte � is never allowed in a UTF-8 string.' === wp_check_invalid_utf8( $invalid, true ); 1123 * 1124 * @since 2.8.0 1125 * @since 6.9.0 Stripping replaces invalid byte sequences with the Unicode replacement character U+FFFD (�). 1126 * 1127 * @param string $text String which is expected to be encoded as UTF-8 unless `blog_charset` is another encoding. 1128 * @param bool $strip Optional. Whether to replace invalid sequences of bytes with the Unicode replacement 1129 * character (U+FFFD `�`). Default `false` returns an empty string for invalid UTF-8 inputs. 1130 * @return string The checked text. 1131 */ 1132 function wp_check_invalid_utf8( $text, $strip = false ) { 1133 $text = (string) $text; 1134 1135 if ( 0 === strlen( $text ) ) { 1136 return ''; 1137 } 1138 1139 // Store the site charset as a static to avoid multiple calls to get_option(). 1140 static $is_utf8 = null; 1141 if ( ! isset( $is_utf8 ) ) { 1142 $is_utf8 = is_utf8_charset(); 1143 } 1144 1145 if ( ! $is_utf8 || wp_is_valid_utf8( $text ) ) { 1146 return $text; 1147 } 1148 1149 return $strip 1150 ? wp_scrub_utf8( $text ) 1151 : ''; 1152 } 1153 1154 /** 1155 * Encodes the Unicode values to be used in the URI. 1156 * 1157 * @since 1.5.0 1158 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 1159 * 1160 * @param string $utf8_string String to encode. 1161 * @param int $length Max length of the string. 1162 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 1163 * @return string String with Unicode encoded for URI. 1164 */ 1165 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 1166 $unicode = ''; 1167 $values = array(); 1168 $num_octets = 1; 1169 $unicode_length = 0; 1170 1171 mbstring_binary_safe_encoding(); 1172 $string_length = strlen( $utf8_string ); 1173 reset_mbstring_encoding(); 1174 1175 for ( $i = 0; $i < $string_length; $i++ ) { 1176 1177 $value = ord( $utf8_string[ $i ] ); 1178 1179 if ( $value < 128 ) { 1180 $char = chr( $value ); 1181 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 1182 $encoded_char_length = strlen( $encoded_char ); 1183 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 1184 break; 1185 } 1186 $unicode .= $encoded_char; 1187 $unicode_length += $encoded_char_length; 1188 } else { 1189 if ( 0 === count( $values ) ) { 1190 if ( $value < 224 ) { 1191 $num_octets = 2; 1192 } elseif ( $value < 240 ) { 1193 $num_octets = 3; 1194 } else { 1195 $num_octets = 4; 1196 } 1197 } 1198 1199 $values[] = $value; 1200 1201 if ( $length && ( $unicode_length + ( $num_octets * 3 ) ) > $length ) { 1202 break; 1203 } 1204 if ( count( $values ) === $num_octets ) { 1205 for ( $j = 0; $j < $num_octets; $j++ ) { 1206 $unicode .= '%' . dechex( $values[ $j ] ); 1207 } 1208 1209 $unicode_length += $num_octets * 3; 1210 1211 $values = array(); 1212 $num_octets = 1; 1213 } 1214 } 1215 } 1216 1217 return $unicode; 1218 } 1219 1220 /** 1221 * Converts all accent characters to ASCII characters. 1222 * 1223 * If there are no accent characters, then the string given is just returned. 1224 * 1225 * **Accent characters converted:** 1226 * 1227 * Currency signs: 1228 * 1229 * | Code | Glyph | Replacement | Description | 1230 * | -------- | ----- | ----------- | ------------------- | 1231 * | U+00A3 | £ | (empty) | British Pound sign | 1232 * | U+20AC | € | E | Euro sign | 1233 * 1234 * Decompositions for Latin-1 Supplement: 1235 * 1236 * | Code | Glyph | Replacement | Description | 1237 * | ------- | ----- | ----------- | -------------------------------------- | 1238 * | U+00AA | ª | a | Feminine ordinal indicator | 1239 * | U+00BA | º | o | Masculine ordinal indicator | 1240 * | U+00C0 | À | A | Latin capital letter A with grave | 1241 * | U+00C1 | Á | A | Latin capital letter A with acute | 1242 * | U+00C2 |  | A | Latin capital letter A with circumflex | 1243 * | U+00C3 | à | A | Latin capital letter A with tilde | 1244 * | U+00C4 | Ä | A | Latin capital letter A with diaeresis | 1245 * | U+00C5 | Å | A | Latin capital letter A with ring above | 1246 * | U+00C6 | Æ | AE | Latin capital letter AE | 1247 * | U+00C7 | Ç | C | Latin capital letter C with cedilla | 1248 * | U+00C8 | È | E | Latin capital letter E with grave | 1249 * | U+00C9 | É | E | Latin capital letter E with acute | 1250 * | U+00CA | Ê | E | Latin capital letter E with circumflex | 1251 * | U+00CB | Ë | E | Latin capital letter E with diaeresis | 1252 * | U+00CC | Ì | I | Latin capital letter I with grave | 1253 * | U+00CD | Í | I | Latin capital letter I with acute | 1254 * | U+00CE | Î | I | Latin capital letter I with circumflex | 1255 * | U+00CF | Ï | I | Latin capital letter I with diaeresis | 1256 * | U+00D0 | Ð | D | Latin capital letter Eth | 1257 * | U+00D1 | Ñ | N | Latin capital letter N with tilde | 1258 * | U+00D2 | Ò | O | Latin capital letter O with grave | 1259 * | U+00D3 | Ó | O | Latin capital letter O with acute | 1260 * | U+00D4 | Ô | O | Latin capital letter O with circumflex | 1261 * | U+00D5 | Õ | O | Latin capital letter O with tilde | 1262 * | U+00D6 | Ö | O | Latin capital letter O with diaeresis | 1263 * | U+00D8 | Ø | O | Latin capital letter O with stroke | 1264 * | U+00D9 | Ù | U | Latin capital letter U with grave | 1265 * | U+00DA | Ú | U | Latin capital letter U with acute | 1266 * | U+00DB | Û | U | Latin capital letter U with circumflex | 1267 * | U+00DC | Ü | U | Latin capital letter U with diaeresis | 1268 * | U+00DD | Ý | Y | Latin capital letter Y with acute | 1269 * | U+00DE | Þ | TH | Latin capital letter Thorn | 1270 * | U+00DF | ß | s | Latin small letter sharp s | 1271 * | U+00E0 | à | a | Latin small letter a with grave | 1272 * | U+00E1 | á | a | Latin small letter a with acute | 1273 * | U+00E2 | â | a | Latin small letter a with circumflex | 1274 * | U+00E3 | ã | a | Latin small letter a with tilde | 1275 * | U+00E4 | ä | a | Latin small letter a with diaeresis | 1276 * | U+00E5 | å | a | Latin small letter a with ring above | 1277 * | U+00E6 | æ | ae | Latin small letter ae | 1278 * | U+00E7 | ç | c | Latin small letter c with cedilla | 1279 * | U+00E8 | è | e | Latin small letter e with grave | 1280 * | U+00E9 | é | e | Latin small letter e with acute | 1281 * | U+00EA | ê | e | Latin small letter e with circumflex | 1282 * | U+00EB | ë | e | Latin small letter e with diaeresis | 1283 * | U+00EC | ì | i | Latin small letter i with grave | 1284 * | U+00ED | í | i | Latin small letter i with acute | 1285 * | U+00EE | î | i | Latin small letter i with circumflex | 1286 * | U+00EF | ï | i | Latin small letter i with diaeresis | 1287 * | U+00F0 | ð | d | Latin small letter Eth | 1288 * | U+00F1 | ñ | n | Latin small letter n with tilde | 1289 * | U+00F2 | ò | o | Latin small letter o with grave | 1290 * | U+00F3 | ó | o | Latin small letter o with acute | 1291 * | U+00F4 | ô | o | Latin small letter o with circumflex | 1292 * | U+00F5 | õ | o | Latin small letter o with tilde | 1293 * | U+00F6 | ö | o | Latin small letter o with diaeresis | 1294 * | U+00F8 | ø | o | Latin small letter o with stroke | 1295 * | U+00F9 | ù | u | Latin small letter u with grave | 1296 * | U+00FA | ú | u | Latin small letter u with acute | 1297 * | U+00FB | û | u | Latin small letter u with circumflex | 1298 * | U+00FC | ü | u | Latin small letter u with diaeresis | 1299 * | U+00FD | ý | y | Latin small letter y with acute | 1300 * | U+00FE | þ | th | Latin small letter Thorn | 1301 * | U+00FF | ÿ | y | Latin small letter y with diaeresis | 1302 * 1303 * Decompositions for Latin Extended-A: 1304 * 1305 * | Code | Glyph | Replacement | Description | 1306 * | ------- | ----- | ----------- | ------------------------------------------------- | 1307 * | U+0100 | Ā | A | Latin capital letter A with macron | 1308 * | U+0101 | ā | a | Latin small letter a with macron | 1309 * | U+0102 | Ă | A | Latin capital letter A with breve | 1310 * | U+0103 | ă | a | Latin small letter a with breve | 1311 * | U+0104 | Ą | A | Latin capital letter A with ogonek | 1312 * | U+0105 | ą | a | Latin small letter a with ogonek | 1313 * | U+01006 | Ć | C | Latin capital letter C with acute | 1314 * | U+0107 | ć | c | Latin small letter c with acute | 1315 * | U+0108 | Ĉ | C | Latin capital letter C with circumflex | 1316 * | U+0109 | ĉ | c | Latin small letter c with circumflex | 1317 * | U+010A | Ċ | C | Latin capital letter C with dot above | 1318 * | U+010B | ċ | c | Latin small letter c with dot above | 1319 * | U+010C | Č | C | Latin capital letter C with caron | 1320 * | U+010D | č | c | Latin small letter c with caron | 1321 * | U+010E | Ď | D | Latin capital letter D with caron | 1322 * | U+010F | ď | d | Latin small letter d with caron | 1323 * | U+0110 | Đ | D | Latin capital letter D with stroke | 1324 * | U+0111 | đ | d | Latin small letter d with stroke | 1325 * | U+0112 | Ē | E | Latin capital letter E with macron | 1326 * | U+0113 | ē | e | Latin small letter e with macron | 1327 * | U+0114 | Ĕ | E | Latin capital letter E with breve | 1328 * | U+0115 | ĕ | e | Latin small letter e with breve | 1329 * | U+0116 | Ė | E | Latin capital letter E with dot above | 1330 * | U+0117 | ė | e | Latin small letter e with dot above | 1331 * | U+0118 | Ę | E | Latin capital letter E with ogonek | 1332 * | U+0119 | ę | e | Latin small letter e with ogonek | 1333 * | U+011A | Ě | E | Latin capital letter E with caron | 1334 * | U+011B | ě | e | Latin small letter e with caron | 1335 * | U+011C | Ĝ | G | Latin capital letter G with circumflex | 1336 * | U+011D | ĝ | g | Latin small letter g with circumflex | 1337 * | U+011E | Ğ | G | Latin capital letter G with breve | 1338 * | U+011F | ğ | g | Latin small letter g with breve | 1339 * | U+0120 | Ġ | G | Latin capital letter G with dot above | 1340 * | U+0121 | ġ | g | Latin small letter g with dot above | 1341 * | U+0122 | Ģ | G | Latin capital letter G with cedilla | 1342 * | U+0123 | ģ | g | Latin small letter g with cedilla | 1343 * | U+0124 | Ĥ | H | Latin capital letter H with circumflex | 1344 * | U+0125 | ĥ | h | Latin small letter h with circumflex | 1345 * | U+0126 | Ħ | H | Latin capital letter H with stroke | 1346 * | U+0127 | ħ | h | Latin small letter h with stroke | 1347 * | U+0128 | Ĩ | I | Latin capital letter I with tilde | 1348 * | U+0129 | ĩ | i | Latin small letter i with tilde | 1349 * | U+012A | Ī | I | Latin capital letter I with macron | 1350 * | U+012B | ī | i | Latin small letter i with macron | 1351 * | U+012C | Ĭ | I | Latin capital letter I with breve | 1352 * | U+012D | ĭ | i | Latin small letter i with breve | 1353 * | U+012E | Į | I | Latin capital letter I with ogonek | 1354 * | U+012F | į | i | Latin small letter i with ogonek | 1355 * | U+0130 | İ | I | Latin capital letter I with dot above | 1356 * | U+0131 | ı | i | Latin small letter dotless i | 1357 * | U+0132 | IJ | IJ | Latin capital ligature IJ | 1358 * | U+0133 | ij | ij | Latin small ligature ij | 1359 * | U+0134 | Ĵ | J | Latin capital letter J with circumflex | 1360 * | U+0135 | ĵ | j | Latin small letter j with circumflex | 1361 * | U+0136 | Ķ | K | Latin capital letter K with cedilla | 1362 * | U+0137 | ķ | k | Latin small letter k with cedilla | 1363 * | U+0138 | ĸ | k | Latin small letter Kra | 1364 * | U+0139 | Ĺ | L | Latin capital letter L with acute | 1365 * | U+013A | ĺ | l | Latin small letter l with acute | 1366 * | U+013B | Ļ | L | Latin capital letter L with cedilla | 1367 * | U+013C | ļ | l | Latin small letter l with cedilla | 1368 * | U+013D | Ľ | L | Latin capital letter L with caron | 1369 * | U+013E | ľ | l | Latin small letter l with caron | 1370 * | U+013F | Ŀ | L | Latin capital letter L with middle dot | 1371 * | U+0140 | ŀ | l | Latin small letter l with middle dot | 1372 * | U+0141 | Ł | L | Latin capital letter L with stroke | 1373 * | U+0142 | ł | l | Latin small letter l with stroke | 1374 * | U+0143 | Ń | N | Latin capital letter N with acute | 1375 * | U+0144 | ń | n | Latin small letter N with acute | 1376 * | U+0145 | Ņ | N | Latin capital letter N with cedilla | 1377 * | U+0146 | ņ | n | Latin small letter n with cedilla | 1378 * | U+0147 | Ň | N | Latin capital letter N with caron | 1379 * | U+0148 | ň | n | Latin small letter n with caron | 1380 * | U+0149 | ʼn | n | Latin small letter n preceded by apostrophe | 1381 * | U+014A | Ŋ | N | Latin capital letter Eng | 1382 * | U+014B | ŋ | n | Latin small letter Eng | 1383 * | U+014C | Ō | O | Latin capital letter O with macron | 1384 * | U+014D | ō | o | Latin small letter o with macron | 1385 * | U+014E | Ŏ | O | Latin capital letter O with breve | 1386 * | U+014F | ŏ | o | Latin small letter o with breve | 1387 * | U+0150 | Ő | O | Latin capital letter O with double acute | 1388 * | U+0151 | ő | o | Latin small letter o with double acute | 1389 * | U+0152 | Œ | OE | Latin capital ligature OE | 1390 * | U+0153 | œ | oe | Latin small ligature oe | 1391 * | U+0154 | Ŕ | R | Latin capital letter R with acute | 1392 * | U+0155 | ŕ | r | Latin small letter r with acute | 1393 * | U+0156 | Ŗ | R | Latin capital letter R with cedilla | 1394 * | U+0157 | ŗ | r | Latin small letter r with cedilla | 1395 * | U+0158 | Ř | R | Latin capital letter R with caron | 1396 * | U+0159 | ř | r | Latin small letter r with caron | 1397 * | U+015A | Ś | S | Latin capital letter S with acute | 1398 * | U+015B | ś | s | Latin small letter s with acute | 1399 * | U+015C | Ŝ | S | Latin capital letter S with circumflex | 1400 * | U+015D | ŝ | s | Latin small letter s with circumflex | 1401 * | U+015E | Ş | S | Latin capital letter S with cedilla | 1402 * | U+015F | ş | s | Latin small letter s with cedilla | 1403 * | U+0160 | Š | S | Latin capital letter S with caron | 1404 * | U+0161 | š | s | Latin small letter s with caron | 1405 * | U+0162 | Ţ | T | Latin capital letter T with cedilla | 1406 * | U+0163 | ţ | t | Latin small letter t with cedilla | 1407 * | U+0164 | Ť | T | Latin capital letter T with caron | 1408 * | U+0165 | ť | t | Latin small letter t with caron | 1409 * | U+0166 | Ŧ | T | Latin capital letter T with stroke | 1410 * | U+0167 | ŧ | t | Latin small letter t with stroke | 1411 * | U+0168 | Ũ | U | Latin capital letter U with tilde | 1412 * | U+0169 | ũ | u | Latin small letter u with tilde | 1413 * | U+016A | Ū | U | Latin capital letter U with macron | 1414 * | U+016B | ū | u | Latin small letter u with macron | 1415 * | U+016C | Ŭ | U | Latin capital letter U with breve | 1416 * | U+016D | ŭ | u | Latin small letter u with breve | 1417 * | U+016E | Ů | U | Latin capital letter U with ring above | 1418 * | U+016F | ů | u | Latin small letter u with ring above | 1419 * | U+0170 | Ű | U | Latin capital letter U with double acute | 1420 * | U+0171 | ű | u | Latin small letter u with double acute | 1421 * | U+0172 | Ų | U | Latin capital letter U with ogonek | 1422 * | U+0173 | ų | u | Latin small letter u with ogonek | 1423 * | U+0174 | Ŵ | W | Latin capital letter W with circumflex | 1424 * | U+0175 | ŵ | w | Latin small letter w with circumflex | 1425 * | U+0176 | Ŷ | Y | Latin capital letter Y with circumflex | 1426 * | U+0177 | ŷ | y | Latin small letter y with circumflex | 1427 * | U+0178 | Ÿ | Y | Latin capital letter Y with diaeresis | 1428 * | U+0179 | Ź | Z | Latin capital letter Z with acute | 1429 * | U+017A | ź | z | Latin small letter z with acute | 1430 * | U+017B | Ż | Z | Latin capital letter Z with dot above | 1431 * | U+017C | ż | z | Latin small letter z with dot above | 1432 * | U+017D | Ž | Z | Latin capital letter Z with caron | 1433 * | U+017E | ž | z | Latin small letter z with caron | 1434 * | U+017F | ſ | s | Latin small letter long s | 1435 * | U+01A0 | Ơ | O | Latin capital letter O with horn | 1436 * | U+01A1 | ơ | o | Latin small letter o with horn | 1437 * | U+01AF | Ư | U | Latin capital letter U with horn | 1438 * | U+01B0 | ư | u | Latin small letter u with horn | 1439 * | U+01CD | Ǎ | A | Latin capital letter A with caron | 1440 * | U+01CE | ǎ | a | Latin small letter a with caron | 1441 * | U+01CF | Ǐ | I | Latin capital letter I with caron | 1442 * | U+01D0 | ǐ | i | Latin small letter i with caron | 1443 * | U+01D1 | Ǒ | O | Latin capital letter O with caron | 1444 * | U+01D2 | ǒ | o | Latin small letter o with caron | 1445 * | U+01D3 | Ǔ | U | Latin capital letter U with caron | 1446 * | U+01D4 | ǔ | u | Latin small letter u with caron | 1447 * | U+01D5 | Ǖ | U | Latin capital letter U with diaeresis and macron | 1448 * | U+01D6 | ǖ | u | Latin small letter u with diaeresis and macron | 1449 * | U+01D7 | Ǘ | U | Latin capital letter U with diaeresis and acute | 1450 * | U+01D8 | ǘ | u | Latin small letter u with diaeresis and acute | 1451 * | U+01D9 | Ǚ | U | Latin capital letter U with diaeresis and caron | 1452 * | U+01DA | ǚ | u | Latin small letter u with diaeresis and caron | 1453 * | U+01DB | Ǜ | U | Latin capital letter U with diaeresis and grave | 1454 * | U+01DC | ǜ | u | Latin small letter u with diaeresis and grave | 1455 * 1456 * Decompositions for Latin Extended-B: 1457 * 1458 * | Code | Glyph | Replacement | Description | 1459 * | -------- | ----- | ----------- | ----------------------------------------- | 1460 * | U+018F | Ə | E | Latin capital letter Ə | 1461 * | U+0259 | ǝ | e | Latin small letter ǝ | 1462 * | U+0218 | Ș | S | Latin capital letter S with comma below | 1463 * | U+0219 | ș | s | Latin small letter s with comma below | 1464 * | U+021A | Ț | T | Latin capital letter T with comma below | 1465 * | U+021B | ț | t | Latin small letter t with comma below | 1466 * 1467 * Vowels with diacritic (Chinese, Hanyu Pinyin): 1468 * 1469 * | Code | Glyph | Replacement | Description | 1470 * | -------- | ----- | ----------- | ----------------------------------------------------- | 1471 * | U+0251 | ɑ | a | Latin small letter alpha | 1472 * | U+1EA0 | Ạ | A | Latin capital letter A with dot below | 1473 * | U+1EA1 | ạ | a | Latin small letter a with dot below | 1474 * | U+1EA2 | Ả | A | Latin capital letter A with hook above | 1475 * | U+1EA3 | ả | a | Latin small letter a with hook above | 1476 * | U+1EA4 | Ấ | A | Latin capital letter A with circumflex and acute | 1477 * | U+1EA5 | ấ | a | Latin small letter a with circumflex and acute | 1478 * | U+1EA6 | Ầ | A | Latin capital letter A with circumflex and grave | 1479 * | U+1EA7 | ầ | a | Latin small letter a with circumflex and grave | 1480 * | U+1EA8 | Ẩ | A | Latin capital letter A with circumflex and hook above | 1481 * | U+1EA9 | ẩ | a | Latin small letter a with circumflex and hook above | 1482 * | U+1EAA | Ẫ | A | Latin capital letter A with circumflex and tilde | 1483 * | U+1EAB | ẫ | a | Latin small letter a with circumflex and tilde | 1484 * | U+1EA6 | Ậ | A | Latin capital letter A with circumflex and dot below | 1485 * | U+1EAD | ậ | a | Latin small letter a with circumflex and dot below | 1486 * | U+1EAE | Ắ | A | Latin capital letter A with breve and acute | 1487 * | U+1EAF | ắ | a | Latin small letter a with breve and acute | 1488 * | U+1EB0 | Ằ | A | Latin capital letter A with breve and grave | 1489 * | U+1EB1 | ằ | a | Latin small letter a with breve and grave | 1490 * | U+1EB2 | Ẳ | A | Latin capital letter A with breve and hook above | 1491 * | U+1EB3 | ẳ | a | Latin small letter a with breve and hook above | 1492 * | U+1EB4 | Ẵ | A | Latin capital letter A with breve and tilde | 1493 * | U+1EB5 | ẵ | a | Latin small letter a with breve and tilde | 1494 * | U+1EB6 | Ặ | A | Latin capital letter A with breve and dot below | 1495 * | U+1EB7 | ặ | a | Latin small letter a with breve and dot below | 1496 * | U+1EB8 | Ẹ | E | Latin capital letter E with dot below | 1497 * | U+1EB9 | ẹ | e | Latin small letter e with dot below | 1498 * | U+1EBA | Ẻ | E | Latin capital letter E with hook above | 1499 * | U+1EBB | ẻ | e | Latin small letter e with hook above | 1500 * | U+1EBC | Ẽ | E | Latin capital letter E with tilde | 1501 * | U+1EBD | ẽ | e | Latin small letter e with tilde | 1502 * | U+1EBE | Ế | E | Latin capital letter E with circumflex and acute | 1503 * | U+1EBF | ế | e | Latin small letter e with circumflex and acute | 1504 * | U+1EC0 | Ề | E | Latin capital letter E with circumflex and grave | 1505 * | U+1EC1 | ề | e | Latin small letter e with circumflex and grave | 1506 * | U+1EC2 | Ể | E | Latin capital letter E with circumflex and hook above | 1507 * | U+1EC3 | ể | e | Latin small letter e with circumflex and hook above | 1508 * | U+1EC4 | Ễ | E | Latin capital letter E with circumflex and tilde | 1509 * | U+1EC5 | ễ | e | Latin small letter e with circumflex and tilde | 1510 * | U+1EC6 | Ệ | E | Latin capital letter E with circumflex and dot below | 1511 * | U+1EC7 | ệ | e | Latin small letter e with circumflex and dot below | 1512 * | U+1EC8 | Ỉ | I | Latin capital letter I with hook above | 1513 * | U+1EC9 | ỉ | i | Latin small letter i with hook above | 1514 * | U+1ECA | Ị | I | Latin capital letter I with dot below | 1515 * | U+1ECB | ị | i | Latin small letter i with dot below | 1516 * | U+1ECC | Ọ | O | Latin capital letter O with dot below | 1517 * | U+1ECD | ọ | o | Latin small letter o with dot below | 1518 * | U+1ECE | Ỏ | O | Latin capital letter O with hook above | 1519 * | U+1ECF | ỏ | o | Latin small letter o with hook above | 1520 * | U+1ED0 | Ố | O | Latin capital letter O with circumflex and acute | 1521 * | U+1ED1 | ố | o | Latin small letter o with circumflex and acute | 1522 * | U+1ED2 | Ồ | O | Latin capital letter O with circumflex and grave | 1523 * | U+1ED3 | ồ | o | Latin small letter o with circumflex and grave | 1524 * | U+1ED4 | Ổ | O | Latin capital letter O with circumflex and hook above | 1525 * | U+1ED5 | ổ | o | Latin small letter o with circumflex and hook above | 1526 * | U+1ED6 | Ỗ | O | Latin capital letter O with circumflex and tilde | 1527 * | U+1ED7 | ỗ | o | Latin small letter o with circumflex and tilde | 1528 * | U+1ED8 | Ộ | O | Latin capital letter O with circumflex and dot below | 1529 * | U+1ED9 | ộ | o | Latin small letter o with circumflex and dot below | 1530 * | U+1EDA | Ớ | O | Latin capital letter O with horn and acute | 1531 * | U+1EDB | ớ | o | Latin small letter o with horn and acute | 1532 * | U+1EDC | Ờ | O | Latin capital letter O with horn and grave | 1533 * | U+1EDD | ờ | o | Latin small letter o with horn and grave | 1534 * | U+1EDE | Ở | O | Latin capital letter O with horn and hook above | 1535 * | U+1EDF | ở | o | Latin small letter o with horn and hook above | 1536 * | U+1EE0 | Ỡ | O | Latin capital letter O with horn and tilde | 1537 * | U+1EE1 | ỡ | o | Latin small letter o with horn and tilde | 1538 * | U+1EE2 | Ợ | O | Latin capital letter O with horn and dot below | 1539 * | U+1EE3 | ợ | o | Latin small letter o with horn and dot below | 1540 * | U+1EE4 | Ụ | U | Latin capital letter U with dot below | 1541 * | U+1EE5 | ụ | u | Latin small letter u with dot below | 1542 * | U+1EE6 | Ủ | U | Latin capital letter U with hook above | 1543 * | U+1EE7 | ủ | u | Latin small letter u with hook above | 1544 * | U+1EE8 | Ứ | U | Latin capital letter U with horn and acute | 1545 * | U+1EE9 | ứ | u | Latin small letter u with horn and acute | 1546 * | U+1EEA | Ừ | U | Latin capital letter U with horn and grave | 1547 * | U+1EEB | ừ | u | Latin small letter u with horn and grave | 1548 * | U+1EEC | Ử | U | Latin capital letter U with horn and hook above | 1549 * | U+1EED | ử | u | Latin small letter u with horn and hook above | 1550 * | U+1EEE | Ữ | U | Latin capital letter U with horn and tilde | 1551 * | U+1EEF | ữ | u | Latin small letter u with horn and tilde | 1552 * | U+1EF0 | Ự | U | Latin capital letter U with horn and dot below | 1553 * | U+1EF1 | ự | u | Latin small letter u with horn and dot below | 1554 * | U+1EF2 | Ỳ | Y | Latin capital letter Y with grave | 1555 * | U+1EF3 | ỳ | y | Latin small letter y with grave | 1556 * | U+1EF4 | Ỵ | Y | Latin capital letter Y with dot below | 1557 * | U+1EF5 | ỵ | y | Latin small letter y with dot below | 1558 * | U+1EF6 | Ỷ | Y | Latin capital letter Y with hook above | 1559 * | U+1EF7 | ỷ | y | Latin small letter y with hook above | 1560 * | U+1EF8 | Ỹ | Y | Latin capital letter Y with tilde | 1561 * | U+1EF9 | ỹ | y | Latin small letter y with tilde | 1562 * 1563 * German (`de_DE`), German formal (`de_DE_formal`), German (Switzerland) formal (`de_CH`), 1564 * German (Switzerland) informal (`de_CH_informal`), and German (Austria) (`de_AT`) locales: 1565 * 1566 * | Code | Glyph | Replacement | Description | 1567 * | -------- | ----- | ----------- | --------------------------------------- | 1568 * | U+00C4 | Ä | Ae | Latin capital letter A with diaeresis | 1569 * | U+00E4 | ä | ae | Latin small letter a with diaeresis | 1570 * | U+00D6 | Ö | Oe | Latin capital letter O with diaeresis | 1571 * | U+00F6 | ö | oe | Latin small letter o with diaeresis | 1572 * | U+00DC | Ü | Ue | Latin capital letter U with diaeresis | 1573 * | U+00FC | ü | ue | Latin small letter u with diaeresis | 1574 * | U+1E9E | ẞ | SS | Latin capital letter sharp s | 1575 * | U+00DF | ß | ss | Latin small letter sharp s | 1576 * 1577 * Danish (`da_DK`) locale: 1578 * 1579 * | Code | Glyph | Replacement | Description | 1580 * | -------- | ----- | ----------- | --------------------------------------- | 1581 * | U+00C6 | Æ | Ae | Latin capital letter AE | 1582 * | U+00E6 | æ | ae | Latin small letter ae | 1583 * | U+00D8 | Ø | Oe | Latin capital letter O with stroke | 1584 * | U+00F8 | ø | oe | Latin small letter o with stroke | 1585 * | U+00C5 | Å | Aa | Latin capital letter A with ring above | 1586 * | U+00E5 | å | aa | Latin small letter a with ring above | 1587 * 1588 * Catalan (`ca`) locale: 1589 * 1590 * | Code | Glyph | Replacement | Description | 1591 * | -------- | ----- | ----------- | --------------------------------------- | 1592 * | U+00B7 | l·l | ll | Flown dot (between two Ls) | 1593 * 1594 * Serbian (`sr_RS`) and Bosnian (`bs_BA`) locales: 1595 * 1596 * | Code | Glyph | Replacement | Description | 1597 * | -------- | ----- | ----------- | --------------------------------------- | 1598 * | U+0110 | Đ | DJ | Latin capital letter D with stroke | 1599 * | U+0111 | đ | dj | Latin small letter d with stroke | 1600 * 1601 * @since 1.2.1 1602 * @since 4.6.0 Added locale support for `de_CH`, `de_CH_informal`, and `ca`. 1603 * @since 4.7.0 Added locale support for `sr_RS`. 1604 * @since 4.8.0 Added locale support for `bs_BA`. 1605 * @since 5.7.0 Added locale support for `de_AT`. 1606 * @since 6.0.0 Added the `$locale` parameter. 1607 * @since 6.1.0 Added Unicode NFC encoding normalization support. 1608 * @since 7.0.0 Added capital Eszett (U+1E9E) support for German locales. 1609 * 1610 * @param string $text Text that might have accent characters. 1611 * @param string $locale Optional. The locale to use for accent removal. Some character 1612 * replacements depend on the locale being used (e.g. 'de_DE'). 1613 * Defaults to the current locale. 1614 * @return string Filtered string with replaced "nice" characters. 1615 */ 1616 function remove_accents( $text, $locale = '' ) { 1617 if ( ! preg_match( '/[\x80-\xff]/', $text ) ) { 1618 return $text; 1619 } 1620 1621 if ( wp_is_valid_utf8( $text ) ) { 1622 1623 /* 1624 * Unicode sequence normalization from NFD (Normalization Form Decomposed) 1625 * to NFC (Normalization Form [Pre]Composed), the encoding used in this function. 1626 */ 1627 if ( function_exists( 'normalizer_is_normalized' ) 1628 && function_exists( 'normalizer_normalize' ) 1629 ) { 1630 if ( ! normalizer_is_normalized( $text ) ) { 1631 $text = normalizer_normalize( $text ); 1632 } 1633 } 1634 1635 $chars = array( 1636 // Decompositions for Latin-1 Supplement. 1637 'ª' => 'a', 1638 'º' => 'o', 1639 'À' => 'A', 1640 'Á' => 'A', 1641 'Â' => 'A', 1642 'Ã' => 'A', 1643 'Ä' => 'A', 1644 'Å' => 'A', 1645 'Æ' => 'AE', 1646 'Ç' => 'C', 1647 'È' => 'E', 1648 'É' => 'E', 1649 'Ê' => 'E', 1650 'Ë' => 'E', 1651 'Ì' => 'I', 1652 'Í' => 'I', 1653 'Î' => 'I', 1654 'Ï' => 'I', 1655 'Ð' => 'D', 1656 'Ñ' => 'N', 1657 'Ò' => 'O', 1658 'Ó' => 'O', 1659 'Ô' => 'O', 1660 'Õ' => 'O', 1661 'Ö' => 'O', 1662 'Ù' => 'U', 1663 'Ú' => 'U', 1664 'Û' => 'U', 1665 'Ü' => 'U', 1666 'Ý' => 'Y', 1667 'Þ' => 'TH', 1668 'ß' => 's', 1669 'à' => 'a', 1670 'á' => 'a', 1671 'â' => 'a', 1672 'ã' => 'a', 1673 'ä' => 'a', 1674 'å' => 'a', 1675 'æ' => 'ae', 1676 'ç' => 'c', 1677 'è' => 'e', 1678 'é' => 'e', 1679 'ê' => 'e', 1680 'ë' => 'e', 1681 'ì' => 'i', 1682 'í' => 'i', 1683 'î' => 'i', 1684 'ï' => 'i', 1685 'ð' => 'd', 1686 'ñ' => 'n', 1687 'ò' => 'o', 1688 'ó' => 'o', 1689 'ô' => 'o', 1690 'õ' => 'o', 1691 'ö' => 'o', 1692 'ø' => 'o', 1693 'ù' => 'u', 1694 'ú' => 'u', 1695 'û' => 'u', 1696 'ü' => 'u', 1697 'ý' => 'y', 1698 'þ' => 'th', 1699 'ÿ' => 'y', 1700 'Ø' => 'O', 1701 // Decompositions for Latin Extended-A. 1702 'Ā' => 'A', 1703 'ā' => 'a', 1704 'Ă' => 'A', 1705 'ă' => 'a', 1706 'Ą' => 'A', 1707 'ą' => 'a', 1708 'Ć' => 'C', 1709 'ć' => 'c', 1710 'Ĉ' => 'C', 1711 'ĉ' => 'c', 1712 'Ċ' => 'C', 1713 'ċ' => 'c', 1714 'Č' => 'C', 1715 'č' => 'c', 1716 'Ď' => 'D', 1717 'ď' => 'd', 1718 'Đ' => 'D', 1719 'đ' => 'd', 1720 'Ē' => 'E', 1721 'ē' => 'e', 1722 'Ĕ' => 'E', 1723 'ĕ' => 'e', 1724 'Ė' => 'E', 1725 'ė' => 'e', 1726 'Ę' => 'E', 1727 'ę' => 'e', 1728 'Ě' => 'E', 1729 'ě' => 'e', 1730 'Ĝ' => 'G', 1731 'ĝ' => 'g', 1732 'Ğ' => 'G', 1733 'ğ' => 'g', 1734 'Ġ' => 'G', 1735 'ġ' => 'g', 1736 'Ģ' => 'G', 1737 'ģ' => 'g', 1738 'Ĥ' => 'H', 1739 'ĥ' => 'h', 1740 'Ħ' => 'H', 1741 'ħ' => 'h', 1742 'Ĩ' => 'I', 1743 'ĩ' => 'i', 1744 'Ī' => 'I', 1745 'ī' => 'i', 1746 'Ĭ' => 'I', 1747 'ĭ' => 'i', 1748 'Į' => 'I', 1749 'į' => 'i', 1750 'İ' => 'I', 1751 'ı' => 'i', 1752 'IJ' => 'IJ', 1753 'ij' => 'ij', 1754 'Ĵ' => 'J', 1755 'ĵ' => 'j', 1756 'Ķ' => 'K', 1757 'ķ' => 'k', 1758 'ĸ' => 'k', 1759 'Ĺ' => 'L', 1760 'ĺ' => 'l', 1761 'Ļ' => 'L', 1762 'ļ' => 'l', 1763 'Ľ' => 'L', 1764 'ľ' => 'l', 1765 'Ŀ' => 'L', 1766 'ŀ' => 'l', 1767 'Ł' => 'L', 1768 'ł' => 'l', 1769 'Ń' => 'N', 1770 'ń' => 'n', 1771 'Ņ' => 'N', 1772 'ņ' => 'n', 1773 'Ň' => 'N', 1774 'ň' => 'n', 1775 'ʼn' => 'n', 1776 'Ŋ' => 'N', 1777 'ŋ' => 'n', 1778 'Ō' => 'O', 1779 'ō' => 'o', 1780 'Ŏ' => 'O', 1781 'ŏ' => 'o', 1782 'Ő' => 'O', 1783 'ő' => 'o', 1784 'Œ' => 'OE', 1785 'œ' => 'oe', 1786 'Ŕ' => 'R', 1787 'ŕ' => 'r', 1788 'Ŗ' => 'R', 1789 'ŗ' => 'r', 1790 'Ř' => 'R', 1791 'ř' => 'r', 1792 'Ś' => 'S', 1793 'ś' => 's', 1794 'Ŝ' => 'S', 1795 'ŝ' => 's', 1796 'Ş' => 'S', 1797 'ş' => 's', 1798 'Š' => 'S', 1799 'š' => 's', 1800 'Ţ' => 'T', 1801 'ţ' => 't', 1802 'Ť' => 'T', 1803 'ť' => 't', 1804 'Ŧ' => 'T', 1805 'ŧ' => 't', 1806 'Ũ' => 'U', 1807 'ũ' => 'u', 1808 'Ū' => 'U', 1809 'ū' => 'u', 1810 'Ŭ' => 'U', 1811 'ŭ' => 'u', 1812 'Ů' => 'U', 1813 'ů' => 'u', 1814 'Ű' => 'U', 1815 'ű' => 'u', 1816 'Ų' => 'U', 1817 'ų' => 'u', 1818 'Ŵ' => 'W', 1819 'ŵ' => 'w', 1820 'Ŷ' => 'Y', 1821 'ŷ' => 'y', 1822 'Ÿ' => 'Y', 1823 'Ź' => 'Z', 1824 'ź' => 'z', 1825 'Ż' => 'Z', 1826 'ż' => 'z', 1827 'Ž' => 'Z', 1828 'ž' => 'z', 1829 'ſ' => 's', 1830 // Decompositions for Latin Extended-B. 1831 'Ə' => 'E', 1832 'ǝ' => 'e', 1833 'Ș' => 'S', 1834 'ș' => 's', 1835 'Ț' => 'T', 1836 'ț' => 't', 1837 // Euro sign. 1838 '€' => 'E', 1839 // GBP (Pound) sign. 1840 '£' => '', 1841 // Vowels with diacritic (Vietnamese). Unmarked. 1842 'Ơ' => 'O', 1843 'ơ' => 'o', 1844 'Ư' => 'U', 1845 'ư' => 'u', 1846 // Grave accent. 1847 'Ầ' => 'A', 1848 'ầ' => 'a', 1849 'Ằ' => 'A', 1850 'ằ' => 'a', 1851 'Ề' => 'E', 1852 'ề' => 'e', 1853 'Ồ' => 'O', 1854 'ồ' => 'o', 1855 'Ờ' => 'O', 1856 'ờ' => 'o', 1857 'Ừ' => 'U', 1858 'ừ' => 'u', 1859 'Ỳ' => 'Y', 1860 'ỳ' => 'y', 1861 // Hook. 1862 'Ả' => 'A', 1863 'ả' => 'a', 1864 'Ẩ' => 'A', 1865 'ẩ' => 'a', 1866 'Ẳ' => 'A', 1867 'ẳ' => 'a', 1868 'Ẻ' => 'E', 1869 'ẻ' => 'e', 1870 'Ể' => 'E', 1871 'ể' => 'e', 1872 'Ỉ' => 'I', 1873 'ỉ' => 'i', 1874 'Ỏ' => 'O', 1875 'ỏ' => 'o', 1876 'Ổ' => 'O', 1877 'ổ' => 'o', 1878 'Ở' => 'O', 1879 'ở' => 'o', 1880 'Ủ' => 'U', 1881 'ủ' => 'u', 1882 'Ử' => 'U', 1883 'ử' => 'u', 1884 'Ỷ' => 'Y', 1885 'ỷ' => 'y', 1886 // Tilde. 1887 'Ẫ' => 'A', 1888 'ẫ' => 'a', 1889 'Ẵ' => 'A', 1890 'ẵ' => 'a', 1891 'Ẽ' => 'E', 1892 'ẽ' => 'e', 1893 'Ễ' => 'E', 1894 'ễ' => 'e', 1895 'Ỗ' => 'O', 1896 'ỗ' => 'o', 1897 'Ỡ' => 'O', 1898 'ỡ' => 'o', 1899 'Ữ' => 'U', 1900 'ữ' => 'u', 1901 'Ỹ' => 'Y', 1902 'ỹ' => 'y', 1903 // Acute accent. 1904 'Ấ' => 'A', 1905 'ấ' => 'a', 1906 'Ắ' => 'A', 1907 'ắ' => 'a', 1908 'Ế' => 'E', 1909 'ế' => 'e', 1910 'Ố' => 'O', 1911 'ố' => 'o', 1912 'Ớ' => 'O', 1913 'ớ' => 'o', 1914 'Ứ' => 'U', 1915 'ứ' => 'u', 1916 // Dot below. 1917 'Ạ' => 'A', 1918 'ạ' => 'a', 1919 'Ậ' => 'A', 1920 'ậ' => 'a', 1921 'Ặ' => 'A', 1922 'ặ' => 'a', 1923 'Ẹ' => 'E', 1924 'ẹ' => 'e', 1925 'Ệ' => 'E', 1926 'ệ' => 'e', 1927 'Ị' => 'I', 1928 'ị' => 'i', 1929 'Ọ' => 'O', 1930 'ọ' => 'o', 1931 'Ộ' => 'O', 1932 'ộ' => 'o', 1933 'Ợ' => 'O', 1934 'ợ' => 'o', 1935 'Ụ' => 'U', 1936 'ụ' => 'u', 1937 'Ự' => 'U', 1938 'ự' => 'u', 1939 'Ỵ' => 'Y', 1940 'ỵ' => 'y', 1941 // Vowels with diacritic (Chinese, Hanyu Pinyin). 1942 'ɑ' => 'a', 1943 // Macron. 1944 'Ǖ' => 'U', 1945 'ǖ' => 'u', 1946 // Acute accent. 1947 'Ǘ' => 'U', 1948 'ǘ' => 'u', 1949 // Caron. 1950 'Ǎ' => 'A', 1951 'ǎ' => 'a', 1952 'Ǐ' => 'I', 1953 'ǐ' => 'i', 1954 'Ǒ' => 'O', 1955 'ǒ' => 'o', 1956 'Ǔ' => 'U', 1957 'ǔ' => 'u', 1958 'Ǚ' => 'U', 1959 'ǚ' => 'u', 1960 // Grave accent. 1961 'Ǜ' => 'U', 1962 'ǜ' => 'u', 1963 ); 1964 1965 // Used for locale-specific rules. 1966 if ( empty( $locale ) ) { 1967 $locale = get_locale(); 1968 } 1969 1970 /* 1971 * German has various locales (de_DE, de_CH, de_AT, ...) with formal and informal variants. 1972 * There is no 3-letter locale like 'def', so checking for 'de' instead of 'de_' is safe, 1973 * since 'de' itself would be a valid locale too. 1974 */ 1975 if ( str_starts_with( $locale, 'de' ) ) { 1976 $chars['Ä'] = 'Ae'; 1977 $chars['ä'] = 'ae'; 1978 $chars['Ö'] = 'Oe'; 1979 $chars['ö'] = 'oe'; 1980 $chars['Ü'] = 'Ue'; 1981 $chars['ü'] = 'ue'; 1982 $chars['ẞ'] = 'SS'; 1983 $chars['ß'] = 'ss'; 1984 } elseif ( 'da_DK' === $locale ) { 1985 $chars['Æ'] = 'Ae'; 1986 $chars['æ'] = 'ae'; 1987 $chars['Ø'] = 'Oe'; 1988 $chars['ø'] = 'oe'; 1989 $chars['Å'] = 'Aa'; 1990 $chars['å'] = 'aa'; 1991 } elseif ( 'ca' === $locale ) { 1992 $chars['l·l'] = 'll'; 1993 } elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) { 1994 $chars['Đ'] = 'DJ'; 1995 $chars['đ'] = 'dj'; 1996 } 1997 1998 $text = strtr( $text, $chars ); 1999 } else { 2000 $chars = array(); 2001 // Assume ISO-8859-1 if not UTF-8. 2002 $chars['in'] = "\x80\x83\x8a\x8e\x9a\x9e" 2003 . "\x9f\xa2\xa5\xb5\xc0\xc1\xc2" 2004 . "\xc3\xc4\xc5\xc7\xc8\xc9\xca" 2005 . "\xcb\xcc\xcd\xce\xcf\xd1\xd2" 2006 . "\xd3\xd4\xd5\xd6\xd8\xd9\xda" 2007 . "\xdb\xdc\xdd\xe0\xe1\xe2\xe3" 2008 . "\xe4\xe5\xe7\xe8\xe9\xea\xeb" 2009 . "\xec\xed\xee\xef\xf1\xf2\xf3" 2010 . "\xf4\xf5\xf6\xf8\xf9\xfa\xfb" 2011 . "\xfc\xfd\xff"; 2012 2013 $chars['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'; 2014 2015 $text = strtr( $text, $chars['in'], $chars['out'] ); 2016 $double_chars = array(); 2017 $double_chars['in'] = array( "\x8c", "\x9c", "\xc6", "\xd0", "\xde", "\xdf", "\xe6", "\xf0", "\xfe" ); 2018 $double_chars['out'] = array( 'OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th' ); 2019 $text = str_replace( $double_chars['in'], $double_chars['out'], $text ); 2020 } 2021 2022 return $text; 2023 } 2024 2025 /** 2026 * Sanitizes a filename, replacing whitespace with dashes. 2027 * 2028 * Removes special characters that are illegal in filenames on certain 2029 * operating systems and special characters requiring special escaping 2030 * to manipulate at the command line. Replaces spaces and consecutive 2031 * dashes with a single dash. Trims period, dash and underscore from beginning 2032 * and end of filename. It is not guaranteed that this function will return a 2033 * filename that is allowed to be uploaded. 2034 * 2035 * @since 2.1.0 2036 * 2037 * @param string $filename The filename to be sanitized. 2038 * @return string The sanitized filename. 2039 */ 2040 function sanitize_file_name( $filename ) { 2041 $filename_raw = $filename; 2042 $filename = remove_accents( $filename ); 2043 2044 $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) ); 2045 2046 if ( ! wp_is_valid_utf8( $filename ) ) { 2047 $_ext = pathinfo( $filename, PATHINFO_EXTENSION ); 2048 $_name = pathinfo( $filename, PATHINFO_FILENAME ); 2049 $filename = sanitize_title_with_dashes( $_name ) . '.' . $_ext; 2050 } 2051 2052 if ( _wp_can_use_pcre_u() ) { 2053 /** 2054 * Replace all whitespace characters with a basic space (U+0020). 2055 * 2056 * The “Zs” in the pattern selects characters in the `Space_Separator` 2057 * category, which is what Unicode considers space characters. 2058 * 2059 * @link https://www.unicode.org/reports/tr44/#General_Category_Values 2060 * @link https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-6/#G17548 2061 * @link https://www.php.net/manual/en/regexp.reference.unicode.php 2062 */ 2063 $filename = preg_replace( '#\p{Zs}#siu', ' ', $filename ); 2064 } 2065 2066 /** 2067 * Filters the list of characters to remove from a filename. 2068 * 2069 * @since 2.8.0 2070 * 2071 * @param string[] $special_chars Array of characters to remove. 2072 * @param string $filename_raw The original filename to be sanitized. 2073 */ 2074 $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); 2075 2076 $filename = str_replace( $special_chars, '', $filename ); 2077 $filename = str_replace( array( '%20', '+' ), '-', $filename ); 2078 $filename = preg_replace( '/\.{2,}/', '.', $filename ); 2079 $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); 2080 $filename = trim( $filename, '.-_' ); 2081 2082 if ( ! str_contains( $filename, '.' ) ) { 2083 $mime_types = wp_get_mime_types(); 2084 $filetype = wp_check_filetype( 'test.' . $filename, $mime_types ); 2085 if ( $filetype['ext'] === $filename ) { 2086 $filename = 'unnamed-file.' . $filetype['ext']; 2087 } 2088 } 2089 2090 // Split the filename into a base and extension[s]. 2091 $parts = explode( '.', $filename ); 2092 2093 // Return if only one extension. 2094 if ( count( $parts ) <= 2 ) { 2095 /** This filter is documented in wp-includes/formatting.php */ 2096 return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); 2097 } 2098 2099 // Process multiple extensions. 2100 $filename = array_shift( $parts ); 2101 $extension = array_pop( $parts ); 2102 $mimes = get_allowed_mime_types(); 2103 2104 /* 2105 * Loop over any intermediate extensions. Postfix them with a trailing underscore 2106 * if they are a 2 - 5 character long alpha string not in the allowed extension list. 2107 */ 2108 foreach ( (array) $parts as $part ) { 2109 $filename .= '.' . $part; 2110 2111 if ( preg_match( '/^[a-zA-Z]{2,5}\d?$/', $part ) ) { 2112 $allowed = false; 2113 foreach ( $mimes as $ext_preg => $mime_match ) { 2114 $ext_preg = '!^(' . $ext_preg . ')$!i'; 2115 if ( preg_match( $ext_preg, $part ) ) { 2116 $allowed = true; 2117 break; 2118 } 2119 } 2120 if ( ! $allowed ) { 2121 $filename .= '_'; 2122 } 2123 } 2124 } 2125 2126 $filename .= '.' . $extension; 2127 2128 /** 2129 * Filters a sanitized filename string. 2130 * 2131 * @since 2.8.0 2132 * 2133 * @param string $filename Sanitized filename. 2134 * @param string $filename_raw The filename prior to sanitization. 2135 */ 2136 return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); 2137 } 2138 2139 /** 2140 * Sanitizes a username, stripping out unsafe characters. 2141 * 2142 * Removes tags, percent-encoded characters, HTML entities, and if strict is enabled, 2143 * will only keep alphanumeric, _, space, ., -, @. After sanitizing, it passes the username, 2144 * raw username (the username in the parameter), and the value of $strict as parameters 2145 * for the {@see 'sanitize_user'} filter. 2146 * 2147 * @since 2.0.0 2148 * 2149 * @param string $username The username to be sanitized. 2150 * @param bool $strict Optional. If set to true, limits $username to specific characters. 2151 * Default false. 2152 * @return string The sanitized username, after passing through filters. 2153 */ 2154 function sanitize_user( $username, $strict = false ) { 2155 $raw_username = $username; 2156 $username = wp_strip_all_tags( $username ); 2157 $username = remove_accents( $username ); 2158 // Remove percent-encoded characters. 2159 $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); 2160 // Remove HTML entities. 2161 $username = preg_replace( '/&.+?;/', '', $username ); 2162 2163 // If strict, reduce to ASCII for max portability. 2164 if ( $strict ) { 2165 $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); 2166 } 2167 2168 $username = trim( $username ); 2169 // Consolidate contiguous whitespace. 2170 $username = preg_replace( '|\s+|', ' ', $username ); 2171 2172 /** 2173 * Filters a sanitized username string. 2174 * 2175 * @since 2.0.1 2176 * 2177 * @param string $username Sanitized username. 2178 * @param string $raw_username The username prior to sanitization. 2179 * @param bool $strict Whether to limit the sanitization to specific characters. 2180 */ 2181 return apply_filters( 'sanitize_user', $username, $raw_username, $strict ); 2182 } 2183 2184 /** 2185 * Sanitizes a string key. 2186 * 2187 * Keys are used as internal identifiers. Lowercase alphanumeric characters, 2188 * dashes, and underscores are allowed. 2189 * 2190 * @since 3.0.0 2191 * 2192 * @param mixed $key String key. Other scalars are cast to a string; any other type yields an empty string. 2193 * @return string Sanitized key. 2194 * @phpstan-return lowercase-string 2195 */ 2196 function sanitize_key( $key ) { 2197 $sanitized_key = ''; 2198 2199 if ( is_scalar( $key ) ) { 2200 $sanitized_key = strtolower( (string) $key ); 2201 $sanitized_key = preg_replace( '/[^a-z0-9_\-]/', '', $sanitized_key ); 2202 } 2203 2204 /** 2205 * Filters a sanitized key string. 2206 * 2207 * @since 3.0.0 2208 * 2209 * @param string $sanitized_key Sanitized key. 2210 * @param mixed $key The key prior to sanitization. 2211 * @phpstan-param lowercase-string $sanitized_key 2212 */ 2213 return apply_filters( 'sanitize_key', $sanitized_key, $key ); 2214 } 2215 2216 /** 2217 * Sanitizes a string into a slug, which can be used in URLs or HTML attributes. 2218 * 2219 * By default, converts accent characters to ASCII characters and further 2220 * limits the output to alphanumeric characters, underscore (_) and dash (-) 2221 * through the {@see 'sanitize_title'} filter. 2222 * 2223 * If `$title` is empty and `$fallback_title` is set, the latter will be used. 2224 * 2225 * @since 1.0.0 2226 * 2227 * @param string $title The string to be sanitized. 2228 * @param string $fallback_title Optional. A title to use if $title is empty. Default empty. 2229 * @param string $context Optional. The operation for which the string is sanitized. 2230 * When set to 'save', the string runs through remove_accents(). 2231 * Default 'save'. 2232 * @return string The sanitized string. 2233 */ 2234 function sanitize_title( $title, $fallback_title = '', $context = 'save' ) { 2235 $raw_title = $title; 2236 2237 if ( 'save' === $context ) { 2238 $title = remove_accents( $title ); 2239 } 2240 2241 /** 2242 * Filters a sanitized title string. 2243 * 2244 * @since 1.2.0 2245 * 2246 * @param string $title Sanitized title. 2247 * @param string $raw_title The title prior to sanitization. 2248 * @param string $context The context for which the title is being sanitized. 2249 */ 2250 $title = apply_filters( 'sanitize_title', $title, $raw_title, $context ); 2251 2252 if ( '' === $title || false === $title ) { 2253 $title = $fallback_title; 2254 } 2255 2256 return $title; 2257 } 2258 2259 /** 2260 * Sanitizes a title with the 'query' context. 2261 * 2262 * Used for querying the database for a value from URL. 2263 * 2264 * @since 3.1.0 2265 * 2266 * @param string $title The string to be sanitized. 2267 * @return string The sanitized string. 2268 */ 2269 function sanitize_title_for_query( $title ) { 2270 return sanitize_title( $title, '', 'query' ); 2271 } 2272 2273 /** 2274 * Sanitizes a title, replacing whitespace and a few other characters with dashes. 2275 * 2276 * Limits the output to alphanumeric characters, underscore (_) and dash (-). 2277 * Whitespace becomes a dash. 2278 * 2279 * @since 1.2.0 2280 * 2281 * @param string $title The title to be sanitized. 2282 * @param string $raw_title Optional. Not used. Default empty. 2283 * @param string $context Optional. The operation for which the string is sanitized. 2284 * When set to 'save', additional entities are converted to hyphens 2285 * or stripped entirely. Default 'display'. 2286 * @return string The sanitized title. 2287 * 2288 * @phpstan-return lowercase-string 2289 */ 2290 function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) { 2291 $title = strip_tags( $title ); 2292 // Preserve escaped octets. 2293 $title = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title ); 2294 // Remove percent signs that are not part of an octet. 2295 $title = str_replace( '%', '', $title ); 2296 // Restore octets. 2297 $title = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title ); 2298 2299 if ( wp_is_valid_utf8( $title ) ) { 2300 if ( function_exists( 'mb_strtolower' ) ) { 2301 $title = mb_strtolower( $title, 'UTF-8' ); 2302 } 2303 $title = utf8_uri_encode( $title, 200 ); 2304 } 2305 2306 $title = strtolower( $title ); 2307 2308 if ( 'save' === $context ) { 2309 // Convert  , non-breaking hyphen, &ndash, and &mdash to hyphens. 2310 $title = str_replace( array( '%c2%a0', '%e2%80%91', '%e2%80%93', '%e2%80%94' ), '-', $title ); 2311 // Convert  , non-breaking hyphen, &ndash, and &mdash HTML entities to hyphens. 2312 $title = str_replace( array( ' ', '‑', ' ', '–', '–', '—', '—' ), '-', $title ); 2313 // Convert forward slash to hyphen. 2314 $title = str_replace( '/', '-', $title ); 2315 2316 // Strip these characters entirely. 2317 $title = str_replace( 2318 array( 2319 // Soft hyphens. 2320 '%c2%ad', 2321 // ¡ and ¿. 2322 '%c2%a1', 2323 '%c2%bf', 2324 // Angle quotes. 2325 '%c2%ab', 2326 '%c2%bb', 2327 '%e2%80%b9', 2328 '%e2%80%ba', 2329 // Curly quotes. 2330 '%e2%80%98', 2331 '%e2%80%99', 2332 '%e2%80%9c', 2333 '%e2%80%9d', 2334 '%e2%80%9a', 2335 '%e2%80%9b', 2336 '%e2%80%9e', 2337 '%e2%80%9f', 2338 // Bullet. 2339 '%e2%80%a2', 2340 // ©, ®, °, &hellip, and &trade. 2341 '%c2%a9', 2342 '%c2%ae', 2343 '%c2%b0', 2344 '%e2%80%a6', 2345 '%e2%84%a2', 2346 // Acute accents. 2347 '%c2%b4', 2348 '%cb%8a', 2349 '%cc%81', 2350 '%cd%81', 2351 // Grave accent, macron, caron. 2352 '%cc%80', 2353 '%cc%84', 2354 '%cc%8c', 2355 // Non-visible characters that display without a width. 2356 '%e2%80%8b', // Zero width space. 2357 '%e2%80%8c', // Zero width non-joiner. 2358 '%e2%80%8d', // Zero width joiner. 2359 '%e2%80%8e', // Left-to-right mark. 2360 '%e2%80%8f', // Right-to-left mark. 2361 '%e2%80%aa', // Left-to-right embedding. 2362 '%e2%80%ab', // Right-to-left embedding. 2363 '%e2%80%ac', // Pop directional formatting. 2364 '%e2%80%ad', // Left-to-right override. 2365 '%e2%80%ae', // Right-to-left override. 2366 '%ef%bb%bf', // Byte order mark. 2367 '%ef%bf%bc', // Object replacement character. 2368 ), 2369 '', 2370 $title 2371 ); 2372 2373 // Convert non-visible characters that display with a width to hyphen. 2374 $title = str_replace( 2375 array( 2376 '%e2%80%80', // En quad. 2377 '%e2%80%81', // Em quad. 2378 '%e2%80%82', // En space. 2379 '%e2%80%83', // Em space. 2380 '%e2%80%84', // Three-per-em space. 2381 '%e2%80%85', // Four-per-em space. 2382 '%e2%80%86', // Six-per-em space. 2383 '%e2%80%87', // Figure space. 2384 '%e2%80%88', // Punctuation space. 2385 '%e2%80%89', // Thin space. 2386 '%e2%80%8a', // Hair space. 2387 '%e2%80%a8', // Line separator. 2388 '%e2%80%a9', // Paragraph separator. 2389 '%e2%80%af', // Narrow no-break space. 2390 ), 2391 '-', 2392 $title 2393 ); 2394 2395 // Convert × to 'x'. 2396 $title = str_replace( '%c3%97', 'x', $title ); 2397 } 2398 2399 // Remove HTML entities. 2400 $title = preg_replace( '/&.+?;/', '', $title ); 2401 $title = str_replace( '.', '-', $title ); 2402 2403 $title = preg_replace( '/[^%a-z0-9 _-]/', '', $title ); 2404 $title = preg_replace( '/\s+/', '-', $title ); 2405 $title = preg_replace( '|-+|', '-', $title ); 2406 $title = trim( $title, '-' ); 2407 2408 /** @var lowercase-string $title Only lowercase characters remain after the replacements above. */ 2409 return $title; 2410 } 2411 2412 /** 2413 * Truncates a slug to a given length. 2414 * 2415 * Non-ASCII slugs are stored percent-encoded, so the slug is truncated on a 2416 * character boundary to avoid cutting a percent-encoded sequence in half. 2417 * 2418 * @since 7.2.0 2419 * @access private 2420 * 2421 * @see utf8_uri_encode() 2422 * 2423 * @param string $slug The slug to truncate. 2424 * @param int $length Optional. Max length of the slug. Default 200 (characters). 2425 * @return string The truncated slug. 2426 */ 2427 function wp_truncate_slug( $slug, $length = 200 ) { 2428 if ( strlen( $slug ) > $length ) { 2429 $decoded_slug = urldecode( $slug ); 2430 if ( $decoded_slug === $slug ) { 2431 $slug = substr( $slug, 0, $length ); 2432 } else { 2433 $slug = utf8_uri_encode( $decoded_slug, $length, true ); 2434 } 2435 } 2436 2437 return rtrim( $slug, '-' ); 2438 } 2439 2440 /** 2441 * Ensures a string is a valid SQL 'order by' clause. 2442 * 2443 * Accepts one or more columns, with or without a sort order (ASC / DESC). 2444 * e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc. 2445 * 2446 * Also accepts 'RAND()'. 2447 * 2448 * @since 2.5.1 2449 * 2450 * @param string $orderby Order by clause to be validated. 2451 * @return string|false Returns $orderby if valid, false otherwise. 2452 * 2453 * @phpstan-template T of string 2454 * @phpstan-param T $orderby 2455 * @phpstan-return ( T is non-empty-string ? T|false : false ) 2456 */ 2457 function sanitize_sql_orderby( $orderby ) { 2458 if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) { 2459 return $orderby; 2460 } 2461 return false; 2462 } 2463 2464 /** 2465 * Sanitizes an HTML classname to ensure it only contains valid characters. 2466 * 2467 * Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty 2468 * string then it will return the alternative value supplied. 2469 * 2470 * @todo Expand to support the full range of CDATA that a class attribute can contain. 2471 * 2472 * @since 2.8.0 2473 * 2474 * @param string $classname The classname to be sanitized. 2475 * @param string $fallback Optional. The value to return if the sanitization ends up as an empty string. 2476 * Default empty string. 2477 * @return string The sanitized value. 2478 */ 2479 function sanitize_html_class( $classname, $fallback = '' ) { 2480 // Strip out any percent-encoded characters. 2481 $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname ); 2482 2483 // Limit to A-Z, a-z, 0-9, '_', '-'. 2484 $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); 2485 2486 if ( '' === $sanitized && $fallback ) { 2487 return sanitize_html_class( $fallback ); 2488 } 2489 /** 2490 * Filters a sanitized HTML class string. 2491 * 2492 * @since 2.8.0 2493 * 2494 * @param string $sanitized The sanitized HTML class. 2495 * @param string $classname HTML class before sanitization. 2496 * @param string $fallback The fallback string. 2497 */ 2498 return apply_filters( 'sanitize_html_class', $sanitized, $classname, $fallback ); 2499 } 2500 2501 /** 2502 * Strips out all characters not allowed in a locale name. 2503 * 2504 * @since 6.2.1 2505 * 2506 * @param string $locale_name The locale name to be sanitized. 2507 * @return string The sanitized value. 2508 */ 2509 function sanitize_locale_name( $locale_name ) { 2510 // Request values can arrive as arrays, and preg_replace() would map over them. 2511 if ( ! is_string( $locale_name ) ) { 2512 return ''; 2513 } 2514 2515 // Limit to A-Z, a-z, 0-9, '_', '-'. 2516 $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $locale_name ); 2517 2518 /** 2519 * Filters a sanitized locale name string. 2520 * 2521 * @since 6.2.1 2522 * 2523 * @param string $sanitized The sanitized locale name. 2524 * @param string $locale_name The locale name before sanitization. 2525 */ 2526 return apply_filters( 'sanitize_locale_name', $sanitized, $locale_name ); 2527 } 2528 2529 /** 2530 * Converts lone & characters into `&` (a.k.a. `&`) 2531 * 2532 * @since 0.71 2533 * 2534 * @param string $content String of characters to be converted. 2535 * @param string $deprecated Not used. 2536 * @return string Converted string. 2537 * 2538 * @phpstan-param '' $deprecated 2539 */ 2540 function convert_chars( $content, $deprecated = '' ) { 2541 if ( ! empty( $deprecated ) ) { 2542 _deprecated_argument( __FUNCTION__, '0.71' ); 2543 } 2544 2545 if ( str_contains( $content, '&' ) ) { 2546 $content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content ); 2547 } 2548 2549 return $content; 2550 } 2551 2552 /** 2553 * Converts invalid Unicode references range to valid range. 2554 * 2555 * @since 4.3.0 2556 * 2557 * @param string $content String with entities that need converting. 2558 * @return string Converted string. 2559 */ 2560 function convert_invalid_entities( $content ) { 2561 $wp_htmltranswinuni = array( 2562 '€' => '€', // The Euro sign. 2563 '' => '', 2564 '‚' => '‚', // These are Windows CP1252 specific characters. 2565 'ƒ' => 'ƒ', // They would look weird on non-Windows browsers. 2566 '„' => '„', 2567 '…' => '…', 2568 '†' => '†', 2569 '‡' => '‡', 2570 'ˆ' => 'ˆ', 2571 '‰' => '‰', 2572 'Š' => 'Š', 2573 '‹' => '‹', 2574 'Œ' => 'Œ', 2575 '' => '', 2576 'Ž' => 'Ž', 2577 '' => '', 2578 '' => '', 2579 '‘' => '‘', 2580 '’' => '’', 2581 '“' => '“', 2582 '”' => '”', 2583 '•' => '•', 2584 '–' => '–', 2585 '—' => '—', 2586 '˜' => '˜', 2587 '™' => '™', 2588 'š' => 'š', 2589 '›' => '›', 2590 'œ' => 'œ', 2591 '' => '', 2592 'ž' => 'ž', 2593 'Ÿ' => 'Ÿ', 2594 ); 2595 2596 if ( str_contains( $content, '' ) ) { 2597 $content = strtr( $content, $wp_htmltranswinuni ); 2598 } 2599 2600 return $content; 2601 } 2602 2603 /** 2604 * Balances tags if forced to, or if the 'use_balanceTags' option is set to true. 2605 * 2606 * @since 0.71 2607 * 2608 * @param string $text Text to be balanced. 2609 * @param bool $force If true, forces balancing, ignoring the value of the option. Default false. 2610 * @return string Balanced text. 2611 */ 2612 function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid 2613 if ( $force || 1 === (int) get_option( 'use_balanceTags' ) ) { 2614 return force_balance_tags( $text ); 2615 } else { 2616 return $text; 2617 } 2618 } 2619 2620 /** 2621 * Balances tags of string using a modified stack. 2622 * 2623 * {@internal Modified by Scott Reilly (coffee2code) 02 Aug 2004 2624 * 1.1 Fixed handling of append/stack pop order of end text 2625 * Added Cleaning Hooks 2626 * 1.0 First Version} 2627 * 2628 * @since 2.0.4 2629 * @since 5.3.0 Improve accuracy and add support for custom element tags. 2630 * 2631 * @author Leonard Lin <leonard@acm.org> 2632 * @license GPL 2633 * @copyright November 4, 2001 2634 * @version 1.1 2635 * @todo Make better - change loop condition to $text in 1.2 2636 * 2637 * @param string $text Text to be balanced. 2638 * @return string Balanced text. 2639 */ 2640 function force_balance_tags( $text ) { 2641 $tagstack = array(); 2642 $stacksize = 0; 2643 $tagqueue = ''; 2644 $newtext = ''; 2645 // Known single-entity/self-closing tags. 2646 $single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source', 'track', 'wbr' ); 2647 // Tags that can be immediately nested within themselves. 2648 $nestable_tags = array( 'article', 'aside', 'blockquote', 'details', 'div', 'figure', 'object', 'q', 'section', 'span' ); 2649 2650 // WP bug fix for comments - in case you REALLY meant to type '< !--'. 2651 $text = str_replace( '< !--', '< !--', $text ); 2652 // WP bug fix for LOVE <3 (and other situations with '<' before a number). 2653 $text = preg_replace( '#<([0-9]{1})#', '<$1', $text ); 2654 2655 /** 2656 * Matches supported tags. 2657 * 2658 * To get the pattern as a string without the comments paste into a PHP 2659 * REPL like `php -a`. 2660 * 2661 * @link https://html.spec.whatwg.org/#elements-2 2662 * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name 2663 * 2664 * @example 2665 * ~# php -a 2666 * php > $s = [paste copied contents of expression below including parentheses]; 2667 * php > echo $s; 2668 */ 2669 $tag_pattern = ( 2670 '#<' . // Start with an opening bracket. 2671 '(/?)' . // Group 1 - If it's a closing tag it'll have a leading slash. 2672 '(' . // Group 2 - Tag name. 2673 // Custom element tags have more lenient rules than HTML tag names. 2674 '(?:[a-z](?:[a-z0-9._]*)-(?:[a-z0-9._-]+)+)' . 2675 '|' . 2676 // Traditional tag rules approximate HTML tag names. 2677 '(?:[\w:]+)' . 2678 ')' . 2679 '(?:' . 2680 // We either immediately close the tag with its '>' and have nothing here. 2681 '\s*' . 2682 '(/?)' . // Group 3 - "attributes" for empty tag. 2683 '|' . 2684 // Or we must start with space characters to separate the tag name from the attributes (or whitespace). 2685 '(\s+)' . // Group 4 - Pre-attribute whitespace. 2686 '([^>]*)' . // Group 5 - Attributes. 2687 ')' . 2688 '>#' // End with a closing bracket. 2689 ); 2690 2691 while ( preg_match( $tag_pattern, $text, $regex ) ) { 2692 $full_match = $regex[0]; 2693 $has_leading_slash = ! empty( $regex[1] ); 2694 $tag_name = $regex[2]; 2695 $tag = strtolower( $tag_name ); 2696 $is_single_tag = in_array( $tag, $single_tags, true ); 2697 $pre_attribute_ws = $regex[4] ?? ''; 2698 $attributes = trim( $regex[5] ?? $regex[3] ); 2699 $has_self_closer = str_ends_with( $attributes, '/' ); 2700 2701 $newtext .= $tagqueue; 2702 2703 $i = strpos( $text, $full_match ); 2704 $l = strlen( $full_match ); 2705 2706 // Clear the shifter. 2707 $tagqueue = ''; 2708 if ( $has_leading_slash ) { // End tag. 2709 // If too many closing tags. 2710 if ( $stacksize <= 0 ) { 2711 $tag = ''; 2712 // Or close to be safe $tag = '/' . $tag. 2713 2714 // If stacktop value = tag close value, then pop. 2715 } elseif ( $tagstack[ $stacksize - 1 ] === $tag ) { // Found closing tag. 2716 $tag = '</' . $tag . '>'; // Close tag. 2717 array_pop( $tagstack ); 2718 --$stacksize; 2719 } else { // Closing tag not at top, search for it. 2720 for ( $j = $stacksize - 1; $j >= 0; $j-- ) { 2721 if ( $tagstack[ $j ] === $tag ) { 2722 // Add tag to tagqueue. 2723 for ( $k = $stacksize - 1; $k >= $j; $k-- ) { 2724 $tagqueue .= '</' . array_pop( $tagstack ) . '>'; 2725 --$stacksize; 2726 } 2727 break; 2728 } 2729 } 2730 $tag = ''; 2731 } 2732 } else { // Begin tag. 2733 if ( $has_self_closer ) { 2734 /* 2735 * If it presents itself as a self-closing tag, but it isn't a known single-entity self-closing tag, 2736 * then don't let it be treated as such and immediately close it with a closing tag. 2737 * The tag will encapsulate no text as a result. 2738 */ 2739 if ( ! $is_single_tag ) { 2740 $attributes = trim( substr( $attributes, 0, -1 ) ) . "></$tag"; 2741 } 2742 } elseif ( $is_single_tag ) { 2743 // Else if it's a known single-entity tag but it doesn't close itself, do so. 2744 $pre_attribute_ws = ' '; 2745 $attributes .= '/'; 2746 } else { 2747 /* 2748 * It's not a single-entity tag. 2749 * If the top of the stack is the same as the tag we want to push, close previous tag. 2750 */ 2751 if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags, true ) && $tagstack[ $stacksize - 1 ] === $tag ) { 2752 $tagqueue = '</' . array_pop( $tagstack ) . '>'; 2753 --$stacksize; 2754 } 2755 $stacksize = array_push( $tagstack, $tag ); 2756 } 2757 2758 // Attributes. 2759 if ( $has_self_closer && $is_single_tag ) { 2760 // We need some space - avoid <br/> and prefer <br />. 2761 $pre_attribute_ws = ' '; 2762 } 2763 2764 $tag = '<' . $tag . $pre_attribute_ws . $attributes . '>'; 2765 // If already queuing a close tag, then put this tag on too. 2766 if ( ! empty( $tagqueue ) ) { 2767 $tagqueue .= $tag; 2768 $tag = ''; 2769 } 2770 } 2771 $newtext .= substr( $text, 0, $i ) . $tag; 2772 $text = substr( $text, $i + $l ); 2773 } 2774 2775 // Clear tag queue. 2776 $newtext .= $tagqueue; 2777 2778 // Add remaining text. 2779 $newtext .= $text; 2780 2781 while ( $x = array_pop( $tagstack ) ) { 2782 $newtext .= '</' . $x . '>'; // Add remaining tags to close. 2783 } 2784 2785 // WP fix for the bug with HTML comments. 2786 $newtext = str_replace( '< !--', '<!--', $newtext ); 2787 $newtext = str_replace( '< !--', '< !--', $newtext ); 2788 2789 return $newtext; 2790 } 2791 2792 /** 2793 * Acts on text which is about to be edited. 2794 * 2795 * The $content is run through esc_textarea(), which uses htmlspecialchars() 2796 * to convert special characters to HTML entities. If `$richedit` is set to true, 2797 * it is simply a holder for the {@see 'format_to_edit'} filter. 2798 * 2799 * @since 0.71 2800 * @since 4.4.0 The `$richedit` parameter was renamed to `$rich_text` for clarity. 2801 * 2802 * @param string $content The text about to be edited. 2803 * @param bool $rich_text Optional. Whether `$content` should be considered rich text, 2804 * in which case it would not be passed through esc_textarea(). 2805 * Default false. 2806 * @return string The text after the filter (and possibly htmlspecialchars()) has been run. 2807 */ 2808 function format_to_edit( $content, $rich_text = false ) { 2809 /** 2810 * Filters the text to be formatted for editing. 2811 * 2812 * @since 1.2.0 2813 * 2814 * @param string $content The text, prior to formatting for editing. 2815 */ 2816 $content = apply_filters( 'format_to_edit', $content ); 2817 if ( ! $rich_text ) { 2818 $content = esc_textarea( $content ); 2819 } 2820 return $content; 2821 } 2822 2823 /** 2824 * Add leading zeros when necessary. 2825 * 2826 * If you set the threshold to '4' and the number is '10', then you will get 2827 * back '0010'. If you set the threshold to '4' and the number is '5000', then you 2828 * will get back '5000'. 2829 * 2830 * Uses sprintf to append the amount of zeros based on the $threshold parameter 2831 * and the size of the number. If the number is large enough, then no zeros will 2832 * be appended. 2833 * 2834 * @since 0.71 2835 * 2836 * @param int $number Number to append zeros to if not greater than threshold. 2837 * @param int $threshold Digit places number needs to be to not have zeros added. 2838 * @return string Adds leading zeros to number if needed. 2839 * 2840 * @phpstan-param non-negative-int $threshold 2841 * @phpstan-return ( 2842 * $threshold is 0 2843 * ? lowercase-string&non-empty-string&numeric-string 2844 * : ( 2845 * $number is int<0, max> 2846 * ? lowercase-string&non-empty-string&numeric-string 2847 * : lowercase-string&non-empty-string 2848 * ) 2849 * ) 2850 */ 2851 function zeroise( $number, $threshold ) { 2852 return sprintf( '%0' . $threshold . 's', $number ); 2853 } 2854 2855 /** 2856 * Adds backslashes before letters and before a number at the start of a string. 2857 * 2858 * @since 0.71 2859 * 2860 * @param string $value Value to which backslashes will be added. 2861 * @return string String with backslashes inserted. 2862 */ 2863 function backslashit( $value ) { 2864 if ( isset( $value[0] ) && $value[0] >= '0' && $value[0] <= '9' ) { 2865 $value = '\\\\' . $value; 2866 } 2867 return addcslashes( $value, 'A..Za..z' ); 2868 } 2869 2870 /** 2871 * Appends a trailing slash. 2872 * 2873 * Will remove trailing forward and backslashes if it exists already before adding 2874 * a trailing forward slash. This prevents double slashing a string or path. 2875 * 2876 * The primary use of this is for paths and thus should be used for paths. It is 2877 * not restricted to paths and offers no specific path support. 2878 * 2879 * @since 1.2.0 2880 * 2881 * @param string $value Value to which trailing slash will be added. 2882 * @return string String with trailing slash added. 2883 * 2884 * @phpstan-return non-falsy-string 2885 */ 2886 function trailingslashit( $value ) { 2887 return untrailingslashit( $value ) . '/'; 2888 } 2889 2890 /** 2891 * Removes trailing forward slashes and backslashes if they exist. 2892 * 2893 * The primary use of this is for paths and thus should be used for paths. It is 2894 * not restricted to paths and offers no specific path support. 2895 * 2896 * @since 2.2.0 2897 * 2898 * @param string $value Value from which trailing slashes will be removed. 2899 * @return string String without the trailing slashes. 2900 */ 2901 function untrailingslashit( $value ) { 2902 return rtrim( $value, '/\\' ); 2903 } 2904 2905 /** 2906 * Navigates through an array, object, or scalar, and removes slashes from the values. 2907 * 2908 * @since 2.0.0 2909 * 2910 * @param mixed $value The value to be stripped. 2911 * @return mixed Stripped value. 2912 * 2913 * @phpstan-template T 2914 * @phpstan-param T $value 2915 * @phpstan-return ( 2916 * T is string ? string : ( 2917 * T is array ? array<key-of<T>, ( value-of<T> is string ? string : value-of<T> )> : T 2918 * ) 2919 * ) 2920 */ 2921 function stripslashes_deep( $value ) { 2922 return map_deep( $value, 'stripslashes_from_strings_only' ); 2923 } 2924 2925 /** 2926 * Callback function for `stripslashes_deep()` which strips slashes from strings. 2927 * 2928 * @since 4.4.0 2929 * 2930 * @param mixed $value The array or string to be stripped. 2931 * @return mixed The stripped value. 2932 * 2933 * @phpstan-template T 2934 * @phpstan-param T $value 2935 * @phpstan-return (T is string ? string : T) 2936 */ 2937 function stripslashes_from_strings_only( $value ) { 2938 return is_string( $value ) ? stripslashes( $value ) : $value; 2939 } 2940 2941 /** 2942 * Navigates through an array, object, or scalar, and encodes the values to be used in a URL. 2943 * 2944 * @since 2.2.0 2945 * 2946 * @param mixed $value The array or string to be encoded. 2947 * @return mixed The encoded value. 2948 */ 2949 function urlencode_deep( $value ) { 2950 return map_deep( $value, 'urlencode' ); 2951 } 2952 2953 /** 2954 * Navigates through an array, object, or scalar, and raw-encodes the values to be used in a URL. 2955 * 2956 * @since 3.4.0 2957 * 2958 * @param mixed $value The array or string to be encoded. 2959 * @return mixed The encoded value. 2960 */ 2961 function rawurlencode_deep( $value ) { 2962 return map_deep( $value, 'rawurlencode' ); 2963 } 2964 2965 /** 2966 * Navigates through an array, object, or scalar, and decodes URL-encoded values 2967 * 2968 * @since 4.4.0 2969 * 2970 * @param mixed $value The array or string to be decoded. 2971 * @return mixed The decoded value. 2972 */ 2973 function urldecode_deep( $value ) { 2974 return map_deep( $value, 'urldecode' ); 2975 } 2976 2977 /** 2978 * Obscures email addresses in HTML to prevent spam bots from harvesting them. 2979 * 2980 * Typically this will randomly replace characters from the email address with 2981 * HTML character references; however, when the hex encoding parameter is set, 2982 * some characters will also be represented in their percent-encoded form. 2983 * 2984 * Because this function is randomized, the outputs for any given input may 2985 * differ between calls. This helps diversify the ways the email addresses 2986 * are obscured. 2987 * 2988 * When non-UTF-8 inputs are provided, any spans of invalid UTF-8 bytes will 2989 * be passed through without any obfuscation. 2990 * 2991 * Example: 2992 * 2993 * $email = 'noreply@example.com'; 2994 * $obscured = antispambot( $email ); 2995 * $obscured === 'noreply@example.com'; 2996 * 2997 * // Hex-encoding also obscures characters with percent-encoding. 2998 * $obscured = antispambot( $email, 1 ); 2999 * $obscured === '%6eore%70l%79@%65x%61mple%2e%63%6fm'; 3000 * 3001 * // Non-UTF-8 characters are not obfuscated. "\xFC" is Latin1 "ü". 3002 * $obscured = antispambot( "b\xFCcher@library.de" ); 3003 * $obscured === 'b�cher@library.de'; 3004 * $obscured === "b\xFCcher@library.de" 3005 * 3006 * @since 0.71 3007 * @since 7.1.0 Masquerades multibyte characters. 3008 * 3009 * @param string $email_address Email address. 3010 * @param int $hex_encoding Optional. Set to 1 to enable hex encoding. 3011 * @return string Converted email address. 3012 * 3013 * @phpstan-param 0|1 $hex_encoding 3014 */ 3015 function antispambot( $email_address, $hex_encoding = 0 ) { 3016 $obfuscated = ''; 3017 $at = 0; 3018 $end = strlen( $email_address ); 3019 $invalid_length = 0; 3020 3021 while ( $at < $end ) { 3022 $was_at = $at; 3023 if ( 3024 0 === _wp_scan_utf8( $email_address, $at, $invalid_length, null, 1 ) && 3025 0 === $invalid_length 3026 ) { 3027 break; 3028 } 3029 3030 $character_length = $at - $was_at; 3031 3032 if ( $character_length > 0 ) { 3033 $character = substr( $email_address, $was_at, $character_length ); 3034 3035 switch ( rand( 0, 1 + $hex_encoding ) ) { 3036 case 0: 3037 $code_point = mb_ord( $character ); 3038 $obfuscated .= "&#{$code_point};"; 3039 break; 3040 3041 case 1: 3042 $obfuscated .= $character; 3043 break; 3044 3045 case 2: 3046 for ( $i = 0; $i < $character_length; $i++ ) { 3047 $hex_value = bin2hex( $character[ $i ] ); 3048 $obfuscated .= "%{$hex_value}"; 3049 } 3050 break; 3051 } 3052 } 3053 3054 if ( 0 !== $invalid_length ) { 3055 $obfuscated .= substr( $email_address, $at, $invalid_length ); 3056 } 3057 3058 $at += $invalid_length; 3059 } 3060 3061 return str_replace( '@', '@', $obfuscated ); 3062 } 3063 3064 /** 3065 * Callback to convert URI match to HTML A element. 3066 * 3067 * This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). 3068 * 3069 * @since 2.3.2 3070 * @access private 3071 * 3072 * @param array $matches Single Regex Match. 3073 * @return string HTML A element with URI address. 3074 */ 3075 function _make_url_clickable_cb( $matches ) { 3076 $url = $matches[2]; 3077 3078 if ( ')' === $matches[3] && strpos( $url, '(' ) ) { 3079 /* 3080 * If the trailing character is a closing parenthesis, and the URL has an opening parenthesis in it, 3081 * add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below. 3082 */ 3083 $url .= $matches[3]; 3084 $suffix = ''; 3085 } else { 3086 $suffix = $matches[3]; 3087 } 3088 3089 if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) { 3090 $url .= $matches[4]; 3091 } 3092 3093 // Include parentheses in the URL only if paired. 3094 while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { 3095 $suffix = strrchr( $url, ')' ) . $suffix; 3096 $url = substr( $url, 0, strrpos( $url, ')' ) ); 3097 } 3098 3099 $url = esc_url( $url ); 3100 if ( empty( $url ) ) { 3101 return $matches[0]; 3102 } 3103 3104 $rel_attr = _make_clickable_rel_attr( $url ); 3105 3106 return $matches[1] . "<a href=\"{$url}\"{$rel_attr}>{$url}</a>" . $suffix; 3107 } 3108 3109 /** 3110 * Callback to convert URL match to HTML A element. 3111 * 3112 * This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). 3113 * 3114 * @since 2.3.2 3115 * @access private 3116 * 3117 * @param array $matches Single Regex Match. 3118 * @return string HTML A element with URL address. 3119 */ 3120 function _make_web_ftp_clickable_cb( $matches ) { 3121 $ret = ''; 3122 $dest = $matches[2]; 3123 $dest = 'http://' . $dest; 3124 3125 // Removed trailing [.,;:)] from URL. 3126 $last_char = substr( $dest, -1 ); 3127 if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) ) { 3128 $ret = $last_char; 3129 $dest = substr( $dest, 0, strlen( $dest ) - 1 ); 3130 } 3131 3132 $dest = esc_url( $dest ); 3133 if ( empty( $dest ) ) { 3134 return $matches[0]; 3135 } 3136 3137 $rel_attr = _make_clickable_rel_attr( $dest ); 3138 3139 return $matches[1] . "<a href=\"{$dest}\"{$rel_attr}>{$dest}</a>{$ret}"; 3140 } 3141 3142 /** 3143 * Callback to convert email address match to HTML A element. 3144 * 3145 * This function was backported from 2.5.0 to 2.3.2. Regex callback for make_clickable(). 3146 * 3147 * @since 2.3.2 3148 * @access private 3149 * 3150 * @param array $matches Single Regex Match. 3151 * @return string HTML A element with email address. 3152 */ 3153 function _make_email_clickable_cb( $matches ) { 3154 $email = $matches[2] . '@' . $matches[3]; 3155 3156 return $matches[1] . "<a href=\"mailto:{$email}\">{$email}</a>"; 3157 } 3158 3159 /** 3160 * Helper function used to build the "rel" attribute for a URL when creating an anchor using make_clickable(). 3161 * 3162 * @since 6.2.0 3163 * 3164 * @param string $url The URL. 3165 * @return string The rel attribute for the anchor or an empty string if no rel attribute should be added. 3166 */ 3167 function _make_clickable_rel_attr( $url ) { 3168 $rel_parts = array(); 3169 $scheme = strtolower( wp_parse_url( $url, PHP_URL_SCHEME ) ); 3170 $nofollow_schemes = array_intersect( wp_allowed_protocols(), array( 'https', 'http' ) ); 3171 3172 // Apply "nofollow" to external links with qualifying URL schemes (mailto:, tel:, etc... shouldn't be followed). 3173 if ( ! wp_is_internal_link( $url ) && in_array( $scheme, $nofollow_schemes, true ) ) { 3174 $rel_parts[] = 'nofollow'; 3175 } 3176 3177 // Apply "ugc" when in comment context. 3178 if ( 'comment_text' === current_filter() ) { 3179 $rel_parts[] = 'ugc'; 3180 } 3181 3182 $rel = implode( ' ', $rel_parts ); 3183 3184 /** 3185 * Filters the rel value that is added to URL matches converted to links. 3186 * 3187 * @since 5.3.0 3188 * 3189 * @param string $rel The rel value. 3190 * @param string $url The matched URL being converted to a link tag. 3191 */ 3192 $rel = apply_filters( 'make_clickable_rel', $rel, $url ); 3193 3194 $rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : ''; 3195 3196 return $rel_attr; 3197 } 3198 3199 /** 3200 * Converts plaintext URI to HTML links. 3201 * 3202 * Converts URI, www and ftp, and email addresses. Finishes by fixing links 3203 * within links. 3204 * 3205 * @since 0.71 3206 * 3207 * @param string $text Content to convert URIs. 3208 * @return string Content with converted URIs. 3209 */ 3210 function make_clickable( $text ) { 3211 $r = ''; 3212 $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Split out HTML tags. 3213 $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>. 3214 foreach ( $textarr as $piece ) { 3215 3216 if ( preg_match( '|^<code[\s>]|i', $piece ) 3217 || preg_match( '|^<pre[\s>]|i', $piece ) 3218 || preg_match( '|^<script[\s>]|i', $piece ) 3219 || preg_match( '|^<style[\s>]|i', $piece ) 3220 ) { 3221 ++$nested_code_pre; 3222 } elseif ( $nested_code_pre 3223 && ( '</code>' === strtolower( $piece ) 3224 || '</pre>' === strtolower( $piece ) 3225 || '</script>' === strtolower( $piece ) 3226 || '</style>' === strtolower( $piece ) 3227 ) 3228 ) { 3229 --$nested_code_pre; 3230 } 3231 3232 if ( $nested_code_pre 3233 || empty( $piece ) 3234 || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) 3235 ) { 3236 $r .= $piece; 3237 continue; 3238 } 3239 3240 // Long strings might contain expensive edge cases... 3241 if ( 10000 < strlen( $piece ) ) { 3242 // ...break it up. 3243 foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing parentheses. 3244 if ( 2101 < strlen( $chunk ) ) { 3245 $r .= $chunk; // Too big, no whitespace: bail. 3246 } else { 3247 $r .= make_clickable( $chunk ); 3248 } 3249 } 3250 } else { 3251 $ret = " $piece "; // Pad with whitespace to simplify the regexes. 3252 3253 $url_clickable = '~ 3254 ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation. 3255 ( # 2: URL. 3256 [\\w]{1,20}+:// # Scheme and hier-part prefix. 3257 (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long. 3258 [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character. 3259 (?: # Unroll the Loop: Only allow punctuation URL character if followed by a non-punctuation URL character. 3260 [\'.,;:!?)] # Punctuation URL character. 3261 [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character. 3262 )* 3263 ) 3264 (\)?) # 3: Trailing closing parenthesis (for parenthesis balancing post processing). 3265 (\\.\\w{2,6})? # 4: Allowing file extensions (e.g., .jpg, .png). 3266 ~xS'; 3267 /* 3268 * The regex is a non-anchored pattern and does not have a single fixed starting character. 3269 * Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. 3270 */ 3271 3272 $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); 3273 3274 $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); 3275 $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); 3276 3277 $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. 3278 $r .= $ret; 3279 } 3280 } 3281 3282 // Cleanup of accidental links within links. 3283 return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', '$1$3</a>', $r ); 3284 } 3285 3286 /** 3287 * Breaks a string into chunks by splitting at whitespace characters. 3288 * 3289 * The length of each returned chunk is as close to the specified length goal as possible, 3290 * with the caveat that each chunk includes its trailing delimiter. 3291 * Chunks longer than the goal are guaranteed to not have any inner whitespace. 3292 * 3293 * Joining the returned chunks with empty delimiters reconstructs the input string losslessly. 3294 * 3295 * Input string must have no null characters (or eventual transformations on output chunks must not care about null characters) 3296 * 3297 * _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) == 3298 * array ( 3299 * 0 => '1234 67890 ', // 11 characters: Perfect split. 3300 * 1 => '1234 ', // 5 characters: '1234 67890a' was too long. 3301 * 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long. 3302 * 3 => '1234 890 ', // 11 characters: Perfect split. 3303 * 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long. 3304 * 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split. 3305 * 6 => ' 45678 ', // 11 characters: Perfect split. 3306 * 7 => '1 3 5 7 90 ', // 11 characters: End of $text. 3307 * ); 3308 * 3309 * @since 3.4.0 3310 * @access private 3311 * 3312 * @param string $text The string to split. 3313 * @param int $goal The desired chunk length. 3314 * @return array Numeric array of chunks. 3315 */ 3316 function _split_str_by_whitespace( $text, $goal ) { 3317 $chunks = array(); 3318 3319 $string_nullspace = strtr( $text, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); 3320 3321 while ( $goal < strlen( $string_nullspace ) ) { 3322 $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); 3323 3324 if ( false === $pos ) { 3325 $pos = strpos( $string_nullspace, "\000", $goal + 1 ); 3326 if ( false === $pos ) { 3327 break; 3328 } 3329 } 3330 3331 $chunks[] = substr( $text, 0, $pos + 1 ); 3332 $text = substr( $text, $pos + 1 ); 3333 $string_nullspace = substr( $string_nullspace, $pos + 1 ); 3334 } 3335 3336 if ( $text ) { 3337 $chunks[] = $text; 3338 } 3339 3340 return $chunks; 3341 } 3342 3343 /** 3344 * Callback to add a rel attribute to HTML A element. 3345 * 3346 * Will remove already existing string before adding to prevent invalidating (X)HTML. 3347 * 3348 * @since 5.3.0 3349 * 3350 * @param array $matches Single match. 3351 * @param string $rel The rel attribute to add. 3352 * @return string HTML A element with the added rel attribute. 3353 */ 3354 function wp_rel_callback( $matches, $rel ) { 3355 $text = $matches[1]; 3356 $atts = wp_kses_hair( $matches[1], wp_allowed_protocols() ); 3357 3358 if ( ! empty( $atts['href'] ) && wp_is_internal_link( $atts['href']['value'] ) ) { 3359 $rel = trim( str_replace( 'nofollow', '', $rel ) ); 3360 } 3361 3362 if ( ! empty( $atts['rel'] ) ) { 3363 $parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) ); 3364 $rel_array = array_map( 'trim', explode( ' ', $rel ) ); 3365 $parts = array_unique( array_merge( $parts, $rel_array ) ); 3366 $rel = implode( ' ', $parts ); 3367 unset( $atts['rel'] ); 3368 3369 $html = ''; 3370 foreach ( $atts as $name => $value ) { 3371 if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) { 3372 $html .= $name . ' '; 3373 } else { 3374 $html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" '; 3375 } 3376 } 3377 $text = trim( $html ); 3378 } 3379 3380 $rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : ''; 3381 3382 return "<a {$text}{$rel_attr}>"; 3383 } 3384 3385 /** 3386 * Adds `rel="nofollow"` string to all HTML A elements in content. 3387 * 3388 * @since 1.5.0 3389 * 3390 * @param string $text Content that may contain HTML A elements. 3391 * @return string Converted content. 3392 */ 3393 function wp_rel_nofollow( $text ) { 3394 // This is a pre-save filter, so text is already escaped. 3395 $text = stripslashes( $text ); 3396 $text = preg_replace_callback( 3397 '|<a (.+?)>|i', 3398 static function ( $matches ) { 3399 return wp_rel_callback( $matches, 'nofollow' ); 3400 }, 3401 $text 3402 ); 3403 return wp_slash( $text ); 3404 } 3405 3406 /** 3407 * Callback to add `rel="nofollow"` string to HTML A element. 3408 * 3409 * @since 2.3.0 3410 * @deprecated 5.3.0 Use wp_rel_callback() 3411 * 3412 * @param array $matches Single match. 3413 * @return string HTML A Element with `rel="nofollow"`. 3414 */ 3415 function wp_rel_nofollow_callback( $matches ) { 3416 return wp_rel_callback( $matches, 'nofollow' ); 3417 } 3418 3419 /** 3420 * Adds `rel="nofollow ugc"` string to all HTML A elements in content. 3421 * 3422 * @since 5.3.0 3423 * 3424 * @param string $text Content that may contain HTML A elements. 3425 * @return string Converted content. 3426 */ 3427 function wp_rel_ugc( $text ) { 3428 // This is a pre-save filter, so text is already escaped. 3429 $text = stripslashes( $text ); 3430 $text = preg_replace_callback( 3431 '|<a (.+?)>|i', 3432 static function ( $matches ) { 3433 return wp_rel_callback( $matches, 'nofollow ugc' ); 3434 }, 3435 $text 3436 ); 3437 return wp_slash( $text ); 3438 } 3439 3440 /** 3441 * Adds `rel="noopener"` to all HTML A elements that have a target. 3442 * 3443 * @since 5.1.0 3444 * @since 5.6.0 Removed 'noreferrer' relationship. 3445 * @deprecated 6.7.0 3446 * 3447 * @param string $text Content that may contain HTML A elements. 3448 * @return string Converted content. 3449 */ 3450 function wp_targeted_link_rel( $text ) { 3451 _deprecated_function( __FUNCTION__, '6.7.0' ); 3452 3453 // Don't run (more expensive) regex if no links with targets. 3454 if ( false === stripos( $text, 'target' ) || false === stripos( $text, '<a ' ) || is_serialized( $text ) ) { 3455 return $text; 3456 } 3457 3458 $script_and_style_regex = '/<(script|style).*?<\/\\1>/si'; 3459 3460 preg_match_all( $script_and_style_regex, $text, $matches ); 3461 $extra_parts = $matches[0]; 3462 $html_parts = preg_split( $script_and_style_regex, $text ); 3463 3464 foreach ( $html_parts as &$part ) { 3465 $part = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $part ); 3466 } 3467 3468 $text = ''; 3469 for ( $i = 0; $i < count( $html_parts ); $i++ ) { 3470 $text .= $html_parts[ $i ]; 3471 if ( isset( $extra_parts[ $i ] ) ) { 3472 $text .= $extra_parts[ $i ]; 3473 } 3474 } 3475 3476 return $text; 3477 } 3478 3479 /** 3480 * Callback to add `rel="noopener"` string to HTML A element. 3481 * 3482 * Will not duplicate an existing 'noopener' value to avoid invalidating the HTML. 3483 * 3484 * @since 5.1.0 3485 * @since 5.6.0 Removed 'noreferrer' relationship. 3486 * @deprecated 6.7.0 3487 * 3488 * @param array $matches Single match. 3489 * @return string HTML A Element with `rel="noopener"` in addition to any existing values. 3490 */ 3491 function wp_targeted_link_rel_callback( $matches ) { 3492 _deprecated_function( __FUNCTION__, '6.7.0' ); 3493 3494 $link_html = $matches[1]; 3495 $original_link_html = $link_html; 3496 3497 // Consider the HTML escaped if there are no unescaped quotes. 3498 $is_escaped = ! preg_match( '/(^|[^\\\\])[\'"]/', $link_html ); 3499 if ( $is_escaped ) { 3500 // Replace only the quotes so that they are parsable by wp_kses_hair(), leave the rest as is. 3501 $link_html = preg_replace( '/\\\\([\'"])/', '$1', $link_html ); 3502 } 3503 3504 $atts = wp_kses_hair( $link_html, wp_allowed_protocols() ); 3505 3506 /** 3507 * Filters the rel values that are added to links with `target` attribute. 3508 * 3509 * @since 5.1.0 3510 * 3511 * @param string $rel The rel values. 3512 * @param string $link_html The matched content of the link tag including all HTML attributes. 3513 */ 3514 $rel = apply_filters( 'wp_targeted_link_rel', 'noopener', $link_html ); 3515 3516 // Return early if no rel values to be added or if no actual target attribute. 3517 if ( ! $rel || ! isset( $atts['target'] ) ) { 3518 return "<a $original_link_html>"; 3519 } 3520 3521 if ( isset( $atts['rel'] ) ) { 3522 $all_parts = preg_split( '/\s/', "{$atts['rel']['value']} $rel", -1, PREG_SPLIT_NO_EMPTY ); 3523 $rel = implode( ' ', array_unique( $all_parts ) ); 3524 } 3525 3526 $atts['rel']['whole'] = 'rel="' . esc_attr( $rel ) . '"'; 3527 $link_html = implode( ' ', array_column( $atts, 'whole' ) ); 3528 3529 if ( $is_escaped ) { 3530 $link_html = preg_replace( '/[\'"]/', '\\\\$0', $link_html ); 3531 } 3532 3533 return "<a $link_html>"; 3534 } 3535 3536 /** 3537 * Adds all filters modifying the rel attribute of targeted links. 3538 * 3539 * @since 5.1.0 3540 * @deprecated 6.7.0 3541 */ 3542 function wp_init_targeted_link_rel_filters() { 3543 _deprecated_function( __FUNCTION__, '6.7.0' ); 3544 } 3545 3546 /** 3547 * Removes all filters modifying the rel attribute of targeted links. 3548 * 3549 * @since 5.1.0 3550 * @deprecated 6.7.0 3551 */ 3552 function wp_remove_targeted_link_rel_filters() { 3553 _deprecated_function( __FUNCTION__, '6.7.0' ); 3554 } 3555 3556 /** 3557 * Converts one smiley code to the icon graphic file equivalent. 3558 * 3559 * Callback handler for convert_smilies(). 3560 * 3561 * Looks up one smiley code in the $wpsmiliestrans global array and returns an 3562 * `<img>` string for that smiley. 3563 * 3564 * @since 2.8.0 3565 * 3566 * @global array $wpsmiliestrans 3567 * 3568 * @param array $matches Single match. Smiley code to convert to image. 3569 * @return string Image string for smiley. 3570 */ 3571 function translate_smiley( $matches ) { 3572 global $wpsmiliestrans; 3573 3574 if ( 0 === count( $matches ) ) { 3575 return ''; 3576 } 3577 3578 $smiley = trim( reset( $matches ) ); 3579 $img = $wpsmiliestrans[ $smiley ]; 3580 3581 $matches = array(); 3582 $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false; 3583 $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp', 'avif' ); 3584 3585 // Don't convert smilies that aren't images - they're probably emoji. 3586 if ( ! in_array( $ext, $image_exts, true ) ) { 3587 return $img; 3588 } 3589 3590 /** 3591 * Filters the Smiley image URL before it's used in the image element. 3592 * 3593 * @since 2.9.0 3594 * 3595 * @param string $smiley_url URL for the smiley image. 3596 * @param string $img Filename for the smiley image. 3597 * @param string $site_url Site URL, as returned by site_url(). 3598 */ 3599 $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); 3600 3601 return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) ); 3602 } 3603 3604 /** 3605 * Converts text equivalent of smilies to images. 3606 * 3607 * Will only convert smilies if the option 'use_smilies' is true and the global 3608 * used in the function isn't empty. 3609 * 3610 * @since 0.71 3611 * 3612 * @global string|array $wp_smiliessearch 3613 * 3614 * @param string $text Content to convert smilies from text. 3615 * @return string Converted content with text smilies replaced with images. 3616 */ 3617 function convert_smilies( $text ) { 3618 global $wp_smiliessearch; 3619 3620 if ( ! get_option( 'use_smilies' ) || empty( $wp_smiliessearch ) ) { 3621 // Return default text. 3622 return $text; 3623 } 3624 3625 // HTML loop taken from texturize function, could possible be consolidated. 3626 $textarr = preg_split( '/(<[^>]*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between. 3627 3628 if ( false === $textarr ) { 3629 // Return default text. 3630 return $text; 3631 } 3632 3633 // Loop stuff. 3634 $stop = count( $textarr ); 3635 $output = ''; 3636 3637 // Ignore processing of specific tags. 3638 $tags_to_ignore = 'code|pre|style|script|textarea'; 3639 $ignore_block_element = ''; 3640 3641 for ( $i = 0; $i < $stop; $i++ ) { 3642 $content = $textarr[ $i ]; 3643 3644 // If we're in an ignore block, wait until we find its closing tag. 3645 if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) { 3646 $ignore_block_element = $matches[1]; 3647 } 3648 3649 // If it's not a tag and not in ignore block. 3650 if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) { 3651 $content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); 3652 } 3653 3654 // Did we exit ignore block? 3655 if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) { 3656 $ignore_block_element = ''; 3657 } 3658 3659 $output .= $content; 3660 } 3661 3662 return $output; 3663 } 3664 3665 /** 3666 * Verifies that an email is valid. 3667 * 3668 * Does not grok i18n domains. Not RFC compliant. 3669 * 3670 * @since 0.71 3671 * 3672 * @param string $email Email address to verify. 3673 * @param bool $deprecated Deprecated. 3674 * @return string|false Valid email address on success, false on failure. 3675 * 3676 * @phpstan-param false $deprecated 3677 */ 3678 function is_email( $email, $deprecated = false ) { 3679 if ( ! empty( $deprecated ) ) { 3680 _deprecated_argument( __FUNCTION__, '3.0.0' ); 3681 } 3682 3683 // Test for the minimum length the email can be. 3684 if ( strlen( $email ) < 6 ) { 3685 /** 3686 * Filters whether an email address is valid. 3687 * 3688 * This filter is evaluated under several different contexts, such as 'email_too_short', 3689 * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', 3690 * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context. 3691 * 3692 * @since 2.8.0 3693 * 3694 * @param string|false $is_email The email address if successfully passed the is_email() checks, false otherwise. 3695 * @param string $email The email address being checked. 3696 * @param string $context Context under which the email was tested. 3697 */ 3698 return apply_filters( 'is_email', false, $email, 'email_too_short' ); 3699 } 3700 3701 // Test for an @ character after the first position. 3702 if ( false === strpos( $email, '@', 1 ) ) { 3703 /** This filter is documented in wp-includes/formatting.php */ 3704 return apply_filters( 'is_email', false, $email, 'email_no_at' ); 3705 } 3706 3707 // Split out the local and domain parts. 3708 list( $local, $domain ) = explode( '@', $email, 2 ); 3709 3710 /* 3711 * LOCAL PART 3712 * Test for invalid characters. 3713 */ 3714 if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { 3715 /** This filter is documented in wp-includes/formatting.php */ 3716 return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); 3717 } 3718 3719 /* 3720 * DOMAIN PART 3721 * Test for sequences of periods. 3722 */ 3723 if ( preg_match( '/\.{2,}/', $domain ) ) { 3724 /** This filter is documented in wp-includes/formatting.php */ 3725 return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); 3726 } 3727 3728 // Test for leading and trailing periods and whitespace. 3729 if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { 3730 /** This filter is documented in wp-includes/formatting.php */ 3731 return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); 3732 } 3733 3734 // Split the domain into subs. 3735 $subs = explode( '.', $domain ); 3736 3737 // Assume the domain will have at least two subs. 3738 if ( 2 > count( $subs ) ) { 3739 /** This filter is documented in wp-includes/formatting.php */ 3740 return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); 3741 } 3742 3743 // Loop through each sub. 3744 foreach ( $subs as $sub ) { 3745 // Test for leading and trailing hyphens and whitespace. 3746 if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { 3747 /** This filter is documented in wp-includes/formatting.php */ 3748 return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); 3749 } 3750 3751 // Test for invalid characters. 3752 if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) { 3753 /** This filter is documented in wp-includes/formatting.php */ 3754 return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); 3755 } 3756 } 3757 3758 // Congratulations, your email made it! 3759 /** This filter is documented in wp-includes/formatting.php */ 3760 return apply_filters( 'is_email', $email, $email, null ); 3761 } 3762 3763 /** 3764 * Converts to ASCII from email subjects. 3765 * 3766 * @since 1.2.0 3767 * 3768 * @param string $subject Subject line. 3769 * @return string Converted string to ASCII. 3770 */ 3771 function wp_iso_descrambler( $subject ) { 3772 /* this may only work with iso-8859-1, I'm afraid */ 3773 if ( ! preg_match( '#\=\?(.+)\?Q\?(.+)\?\=#i', $subject, $matches ) ) { 3774 return $subject; 3775 } 3776 3777 $subject = str_replace( '_', ' ', $matches[2] ); 3778 return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject ); 3779 } 3780 3781 /** 3782 * Helper function to convert hex encoded chars to ASCII. 3783 * 3784 * @since 3.1.0 3785 * @access private 3786 * 3787 * @param array $matches The preg_replace_callback matches array. 3788 * @return string Converted chars. 3789 */ 3790 function _wp_iso_convert( $matches ) { 3791 return chr( hexdec( strtolower( $matches[1] ) ) ); 3792 } 3793 3794 /** 3795 * Given a date in the timezone of the site, returns that date in UTC. 3796 * 3797 * Requires and returns a date in the Y-m-d H:i:s format. 3798 * Return format can be overridden using the $format parameter. 3799 * 3800 * @since 1.2.0 3801 * 3802 * @param string $date_string The date to be converted, in the timezone of the site. 3803 * @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'. 3804 * @return string Formatted version of the date, in UTC. 3805 */ 3806 function get_gmt_from_date( $date_string, $format = 'Y-m-d H:i:s' ) { 3807 $datetime = date_create( $date_string, wp_timezone() ); 3808 3809 if ( false === $datetime ) { 3810 return gmdate( $format, 0 ); 3811 } 3812 3813 return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( $format ); 3814 } 3815 3816 /** 3817 * Given a date in UTC or GMT timezone, returns that date in the timezone of the site. 3818 * 3819 * Requires a date in the Y-m-d H:i:s format. 3820 * Default return format of 'Y-m-d H:i:s' can be overridden using the `$format` parameter. 3821 * 3822 * @since 1.2.0 3823 * 3824 * @param string $date_string The date to be converted, in UTC or GMT timezone. 3825 * @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'. 3826 * @return string Formatted version of the date, in the site's timezone. 3827 */ 3828 function get_date_from_gmt( $date_string, $format = 'Y-m-d H:i:s' ) { 3829 $datetime = date_create( $date_string, new DateTimeZone( 'UTC' ) ); 3830 3831 if ( false === $datetime ) { 3832 return gmdate( $format, 0 ); 3833 } 3834 3835 return $datetime->setTimezone( wp_timezone() )->format( $format ); 3836 } 3837 3838 /** 3839 * Given an ISO 8601 timezone, returns its UTC offset in seconds. 3840 * 3841 * @since 1.5.0 3842 * 3843 * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. 3844 * @return int|float The offset in seconds. 3845 */ 3846 function iso8601_timezone_to_offset( $timezone ) { 3847 // $timezone is either 'Z' or '[+|-]hhmm'. 3848 if ( 'Z' === $timezone ) { 3849 $offset = 0; 3850 } else { 3851 $sign = ( str_starts_with( $timezone, '+' ) ) ? 1 : -1; 3852 $hours = (int) substr( $timezone, 1, 2 ); 3853 $minutes = (int) substr( $timezone, 3, 4 ) / 60; 3854 $offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes ); 3855 } 3856 return $offset; 3857 } 3858 3859 /** 3860 * Given an ISO 8601 (Ymd\TH:i:sO) date, returns a MySQL DateTime (Y-m-d H:i:s) format used by post_date[_gmt]. 3861 * 3862 * @since 1.5.0 3863 * 3864 * @param string $date_string Date and time in ISO 8601 format {@link https://en.wikipedia.org/wiki/ISO_8601}. 3865 * @param string $timezone Optional. If set to 'gmt' returns the result in UTC. Default 'user'. 3866 * @return string|false The date and time in MySQL DateTime format - Y-m-d H:i:s, or false on failure. 3867 */ 3868 function iso8601_to_datetime( $date_string, $timezone = 'user' ) { 3869 $timezone = strtolower( $timezone ); 3870 $wp_timezone = wp_timezone(); 3871 $datetime = date_create( $date_string, $wp_timezone ); // Timezone is ignored if input has one. 3872 3873 if ( false === $datetime ) { 3874 return false; 3875 } 3876 3877 if ( 'gmt' === $timezone ) { 3878 return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( 'Y-m-d H:i:s' ); 3879 } 3880 3881 if ( 'user' === $timezone ) { 3882 return $datetime->setTimezone( $wp_timezone )->format( 'Y-m-d H:i:s' ); 3883 } 3884 3885 return false; 3886 } 3887 3888 /** 3889 * Strips out all characters that are not allowable in an email. 3890 * 3891 * @since 1.5.0 3892 * 3893 * @param string $email Email address to filter. 3894 * @return string Filtered email address. 3895 */ 3896 function sanitize_email( $email ) { 3897 // Test for the minimum length the email can be. 3898 if ( strlen( $email ) < 6 ) { 3899 /** 3900 * Filters a sanitized email address. 3901 * 3902 * This filter is evaluated under several contexts, including 'email_too_short', 3903 * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits', 3904 * 'domain_no_periods', 'domain_no_valid_subs', or no context. 3905 * 3906 * @since 2.8.0 3907 * 3908 * @param string $sanitized_email The sanitized email address. 3909 * @param string $email The email address, as provided to sanitize_email(). 3910 * @param string|null $message A message to pass to the user. null if email is sanitized. 3911 */ 3912 return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); 3913 } 3914 3915 // Test for an @ character after the first position. 3916 if ( false === strpos( $email, '@', 1 ) ) { 3917 /** This filter is documented in wp-includes/formatting.php */ 3918 return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); 3919 } 3920 3921 // Split out the local and domain parts. 3922 list( $local, $domain ) = explode( '@', $email, 2 ); 3923 3924 /* 3925 * LOCAL PART 3926 * Test for invalid characters. 3927 */ 3928 $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); 3929 if ( '' === $local ) { 3930 /** This filter is documented in wp-includes/formatting.php */ 3931 return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); 3932 } 3933 3934 /* 3935 * DOMAIN PART 3936 * Test for sequences of periods. 3937 */ 3938 $domain = preg_replace( '/\.{2,}/', '', $domain ); 3939 if ( '' === $domain ) { 3940 /** This filter is documented in wp-includes/formatting.php */ 3941 return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); 3942 } 3943 3944 // Test for leading and trailing periods and whitespace. 3945 $domain = trim( $domain, " \t\n\r\0\x0B." ); 3946 if ( '' === $domain ) { 3947 /** This filter is documented in wp-includes/formatting.php */ 3948 return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); 3949 } 3950 3951 // Split the domain into subs. 3952 $subs = explode( '.', $domain ); 3953 3954 // Assume the domain will have at least two subs. 3955 if ( 2 > count( $subs ) ) { 3956 /** This filter is documented in wp-includes/formatting.php */ 3957 return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); 3958 } 3959 3960 // Create an array that will contain valid subs. 3961 $new_subs = array(); 3962 3963 // Loop through each sub. 3964 foreach ( $subs as $sub ) { 3965 // Test for leading and trailing hyphens. 3966 $sub = trim( $sub, " \t\n\r\0\x0B-" ); 3967 3968 // Test for invalid characters. 3969 $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); 3970 3971 // If there's anything left, add it to the valid subs. 3972 if ( '' !== $sub ) { 3973 $new_subs[] = $sub; 3974 } 3975 } 3976 3977 // If there aren't 2 or more valid subs. 3978 if ( 2 > count( $new_subs ) ) { 3979 /** This filter is documented in wp-includes/formatting.php */ 3980 return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); 3981 } 3982 3983 // Join valid subs into the new domain. 3984 $domain = implode( '.', $new_subs ); 3985 3986 // Put the email back together. 3987 $sanitized_email = $local . '@' . $domain; 3988 3989 // Congratulations, your email made it! 3990 /** This filter is documented in wp-includes/formatting.php */ 3991 return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); 3992 } 3993 3994 /** 3995 * Determines the difference between two timestamps. 3996 * 3997 * The difference is returned in a human-readable format such as "1 hour", 3998 * "5 minutes", "2 days". 3999 * 4000 * @since 1.5.0 4001 * @since 5.3.0 Added support for showing a difference in seconds. 4002 * 4003 * @param int $from Unix timestamp from which the difference begins. 4004 * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. 4005 * @return string Human-readable time difference. 4006 */ 4007 function human_time_diff( $from, $to = 0 ) { 4008 if ( empty( $to ) ) { 4009 $to = time(); 4010 } 4011 4012 $diff = (int) abs( $to - $from ); 4013 4014 if ( $diff < MINUTE_IN_SECONDS ) { 4015 $secs = $diff; 4016 if ( $secs <= 1 ) { 4017 $secs = 1; 4018 } 4019 /* translators: Time difference between two dates, in seconds. %s: Number of seconds. */ 4020 $since = sprintf( _n( '%s second', '%s seconds', $secs ), $secs ); 4021 } elseif ( $diff < HOUR_IN_SECONDS ) { 4022 $mins = (int) round( $diff / MINUTE_IN_SECONDS ); 4023 /* translators: Time difference between two dates, in minutes. %s: Number of minutes. */ 4024 $since = sprintf( _n( '%s minute', '%s minutes', $mins ), $mins ); 4025 } elseif ( $diff < DAY_IN_SECONDS ) { 4026 $hours = (int) round( $diff / HOUR_IN_SECONDS ); 4027 /* translators: Time difference between two dates, in hours. %s: Number of hours. */ 4028 $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); 4029 } elseif ( $diff < WEEK_IN_SECONDS ) { 4030 $days = (int) round( $diff / DAY_IN_SECONDS ); 4031 /* translators: Time difference between two dates, in days. %s: Number of days. */ 4032 $since = sprintf( _n( '%s day', '%s days', $days ), $days ); 4033 } elseif ( $diff < MONTH_IN_SECONDS ) { 4034 $weeks = (int) round( $diff / WEEK_IN_SECONDS ); 4035 /* translators: Time difference between two dates, in weeks. %s: Number of weeks. */ 4036 $since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks ); 4037 } elseif ( $diff < YEAR_IN_SECONDS ) { 4038 $months = (int) round( $diff / MONTH_IN_SECONDS ); 4039 /* translators: Time difference between two dates, in months. %s: Number of months. */ 4040 $since = sprintf( _n( '%s month', '%s months', $months ), $months ); 4041 } else { 4042 $years = (int) round( $diff / YEAR_IN_SECONDS ); 4043 /* translators: Time difference between two dates, in years. %s: Number of years. */ 4044 $since = sprintf( _n( '%s year', '%s years', $years ), $years ); 4045 } 4046 4047 /** 4048 * Filters the human-readable difference between two timestamps. 4049 * 4050 * @since 4.0.0 4051 * 4052 * @param string $since The difference in human-readable text. 4053 * @param int $diff The difference in seconds. 4054 * @param int $from Unix timestamp from which the difference begins. 4055 * @param int $to Unix timestamp to end the time difference. 4056 */ 4057 return apply_filters( 'human_time_diff', $since, $diff, $from, $to ); 4058 } 4059 4060 /** 4061 * Generates an excerpt from the content, if needed. 4062 * 4063 * Returns a maximum of 55 words with an ellipsis appended if necessary. 4064 * 4065 * The 55-word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter 4066 * The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter 4067 * 4068 * @since 1.5.0 4069 * @since 5.2.0 Added the `$post` parameter. 4070 * @since 6.3.0 Removes footnotes markup from the excerpt content. 4071 * 4072 * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated. 4073 * @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default null. 4074 * @return string The excerpt. 4075 */ 4076 function wp_trim_excerpt( $text = '', $post = null ) { 4077 $raw_excerpt = $text; 4078 4079 if ( '' === trim( $text ) ) { 4080 $post = get_post( $post ); 4081 $text = get_the_content( '', false, $post ); 4082 4083 $text = strip_shortcodes( $text ); 4084 $text = excerpt_remove_blocks( $text ); 4085 $text = excerpt_remove_footnotes( $text ); 4086 4087 /* 4088 * Temporarily unhook wp_filter_content_tags() since any tags 4089 * within the excerpt are stripped out. Modifying the tags here 4090 * is wasteful and can lead to bugs in the image counting logic. 4091 */ 4092 $filter_image_removed = remove_filter( 'the_content', 'wp_filter_content_tags', 12 ); 4093 4094 /* 4095 * Temporarily unhook do_blocks() since excerpt_remove_blocks( $text ) 4096 * handles block rendering needed for excerpt. 4097 */ 4098 $filter_block_removed = remove_filter( 'the_content', 'do_blocks', 9 ); 4099 4100 /** This filter is documented in wp-includes/post-template.php */ 4101 $text = apply_filters( 'the_content', $text ); 4102 $text = str_replace( ']]>', ']]>', $text ); 4103 4104 // Restore the original filter if removed. 4105 if ( $filter_block_removed ) { 4106 add_filter( 'the_content', 'do_blocks', 9 ); 4107 } 4108 4109 /* 4110 * Only restore the filter callback if it was removed above. The logic 4111 * to unhook and restore only applies on the default priority of 10, 4112 * which is generally used for the filter callback in WordPress core. 4113 */ 4114 if ( $filter_image_removed ) { 4115 add_filter( 'the_content', 'wp_filter_content_tags', 12 ); 4116 } 4117 4118 /* translators: Maximum number of words used in a post excerpt. */ 4119 $excerpt_length = (int) _x( '55', 'excerpt_length' ); 4120 4121 /** 4122 * Filters the maximum number of words in a post excerpt. 4123 * 4124 * @since 2.7.0 4125 * 4126 * @param int $number The maximum number of words. Default 55. 4127 */ 4128 $excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length ); 4129 4130 /** 4131 * Filters the string in the "more" link displayed after a trimmed excerpt. 4132 * 4133 * @since 2.9.0 4134 * 4135 * @param string $more_string The string shown within the more link. 4136 */ 4137 $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); 4138 $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); 4139 4140 } 4141 4142 /** 4143 * Filters the trimmed excerpt string. 4144 * 4145 * @since 2.8.0 4146 * 4147 * @param string $text The trimmed text. 4148 * @param string $raw_excerpt The text prior to trimming. 4149 */ 4150 return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt ); 4151 } 4152 4153 /** 4154 * Trims text to a certain number of words. 4155 * 4156 * This function is localized. For languages that count 'words' by the individual 4157 * character (such as East Asian languages), the $num_words argument will apply 4158 * to the number of individual characters. 4159 * 4160 * @since 3.3.0 4161 * 4162 * @param string $text Text to trim. 4163 * @param int $num_words Number of words. Default 55. 4164 * @param string $more Optional. What to append if $text needs to be trimmed. Default '…'. 4165 * @return string Trimmed text. 4166 */ 4167 function wp_trim_words( $text, $num_words = 55, $more = null ) { 4168 if ( null === $more ) { 4169 $more = __( '…' ); 4170 } 4171 4172 $original_text = $text; 4173 $text = wp_strip_all_tags( $text ); 4174 $num_words = (int) $num_words; 4175 4176 if ( str_starts_with( wp_get_word_count_type(), 'characters' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { 4177 $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); 4178 preg_match_all( '/./u', $text, $words_array ); 4179 $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); 4180 $sep = ''; 4181 } else { 4182 $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); 4183 $sep = ' '; 4184 } 4185 4186 if ( count( $words_array ) > $num_words ) { 4187 array_pop( $words_array ); 4188 $text = implode( $sep, $words_array ); 4189 $text = $text . $more; 4190 } else { 4191 $text = implode( $sep, $words_array ); 4192 } 4193 4194 /** 4195 * Filters the text content after words have been trimmed. 4196 * 4197 * @since 3.3.0 4198 * 4199 * @param string $text The trimmed text. 4200 * @param int $num_words The number of words to trim the text to. Default 55. 4201 * @param string $more An optional string to append to the end of the trimmed text, e.g. …. 4202 * @param string $original_text The text before it was trimmed. 4203 */ 4204 return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); 4205 } 4206 4207 /** 4208 * Converts named entities into numbered entities. 4209 * 4210 * @since 1.5.1 4211 * 4212 * @param string $text The text within which entities will be converted. 4213 * @return string Text with converted entities. 4214 */ 4215 function ent2ncr( $text ) { 4216 4217 /** 4218 * Filters text before named entities are converted into numbered entities. 4219 * 4220 * A non-null string must be returned for the filter to be evaluated. 4221 * 4222 * @since 3.3.0 4223 * 4224 * @param string|null $converted_text The text to be converted. Default null. 4225 * @param string $text The text prior to entity conversion. 4226 */ 4227 $filtered = apply_filters( 'pre_ent2ncr', null, $text ); 4228 if ( null !== $filtered ) { 4229 return $filtered; 4230 } 4231 4232 $to_ncr = array( 4233 '"' => '"', 4234 '&' => '&', 4235 '<' => '<', 4236 '>' => '>', 4237 '|' => '|', 4238 ' ' => ' ', 4239 '¡' => '¡', 4240 '¢' => '¢', 4241 '£' => '£', 4242 '¤' => '¤', 4243 '¥' => '¥', 4244 '¦' => '¦', 4245 '&brkbar;' => '¦', 4246 '§' => '§', 4247 '¨' => '¨', 4248 '¨' => '¨', 4249 '©' => '©', 4250 'ª' => 'ª', 4251 '«' => '«', 4252 '¬' => '¬', 4253 '­' => '­', 4254 '®' => '®', 4255 '¯' => '¯', 4256 '&hibar;' => '¯', 4257 '°' => '°', 4258 '±' => '±', 4259 '²' => '²', 4260 '³' => '³', 4261 '´' => '´', 4262 'µ' => 'µ', 4263 '¶' => '¶', 4264 '·' => '·', 4265 '¸' => '¸', 4266 '¹' => '¹', 4267 'º' => 'º', 4268 '»' => '»', 4269 '¼' => '¼', 4270 '½' => '½', 4271 '¾' => '¾', 4272 '¿' => '¿', 4273 'À' => 'À', 4274 'Á' => 'Á', 4275 'Â' => 'Â', 4276 'Ã' => 'Ã', 4277 'Ä' => 'Ä', 4278 'Å' => 'Å', 4279 'Æ' => 'Æ', 4280 'Ç' => 'Ç', 4281 'È' => 'È', 4282 'É' => 'É', 4283 'Ê' => 'Ê', 4284 'Ë' => 'Ë', 4285 'Ì' => 'Ì', 4286 'Í' => 'Í', 4287 'Î' => 'Î', 4288 'Ï' => 'Ï', 4289 'Ð' => 'Ð', 4290 'Ñ' => 'Ñ', 4291 'Ò' => 'Ò', 4292 'Ó' => 'Ó', 4293 'Ô' => 'Ô', 4294 'Õ' => 'Õ', 4295 'Ö' => 'Ö', 4296 '×' => '×', 4297 'Ø' => 'Ø', 4298 'Ù' => 'Ù', 4299 'Ú' => 'Ú', 4300 'Û' => 'Û', 4301 'Ü' => 'Ü', 4302 'Ý' => 'Ý', 4303 'Þ' => 'Þ', 4304 'ß' => 'ß', 4305 'à' => 'à', 4306 'á' => 'á', 4307 'â' => 'â', 4308 'ã' => 'ã', 4309 'ä' => 'ä', 4310 'å' => 'å', 4311 'æ' => 'æ', 4312 'ç' => 'ç', 4313 'è' => 'è', 4314 'é' => 'é', 4315 'ê' => 'ê', 4316 'ë' => 'ë', 4317 'ì' => 'ì', 4318 'í' => 'í', 4319 'î' => 'î', 4320 'ï' => 'ï', 4321 'ð' => 'ð', 4322 'ñ' => 'ñ', 4323 'ò' => 'ò', 4324 'ó' => 'ó', 4325 'ô' => 'ô', 4326 'õ' => 'õ', 4327 'ö' => 'ö', 4328 '÷' => '÷', 4329 'ø' => 'ø', 4330 'ù' => 'ù', 4331 'ú' => 'ú', 4332 'û' => 'û', 4333 'ü' => 'ü', 4334 'ý' => 'ý', 4335 'þ' => 'þ', 4336 'ÿ' => 'ÿ', 4337 'Œ' => 'Œ', 4338 'œ' => 'œ', 4339 'Š' => 'Š', 4340 'š' => 'š', 4341 'Ÿ' => 'Ÿ', 4342 'ƒ' => 'ƒ', 4343 'ˆ' => 'ˆ', 4344 '˜' => '˜', 4345 'Α' => 'Α', 4346 'Β' => 'Β', 4347 'Γ' => 'Γ', 4348 'Δ' => 'Δ', 4349 'Ε' => 'Ε', 4350 'Ζ' => 'Ζ', 4351 'Η' => 'Η', 4352 'Θ' => 'Θ', 4353 'Ι' => 'Ι', 4354 'Κ' => 'Κ', 4355 'Λ' => 'Λ', 4356 'Μ' => 'Μ', 4357 'Ν' => 'Ν', 4358 'Ξ' => 'Ξ', 4359 'Ο' => 'Ο', 4360 'Π' => 'Π', 4361 'Ρ' => 'Ρ', 4362 'Σ' => 'Σ', 4363 'Τ' => 'Τ', 4364 'Υ' => 'Υ', 4365 'Φ' => 'Φ', 4366 'Χ' => 'Χ', 4367 'Ψ' => 'Ψ', 4368 'Ω' => 'Ω', 4369 'α' => 'α', 4370 'β' => 'β', 4371 'γ' => 'γ', 4372 'δ' => 'δ', 4373 'ε' => 'ε', 4374 'ζ' => 'ζ', 4375 'η' => 'η', 4376 'θ' => 'θ', 4377 'ι' => 'ι', 4378 'κ' => 'κ', 4379 'λ' => 'λ', 4380 'μ' => 'μ', 4381 'ν' => 'ν', 4382 'ξ' => 'ξ', 4383 'ο' => 'ο', 4384 'π' => 'π', 4385 'ρ' => 'ρ', 4386 'ς' => 'ς', 4387 'σ' => 'σ', 4388 'τ' => 'τ', 4389 'υ' => 'υ', 4390 'φ' => 'φ', 4391 'χ' => 'χ', 4392 'ψ' => 'ψ', 4393 'ω' => 'ω', 4394 'ϑ' => 'ϑ', 4395 'ϒ' => 'ϒ', 4396 'ϖ' => 'ϖ', 4397 ' ' => ' ', 4398 ' ' => ' ', 4399 ' ' => ' ', 4400 '‌' => '‌', 4401 '‍' => '‍', 4402 '‎' => '‎', 4403 '‏' => '‏', 4404 '–' => '–', 4405 '—' => '—', 4406 '‘' => '‘', 4407 '’' => '’', 4408 '‚' => '‚', 4409 '“' => '“', 4410 '”' => '”', 4411 '„' => '„', 4412 '†' => '†', 4413 '‡' => '‡', 4414 '•' => '•', 4415 '…' => '…', 4416 '‰' => '‰', 4417 '′' => '′', 4418 '″' => '″', 4419 '‹' => '‹', 4420 '›' => '›', 4421 '‾' => '‾', 4422 '⁄' => '⁄', 4423 '€' => '€', 4424 'ℑ' => 'ℑ', 4425 '℘' => '℘', 4426 'ℜ' => 'ℜ', 4427 '™' => '™', 4428 'ℵ' => 'ℵ', 4429 '↵' => '↵', 4430 '⇐' => '⇐', 4431 '⇑' => '⇑', 4432 '⇒' => '⇒', 4433 '⇓' => '⇓', 4434 '⇔' => '⇔', 4435 '∀' => '∀', 4436 '∂' => '∂', 4437 '∃' => '∃', 4438 '∅' => '∅', 4439 '∇' => '∇', 4440 '∈' => '∈', 4441 '∉' => '∉', 4442 '∋' => '∋', 4443 '∏' => '∏', 4444 '∑' => '∑', 4445 '−' => '−', 4446 '∗' => '∗', 4447 '√' => '√', 4448 '∝' => '∝', 4449 '∞' => '∞', 4450 '∠' => '∠', 4451 '∧' => '∧', 4452 '∨' => '∨', 4453 '∩' => '∩', 4454 '∪' => '∪', 4455 '∫' => '∫', 4456 '∴' => '∴', 4457 '∼' => '∼', 4458 '≅' => '≅', 4459 '≈' => '≈', 4460 '≠' => '≠', 4461 '≡' => '≡', 4462 '≤' => '≤', 4463 '≥' => '≥', 4464 '⊂' => '⊂', 4465 '⊃' => '⊃', 4466 '⊄' => '⊄', 4467 '⊆' => '⊆', 4468 '⊇' => '⊇', 4469 '⊕' => '⊕', 4470 '⊗' => '⊗', 4471 '⊥' => '⊥', 4472 '⋅' => '⋅', 4473 '⌈' => '⌈', 4474 '⌉' => '⌉', 4475 '⌊' => '⌊', 4476 '⌋' => '⌋', 4477 '⟨' => '〈', 4478 '⟩' => '〉', 4479 '←' => '←', 4480 '↑' => '↑', 4481 '→' => '→', 4482 '↓' => '↓', 4483 '↔' => '↔', 4484 '◊' => '◊', 4485 '♠' => '♠', 4486 '♣' => '♣', 4487 '♥' => '♥', 4488 '♦' => '♦', 4489 ); 4490 4491 return str_replace( array_keys( $to_ncr ), array_values( $to_ncr ), $text ); 4492 } 4493 4494 /** 4495 * Formats text for the editor. 4496 * 4497 * Generally the browsers treat everything inside a textarea as text, but 4498 * it is still a good idea to HTML entity encode `<`, `>` and `&` in the content. 4499 * 4500 * The filter {@see 'format_for_editor'} is applied here. If `$text` is empty the 4501 * filter will be applied to an empty string. 4502 * 4503 * @since 4.3.0 4504 * 4505 * @see _WP_Editors::editor() 4506 * 4507 * @param string $text The text to be formatted. 4508 * @param string $default_editor The default editor for the current user. 4509 * It is usually either 'html' or 'tinymce'. 4510 * @return string The formatted text after filter is applied. 4511 */ 4512 function format_for_editor( $text, $default_editor = null ) { 4513 if ( $text ) { 4514 $text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) ); 4515 } 4516 4517 /** 4518 * Filters the text after it is formatted for the editor. 4519 * 4520 * @since 4.3.0 4521 * 4522 * @param string $text The formatted text. 4523 * @param string $default_editor The default editor for the current user. 4524 * It is usually either 'html' or 'tinymce'. 4525 */ 4526 return apply_filters( 'format_for_editor', $text, $default_editor ); 4527 } 4528 4529 /** 4530 * Performs a deep string replace operation to ensure the values in $search are no longer present. 4531 * 4532 * Repeats the replacement operation until it no longer replaces anything to remove "nested" values 4533 * e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that 4534 * str_replace would return 4535 * 4536 * @since 2.8.1 4537 * @access private 4538 * 4539 * @param string|array $search The value being searched for, otherwise known as the needle. 4540 * An array may be used to designate multiple needles. 4541 * @param string $subject The string being searched and replaced on, otherwise known as the haystack. 4542 * @return string The string with the replaced values. 4543 */ 4544 function _deep_replace( $search, $subject ) { 4545 $subject = (string) $subject; 4546 4547 $count = 1; 4548 while ( $count ) { 4549 $subject = str_replace( $search, '', $subject, $count ); 4550 } 4551 4552 return $subject; 4553 } 4554 4555 /** 4556 * Escapes data for use in a MySQL query. 4557 * 4558 * Usually you should prepare queries using wpdb::prepare(). 4559 * Sometimes, spot-escaping is required or useful. One example 4560 * is preparing an array for use in an IN clause. 4561 * 4562 * NOTE: Since 4.8.3, '%' characters will be replaced with a placeholder string, 4563 * this prevents certain SQLi attacks from taking place. This change in behavior 4564 * may cause issues for code that expects the return value of esc_sql() to be usable 4565 * for other purposes. 4566 * 4567 * @since 2.8.0 4568 * 4569 * @global wpdb $wpdb WordPress database abstraction object. 4570 * 4571 * @param string|string[] $data Unescaped data. 4572 * @return string|string[] Escaped data, in the same type as supplied. 4573 * 4574 * @phpstan-template TKey of array-key 4575 * @phpstan-param string|array<TKey, string> $data 4576 * @phpstan-return ( $data is string ? string : array<TKey, string> ) 4577 */ 4578 function esc_sql( $data ) { 4579 global $wpdb; 4580 return $wpdb->_escape( $data ); 4581 } 4582 4583 /** 4584 * Checks and cleans a URL. 4585 * 4586 * A number of characters are removed from the URL. If the URL is for displaying 4587 * (the default behavior) ampersands are also replaced. The {@see 'clean_url'} filter 4588 * is applied to the returned cleaned URL. 4589 * 4590 * @since 2.8.0 4591 * @since 6.9.0 Prepends `https://` to the URL if it does not already contain a scheme 4592 * and the first item in `$protocols` is 'https'. 4593 * 4594 * @param string $url The URL to be cleaned. 4595 * @param string[] $protocols Optional. An array of acceptable protocols. 4596 * Defaults to return value of wp_allowed_protocols(). 4597 * @param string $_context Private. Use sanitize_url() for database usage. 4598 * @return string The cleaned URL after the {@see 'clean_url'} filter is applied. 4599 * An empty string is returned if `$url` specifies a protocol other than 4600 * those in `$protocols`, or if `$url` contains an empty string. 4601 */ 4602 function esc_url( $url, $protocols = null, $_context = 'display' ) { 4603 $original_url = $url; 4604 4605 if ( '' === $url ) { 4606 return $url; 4607 } 4608 4609 $url = str_replace( ' ', '%20', ltrim( $url ) ); 4610 $url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url ); 4611 4612 if ( '' === $url ) { 4613 return $url; 4614 } 4615 4616 if ( 0 !== stripos( $url, 'mailto:' ) ) { 4617 $strip = array( '%0d', '%0a', '%0D', '%0A' ); 4618 $url = _deep_replace( $strip, $url ); 4619 } 4620 4621 $url = str_replace( ';//', '://', $url ); 4622 /* 4623 * If the URL doesn't appear to contain a scheme, we presume 4624 * it needs http:// prepended (unless it's a relative link 4625 * starting with /, # or ?, or a PHP file). If the first item 4626 * in $protocols is 'https', then https:// is prepended. 4627 */ 4628 if ( ! str_contains( $url, ':' ) && ! in_array( $url[0], array( '/', '#', '?' ), true ) && 4629 ! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) 4630 ) { 4631 $scheme = ( is_array( $protocols ) && 'https' === array_first( $protocols ) ) ? 'https://' : 'http://'; 4632 $url = $scheme . $url; 4633 } 4634 4635 // Replace ampersands and single quotes only when displaying. 4636 if ( 'display' === $_context ) { 4637 $url = wp_kses_normalize_entities( $url ); 4638 $url = str_replace( '&', '&', $url ); 4639 $url = str_replace( "'", ''', $url ); 4640 } 4641 4642 if ( str_contains( $url, '[' ) || str_contains( $url, ']' ) ) { 4643 4644 $parsed = wp_parse_url( $url ); 4645 $front = ''; 4646 4647 if ( isset( $parsed['scheme'] ) ) { 4648 $front .= $parsed['scheme'] . '://'; 4649 } elseif ( '/' === $url[0] ) { 4650 $front .= '//'; 4651 } 4652 4653 if ( isset( $parsed['user'] ) ) { 4654 $front .= $parsed['user']; 4655 } 4656 4657 if ( isset( $parsed['pass'] ) ) { 4658 $front .= ':' . $parsed['pass']; 4659 } 4660 4661 if ( isset( $parsed['user'] ) || isset( $parsed['pass'] ) ) { 4662 $front .= '@'; 4663 } 4664 4665 if ( isset( $parsed['host'] ) ) { 4666 $front .= $parsed['host']; 4667 } 4668 4669 if ( isset( $parsed['port'] ) ) { 4670 $front .= ':' . $parsed['port']; 4671 } 4672 4673 $end_dirty = str_replace( $front, '', $url ); 4674 $end_clean = str_replace( array( '[', ']' ), array( '%5B', '%5D' ), $end_dirty ); 4675 $url = str_replace( $end_dirty, $end_clean, $url ); 4676 4677 } 4678 4679 if ( '/' === $url[0] ) { 4680 $good_protocol_url = $url; 4681 } else { 4682 if ( ! is_array( $protocols ) ) { 4683 $protocols = wp_allowed_protocols(); 4684 } 4685 $good_protocol_url = wp_kses_bad_protocol( $url, $protocols ); 4686 if ( strtolower( $good_protocol_url ) !== strtolower( $url ) ) { 4687 return ''; 4688 } 4689 } 4690 4691 /** 4692 * Filters a string cleaned and escaped for output as a URL. 4693 * 4694 * @since 2.3.0 4695 * 4696 * @param string $good_protocol_url The cleaned URL to be returned. 4697 * @param string $original_url The URL prior to cleaning. 4698 * @param string $_context If 'display', replace ampersands and single quotes only. 4699 */ 4700 return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context ); 4701 } 4702 4703 /** 4704 * Sanitizes a URL for database or redirect usage. 4705 * 4706 * This function is an alias for sanitize_url(). 4707 * 4708 * @since 2.8.0 4709 * @since 6.1.0 Turned into an alias for sanitize_url(). 4710 * @since 6.9.0 Prepends `https://` to the URL if it does not already contain a scheme 4711 * and the first item in `$protocols` is 'https'. 4712 * 4713 * @see sanitize_url() 4714 * 4715 * @param string $url The URL to be cleaned. 4716 * @param string[] $protocols Optional. An array of acceptable protocols. 4717 * Defaults to return value of wp_allowed_protocols(). 4718 * @return string The cleaned URL after sanitize_url() is run. 4719 */ 4720 function esc_url_raw( $url, $protocols = null ) { 4721 return sanitize_url( $url, $protocols ); 4722 } 4723 4724 /** 4725 * Sanitizes a URL for database or redirect usage. 4726 * 4727 * @since 2.3.1 4728 * @since 2.8.0 Deprecated in favor of esc_url_raw(). 4729 * @since 5.9.0 Restored (un-deprecated). 4730 * @since 6.9.0 Prepends `https://` to the URL if it does not already contain a scheme 4731 * and the first item in `$protocols` is 'https'. 4732 * 4733 * @see esc_url() 4734 * 4735 * @param string $url The URL to be cleaned. 4736 * @param string[] $protocols Optional. An array of acceptable protocols. 4737 * Defaults to return value of wp_allowed_protocols(). 4738 * @return string The cleaned URL after esc_url() is run with the 'db' context. 4739 */ 4740 function sanitize_url( $url, $protocols = null ) { 4741 return esc_url( $url, $protocols, 'db' ); 4742 } 4743 4744 /** 4745 * Converts entities, while preserving already-encoded entities. 4746 * 4747 * @link https://www.php.net/htmlentities Borrowed from the PHP Manual user notes. 4748 * 4749 * @since 1.2.2 4750 * 4751 * @param string $text The text to be converted. 4752 * @return string Converted text. 4753 */ 4754 function htmlentities2( $text ) { 4755 $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); 4756 4757 $translation_table[ chr( 38 ) ] = '&'; 4758 4759 return preg_replace( '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', strtr( $text, $translation_table ) ); 4760 } 4761 4762 /** 4763 * Escapes single quotes, `"`, `<`, `>`, `&`, and fixes line endings. 4764 * 4765 * Escapes text strings for echoing in JS. It is intended to be used for inline JS 4766 * (in a tag attribute, for example `onclick="..."`). Note that the strings have to 4767 * be in single quotes. The {@see 'js_escape'} filter is also applied here. 4768 * 4769 * @since 2.8.0 4770 * @since 7.2.0 Non-string scalars are cast to string before escaping. 4771 * 4772 * @param string|int|float $text The text to be escaped. 4773 * @return string Escaped text. 4774 */ 4775 function esc_js( $text ) { 4776 $text = (string) $text; 4777 $safe_text = wp_check_invalid_utf8( $text ); 4778 $safe_text = _wp_specialchars( $safe_text, ENT_COMPAT ); 4779 $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); 4780 $safe_text = str_replace( "\r", '', $safe_text ); 4781 $safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) ); 4782 /** 4783 * Filters a string cleaned and escaped for output in JavaScript. 4784 * 4785 * Text passed to esc_js() is stripped of invalid or special characters, 4786 * and properly slashed for output. 4787 * 4788 * @since 2.0.6 4789 * 4790 * @param string $safe_text The text after it has been escaped. 4791 * @param string $text The text prior to being escaped. 4792 */ 4793 return apply_filters( 'js_escape', $safe_text, $text ); 4794 } 4795 4796 /** 4797 * Escaping for HTML blocks. 4798 * 4799 * @since 2.8.0 4800 * @since 7.2.0 Non-string scalars are cast to string before escaping. 4801 * 4802 * @param string|int|float $text The text to be escaped. 4803 * @return string Escaped text. 4804 */ 4805 function esc_html( $text ) { 4806 $text = (string) $text; 4807 $safe_text = wp_check_invalid_utf8( $text ); 4808 $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); 4809 /** 4810 * Filters a string cleaned and escaped for output in HTML. 4811 * 4812 * Text passed to esc_html() is stripped of invalid or special characters 4813 * before output. 4814 * 4815 * @since 2.8.0 4816 * 4817 * @param string $safe_text The text after it has been escaped. 4818 * @param string $text The text prior to being escaped. 4819 */ 4820 return apply_filters( 'esc_html', $safe_text, $text ); 4821 } 4822 4823 /** 4824 * Escaping for HTML attributes. 4825 * 4826 * @since 2.8.0 4827 * @since 7.2.0 Non-string scalars are cast to string before escaping. 4828 * 4829 * @param string|int|float $text The text to be escaped. 4830 * @return string Escaped text. 4831 */ 4832 function esc_attr( $text ) { 4833 $text = (string) $text; 4834 $safe_text = wp_check_invalid_utf8( $text ); 4835 $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); 4836 /** 4837 * Filters a string cleaned and escaped for output in an HTML attribute. 4838 * 4839 * Text passed to esc_attr() is stripped of invalid or special characters 4840 * before output. 4841 * 4842 * @since 2.0.6 4843 * 4844 * @param string $safe_text The text after it has been escaped. 4845 * @param string $text The text prior to being escaped. 4846 */ 4847 return apply_filters( 'attribute_escape', $safe_text, $text ); 4848 } 4849 4850 /** 4851 * Escaping for textarea values. 4852 * 4853 * @since 3.1.0 4854 * @since 7.2.0 Non-string scalars are cast to string before escaping. 4855 * 4856 * @param string|int|float $text The text to be escaped. 4857 * @return string Escaped text. 4858 */ 4859 function esc_textarea( $text ) { 4860 $text = (string) $text; 4861 $safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) ); 4862 /** 4863 * Filters a string cleaned and escaped for output in a textarea element. 4864 * 4865 * @since 3.1.0 4866 * 4867 * @param string $safe_text The text after it has been escaped. 4868 * @param string $text The text prior to being escaped. 4869 */ 4870 return apply_filters( 'esc_textarea', $safe_text, $text ); 4871 } 4872 4873 /** 4874 * Escaping for XML blocks. 4875 * 4876 * @since 5.5.0 4877 * @since 7.2.0 Non-string scalars are cast to string before escaping. 4878 * 4879 * @param string|int|float $text The text to be escaped. 4880 * @return string Escaped text. 4881 */ 4882 function esc_xml( $text ) { 4883 $text = (string) $text; 4884 $safe_text = wp_check_invalid_utf8( $text ); 4885 4886 $cdata_regex = '\<\!\[CDATA\[.*?\]\]\>'; 4887 $regex = <<<EOF 4888 / 4889 (?=.*?{$cdata_regex}) # lookahead that will match anything followed by a CDATA Section 4890 (?<non_cdata_followed_by_cdata>(.*?)) # the "anything" matched by the lookahead 4891 (?<cdata>({$cdata_regex})) # the CDATA Section matched by the lookahead 4892 4893 | # alternative 4894 4895 (?<non_cdata>(.*)) # non-CDATA Section 4896 /sx 4897 EOF; 4898 4899 $safe_text = (string) preg_replace_callback( 4900 $regex, 4901 static function ( $matches ) { 4902 if ( isset( $matches['non_cdata'] ) ) { 4903 // escape HTML entities in the non-CDATA Section. 4904 return _wp_specialchars( $matches['non_cdata'], ENT_XML1 ); 4905 } 4906 4907 // Return the CDATA Section unchanged, escape HTML entities in the rest. 4908 return _wp_specialchars( $matches['non_cdata_followed_by_cdata'], ENT_XML1 ) . $matches['cdata']; 4909 }, 4910 $safe_text 4911 ); 4912 4913 /** 4914 * Filters a string cleaned and escaped for output in XML. 4915 * 4916 * Text passed to esc_xml() is stripped of invalid or special characters 4917 * before output. HTML named character references are converted to their 4918 * equivalent code points. 4919 * 4920 * @since 5.5.0 4921 * 4922 * @param string $safe_text The text after it has been escaped. 4923 * @param string $text The text prior to being escaped. 4924 */ 4925 return apply_filters( 'esc_xml', $safe_text, $text ); 4926 } 4927 4928 /** 4929 * Escapes an HTML tag name. 4930 * 4931 * @since 2.5.0 4932 * @since 6.5.5 Allow hyphens in tag names (i.e. custom elements). 4933 * 4934 * @param string $tag_name 4935 * @return string Sanitized tag name. 4936 */ 4937 function tag_escape( $tag_name ) { 4938 $safe_tag = strtolower( preg_replace( '/[^a-zA-Z0-9-_:]/', '', $tag_name ) ); 4939 /** 4940 * Filters a string cleaned and escaped for output as an HTML tag. 4941 * 4942 * @since 2.8.0 4943 * 4944 * @param string $safe_tag The tag name after it has been escaped. 4945 * @param string $tag_name The text before it was escaped. 4946 */ 4947 return apply_filters( 'tag_escape', $safe_tag, $tag_name ); 4948 } 4949 4950 /** 4951 * Converts full URL paths to absolute paths. 4952 * 4953 * Removes the http or https protocols and the domain. Keeps the path '/' at the 4954 * beginning, so it isn't a true relative link, but from the web root base. 4955 * 4956 * @since 2.1.0 4957 * @since 4.1.0 Support was added for relative URLs. 4958 * 4959 * @param string $link Full URL path. 4960 * @return string Absolute path. 4961 */ 4962 function wp_make_link_relative( $link ) { 4963 return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link ); 4964 } 4965 4966 /** 4967 * Sanitizes various option values based on the nature of the option. 4968 * 4969 * This is basically a switch statement which will pass $value through a number 4970 * of functions depending on the $option. 4971 * 4972 * @since 2.0.5 4973 * @since 7.1.5 The `show_on_front` option is sanitized. 4974 * 4975 * @global wpdb $wpdb WordPress database abstraction object. 4976 * 4977 * @param string $option The name of the option. 4978 * @param mixed $value The unsanitized value. 4979 * @return mixed Sanitized value. 4980 */ 4981 function sanitize_option( $option, $value ) { 4982 global $wpdb; 4983 4984 $original_value = $value; 4985 $error = null; 4986 4987 switch ( $option ) { 4988 case 'admin_email': 4989 case 'new_admin_email': 4990 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 4991 if ( is_wp_error( $value ) ) { 4992 $error = $value->get_error_message(); 4993 } else { 4994 $value = sanitize_email( $value ); 4995 if ( ! is_email( $value ) ) { 4996 $error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ); 4997 } 4998 } 4999 break; 5000 5001 case 'thumbnail_size_w': 5002 case 'thumbnail_size_h': 5003 case 'medium_size_w': 5004 case 'medium_size_h': 5005 case 'medium_large_size_w': 5006 case 'medium_large_size_h': 5007 case 'large_size_w': 5008 case 'large_size_h': 5009 case 'mailserver_port': 5010 case 'comment_max_links': 5011 case 'page_on_front': 5012 case 'page_for_posts': 5013 case 'rss_excerpt_length': 5014 case 'default_category': 5015 case 'default_email_category': 5016 case 'default_link_category': 5017 case 'close_comments_days_old': 5018 case 'comments_per_page': 5019 case 'thread_comments_depth': 5020 case 'users_can_register': 5021 case 'start_of_week': 5022 case 'site_icon': 5023 case 'fileupload_maxk': 5024 $value = absint( $value ); 5025 break; 5026 5027 case 'posts_per_page': 5028 case 'posts_per_rss': 5029 $value = (int) $value; 5030 if ( empty( $value ) ) { 5031 $value = 1; 5032 } 5033 if ( $value < -1 ) { 5034 $value = abs( $value ); 5035 } 5036 break; 5037 5038 case 'default_ping_status': 5039 case 'default_comment_status': 5040 // Options that if not there have 0 value but need to be something like "closed". 5041 if ( '0' === (string) $value || '' === $value ) { 5042 $value = 'closed'; 5043 } 5044 break; 5045 5046 case 'blogdescription': 5047 case 'blogname': 5048 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5049 if ( $value !== $original_value ) { 5050 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) ); 5051 } 5052 5053 if ( is_wp_error( $value ) ) { 5054 $error = $value->get_error_message(); 5055 } else { 5056 $value = esc_html( $value ); 5057 } 5058 break; 5059 5060 case 'blog_charset': 5061 if ( is_string( $value ) ) { 5062 $value = preg_replace( '/[^a-zA-Z0-9_-]/', '', $value ); // Strips slashes. 5063 } else { 5064 $value = ''; 5065 } 5066 break; 5067 5068 case 'blog_public': 5069 // This is the value if the settings checkbox is not checked on POST. Don't rely on this. 5070 if ( null === $value ) { 5071 $value = 1; 5072 } else { 5073 $value = (int) $value; 5074 } 5075 break; 5076 5077 case 'date_format': 5078 case 'time_format': 5079 case 'mailserver_url': 5080 case 'mailserver_login': 5081 case 'mailserver_pass': 5082 case 'upload_path': 5083 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5084 if ( is_wp_error( $value ) ) { 5085 $error = $value->get_error_message(); 5086 } else { 5087 $value = strip_tags( $value ); 5088 $value = wp_kses_data( $value ); 5089 } 5090 break; 5091 5092 case 'ping_sites': 5093 $value = explode( "\n", $value ); 5094 $value = array_filter( array_map( 'trim', $value ) ); 5095 $value = array_filter( array_map( 'sanitize_url', $value ) ); 5096 $value = implode( "\n", $value ); 5097 break; 5098 5099 case 'gmt_offset': 5100 if ( is_numeric( $value ) ) { 5101 $value = preg_replace( '/[^0-9:.-]/', '', $value ); // Strips slashes. 5102 } else { 5103 $value = ''; 5104 } 5105 break; 5106 5107 case 'siteurl': 5108 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5109 if ( is_wp_error( $value ) ) { 5110 $error = $value->get_error_message(); 5111 } else { 5112 if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { 5113 $value = sanitize_url( $value ); 5114 } else { 5115 $error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' ); 5116 } 5117 } 5118 break; 5119 5120 case 'home': 5121 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5122 if ( is_wp_error( $value ) ) { 5123 $error = $value->get_error_message(); 5124 } else { 5125 if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { 5126 $value = sanitize_url( $value ); 5127 } else { 5128 $error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' ); 5129 } 5130 } 5131 break; 5132 5133 case 'WPLANG': 5134 $allowed = get_available_languages(); 5135 if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) { 5136 $allowed[] = WPLANG; 5137 } 5138 if ( ! in_array( $value, $allowed, true ) && ! empty( $value ) ) { 5139 $value = get_option( $option ); 5140 } 5141 break; 5142 5143 case 'illegal_names': 5144 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5145 if ( is_wp_error( $value ) ) { 5146 $error = $value->get_error_message(); 5147 } else { 5148 if ( ! is_array( $value ) ) { 5149 $value = explode( ' ', $value ); 5150 } 5151 5152 $value = array_values( array_filter( array_map( 'trim', $value ) ) ); 5153 5154 if ( ! $value ) { 5155 $value = ''; 5156 } 5157 } 5158 break; 5159 5160 case 'limited_email_domains': 5161 case 'banned_email_domains': 5162 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5163 if ( is_wp_error( $value ) ) { 5164 $error = $value->get_error_message(); 5165 } else { 5166 if ( ! is_array( $value ) ) { 5167 $value = explode( "\n", $value ); 5168 } 5169 5170 $domains = array_values( array_filter( array_map( 'trim', $value ) ) ); 5171 $value = array(); 5172 5173 foreach ( $domains as $domain ) { 5174 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) { 5175 $value[] = $domain; 5176 } 5177 } 5178 if ( ! $value ) { 5179 $value = ''; 5180 } 5181 } 5182 break; 5183 5184 case 'timezone_string': 5185 $allowed_zones = timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ); 5186 if ( ! in_array( $value, $allowed_zones, true ) && ! empty( $value ) ) { 5187 $error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' ); 5188 } 5189 break; 5190 5191 case 'permalink_structure': 5192 case 'category_base': 5193 case 'tag_base': 5194 case 'wp_random_base': 5195 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5196 if ( is_wp_error( $value ) ) { 5197 $error = $value->get_error_message(); 5198 } else { 5199 $value = sanitize_url( $value ); 5200 $value = str_replace( 'http://', '', $value ); 5201 } 5202 5203 if ( 'permalink_structure' === $option && null === $error 5204 && '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) 5205 ) { 5206 $error = sprintf( 5207 /* translators: %s: Documentation URL. */ 5208 __( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ), 5209 __( 'https://wordpress.org/documentation/article/customize-permalinks/#choosing-your-permalink-structure' ) 5210 ); 5211 } 5212 break; 5213 5214 case 'show_on_front': 5215 // Any value other than 'page' is treated as 'posts'. 5216 if ( 'page' !== $value ) { 5217 $value = 'posts'; 5218 } 5219 break; 5220 5221 case 'default_role': 5222 if ( ! get_role( $value ) && get_role( 'subscriber' ) ) { 5223 $value = 'subscriber'; 5224 } 5225 break; 5226 5227 case 'moderation_keys': 5228 case 'disallowed_keys': 5229 $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); 5230 if ( is_wp_error( $value ) ) { 5231 $error = $value->get_error_message(); 5232 } else { 5233 $value = explode( "\n", $value ); 5234 $value = array_filter( array_map( 'trim', $value ) ); 5235 $value = array_unique( $value ); 5236 $value = implode( "\n", $value ); 5237 } 5238 break; 5239 } 5240 5241 if ( null !== $error ) { 5242 if ( '' === $error && is_wp_error( $value ) ) { 5243 /* translators: 1: Option name, 2: Error code. */ 5244 $error = sprintf( __( 'Could not sanitize the %1$s option. Error code: %2$s' ), $option, $value->get_error_code() ); 5245 } 5246 5247 $value = get_option( $option ); 5248 if ( function_exists( 'add_settings_error' ) ) { 5249 add_settings_error( $option, "invalid_{$option}", $error ); 5250 } 5251 } 5252 5253 /** 5254 * Filters an option value following sanitization. 5255 * 5256 * @since 2.3.0 5257 * @since 4.3.0 Added the `$original_value` parameter. 5258 * 5259 * @param mixed $value The sanitized option value. 5260 * @param string $option The option name. 5261 * @param mixed $original_value The original value passed to the function. 5262 */ 5263 return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value ); 5264 } 5265 5266 /** 5267 * Maps a function to all non-iterable elements of an array or an object. 5268 * 5269 * This is similar to `array_walk_recursive()` but acts upon objects too. 5270 * 5271 * @since 4.4.0 5272 * 5273 * @param mixed $value The array, object, or scalar. 5274 * @param callable $callback The function to map onto $value. 5275 * @return mixed The value with the callback applied to all non-arrays and non-objects inside it. 5276 * 5277 * @phpstan-template T 5278 * @phpstan-param T $value 5279 * @phpstan-return (T is array ? array<key-of<T>, mixed> : (T is object ? T : mixed)) 5280 */ 5281 function map_deep( $value, $callback ) { 5282 if ( is_array( $value ) ) { 5283 foreach ( $value as $index => $item ) { 5284 $value[ $index ] = map_deep( $item, $callback ); 5285 } 5286 } elseif ( is_object( $value ) ) { 5287 $object_vars = get_object_vars( $value ); 5288 foreach ( $object_vars as $property_name => $property_value ) { 5289 $value->$property_name = map_deep( $property_value, $callback ); 5290 } 5291 } else { 5292 $value = call_user_func( $callback, $value ); 5293 } 5294 5295 return $value; 5296 } 5297 5298 /** 5299 * Parses a string into variables to be stored in an array. 5300 * 5301 * @since 2.2.1 5302 * 5303 * @param string $input_string The string to be parsed. 5304 * @param array $result Variables will be stored in this array. 5305 */ 5306 function wp_parse_str( $input_string, &$result ) { 5307 parse_str( (string) $input_string, $result ); 5308 5309 /** 5310 * Filters the array of variables derived from a parsed string. 5311 * 5312 * @since 2.2.1 5313 * 5314 * @param array $result The array populated with variables. 5315 */ 5316 $result = apply_filters( 'wp_parse_str', $result ); 5317 } 5318 5319 /** 5320 * Converts lone less than signs. 5321 * 5322 * KSES already converts lone greater than signs. 5323 * 5324 * @since 2.3.0 5325 * 5326 * @global string $wp_kses_operating_mode Indicates if this filter should run. 5327 * 5328 * @param string $content Text to be converted. 5329 * @return string Converted text. 5330 */ 5331 function wp_pre_kses_less_than( $content ) { 5332 global $wp_kses_operating_mode; 5333 5334 if ( 'legacy' !== ( $wp_kses_operating_mode ?? 'legacy' ) ) { 5335 return $content; 5336 } 5337 5338 return preg_replace_callback( '%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $content ); 5339 } 5340 5341 /** 5342 * Callback function used by preg_replace. 5343 * 5344 * @since 2.3.0 5345 * 5346 * @param string[] $matches Populated by matches to preg_replace. 5347 * @return string The text returned after esc_html if needed. 5348 */ 5349 function wp_pre_kses_less_than_callback( $matches ) { 5350 if ( ! str_contains( $matches[0], '>' ) ) { 5351 return esc_html( $matches[0] ); 5352 } 5353 return $matches[0]; 5354 } 5355 5356 /** 5357 * Removes non-allowable HTML from parsed block attribute values when filtering 5358 * in the post context. 5359 * 5360 * @since 5.3.1 5361 * 5362 * @global string $wp_kses_operating_mode Indicates if this filter should run. 5363 * 5364 * @param string $content Content to be run through KSES. 5365 * @param array[]|string $allowed_html An array of allowed HTML elements 5366 * and attributes, or a context name 5367 * such as 'post'. 5368 * @param string[] $allowed_protocols Array of allowed URL protocols. 5369 * @return string Filtered text to run through KSES. 5370 */ 5371 function wp_pre_kses_block_attributes( $content, $allowed_html, $allowed_protocols ) { 5372 global $wp_kses_operating_mode; 5373 5374 if ( 'legacy' !== ( $wp_kses_operating_mode ?? 'legacy' ) ) { 5375 return $content; 5376 } 5377 5378 /* 5379 * `filter_block_content` is expected to call `wp_kses`. Temporarily remove 5380 * the filter to avoid recursion. 5381 */ 5382 remove_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10 ); 5383 $content = filter_block_content( $content, $allowed_html, $allowed_protocols ); 5384 add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 ); 5385 5386 return $content; 5387 } 5388 5389 /** 5390 * WordPress' implementation of PHP sprintf() with filters. 5391 * 5392 * @since 2.5.0 5393 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter 5394 * by adding it to the function signature. 5395 * 5396 * @link https://www.php.net/sprintf 5397 * 5398 * @param string $pattern The string which formatted args are inserted. 5399 * @param mixed ...$args Arguments to be formatted into the $pattern string. 5400 * @return string The formatted string. 5401 */ 5402 function wp_sprintf( $pattern, ...$args ) { 5403 $len = strlen( $pattern ); 5404 $start = 0; 5405 $result = ''; 5406 $arg_index = 0; 5407 5408 while ( $len > $start ) { 5409 // Last character: append and break. 5410 if ( strlen( $pattern ) - 1 === $start ) { 5411 $result .= substr( $pattern, -1 ); 5412 break; 5413 } 5414 5415 // Literal %: append and continue. 5416 if ( '%%' === substr( $pattern, $start, 2 ) ) { 5417 $start += 2; 5418 $result .= '%'; 5419 continue; 5420 } 5421 5422 // Get fragment before next %. 5423 $end = strpos( $pattern, '%', $start + 1 ); 5424 if ( false === $end ) { 5425 $end = $len; 5426 } 5427 $fragment = substr( $pattern, $start, $end - $start ); 5428 5429 // Fragment has a specifier. 5430 if ( '%' === $pattern[ $start ] ) { 5431 // Find numbered arguments or take the next one in order. 5432 if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) { 5433 $index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments. 5434 $arg = $args[ $index ] ?? ''; 5435 $fragment = str_replace( "%{$matches[1]}$", '%', $fragment ); 5436 } else { 5437 $arg = $args[ $arg_index ] ?? ''; 5438 ++$arg_index; 5439 } 5440 5441 /** 5442 * Filters a fragment from the pattern passed to wp_sprintf(). 5443 * 5444 * If the fragment is unchanged, then sprintf() will be run on the fragment. 5445 * 5446 * @since 2.5.0 5447 * 5448 * @param string $fragment A fragment from the pattern. 5449 * @param string $arg The argument. 5450 */ 5451 $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); 5452 5453 if ( $_fragment !== $fragment ) { 5454 $fragment = $_fragment; 5455 } else { 5456 $fragment = sprintf( $fragment, (string) $arg ); 5457 } 5458 } 5459 5460 // Append to result and move to next fragment. 5461 $result .= $fragment; 5462 $start = $end; 5463 } 5464 5465 return $result; 5466 } 5467 5468 /** 5469 * Localizes list items before the rest of the content. 5470 * 5471 * The '%l' must be at the first characters can then contain the rest of the 5472 * content. The list items will have ', ', ', and', and ' and ' added depending 5473 * on the amount of list items in the $args parameter. 5474 * 5475 * @since 2.5.0 5476 * 5477 * @param string $pattern Content containing '%l' at the beginning. 5478 * @param array $args List items to prepend to the content and replace '%l'. 5479 * @return string Localized list items and rest of the content. 5480 */ 5481 function wp_sprintf_l( $pattern, $args ) { 5482 // Not a match. 5483 if ( ! str_starts_with( $pattern, '%l' ) ) { 5484 return $pattern; 5485 } 5486 5487 // Nothing to work with. 5488 if ( empty( $args ) ) { 5489 return ''; 5490 } 5491 5492 /** 5493 * Filters the translated delimiters used by wp_sprintf_l(). 5494 * Placeholders (%s) are included to assist translators and then 5495 * removed before the array of strings reaches the filter. 5496 * 5497 * Please note: Ampersands and entities should be avoided here. 5498 * 5499 * @since 2.5.0 5500 * 5501 * @param array $delimiters An array of translated delimiters. 5502 */ 5503 $l = apply_filters( 5504 'wp_sprintf_l', 5505 array( 5506 /* translators: Used to join items in a list with more than 2 items. */ 5507 'between' => sprintf( __( '%1$s, %2$s' ), '', '' ), 5508 /* translators: Used to join last two items in a list with more than 2 times. */ 5509 'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ), 5510 /* translators: Used to join items in a list with only 2 items. */ 5511 'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ), 5512 ) 5513 ); 5514 5515 $args = (array) $args; 5516 $result = array_shift( $args ); 5517 if ( 1 === count( $args ) ) { 5518 $result .= $l['between_only_two'] . array_shift( $args ); 5519 } 5520 5521 // Loop when more than two args. 5522 $i = count( $args ); 5523 while ( $i ) { 5524 $arg = array_shift( $args ); 5525 --$i; 5526 if ( 0 === $i ) { 5527 $result .= $l['between_last_two'] . $arg; 5528 } else { 5529 $result .= $l['between'] . $arg; 5530 } 5531 } 5532 5533 return $result . substr( $pattern, 2 ); 5534 } 5535 5536 /** 5537 * Safely extracts not more than the first $count characters from HTML string. 5538 * 5539 * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* 5540 * be counted as one character. For example & will be counted as 4, < as 5541 * 3, etc. 5542 * 5543 * @since 2.5.0 5544 * 5545 * @param string $str String to get the excerpt from. 5546 * @param int $count Maximum number of characters to take. 5547 * @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string. 5548 * @return string The excerpt. 5549 */ 5550 function wp_html_excerpt( $str, $count, $more = null ) { 5551 if ( null === $more ) { 5552 $more = ''; 5553 } 5554 5555 $str = wp_strip_all_tags( $str, true ); 5556 $excerpt = mb_substr( $str, 0, $count ); 5557 5558 // Remove part of an entity at the end. 5559 $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); 5560 5561 if ( $str !== $excerpt ) { 5562 $excerpt = trim( $excerpt ) . $more; 5563 } 5564 5565 return $excerpt; 5566 } 5567 5568 /** 5569 * Adds a base URL to relative links in passed content. 5570 * 5571 * By default, this function supports the 'src' and 'href' attributes. 5572 * However, this can be modified via the `$attrs` parameter. 5573 * 5574 * @since 2.7.0 5575 * 5576 * @global string $_links_add_base 5577 * 5578 * @param string $content String to search for links in. 5579 * @param string $base The base URL to prefix to links. 5580 * @param string[] $attrs The attributes which should be processed. 5581 * @return string The processed content. 5582 */ 5583 function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) { 5584 global $_links_add_base; 5585 $_links_add_base = $base; 5586 $attrs = implode( '|', (array) $attrs ); 5587 return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); 5588 } 5589 5590 /** 5591 * Callback to add a base URL to relative links in passed content. 5592 * 5593 * @since 2.7.0 5594 * @access private 5595 * 5596 * @global string $_links_add_base 5597 * 5598 * @param string $m The matched link. 5599 * @return string The processed link. 5600 */ 5601 function _links_add_base( $m ) { 5602 global $_links_add_base; 5603 // 1 = attribute name 2 = quotation mark 3 = URL. 5604 return $m[1] . '=' . $m[2] . 5605 ( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols(), true ) ? 5606 $m[3] : 5607 WP_Http::make_absolute_url( $m[3], $_links_add_base ) 5608 ) 5609 . $m[2]; 5610 } 5611 5612 /** 5613 * Adds a target attribute to all links in passed content. 5614 * 5615 * By default, this function only applies to `<a>` tags. 5616 * However, this can be modified via the `$tags` parameter. 5617 * 5618 * *NOTE:* Any current target attribute will be stripped and replaced. 5619 * 5620 * @since 2.7.0 5621 * 5622 * @global string $_links_add_target 5623 * 5624 * @param string $content String to search for links in. 5625 * @param string $target The target to add to the links. 5626 * @param string[] $tags An array of tags to apply to. 5627 * @return string The processed content. 5628 */ 5629 function links_add_target( $content, $target = '_blank', $tags = array( 'a' ) ) { 5630 global $_links_add_target; 5631 $_links_add_target = $target; 5632 $tags = implode( '|', (array) $tags ); 5633 return preg_replace_callback( "!<($tags)((\s[^>]*)?)>!i", '_links_add_target', $content ); 5634 } 5635 5636 /** 5637 * Callback to add a target attribute to all links in passed content. 5638 * 5639 * @since 2.7.0 5640 * @access private 5641 * 5642 * @global string $_links_add_target 5643 * 5644 * @param string $m The matched link. 5645 * @return string The processed link. 5646 */ 5647 function _links_add_target( $m ) { 5648 global $_links_add_target; 5649 $tag = $m[1]; 5650 $link = preg_replace( '|( target=([\'"])(.*?)\2)|i', '', $m[2] ); 5651 return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; 5652 } 5653 5654 /** 5655 * Normalizes EOL characters and strips duplicate whitespace. 5656 * 5657 * @since 2.7.0 5658 * 5659 * @param string $str The string to normalize. 5660 * @return string The normalized string. 5661 */ 5662 function normalize_whitespace( $str ) { 5663 $str = trim( $str ); 5664 $str = str_replace( "\r", "\n", $str ); 5665 $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); 5666 return $str; 5667 } 5668 5669 /** 5670 * Properly strips all HTML tags including 'script' and 'style'. 5671 * 5672 * This differs from strip_tags() because it removes the contents of 5673 * the `<script>` and `<style>` tags. E.g. `strip_tags( '<script>something</script>' )` 5674 * will return 'something'. wp_strip_all_tags() will return an empty string. 5675 * 5676 * @since 2.9.0 5677 * 5678 * @param string $text String containing HTML tags 5679 * @param bool $remove_breaks Optional. Whether to remove left over line breaks and white space chars 5680 * @return string The processed string. 5681 */ 5682 function wp_strip_all_tags( $text, $remove_breaks = false ) { 5683 if ( is_null( $text ) ) { 5684 return ''; 5685 } 5686 5687 if ( ! is_scalar( $text ) ) { 5688 /* 5689 * To maintain consistency with pre-PHP 8 error levels, 5690 * wp_trigger_error() is used to trigger an E_USER_WARNING, 5691 * rather than _doing_it_wrong(), which triggers an E_USER_NOTICE. 5692 */ 5693 wp_trigger_error( 5694 '', 5695 sprintf( 5696 /* translators: 1: The function name, 2: The argument number, 3: The argument name, 4: The expected type, 5: The provided type. */ 5697 __( 'Warning: %1$s expects parameter %2$s (%3$s) to be a %4$s, %5$s given.' ), 5698 __FUNCTION__, 5699 '#1', 5700 '$text', 5701 'string', 5702 gettype( $text ) 5703 ), 5704 E_USER_WARNING 5705 ); 5706 5707 return ''; 5708 } 5709 5710 $text = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $text ); 5711 $text = strip_tags( $text ); 5712 5713 if ( $remove_breaks ) { 5714 $text = preg_replace( '/[\r\n\t ]+/', ' ', $text ); 5715 } 5716 5717 return trim( $text ); 5718 } 5719 5720 /** 5721 * Sanitizes a string from user input or from the database. 5722 * 5723 * - Checks for invalid UTF-8, 5724 * - Converts single `<` characters to entities 5725 * - Strips all tags 5726 * - Removes line breaks, tabs, and extra whitespace 5727 * - Strips percent-encoded characters 5728 * 5729 * @since 2.9.0 5730 * 5731 * @see sanitize_textarea_field() 5732 * @see wp_check_invalid_utf8() 5733 * @see wp_strip_all_tags() 5734 * 5735 * @param string $str String to sanitize. 5736 * @return string Sanitized string. 5737 */ 5738 function sanitize_text_field( $str ) { 5739 $filtered = _sanitize_text_fields( $str, false ); 5740 5741 /** 5742 * Filters a sanitized text field string. 5743 * 5744 * @since 2.9.0 5745 * 5746 * @param string $filtered The sanitized string. 5747 * @param string $str The string prior to being sanitized. 5748 */ 5749 return apply_filters( 'sanitize_text_field', $filtered, $str ); 5750 } 5751 5752 /** 5753 * Sanitizes a multiline string from user input or from the database. 5754 * 5755 * The function is like sanitize_text_field(), but preserves 5756 * new lines (\n) and other whitespace, which are legitimate 5757 * input in textarea elements. 5758 * 5759 * @see sanitize_text_field() 5760 * 5761 * @since 4.7.0 5762 * 5763 * @param string $str String to sanitize. 5764 * @return string Sanitized string. 5765 */ 5766 function sanitize_textarea_field( $str ) { 5767 $filtered = _sanitize_text_fields( $str, true ); 5768 5769 /** 5770 * Filters a sanitized textarea field string. 5771 * 5772 * @since 4.7.0 5773 * 5774 * @param string $filtered The sanitized string. 5775 * @param string $str The string prior to being sanitized. 5776 */ 5777 return apply_filters( 'sanitize_textarea_field', $filtered, $str ); 5778 } 5779 5780 /** 5781 * Internal helper function to sanitize a string from user input or from the database. 5782 * 5783 * @since 4.7.0 5784 * @access private 5785 * 5786 * @param string $str String to sanitize. 5787 * @param bool $keep_newlines Optional. Whether to keep newlines. Default: false. 5788 * @return string Sanitized string. 5789 */ 5790 function _sanitize_text_fields( $str, $keep_newlines = false ) { 5791 if ( is_object( $str ) || is_array( $str ) ) { 5792 return ''; 5793 } 5794 5795 $str = (string) $str; 5796 5797 $filtered = wp_check_invalid_utf8( $str ); 5798 5799 if ( str_contains( $filtered, '<' ) ) { 5800 $filtered = wp_pre_kses_less_than( $filtered ); 5801 // This will strip extra whitespace for us. 5802 $filtered = wp_strip_all_tags( $filtered, false ); 5803 5804 /* 5805 * Use HTML entities in a special case to make sure that 5806 * later newline stripping stages cannot lead to a functional tag. 5807 */ 5808 $filtered = str_replace( "<\n", "<\n", $filtered ); 5809 } 5810 5811 if ( ! $keep_newlines ) { 5812 $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); 5813 } 5814 $filtered = trim( $filtered ); 5815 5816 // Remove percent-encoded characters. 5817 $found = false; 5818 while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) { 5819 $filtered = str_replace( $match[0], '', $filtered ); 5820 $found = true; 5821 } 5822 5823 if ( $found ) { 5824 // Strip out the whitespace that may now exist after removing percent-encoded characters. 5825 $filtered = trim( preg_replace( '/ +/', ' ', $filtered ) ); 5826 } 5827 5828 return $filtered; 5829 } 5830 5831 /** 5832 * i18n-friendly version of basename(). 5833 * 5834 * @since 3.1.0 5835 * 5836 * @param string $path A path. 5837 * @param string $suffix If the filename ends in suffix this will also be cut off. 5838 * @return string The base name of the given path. 5839 */ 5840 function wp_basename( $path, $suffix = '' ) { 5841 return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) ); 5842 } 5843 5844 // phpcs:disable WordPress.WP.CapitalPDangit.MisspelledInComment,WordPress.WP.CapitalPDangit.MisspelledInText,WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-) 5845 /** 5846 * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). 5847 * 5848 * Violating our coding standards for a good function name. 5849 * 5850 * @since 3.0.0 5851 * 5852 * @param string $text The text to be modified. 5853 * @return string The modified text. 5854 */ 5855 function capital_P_dangit( $text ) { 5856 // Simple replacement for titles. 5857 $current_filter = current_filter(); 5858 if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) { 5859 return str_replace( 'Wordpress', 'WordPress', $text ); 5860 } 5861 // Still here? Use the more judicious replacement. 5862 static $dblq = false; 5863 if ( false === $dblq ) { 5864 $dblq = _x( '“', 'opening curly double quote' ); 5865 } 5866 return str_replace( 5867 array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), 5868 array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), 5869 $text 5870 ); 5871 } 5872 // phpcs:enable 5873 5874 /** 5875 * Sanitizes a mime type 5876 * 5877 * @since 3.1.3 5878 * 5879 * @param string $mime_type Mime type. 5880 * @return string Sanitized mime type. 5881 */ 5882 function sanitize_mime_type( $mime_type ) { 5883 $sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type ); 5884 /** 5885 * Filters a mime type following sanitization. 5886 * 5887 * @since 3.1.3 5888 * 5889 * @param string $sani_mime_type The sanitized mime type. 5890 * @param string $mime_type The mime type prior to sanitization. 5891 */ 5892 return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); 5893 } 5894 5895 /** 5896 * Sanitizes space or carriage return separated URLs that are used to send trackbacks. 5897 * 5898 * @since 3.4.0 5899 * 5900 * @param string $to_ping Space or carriage return separated URLs 5901 * @return string URLs starting with the http or https protocol, separated by a carriage return. 5902 */ 5903 function sanitize_trackback_urls( $to_ping ) { 5904 $urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); 5905 foreach ( $urls_to_ping as $k => $url ) { 5906 if ( ! preg_match( '#^https?://.#i', $url ) ) { 5907 unset( $urls_to_ping[ $k ] ); 5908 } 5909 } 5910 $urls_to_ping = array_map( 'sanitize_url', $urls_to_ping ); 5911 $urls_to_ping = implode( "\n", $urls_to_ping ); 5912 /** 5913 * Filters a list of trackback URLs following sanitization. 5914 * 5915 * The string returned here consists of a space or carriage return-delimited list 5916 * of trackback URLs. 5917 * 5918 * @since 3.4.0 5919 * 5920 * @param string $urls_to_ping Sanitized space or carriage return separated URLs. 5921 * @param string $to_ping Space or carriage return separated URLs before sanitization. 5922 */ 5923 return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping ); 5924 } 5925 5926 /** 5927 * Adds slashes to a string or recursively adds slashes to strings within an array. 5928 * 5929 * This should be used when preparing data for core API that expects slashed data. 5930 * This should not be used to escape data going directly into an SQL query. 5931 * 5932 * @since 3.6.0 5933 * @since 5.5.0 Non-string values are left untouched. 5934 * 5935 * @param string|array $value String or array of data to slash. 5936 * @return string|array Slashed `$value`, in the same type as supplied. 5937 * 5938 * @phpstan-template T 5939 * @phpstan-param T $value 5940 * @phpstan-return ( 5941 * T is string ? string : ( 5942 * T is array ? array<key-of<T>, ( value-of<T> is string ? string : value-of<T> )> : T 5943 * ) 5944 * ) 5945 */ 5946 function wp_slash( $value ) { 5947 if ( is_array( $value ) ) { 5948 return array_map( 'wp_slash', $value ); 5949 } 5950 5951 if ( is_string( $value ) ) { 5952 return addslashes( $value ); 5953 } 5954 5955 return $value; 5956 } 5957 5958 /** 5959 * Removes slashes from a string or recursively removes slashes from strings within an array. 5960 * 5961 * This should be used to remove slashes from data passed to core API that 5962 * expects data to be unslashed. 5963 * 5964 * @since 3.6.0 5965 * 5966 * @param string|array $value String or array of data to unslash. 5967 * @return string|array Unslashed `$value`, in the same type as supplied. 5968 * 5969 * @phpstan-template T 5970 * @phpstan-param T $value 5971 * @phpstan-return ( 5972 * T is string ? string : ( 5973 * T is array ? array<key-of<T>, ( value-of<T> is string ? string : value-of<T> )> : T 5974 * ) 5975 * ) 5976 */ 5977 function wp_unslash( $value ) { 5978 return stripslashes_deep( $value ); 5979 } 5980 5981 /** 5982 * Extracts and returns the first URL from passed content. 5983 * 5984 * @since 3.6.0 5985 * 5986 * @param string $content A string which might contain an `A` element with a non-empty `href` attribute. 5987 * @return string|false Database-escaped URL via {@see esc_url()} if found, otherwise `false`. 5988 */ 5989 function get_url_in_content( $content ) { 5990 if ( empty( $content ) ) { 5991 return false; 5992 } 5993 5994 $processor = new WP_HTML_Tag_Processor( $content ); 5995 while ( $processor->next_tag( 'A' ) ) { 5996 $href = $processor->get_attribute( 'href' ); 5997 if ( is_string( $href ) && '' !== $href ) { 5998 return sanitize_url( $href ); 5999 } 6000 } 6001 6002 return false; 6003 } 6004 6005 /** 6006 * Returns the regexp for common whitespace characters. 6007 * 6008 * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. 6009 * This is designed to replace the PCRE \s sequence. In ticket #22692, that 6010 * sequence was found to be unreliable due to random inclusion of the A0 byte. 6011 * 6012 * @since 4.0.0 6013 * 6014 * @return string The spaces regexp. 6015 */ 6016 function wp_spaces_regexp() { 6017 static $spaces = ''; 6018 6019 if ( empty( $spaces ) ) { 6020 /** 6021 * Filters the regexp for common whitespace characters. 6022 * 6023 * This string is substituted for the \s sequence as needed in regular 6024 * expressions. For websites not written in English, different characters 6025 * may represent whitespace. For websites not encoded in UTF-8, the 0xC2 0xA0 6026 * sequence may not be in use. 6027 * 6028 * @since 4.0.0 6029 * 6030 * @param string $spaces Regexp pattern for matching common whitespace characters. 6031 */ 6032 $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' ); 6033 } 6034 6035 return $spaces; 6036 } 6037 6038 /** 6039 * Enqueues the important emoji-related styles. 6040 * 6041 * @since 6.4.0 6042 */ 6043 function wp_enqueue_emoji_styles() { 6044 // Back-compat for plugins that disable functionality by unhooking this action. 6045 $action = is_admin() ? 'admin_print_styles' : 'wp_print_styles'; 6046 if ( ! has_action( $action, 'print_emoji_styles' ) ) { 6047 return; 6048 } 6049 remove_action( $action, 'print_emoji_styles' ); 6050 6051 $emoji_styles = ' 6052 img.wp-smiley, img.emoji { 6053 display: inline !important; 6054 border: none !important; 6055 box-shadow: none !important; 6056 height: 1em !important; 6057 width: 1em !important; 6058 margin: 0 0.07em !important; 6059 vertical-align: -0.1em !important; 6060 background: none !important; 6061 padding: 0 !important; 6062 }'; 6063 $handle = 'wp-emoji-styles'; 6064 wp_register_style( $handle, false ); 6065 wp_add_inline_style( $handle, $emoji_styles ); 6066 wp_enqueue_style( $handle ); 6067 } 6068 6069 /** 6070 * Prints the inline Emoji detection script if it is not already printed. 6071 * 6072 * @since 4.2.0 6073 */ 6074 function print_emoji_detection_script(): void { 6075 static $printed = false; 6076 6077 if ( $printed ) { 6078 return; 6079 } 6080 6081 $printed = true; 6082 6083 if ( is_admin() ) { 6084 if ( did_action( 'admin_print_footer_scripts' ) ) { 6085 _print_emoji_detection_script(); 6086 } else { 6087 add_action( 'admin_print_footer_scripts', '_print_emoji_detection_script' ); 6088 } 6089 } else { 6090 if ( did_action( 'wp_print_footer_scripts' ) ) { 6091 _print_emoji_detection_script(); 6092 } else { 6093 add_action( 'wp_print_footer_scripts', '_print_emoji_detection_script' ); 6094 } 6095 } 6096 } 6097 6098 /** 6099 * Prints inline Emoji detection script. 6100 * 6101 * @ignore 6102 * @since 4.6.0 6103 * @access private 6104 */ 6105 function _print_emoji_detection_script() { 6106 $settings = array( 6107 /** 6108 * Filters the URL where emoji png images are hosted. 6109 * 6110 * @since 4.2.0 6111 * 6112 * @param string $url The emoji base URL for png images. 6113 */ 6114 'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/17.0.2/72x72/' ), 6115 6116 /** 6117 * Filters the extension of the emoji png files. 6118 * 6119 * @since 4.2.0 6120 * 6121 * @param string $extension The emoji extension for png files. Default .png. 6122 */ 6123 'ext' => apply_filters( 'emoji_ext', '.png' ), 6124 6125 /** 6126 * Filters the URL where emoji SVG images are hosted. 6127 * 6128 * @since 4.6.0 6129 * 6130 * @param string $url The emoji base URL for svg images. 6131 */ 6132 'svgUrl' => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/17.0.2/svg/' ), 6133 6134 /** 6135 * Filters the extension of the emoji SVG files. 6136 * 6137 * @since 4.6.0 6138 * 6139 * @param string $extension The emoji extension for svg files. Default .svg. 6140 */ 6141 'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ), 6142 ); 6143 6144 $version = 'ver=' . get_bloginfo( 'version' ); 6145 6146 if ( SCRIPT_DEBUG ) { 6147 $settings['source'] = array( 6148 /** This filter is documented in wp-includes/class-wp-scripts.php */ 6149 'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ), 6150 /** This filter is documented in wp-includes/class-wp-scripts.php */ 6151 'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ), 6152 ); 6153 } else { 6154 $settings['source'] = array( 6155 /** This filter is documented in wp-includes/class-wp-scripts.php */ 6156 'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ), 6157 ); 6158 } 6159 6160 wp_print_inline_script_tag( 6161 wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 6162 array( 6163 'id' => 'wp-emoji-settings', 6164 'type' => 'application/json', 6165 ) 6166 ); 6167 6168 $emoji_loader_script_path = '/js/wp-emoji-loader' . wp_scripts_get_suffix() . '.js'; 6169 wp_print_inline_script_tag( 6170 rtrim( file_get_contents( ABSPATH . WPINC . $emoji_loader_script_path ) ) . "\n" . 6171 '//# sourceURL=' . esc_url_raw( includes_url( $emoji_loader_script_path ) ), 6172 array( 6173 'type' => 'module', 6174 ) 6175 ); 6176 } 6177 6178 /** 6179 * Converts emoji characters to their equivalent HTML entity. 6180 * 6181 * This allows us to store emoji in a DB using the utf8 character set. 6182 * 6183 * @since 4.2.0 6184 * 6185 * @param string $content The content to encode. 6186 * @return string The encoded content. 6187 */ 6188 function wp_encode_emoji( $content ) { 6189 $emoji = _wp_emoji_list( 'partials' ); 6190 6191 foreach ( $emoji as $emojum ) { 6192 $emoji_char = html_entity_decode( $emojum ); 6193 if ( str_contains( $content, $emoji_char ) ) { 6194 $content = preg_replace( "/$emoji_char/", $emojum, $content ); 6195 } 6196 } 6197 6198 return $content; 6199 } 6200 6201 /** 6202 * Converts emoji to a static img element. 6203 * 6204 * @since 4.2.0 6205 * 6206 * @param string $text The content to encode. 6207 * @return string The encoded content. 6208 */ 6209 function wp_staticize_emoji( $text ) { 6210 if ( ! str_contains( $text, '&#x' ) ) { 6211 if ( ( function_exists( 'mb_check_encoding' ) && mb_check_encoding( $text, 'ASCII' ) ) || ! preg_match( '/[^\x00-\x7F]/', $text ) ) { 6212 // The text doesn't contain anything that might be emoji, so we can return early. 6213 return $text; 6214 } else { 6215 $encoded_text = wp_encode_emoji( $text ); 6216 if ( $encoded_text === $text ) { 6217 return $encoded_text; 6218 } 6219 6220 $text = $encoded_text; 6221 } 6222 } 6223 6224 $emoji = _wp_emoji_list( 'entities' ); 6225 6226 // Quickly narrow down the list of emoji that might be in the text and need replacing. 6227 $possible_emoji = array(); 6228 foreach ( $emoji as $emojum ) { 6229 if ( str_contains( $text, $emojum ) ) { 6230 $possible_emoji[ $emojum ] = html_entity_decode( $emojum ); 6231 } 6232 } 6233 6234 if ( ! $possible_emoji ) { 6235 return $text; 6236 } 6237 6238 /** This filter is documented in wp-includes/formatting.php */ 6239 $cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/17.0.2/72x72/' ); 6240 6241 /** This filter is documented in wp-includes/formatting.php */ 6242 $ext = apply_filters( 'emoji_ext', '.png' ); 6243 6244 $output = ''; 6245 /* 6246 * HTML loop taken from smiley function, which was taken from texturize function. 6247 * It'll never be consolidated. 6248 * 6249 * First, capture the tags as well as in between. 6250 */ 6251 $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); 6252 $stop = count( $textarr ); 6253 6254 // Ignore processing of specific tags. 6255 $tags_to_ignore = 'code|pre|style|script|textarea'; 6256 $ignore_block_element = ''; 6257 6258 for ( $i = 0; $i < $stop; $i++ ) { 6259 $content = $textarr[ $i ]; 6260 6261 // If we're in an ignore block, wait until we find its closing tag. 6262 if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { 6263 $ignore_block_element = $matches[1]; 6264 } 6265 6266 // If it's not a tag and not in ignore block. 6267 if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] && str_contains( $content, '&#x' ) ) { 6268 foreach ( $possible_emoji as $emojum => $emoji_char ) { 6269 if ( ! str_contains( $content, $emojum ) ) { 6270 continue; 6271 } 6272 6273 $file = str_replace( ';&#x', '-', $emojum ); 6274 $file = str_replace( array( '&#x', ';' ), '', $file ); 6275 6276 $entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $file . $ext, $emoji_char ); 6277 6278 $content = str_replace( $emojum, $entity, $content ); 6279 } 6280 } 6281 6282 // Did we exit ignore block? 6283 if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) { 6284 $ignore_block_element = ''; 6285 } 6286 6287 $output .= $content; 6288 } 6289 6290 // Finally, remove any stray U+FE0F characters. 6291 $output = str_replace( '️', '', $output ); 6292 6293 return $output; 6294 } 6295 6296 /** 6297 * Converts emoji in emails into static images. 6298 * 6299 * @since 4.2.0 6300 * 6301 * @param array $mail The email data array. 6302 * @return array The email data array, with emoji in the message staticized. 6303 */ 6304 function wp_staticize_emoji_for_email( $mail ) { 6305 if ( ! isset( $mail['message'] ) ) { 6306 return $mail; 6307 } 6308 6309 /* 6310 * We can only transform the emoji into images if it's a `text/html` email. 6311 * To do that, here's a cut down version of the same process that happens 6312 * in wp_mail() - get the `Content-Type` from the headers, if there is one, 6313 * then pass it through the {@see 'wp_mail_content_type'} filter, in case 6314 * a plugin is handling changing the `Content-Type`. 6315 */ 6316 $headers = array(); 6317 if ( isset( $mail['headers'] ) ) { 6318 if ( is_array( $mail['headers'] ) ) { 6319 $headers = $mail['headers']; 6320 } else { 6321 $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); 6322 } 6323 } 6324 6325 foreach ( $headers as $header ) { 6326 if ( ! str_contains( $header, ':' ) ) { 6327 continue; 6328 } 6329 6330 // Explode them out. 6331 list( $name, $content ) = explode( ':', trim( $header ), 2 ); 6332 6333 // Cleanup crew. 6334 $name = trim( $name ); 6335 $content = trim( $content ); 6336 6337 if ( 'content-type' === strtolower( $name ) ) { 6338 if ( str_contains( $content, ';' ) ) { 6339 list( $type, $charset ) = explode( ';', $content ); 6340 $content_type = trim( $type ); 6341 } else { 6342 $content_type = trim( $content ); 6343 } 6344 break; 6345 } 6346 } 6347 6348 // Set Content-Type if we don't have a content-type from the input headers. 6349 if ( ! isset( $content_type ) ) { 6350 $content_type = 'text/plain'; 6351 } 6352 6353 /** This filter is documented in wp-includes/pluggable.php */ 6354 $content_type = apply_filters( 'wp_mail_content_type', $content_type ); 6355 6356 if ( 'text/html' === $content_type ) { 6357 $mail['message'] = wp_staticize_emoji( $mail['message'] ); 6358 } 6359 6360 return $mail; 6361 } 6362 6363 /** 6364 * Returns arrays of emoji data. 6365 * 6366 * These arrays are automatically built from the regex in twemoji.js - if they need to be updated, 6367 * you should update the regex there, then run the `npm run grunt precommit:emoji` job. 6368 * 6369 * @since 4.9.0 6370 * @access private 6371 * 6372 * @param string $type Optional. Which array type to return. Accepts 'partials' or 'entities', default 'entities'. 6373 * @return array An array to match all emoji that WordPress recognises. 6374 */ 6375 function _wp_emoji_list( $type = 'entities' ) { 6376 // Do not remove the START/END comments - they're used to find where to insert the arrays. 6377 6378 // START: emoji arrays 6379 $entities = array( '👨🏻‍❤️‍💋‍👨🏻', '👨🏻‍❤️‍💋‍👨🏼', '👨🏻‍❤️‍💋‍👨🏽', '👨🏻‍❤️‍💋‍👨🏾', '👨🏻‍❤️‍💋‍👨🏿', '👨🏼‍❤️‍💋‍👨🏻', '👨🏼‍❤️‍💋‍👨🏼', '👨🏼‍❤️‍💋‍👨🏽', '👨🏼‍❤️‍💋‍👨🏾', '👨🏼‍❤️‍💋‍👨🏿', '👨🏽‍❤️‍💋‍👨🏻', '👨🏽‍❤️‍💋‍👨🏼', '👨🏽‍❤️‍💋‍👨🏽', '👨🏽‍❤️‍💋‍👨🏾', '👨🏽‍❤️‍💋‍👨🏿', '👨🏾‍❤️‍💋‍👨🏻', '👨🏾‍❤️‍💋‍👨🏼', '👨🏾‍❤️‍💋‍👨🏽', '👨🏾‍❤️‍💋‍👨🏾', '👨🏾‍❤️‍💋‍👨🏿', '👨🏿‍❤️‍💋‍👨🏻', '👨🏿‍❤️‍💋‍👨🏼', '👨🏿‍❤️‍💋‍👨🏽', '👨🏿‍❤️‍💋‍👨🏾', '👨🏿‍❤️‍💋‍👨🏿', '👩🏻‍❤️‍💋‍👨🏻', '👩🏻‍❤️‍💋‍👨🏼', '👩🏻‍❤️‍💋‍👨🏽', '👩🏻‍❤️‍💋‍👨🏾', '👩🏻‍❤️‍💋‍👨🏿', '👩🏻‍❤️‍💋‍👩🏻', '👩🏻‍❤️‍💋‍👩🏼', '👩🏻‍❤️‍💋‍👩🏽', '👩🏻‍❤️‍💋‍👩🏾', '👩🏻‍❤️‍💋‍👩🏿', '👩🏼‍❤️‍💋‍👨🏻', '👩🏼‍❤️‍💋‍👨🏼', '👩🏼‍❤️‍💋‍👨🏽', '👩🏼‍❤️‍💋‍👨🏾', '👩🏼‍❤️‍💋‍👨🏿', '👩🏼‍❤️‍💋‍👩🏻', '👩🏼‍❤️‍💋‍👩🏼', '👩🏼‍❤️‍💋‍👩🏽', '👩🏼‍❤️‍💋‍👩🏾', '👩🏼‍❤️‍💋‍👩🏿', '👩🏽‍❤️‍💋‍👨🏻', '👩🏽‍❤️‍💋‍👨🏼', '👩🏽‍❤️‍💋‍👨🏽', '👩🏽‍❤️‍💋‍👨🏾', '👩🏽‍❤️‍💋‍👨🏿', '👩🏽‍❤️‍💋‍👩🏻', '👩🏽‍❤️‍💋‍👩🏼', '👩🏽‍❤️‍💋‍👩🏽', '👩🏽‍❤️‍💋‍👩🏾', '👩🏽‍❤️‍💋‍👩🏿', '👩🏾‍❤️‍💋‍👨🏻', '👩🏾‍❤️‍💋‍👨🏼', '👩🏾‍❤️‍💋‍👨🏽', '👩🏾‍❤️‍💋‍👨🏾', '👩🏾‍❤️‍💋‍👨🏿', '👩🏾‍❤️‍💋‍👩🏻', '👩🏾‍❤️‍💋‍👩🏼', '👩🏾‍❤️‍💋‍👩🏽', '👩🏾‍❤️‍💋‍👩🏾', '👩🏾‍❤️‍💋‍👩🏿', '👩🏿‍❤️‍💋‍👨🏻', '👩🏿‍❤️‍💋‍👨🏼', '👩🏿‍❤️‍💋‍👨🏽', '👩🏿‍❤️‍💋‍👨🏾', '👩🏿‍❤️‍💋‍👨🏿', '👩🏿‍❤️‍💋‍👩🏻', '👩🏿‍❤️‍💋‍👩🏼', '👩🏿‍❤️‍💋‍👩🏽', '👩🏿‍❤️‍💋‍👩🏾', '👩🏿‍❤️‍💋‍👩🏿', '🧑🏻‍❤️‍💋‍🧑🏼', '🧑🏻‍❤️‍💋‍🧑🏽', '🧑🏻‍❤️‍💋‍🧑🏾', '🧑🏻‍❤️‍💋‍🧑🏿', '🧑🏼‍❤️‍💋‍🧑🏻', '🧑🏼‍❤️‍💋‍🧑🏽', '🧑🏼‍❤️‍💋‍🧑🏾', '🧑🏼‍❤️‍💋‍🧑🏿', '🧑🏽‍❤️‍💋‍🧑🏻', '🧑🏽‍❤️‍💋‍🧑🏼', '🧑🏽‍❤️‍💋‍🧑🏾', '🧑🏽‍❤️‍💋‍🧑🏿', '🧑🏾‍❤️‍💋‍🧑🏻', '🧑🏾‍❤️‍💋‍🧑🏼', '🧑🏾‍❤️‍💋‍🧑🏽', '🧑🏾‍❤️‍💋‍🧑🏿', '🧑🏿‍❤️‍💋‍🧑🏻', '🧑🏿‍❤️‍💋‍🧑🏼', '🧑🏿‍❤️‍💋‍🧑🏽', '🧑🏿‍❤️‍💋‍🧑🏾', '👨🏻‍❤️‍👨🏻', '👨🏻‍❤️‍👨🏼', '👨🏻‍❤️‍👨🏽', '👨🏻‍❤️‍👨🏾', '👨🏻‍❤️‍👨🏿', '👨🏼‍❤️‍👨🏻', '👨🏼‍❤️‍👨🏼', '👨🏼‍❤️‍👨🏽', '👨🏼‍❤️‍👨🏾', '👨🏼‍❤️‍👨🏿', '👨🏽‍❤️‍👨🏻', '👨🏽‍❤️‍👨🏼', '👨🏽‍❤️‍👨🏽', '👨🏽‍❤️‍👨🏾', '👨🏽‍❤️‍👨🏿', '👨🏾‍❤️‍👨🏻', '👨🏾‍❤️‍👨🏼', '👨🏾‍❤️‍👨🏽', '👨🏾‍❤️‍👨🏾', '👨🏾‍❤️‍👨🏿', '👨🏿‍❤️‍👨🏻', '👨🏿‍❤️‍👨🏼', '👨🏿‍❤️‍👨🏽', '👨🏿‍❤️‍👨🏾', '👨🏿‍❤️‍👨🏿', '👩🏻‍❤️‍👨🏻', '👩🏻‍❤️‍👨🏼', '👩🏻‍❤️‍👨🏽', '👩🏻‍❤️‍👨🏾', '👩🏻‍❤️‍👨🏿', '👩🏻‍❤️‍👩🏻', '👩🏻‍❤️‍👩🏼', '👩🏻‍❤️‍👩🏽', '👩🏻‍❤️‍👩🏾', '👩🏻‍❤️‍👩🏿', '👩🏼‍❤️‍👨🏻', '👩🏼‍❤️‍👨🏼', '👩🏼‍❤️‍👨🏽', '👩🏼‍❤️‍👨🏾', '👩🏼‍❤️‍👨🏿', '👩🏼‍❤️‍👩🏻', '👩🏼‍❤️‍👩🏼', '👩🏼‍❤️‍👩🏽', '👩🏼‍❤️‍👩🏾', '👩🏼‍❤️‍👩🏿', '👩🏽‍❤️‍👨🏻', '👩🏽‍❤️‍👨🏼', '👩🏽‍❤️‍👨🏽', '👩🏽‍❤️‍👨🏾', '👩🏽‍❤️‍👨🏿', '👩🏽‍❤️‍👩🏻', '👩🏽‍❤️‍👩🏼', '👩🏽‍❤️‍👩🏽', '👩🏽‍❤️‍👩🏾', '👩🏽‍❤️‍👩🏿', '👩🏾‍❤️‍👨🏻', '👩🏾‍❤️‍👨🏼', '👩🏾‍❤️‍👨🏽', '👩🏾‍❤️‍👨🏾', '👩🏾‍❤️‍👨🏿', '👩🏾‍❤️‍👩🏻', '👩🏾‍❤️‍👩🏼', '👩🏾‍❤️‍👩🏽', '👩🏾‍❤️‍👩🏾', '👩🏾‍❤️‍👩🏿', '👩🏿‍❤️‍👨🏻', '👩🏿‍❤️‍👨🏼', '👩🏿‍❤️‍👨🏽', '👩🏿‍❤️‍👨🏾', '👩🏿‍❤️‍👨🏿', '👩🏿‍❤️‍👩🏻', '👩🏿‍❤️‍👩🏼', '👩🏿‍❤️‍👩🏽', '👩🏿‍❤️‍👩🏾', '👩🏿‍❤️‍👩🏿', '🧑🏻‍❤️‍🧑🏼', '🧑🏻‍❤️‍🧑🏽', '🧑🏻‍❤️‍🧑🏾', '🧑🏻‍❤️‍🧑🏿', '🧑🏼‍❤️‍🧑🏻', '🧑🏼‍❤️‍🧑🏽', '🧑🏼‍❤️‍🧑🏾', '🧑🏼‍❤️‍🧑🏿', '🧑🏽‍❤️‍🧑🏻', '🧑🏽‍❤️‍🧑🏼', '🧑🏽‍❤️‍🧑🏾', '🧑🏽‍❤️‍🧑🏿', '🧑🏾‍❤️‍🧑🏻', '🧑🏾‍❤️‍🧑🏼', '🧑🏾‍❤️‍🧑🏽', '🧑🏾‍❤️‍🧑🏿', '🧑🏿‍❤️‍🧑🏻', '🧑🏿‍❤️‍🧑🏼', '🧑🏿‍❤️‍🧑🏽', '🧑🏿‍❤️‍🧑🏾', '👨‍❤️‍💋‍👨', '👩‍❤️‍💋‍👨', '👩‍❤️‍💋‍👩', '🏃🏻‍♀️‍➡️', '🏃🏻‍♂️‍➡️', '🏃🏼‍♀️‍➡️', '🏃🏼‍♂️‍➡️', '🏃🏽‍♀️‍➡️', '🏃🏽‍♂️‍➡️', '🏃🏾‍♀️‍➡️', '🏃🏾‍♂️‍➡️', '🏃🏿‍♀️‍➡️', '🏃🏿‍♂️‍➡️', '🚶🏻‍♀️‍➡️', '🚶🏻‍♂️‍➡️', '🚶🏼‍♀️‍➡️', '🚶🏼‍♂️‍➡️', '🚶🏽‍♀️‍➡️', '🚶🏽‍♂️‍➡️', '🚶🏾‍♀️‍➡️', '🚶🏾‍♂️‍➡️', '🚶🏿‍♀️‍➡️', '🚶🏿‍♂️‍➡️', '🧎🏻‍♀️‍➡️', '🧎🏻‍♂️‍➡️', '🧎🏼‍♀️‍➡️', '🧎🏼‍♂️‍➡️', '🧎🏽‍♀️‍➡️', '🧎🏽‍♂️‍➡️', '🧎🏾‍♀️‍➡️', '🧎🏾‍♂️‍➡️', '🧎🏿‍♀️‍➡️', '🧎🏿‍♂️‍➡️', '🏴󠁧󠁢󠁥󠁮󠁧󠁿', '🏴󠁧󠁢󠁳󠁣󠁴󠁿', '🏴󠁧󠁢󠁷󠁬󠁳󠁿', '👨🏻‍🐰‍👨🏼', '👨🏻‍🐰‍👨🏽', '👨🏻‍🐰‍👨🏾', '👨🏻‍🐰‍👨🏿', '👨🏻‍🤝‍👨🏼', '👨🏻‍🤝‍👨🏽', '👨🏻‍🤝‍👨🏾', '👨🏻‍🤝‍👨🏿', '👨🏻‍🫯‍👨🏼', '👨🏻‍🫯‍👨🏽', '👨🏻‍🫯‍👨🏾', '👨🏻‍🫯‍👨🏿', '👨🏼‍🐰‍👨🏻', '👨🏼‍🐰‍👨🏼', '👨🏼‍🐰‍👨🏽', '👨🏼‍🐰‍👨🏾', '👨🏼‍🐰‍👨🏿', '👨🏼‍🤝‍👨🏻', '👨🏼‍🤝‍👨🏽', '👨🏼‍🤝‍👨🏾', '👨🏼‍🤝‍👨🏿', '👨🏼‍🫯‍👨🏻', '👨🏼‍🫯‍👨🏽', '👨🏼‍🫯‍👨🏾', '👨🏼‍🫯‍👨🏿', '👨🏽‍🐰‍👨🏻', '👨🏽‍🐰‍👨🏼', '👨🏽‍🐰‍👨🏾', '👨🏽‍🐰‍👨🏿', '👨🏽‍🤝‍👨🏻', '👨🏽‍🤝‍👨🏼', '👨🏽‍🤝‍👨🏾', '👨🏽‍🤝‍👨🏿', '👨🏽‍🫯‍👨🏻', '👨🏽‍🫯‍👨🏼', '👨🏽‍🫯‍👨🏾', '👨🏽‍🫯‍👨🏿', '👨🏾‍🐰‍👨🏻', '👨🏾‍🐰‍👨🏼', '👨🏾‍🐰‍👨🏽', '👨🏾‍🐰‍👨🏿', '👨🏾‍🤝‍👨🏻', '👨🏾‍🤝‍👨🏼', '👨🏾‍🤝‍👨🏽', '👨🏾‍🤝‍👨🏿', '👨🏾‍🫯‍👨🏻', '👨🏾‍🫯‍👨🏼', '👨🏾‍🫯‍👨🏽', '👨🏾‍🫯‍👨🏿', '👨🏿‍🐰‍👨🏻', '👨🏿‍🐰‍👨🏼', '👨🏿‍🐰‍👨🏽', '👨🏿‍🐰‍👨🏾', '👨🏿‍🤝‍👨🏻', '👨🏿‍🤝‍👨🏼', '👨🏿‍🤝‍👨🏽', '👨🏿‍🤝‍👨🏾', '👨🏿‍🫯‍👨🏻', '👨🏿‍🫯‍👨🏼', '👨🏿‍🫯‍👨🏽', '👨🏿‍🫯‍👨🏾', '👩🏻‍🐰‍👩🏼', '👩🏻‍🐰‍👩🏽', '👩🏻‍🐰‍👩🏾', '👩🏻‍🐰‍👩🏿', '👩🏻‍🤝‍👨🏼', '👩🏻‍🤝‍👨🏽', '👩🏻‍🤝‍👨🏾', '👩🏻‍🤝‍👨🏿', '👩🏻‍🤝‍👩🏼', '👩🏻‍🤝‍👩🏽', '👩🏻‍🤝‍👩🏾', '👩🏻‍🤝‍👩🏿', '👩🏻‍🫯‍👩🏼', '👩🏻‍🫯‍👩🏽', '👩🏻‍🫯‍👩🏾', '👩🏻‍🫯‍👩🏿', '👩🏼‍🐰‍👩🏻', '👩🏼‍🐰‍👩🏽', '👩🏼‍🐰‍👩🏾', '👩🏼‍🐰‍👩🏿', '👩🏼‍🤝‍👨🏻', '👩🏼‍🤝‍👨🏽', '👩🏼‍🤝‍👨🏾', '👩🏼‍🤝‍👨🏿', '👩🏼‍🤝‍👩🏻', '👩🏼‍🤝‍👩🏽', '👩🏼‍🤝‍👩🏾', '👩🏼‍🤝‍👩🏿', '👩🏼‍🫯‍👩🏻', '👩🏼‍🫯‍👩🏽', '👩🏼‍🫯‍👩🏾', '👩🏼‍🫯‍👩🏿', '👩🏽‍🐰‍👩🏻', '👩🏽‍🐰‍👩🏼', '👩🏽‍🐰‍👩🏾', '👩🏽‍🐰‍👩🏿', '👩🏽‍🤝‍👨🏻', '👩🏽‍🤝‍👨🏼', '👩🏽‍🤝‍👨🏾', '👩🏽‍🤝‍👨🏿', '👩🏽‍🤝‍👩🏻', '👩🏽‍🤝‍👩🏼', '👩🏽‍🤝‍👩🏾', '👩🏽‍🤝‍👩🏿', '👩🏽‍🫯‍👩🏻', '👩🏽‍🫯‍👩🏼', '👩🏽‍🫯‍👩🏾', '👩🏽‍🫯‍👩🏿', '👩🏾‍🐰‍👩🏻', '👩🏾‍🐰‍👩🏼', '👩🏾‍🐰‍👩🏽', '👩🏾‍🐰‍👩🏿', '👩🏾‍🤝‍👨🏻', '👩🏾‍🤝‍👨🏼', '👩🏾‍🤝‍👨🏽', '👩🏾‍🤝‍👨🏿', '👩🏾‍🤝‍👩🏻', '👩🏾‍🤝‍👩🏼', '👩🏾‍🤝‍👩🏽', '👩🏾‍🤝‍👩🏿', '👩🏾‍🫯‍👩🏻', '👩🏾‍🫯‍👩🏼', '👩🏾‍🫯‍👩🏽', '👩🏾‍🫯‍👩🏿', '👩🏿‍🐰‍👩🏻', '👩🏿‍🐰‍👩🏼', '👩🏿‍🐰‍👩🏽', '👩🏿‍🐰‍👩🏾', '👩🏿‍🤝‍👨🏻', '👩🏿‍🤝‍👨🏼', '👩🏿‍🤝‍👨🏽', '👩🏿‍🤝‍👨🏾', '👩🏿‍🤝‍👩🏻', '👩🏿‍🤝‍👩🏼', '👩🏿‍🤝‍👩🏽', '👩🏿‍🤝‍👩🏾', '👩🏿‍🫯‍👩🏻', '👩🏿‍🫯‍👩🏼', '👩🏿‍🫯‍👩🏽', '👩🏿‍🫯‍👩🏾', '🧑🏻‍🐰‍🧑🏼', '🧑🏻‍🐰‍🧑🏽', '🧑🏻‍🐰‍🧑🏾', '🧑🏻‍🐰‍🧑🏿', '🧑🏻‍🤝‍🧑🏻', '🧑🏻‍🤝‍🧑🏼', '🧑🏻‍🤝‍🧑🏽', '🧑🏻‍🤝‍🧑🏾', '🧑🏻‍🤝‍🧑🏿', '🧑🏻‍🫯‍🧑🏼', '🧑🏻‍🫯‍🧑🏽', '🧑🏻‍🫯‍🧑🏾', '🧑🏻‍🫯‍🧑🏿', '🧑🏼‍🐰‍🧑🏻', '🧑🏼‍🐰‍🧑🏽', '🧑🏼‍🐰‍🧑🏾', '🧑🏼‍🐰‍🧑🏿', '🧑🏼‍🤝‍🧑🏻', '🧑🏼‍🤝‍🧑🏼', '🧑🏼‍🤝‍🧑🏽', '🧑🏼‍🤝‍🧑🏾', '🧑🏼‍🤝‍🧑🏿', '🧑🏼‍🫯‍🧑🏻', '🧑🏼‍🫯‍🧑🏽', '🧑🏼‍🫯‍🧑🏾', '🧑🏼‍🫯‍🧑🏿', '🧑🏽‍🐰‍🧑🏻', '🧑🏽‍🐰‍🧑🏼', '🧑🏽‍🐰‍🧑🏾', '🧑🏽‍🐰‍🧑🏿', '🧑🏽‍🤝‍🧑🏻', '🧑🏽‍🤝‍🧑🏼', '🧑🏽‍🤝‍🧑🏽', '🧑🏽‍🤝‍🧑🏾', '🧑🏽‍🤝‍🧑🏿', '🧑🏽‍🫯‍🧑🏻', '🧑🏽‍🫯‍🧑🏼', '🧑🏽‍🫯‍🧑🏾', '🧑🏽‍🫯‍🧑🏿', '🧑🏾‍🐰‍🧑🏻', '🧑🏾‍🐰‍🧑🏼', '🧑🏾‍🐰‍🧑🏽', '🧑🏾‍🐰‍🧑🏿', '🧑🏾‍🤝‍🧑🏻', '🧑🏾‍🤝‍🧑🏼', '🧑🏾‍🤝‍🧑🏽', '🧑🏾‍🤝‍🧑🏾', '🧑🏾‍🤝‍🧑🏿', '🧑🏾‍🫯‍🧑🏻', '🧑🏾‍🫯‍🧑🏼', '🧑🏾‍🫯‍🧑🏽', '🧑🏾‍🫯‍🧑🏿', '🧑🏿‍🐰‍🧑🏻', '🧑🏿‍🐰‍🧑🏼', '🧑🏿‍🐰‍🧑🏽', '🧑🏿‍🐰‍🧑🏾', '🧑🏿‍🤝‍🧑🏻', '🧑🏿‍🤝‍🧑🏼', '🧑🏿‍🤝‍🧑🏽', '🧑🏿‍🤝‍🧑🏾', '🧑🏿‍🤝‍🧑🏿', '🧑🏿‍🫯‍🧑🏻', '🧑🏿‍🫯‍🧑🏼', '🧑🏿‍🫯‍🧑🏽', '🧑🏿‍🫯‍🧑🏾', '👨‍👨‍👦‍👦', '👨‍👨‍👧‍👦', '👨‍👨‍👧‍👧', '👨‍👩‍👦‍👦', '👨‍👩‍👧‍👦', '👨‍👩‍👧‍👧', '👩‍👩‍👦‍👦', '👩‍👩‍👧‍👦', '👩‍👩‍👧‍👧', '🧑‍🧑‍🧒‍🧒', '👨🏻‍🦯‍➡️', '👨🏻‍🦼‍➡️', '👨🏻‍🦽‍➡️', '👨🏼‍🦯‍➡️', '👨🏼‍🦼‍➡️', '👨🏼‍🦽‍➡️', '👨🏽‍🦯‍➡️', '👨🏽‍🦼‍➡️', '👨🏽‍🦽‍➡️', '👨🏾‍🦯‍➡️', '👨🏾‍🦼‍➡️', '👨🏾‍🦽‍➡️', '👨🏿‍🦯‍➡️', '👨🏿‍🦼‍➡️', '👨🏿‍🦽‍➡️', '👩🏻‍🦯‍➡️', '👩🏻‍🦼‍➡️', '👩🏻‍🦽‍➡️', '👩🏼‍🦯‍➡️', '👩🏼‍🦼‍➡️', '👩🏼‍🦽‍➡️', '👩🏽‍🦯‍➡️', '👩🏽‍🦼‍➡️', '👩🏽‍🦽‍➡️', '👩🏾‍🦯‍➡️', '👩🏾‍🦼‍➡️', '👩🏾‍🦽‍➡️', '👩🏿‍🦯‍➡️', '👩🏿‍🦼‍➡️', '👩🏿‍🦽‍➡️', '🧑🏻‍🦯‍➡️', '🧑🏻‍🦼‍➡️', '🧑🏻‍🦽‍➡️', '🧑🏼‍🦯‍➡️', '🧑🏼‍🦼‍➡️', '🧑🏼‍🦽‍➡️', '🧑🏽‍🦯‍➡️', '🧑🏽‍🦼‍➡️', '🧑🏽‍🦽‍➡️', '🧑🏾‍🦯‍➡️', '🧑🏾‍🦼‍➡️', '🧑🏾‍🦽‍➡️', '🧑🏿‍🦯‍➡️', '🧑🏿‍🦼‍➡️', '🧑🏿‍🦽‍➡️', '🏃‍♀️‍➡️', '🏃‍♂️‍➡️', '🚶‍♀️‍➡️', '🚶‍♂️‍➡️', '🧎‍♀️‍➡️', '🧎‍♂️‍➡️', '👨‍🦯‍➡️', '👨‍🦼‍➡️', '👨‍🦽‍➡️', '👨‍❤️‍👨', '👩‍🦯‍➡️', '👩‍🦼‍➡️', '👩‍🦽‍➡️', '👩‍❤️‍👨', '👩‍❤️‍👩', '🧑‍🦯‍➡️', '🧑‍🦼‍➡️', '🧑‍🦽‍➡️', '🫱🏻‍🫲🏼', '🫱🏻‍🫲🏽', '🫱🏻‍🫲🏾', '🫱🏻‍🫲🏿', '🫱🏼‍🫲🏻', '🫱🏼‍🫲🏽', '🫱🏼‍🫲🏾', '🫱🏼‍🫲🏿', '🫱🏽‍🫲🏻', '🫱🏽‍🫲🏼', '🫱🏽‍🫲🏾', '🫱🏽‍🫲🏿', '🫱🏾‍🫲🏻', '🫱🏾‍🫲🏼', '🫱🏾‍🫲🏽', '🫱🏾‍🫲🏿', '🫱🏿‍🫲🏻', '🫱🏿‍🫲🏼', '🫱🏿‍🫲🏽', '🫱🏿‍🫲🏾', '👨‍👦‍👦', '👨‍👧‍👦', '👨‍👧‍👧', '👨‍👨‍👦', '👨‍👨‍👧', '👨‍👩‍👦', '👨‍👩‍👧', '👩‍👦‍👦', '👩‍👧‍👦', '👩‍👧‍👧', '👩‍👩‍👦', '👩‍👩‍👧', '🧑‍🤝‍🧑', '🧑‍🧑‍🧒', '🧑‍🧒‍🧒', '🏃🏻‍♀️', '🏃🏻‍♂️', '🏃🏻‍➡️', '🏃🏼‍♀️', '🏃🏼‍♂️', '🏃🏼‍➡️', '🏃🏽‍♀️', '🏃🏽‍♂️', '🏃🏽‍➡️', '🏃🏾‍♀️', '🏃🏾‍♂️', '🏃🏾‍➡️', '🏃🏿‍♀️', '🏃🏿‍♂️', '🏃🏿‍➡️', '🏄🏻‍♀️', '🏄🏻‍♂️', '🏄🏼‍♀️', '🏄🏼‍♂️', '🏄🏽‍♀️', '🏄🏽‍♂️', '🏄🏾‍♀️', '🏄🏾‍♂️', '🏄🏿‍♀️', '🏄🏿‍♂️', '🏊🏻‍♀️', '🏊🏻‍♂️', '🏊🏼‍♀️', '🏊🏼‍♂️', '🏊🏽‍♀️', '🏊🏽‍♂️', '🏊🏾‍♀️', '🏊🏾‍♂️', '🏊🏿‍♀️', '🏊🏿‍♂️', '🏋🏻‍♀️', '🏋🏻‍♂️', '🏋🏼‍♀️', '🏋🏼‍♂️', '🏋🏽‍♀️', '🏋🏽‍♂️', '🏋🏾‍♀️', '🏋🏾‍♂️', '🏋🏿‍♀️', '🏋🏿‍♂️', '🏌🏻‍♀️', '🏌🏻‍♂️', '🏌🏼‍♀️', '🏌🏼‍♂️', '🏌🏽‍♀️', '🏌🏽‍♂️', '🏌🏾‍♀️', '🏌🏾‍♂️', '🏌🏿‍♀️', '🏌🏿‍♂️', '👨🏻‍⚕️', '👨🏻‍⚖️', '👨🏻‍✈️', '👨🏼‍⚕️', '👨🏼‍⚖️', '👨🏼‍✈️', '👨🏽‍⚕️', '👨🏽‍⚖️', '👨🏽‍✈️', '👨🏾‍⚕️', '👨🏾‍⚖️', '👨🏾‍✈️', '👨🏿‍⚕️', '👨🏿‍⚖️', '👨🏿‍✈️', '👩🏻‍⚕️', '👩🏻‍⚖️', '👩🏻‍✈️', '👩🏼‍⚕️', '👩🏼‍⚖️', '👩🏼‍✈️', '👩🏽‍⚕️', '👩🏽‍⚖️', '👩🏽‍✈️', '👩🏾‍⚕️', '👩🏾‍⚖️', '👩🏾‍✈️', '👩🏿‍⚕️', '👩🏿‍⚖️', '👩🏿‍✈️', '👮🏻‍♀️', '👮🏻‍♂️', '👮🏼‍♀️', '👮🏼‍♂️', '👮🏽‍♀️', '👮🏽‍♂️', '👮🏾‍♀️', '👮🏾‍♂️', '👮🏿‍♀️', '👮🏿‍♂️', '👯🏻‍♀️', '👯🏻‍♂️', '👯🏼‍♀️', '👯🏼‍♂️', '👯🏽‍♀️', '👯🏽‍♂️', '👯🏾‍♀️', '👯🏾‍♂️', '👯🏿‍♀️', '👯🏿‍♂️', '👰🏻‍♀️', '👰🏻‍♂️', '👰🏼‍♀️', '👰🏼‍♂️', '👰🏽‍♀️', '👰🏽‍♂️', '👰🏾‍♀️', '👰🏾‍♂️', '👰🏿‍♀️', '👰🏿‍♂️', '👱🏻‍♀️', '👱🏻‍♂️', '👱🏼‍♀️', '👱🏼‍♂️', '👱🏽‍♀️', '👱🏽‍♂️', '👱🏾‍♀️', '👱🏾‍♂️', '👱🏿‍♀️', '👱🏿‍♂️', '👳🏻‍♀️', '👳🏻‍♂️', '👳🏼‍♀️', '👳🏼‍♂️', '👳🏽‍♀️', '👳🏽‍♂️', '👳🏾‍♀️', '👳🏾‍♂️', '👳🏿‍♀️', '👳🏿‍♂️', '👷🏻‍♀️', '👷🏻‍♂️', '👷🏼‍♀️', '👷🏼‍♂️', '👷🏽‍♀️', '👷🏽‍♂️', '👷🏾‍♀️', '👷🏾‍♂️', '👷🏿‍♀️', '👷🏿‍♂️', '💁🏻‍♀️', '💁🏻‍♂️', '💁🏼‍♀️', '💁🏼‍♂️', '💁🏽‍♀️', '💁🏽‍♂️', '💁🏾‍♀️', '💁🏾‍♂️', '💁🏿‍♀️', '💁🏿‍♂️', '💂🏻‍♀️', '💂🏻‍♂️', '💂🏼‍♀️', '💂🏼‍♂️', '💂🏽‍♀️', '💂🏽‍♂️', '💂🏾‍♀️', '💂🏾‍♂️', '💂🏿‍♀️', '💂🏿‍♂️', '💆🏻‍♀️', '💆🏻‍♂️', '💆🏼‍♀️', '💆🏼‍♂️', '💆🏽‍♀️', '💆🏽‍♂️', '💆🏾‍♀️', '💆🏾‍♂️', '💆🏿‍♀️', '💆🏿‍♂️', '💇🏻‍♀️', '💇🏻‍♂️', '💇🏼‍♀️', '💇🏼‍♂️', '💇🏽‍♀️', '💇🏽‍♂️', '💇🏾‍♀️', '💇🏾‍♂️', '💇🏿‍♀️', '💇🏿‍♂️', '🕴🏻‍♀️', '🕴🏻‍♂️', '🕴🏼‍♀️', '🕴🏼‍♂️', '🕴🏽‍♀️', '🕴🏽‍♂️', '🕴🏾‍♀️', '🕴🏾‍♂️', '🕴🏿‍♀️', '🕴🏿‍♂️', '🕵🏻‍♀️', '🕵🏻‍♂️', '🕵🏼‍♀️', '🕵🏼‍♂️', '🕵🏽‍♀️', '🕵🏽‍♂️', '🕵🏾‍♀️', '🕵🏾‍♂️', '🕵🏿‍♀️', '🕵🏿‍♂️', '🙅🏻‍♀️', '🙅🏻‍♂️', '🙅🏼‍♀️', '🙅🏼‍♂️', '🙅🏽‍♀️', '🙅🏽‍♂️', '🙅🏾‍♀️', '🙅🏾‍♂️', '🙅🏿‍♀️', '🙅🏿‍♂️', '🙆🏻‍♀️', '🙆🏻‍♂️', '🙆🏼‍♀️', '🙆🏼‍♂️', '🙆🏽‍♀️', '🙆🏽‍♂️', '🙆🏾‍♀️', '🙆🏾‍♂️', '🙆🏿‍♀️', '🙆🏿‍♂️', '🙇🏻‍♀️', '🙇🏻‍♂️', '🙇🏼‍♀️', '🙇🏼‍♂️', '🙇🏽‍♀️', '🙇🏽‍♂️', '🙇🏾‍♀️', '🙇🏾‍♂️', '🙇🏿‍♀️', '🙇🏿‍♂️', '🙋🏻‍♀️', '🙋🏻‍♂️', '🙋🏼‍♀️', '🙋🏼‍♂️', '🙋🏽‍♀️', '🙋🏽‍♂️', '🙋🏾‍♀️', '🙋🏾‍♂️', '🙋🏿‍♀️', '🙋🏿‍♂️', '🙍🏻‍♀️', '🙍🏻‍♂️', '🙍🏼‍♀️', '🙍🏼‍♂️', '🙍🏽‍♀️', '🙍🏽‍♂️', '🙍🏾‍♀️', '🙍🏾‍♂️', '🙍🏿‍♀️', '🙍🏿‍♂️', '🙎🏻‍♀️', '🙎🏻‍♂️', '🙎🏼‍♀️', '🙎🏼‍♂️', '🙎🏽‍♀️', '🙎🏽‍♂️', '🙎🏾‍♀️', '🙎🏾‍♂️', '🙎🏿‍♀️', '🙎🏿‍♂️', '🚣🏻‍♀️', '🚣🏻‍♂️', '🚣🏼‍♀️', '🚣🏼‍♂️', '🚣🏽‍♀️', '🚣🏽‍♂️', '🚣🏾‍♀️', '🚣🏾‍♂️', '🚣🏿‍♀️', '🚣🏿‍♂️', '🚴🏻‍♀️', '🚴🏻‍♂️', '🚴🏼‍♀️', '🚴🏼‍♂️', '🚴🏽‍♀️', '🚴🏽‍♂️', '🚴🏾‍♀️', '🚴🏾‍♂️', '🚴🏿‍♀️', '🚴🏿‍♂️', '🚵🏻‍♀️', '🚵🏻‍♂️', '🚵🏼‍♀️', '🚵🏼‍♂️', '🚵🏽‍♀️', '🚵🏽‍♂️', '🚵🏾‍♀️', '🚵🏾‍♂️', '🚵🏿‍♀️', '🚵🏿‍♂️', '🚶🏻‍♀️', '🚶🏻‍♂️', '🚶🏻‍➡️', '🚶🏼‍♀️', '🚶🏼‍♂️', '🚶🏼‍➡️', '🚶🏽‍♀️', '🚶🏽‍♂️', '🚶🏽‍➡️', '🚶🏾‍♀️', '🚶🏾‍♂️', '🚶🏾‍➡️', '🚶🏿‍♀️', '🚶🏿‍♂️', '🚶🏿‍➡️', '🤦🏻‍♀️', '🤦🏻‍♂️', '🤦🏼‍♀️', '🤦🏼‍♂️', '🤦🏽‍♀️', '🤦🏽‍♂️', '🤦🏾‍♀️', '🤦🏾‍♂️', '🤦🏿‍♀️', '🤦🏿‍♂️', '🤵🏻‍♀️', '🤵🏻‍♂️', '🤵🏼‍♀️', '🤵🏼‍♂️', '🤵🏽‍♀️', '🤵🏽‍♂️', '🤵🏾‍♀️', '🤵🏾‍♂️', '🤵🏿‍♀️', '🤵🏿‍♂️', '🤷🏻‍♀️', '🤷🏻‍♂️', '🤷🏼‍♀️', '🤷🏼‍♂️', '🤷🏽‍♀️', '🤷🏽‍♂️', '🤷🏾‍♀️', '🤷🏾‍♂️', '🤷🏿‍♀️', '🤷🏿‍♂️', '🤸🏻‍♀️', '🤸🏻‍♂️', '🤸🏼‍♀️', '🤸🏼‍♂️', '🤸🏽‍♀️', '🤸🏽‍♂️', '🤸🏾‍♀️', '🤸🏾‍♂️', '🤸🏿‍♀️', '🤸🏿‍♂️', '🤹🏻‍♀️', '🤹🏻‍♂️', '🤹🏼‍♀️', '🤹🏼‍♂️', '🤹🏽‍♀️', '🤹🏽‍♂️', '🤹🏾‍♀️', '🤹🏾‍♂️', '🤹🏿‍♀️', '🤹🏿‍♂️', '🤼🏻‍♀️', '🤼🏻‍♂️', '🤼🏼‍♀️', '🤼🏼‍♂️', '🤼🏽‍♀️', '🤼🏽‍♂️', '🤼🏾‍♀️', '🤼🏾‍♂️', '🤼🏿‍♀️', '🤼🏿‍♂️', '🤽🏻‍♀️', '🤽🏻‍♂️', '🤽🏼‍♀️', '🤽🏼‍♂️', '🤽🏽‍♀️', '🤽🏽‍♂️', '🤽🏾‍♀️', '🤽🏾‍♂️', '🤽🏿‍♀️', '🤽🏿‍♂️', '🤾🏻‍♀️', '🤾🏻‍♂️', '🤾🏼‍♀️', '🤾🏼‍♂️', '🤾🏽‍♀️', '🤾🏽‍♂️', '🤾🏾‍♀️', '🤾🏾‍♂️', '🤾🏿‍♀️', '🤾🏿‍♂️', '🦸🏻‍♀️', '🦸🏻‍♂️', '🦸🏼‍♀️', '🦸🏼‍♂️', '🦸🏽‍♀️', '🦸🏽‍♂️', '🦸🏾‍♀️', '🦸🏾‍♂️', '🦸🏿‍♀️', '🦸🏿‍♂️', '🦹🏻‍♀️', '🦹🏻‍♂️', '🦹🏼‍♀️', '🦹🏼‍♂️', '🦹🏽‍♀️', '🦹🏽‍♂️', '🦹🏾‍♀️', '🦹🏾‍♂️', '🦹🏿‍♀️', '🦹🏿‍♂️', '🧍🏻‍♀️', '🧍🏻‍♂️', '🧍🏼‍♀️', '🧍🏼‍♂️', '🧍🏽‍♀️', '🧍🏽‍♂️', '🧍🏾‍♀️', '🧍🏾‍♂️', '🧍🏿‍♀️', '🧍🏿‍♂️', '🧎🏻‍♀️', '🧎🏻‍♂️', '🧎🏻‍➡️', '🧎🏼‍♀️', '🧎🏼‍♂️', '🧎🏼‍➡️', '🧎🏽‍♀️', '🧎🏽‍♂️', '🧎🏽‍➡️', '🧎🏾‍♀️', '🧎🏾‍♂️', '🧎🏾‍➡️', '🧎🏿‍♀️', '🧎🏿‍♂️', '🧎🏿‍➡️', '🧏🏻‍♀️', '🧏🏻‍♂️', '🧏🏼‍♀️', '🧏🏼‍♂️', '🧏🏽‍♀️', '🧏🏽‍♂️', '🧏🏾‍♀️', '🧏🏾‍♂️', '🧏🏿‍♀️', '🧏🏿‍♂️', '🧑🏻‍⚕️', '🧑🏻‍⚖️', '🧑🏻‍✈️', '🧑🏼‍⚕️', '🧑🏼‍⚖️', '🧑🏼‍✈️', '🧑🏽‍⚕️', '🧑🏽‍⚖️', '🧑🏽‍✈️', '🧑🏾‍⚕️', '🧑🏾‍⚖️', '🧑🏾‍✈️', '🧑🏿‍⚕️', '🧑🏿‍⚖️', '🧑🏿‍✈️', '🧔🏻‍♀️', '🧔🏻‍♂️', '🧔🏼‍♀️', '🧔🏼‍♂️', '🧔🏽‍♀️', '🧔🏽‍♂️', '🧔🏾‍♀️', '🧔🏾‍♂️', '🧔🏿‍♀️', '🧔🏿‍♂️', '🧖🏻‍♀️', '🧖🏻‍♂️', '🧖🏼‍♀️', '🧖🏼‍♂️', '🧖🏽‍♀️', '🧖🏽‍♂️', '🧖🏾‍♀️', '🧖🏾‍♂️', '🧖🏿‍♀️', '🧖🏿‍♂️', '🧗🏻‍♀️', '🧗🏻‍♂️', '🧗🏼‍♀️', '🧗🏼‍♂️', '🧗🏽‍♀️', '🧗🏽‍♂️', '🧗🏾‍♀️', '🧗🏾‍♂️', '🧗🏿‍♀️', '🧗🏿‍♂️', '🧘🏻‍♀️', '🧘🏻‍♂️', '🧘🏼‍♀️', '🧘🏼‍♂️', '🧘🏽‍♀️', '🧘🏽‍♂️', '🧘🏾‍♀️', '🧘🏾‍♂️', '🧘🏿‍♀️', '🧘🏿‍♂️', '🧙🏻‍♀️', '🧙🏻‍♂️', '🧙🏼‍♀️', '🧙🏼‍♂️', '🧙🏽‍♀️', '🧙🏽‍♂️', '🧙🏾‍♀️', '🧙🏾‍♂️', '🧙🏿‍♀️', '🧙🏿‍♂️', '🧚🏻‍♀️', '🧚🏻‍♂️', '🧚🏼‍♀️', '🧚🏼‍♂️', '🧚🏽‍♀️', '🧚🏽‍♂️', '🧚🏾‍♀️', '🧚🏾‍♂️', '🧚🏿‍♀️', '🧚🏿‍♂️', '🧛🏻‍♀️', '🧛🏻‍♂️', '🧛🏼‍♀️', '🧛🏼‍♂️', '🧛🏽‍♀️', '🧛🏽‍♂️', '🧛🏾‍♀️', '🧛🏾‍♂️', '🧛🏿‍♀️', '🧛🏿‍♂️', '🧜🏻‍♀️', '🧜🏻‍♂️', '🧜🏼‍♀️', '🧜🏼‍♂️', '🧜🏽‍♀️', '🧜🏽‍♂️', '🧜🏾‍♀️', '🧜🏾‍♂️', '🧜🏿‍♀️', '🧜🏿‍♂️', '🧝🏻‍♀️', '🧝🏻‍♂️', '🧝🏼‍♀️', '🧝🏼‍♂️', '🧝🏽‍♀️', '🧝🏽‍♂️', '🧝🏾‍♀️', '🧝🏾‍♂️', '🧝🏿‍♀️', '🧝🏿‍♂️', '🏋️‍♀️', '🏋️‍♂️', '🏌️‍♀️', '🏌️‍♂️', '🏳️‍⚧️', '🕴️‍♀️', '🕴️‍♂️', '🕵️‍♀️', '🕵️‍♂️', '⛹🏻‍♀️', '⛹🏻‍♂️', '⛹🏼‍♀️', '⛹🏼‍♂️', '⛹🏽‍♀️', '⛹🏽‍♂️', '⛹🏾‍♀️', '⛹🏾‍♂️', '⛹🏿‍♀️', '⛹🏿‍♂️', '⛹️‍♀️', '⛹️‍♂️', '👨🏻‍🌾', '👨🏻‍🍳', '👨🏻‍🍼', '👨🏻‍🎄', '👨🏻‍🎓', '👨🏻‍🎤', '👨🏻‍🎨', '👨🏻‍🏫', '👨🏻‍🏭', '👨🏻‍💻', '👨🏻‍💼', '👨🏻‍🔧', '👨🏻‍🔬', '👨🏻‍🚀', '👨🏻‍🚒', '👨🏻‍🦯', '👨🏻‍🦰', '👨🏻‍🦱', '👨🏻‍🦲', '👨🏻‍🦳', '👨🏻‍🦼', '👨🏻‍🦽', '👨🏼‍🌾', '👨🏼‍🍳', '👨🏼‍🍼', '👨🏼‍🎄', '👨🏼‍🎓', '👨🏼‍🎤', '👨🏼‍🎨', '👨🏼‍🏫', '👨🏼‍🏭', '👨🏼‍💻', '👨🏼‍💼', '👨🏼‍🔧', '👨🏼‍🔬', '👨🏼‍🚀', '👨🏼‍🚒', '👨🏼‍🦯', '👨🏼‍🦰', '👨🏼‍🦱', '👨🏼‍🦲', '👨🏼‍🦳', '👨🏼‍🦼', '👨🏼‍🦽', '👨🏽‍🌾', '👨🏽‍🍳', '👨🏽‍🍼', '👨🏽‍🎄', '👨🏽‍🎓', '👨🏽‍🎤', '👨🏽‍🎨', '👨🏽‍🏫', '👨🏽‍🏭', '👨🏽‍💻', '👨🏽‍💼', '👨🏽‍🔧', '👨🏽‍🔬', '👨🏽‍🚀', '👨🏽‍🚒', '👨🏽‍🦯', '👨🏽‍🦰', '👨🏽‍🦱', '👨🏽‍🦲', '👨🏽‍🦳', '👨🏽‍🦼', '👨🏽‍🦽', '👨🏾‍🌾', '👨🏾‍🍳', '👨🏾‍🍼', '👨🏾‍🎄', '👨🏾‍🎓', '👨🏾‍🎤', '👨🏾‍🎨', '👨🏾‍🏫', '👨🏾‍🏭', '👨🏾‍💻', '👨🏾‍💼', '👨🏾‍🔧', '👨🏾‍🔬', '👨🏾‍🚀', '👨🏾‍🚒', '👨🏾‍🦯', '👨🏾‍🦰', '👨🏾‍🦱', '👨🏾‍🦲', '👨🏾‍🦳', '👨🏾‍🦼', '👨🏾‍🦽', '👨🏿‍🌾', '👨🏿‍🍳', '👨🏿‍🍼', '👨🏿‍🎄', '👨🏿‍🎓', '👨🏿‍🎤', '👨🏿‍🎨', '👨🏿‍🏫', '👨🏿‍🏭', '👨🏿‍💻', '👨🏿‍💼', '👨🏿‍🔧', '👨🏿‍🔬', '👨🏿‍🚀', '👨🏿‍🚒', '👨🏿‍🦯', '👨🏿‍🦰', '👨🏿‍🦱', '👨🏿‍🦲', '👨🏿‍🦳', '👨🏿‍🦼', '👨🏿‍🦽', '👩🏻‍🌾', '👩🏻‍🍳', '👩🏻‍🍼', '👩🏻‍🎄', '👩🏻‍🎓', '👩🏻‍🎤', '👩🏻‍🎨', '👩🏻‍🏫', '👩🏻‍🏭', '👩🏻‍💻', '👩🏻‍💼', '👩🏻‍🔧', '👩🏻‍🔬', '👩🏻‍🚀', '👩🏻‍🚒', '👩🏻‍🦯', '👩🏻‍🦰', '👩🏻‍🦱', '👩🏻‍🦲', '👩🏻‍🦳', '👩🏻‍🦼', '👩🏻‍🦽', '👩🏼‍🌾', '👩🏼‍🍳', '👩🏼‍🍼', '👩🏼‍🎄', '👩🏼‍🎓', '👩🏼‍🎤', '👩🏼‍🎨', '👩🏼‍🏫', '👩🏼‍🏭', '👩🏼‍💻', '👩🏼‍💼', '👩🏼‍🔧', '👩🏼‍🔬', '👩🏼‍🚀', '👩🏼‍🚒', '👩🏼‍🦯', '👩🏼‍🦰', '👩🏼‍🦱', '👩🏼‍🦲', '👩🏼‍🦳', '👩🏼‍🦼', '👩🏼‍🦽', '👩🏽‍🌾', '👩🏽‍🍳', '👩🏽‍🍼', '👩🏽‍🎄', '👩🏽‍🎓', '👩🏽‍🎤', '👩🏽‍🎨', '👩🏽‍🏫', '👩🏽‍🏭', '👩🏽‍💻', '👩🏽‍💼', '👩🏽‍🔧', '👩🏽‍🔬', '👩🏽‍🚀', '👩🏽‍🚒', '👩🏽‍🦯', '👩🏽‍🦰', '👩🏽‍🦱', '👩🏽‍🦲', '👩🏽‍🦳', '👩🏽‍🦼', '👩🏽‍🦽', '👩🏾‍🌾', '👩🏾‍🍳', '👩🏾‍🍼', '👩🏾‍🎄', '👩🏾‍🎓', '👩🏾‍🎤', '👩🏾‍🎨', '👩🏾‍🏫', '👩🏾‍🏭', '👩🏾‍💻', '👩🏾‍💼', '👩🏾‍🔧', '👩🏾‍🔬', '👩🏾‍🚀', '👩🏾‍🚒', '👩🏾‍🦯', '👩🏾‍🦰', '👩🏾‍🦱', '👩🏾‍🦲', '👩🏾‍🦳', '👩🏾‍🦼', '👩🏾‍🦽', '👩🏿‍🌾', '👩🏿‍🍳', '👩🏿‍🍼', '👩🏿‍🎄', '👩🏿‍🎓', '👩🏿‍🎤', '👩🏿‍🎨', '👩🏿‍🏫', '👩🏿‍🏭', '👩🏿‍💻', '👩🏿‍💼', '👩🏿‍🔧', '👩🏿‍🔬', '👩🏿‍🚀', '👩🏿‍🚒', '👩🏿‍🦯', '👩🏿‍🦰', '👩🏿‍🦱', '👩🏿‍🦲', '👩🏿‍🦳', '👩🏿‍🦼', '👩🏿‍🦽', '🧑🏻‍🌾', '🧑🏻‍🍳', '🧑🏻‍🍼', '🧑🏻‍🎄', '🧑🏻‍🎓', '🧑🏻‍🎤', '🧑🏻‍🎨', '🧑🏻‍🏫', '🧑🏻‍🏭', '🧑🏻‍💻', '🧑🏻‍💼', '🧑🏻‍🔧', '🧑🏻‍🔬', '🧑🏻‍🚀', '🧑🏻‍🚒', '🧑🏻‍🦯', '🧑🏻‍🦰', '🧑🏻‍🦱', '🧑🏻‍🦲', '🧑🏻‍🦳', '🧑🏻‍🦼', '🧑🏻‍🦽', '🧑🏻‍🩰', '🧑🏼‍🌾', '🧑🏼‍🍳', '🧑🏼‍🍼', '🧑🏼‍🎄', '🧑🏼‍🎓', '🧑🏼‍🎤', '🧑🏼‍🎨', '🧑🏼‍🏫', '🧑🏼‍🏭', '🧑🏼‍💻', '🧑🏼‍💼', '🧑🏼‍🔧', '🧑🏼‍🔬', '🧑🏼‍🚀', '🧑🏼‍🚒', '🧑🏼‍🦯', '🧑🏼‍🦰', '🧑🏼‍🦱', '🧑🏼‍🦲', '🧑🏼‍🦳', '🧑🏼‍🦼', '🧑🏼‍🦽', '🧑🏼‍🩰', '🧑🏽‍🌾', '🧑🏽‍🍳', '🧑🏽‍🍼', '🧑🏽‍🎄', '🧑🏽‍🎓', '🧑🏽‍🎤', '🧑🏽‍🎨', '🧑🏽‍🏫', '🧑🏽‍🏭', '🧑🏽‍💻', '🧑🏽‍💼', '🧑🏽‍🔧', '🧑🏽‍🔬', '🧑🏽‍🚀', '🧑🏽‍🚒', '🧑🏽‍🦯', '🧑🏽‍🦰', '🧑🏽‍🦱', '🧑🏽‍🦲', '🧑🏽‍🦳', '🧑🏽‍🦼', '🧑🏽‍🦽', '🧑🏽‍🩰', '🧑🏾‍🌾', '🧑🏾‍🍳', '🧑🏾‍🍼', '🧑🏾‍🎄', '🧑🏾‍🎓', '🧑🏾‍🎤', '🧑🏾‍🎨', '🧑🏾‍🏫', '🧑🏾‍🏭', '🧑🏾‍💻', '🧑🏾‍💼', '🧑🏾‍🔧', '🧑🏾‍🔬', '🧑🏾‍🚀', '🧑🏾‍🚒', '🧑🏾‍🦯', '🧑🏾‍🦰', '🧑🏾‍🦱', '🧑🏾‍🦲', '🧑🏾‍🦳', '🧑🏾‍🦼', '🧑🏾‍🦽', '🧑🏾‍🩰', '🧑🏿‍🌾', '🧑🏿‍🍳', '🧑🏿‍🍼', '🧑🏿‍🎄', '🧑🏿‍🎓', '🧑🏿‍🎤', '🧑🏿‍🎨', '🧑🏿‍🏫', '🧑🏿‍🏭', '🧑🏿‍💻', '🧑🏿‍💼', '🧑🏿‍🔧', '🧑🏿‍🔬', '🧑🏿‍🚀', '🧑🏿‍🚒', '🧑🏿‍🦯', '🧑🏿‍🦰', '🧑🏿‍🦱', '🧑🏿‍🦲', '🧑🏿‍🦳', '🧑🏿‍🦼', '🧑🏿‍🦽', '🧑🏿‍🩰', '🏳️‍🌈', '😶‍🌫️', '🏃‍♀️', '🏃‍♂️', '🏃‍➡️', '🏄‍♀️', '🏄‍♂️', '🏊‍♀️', '🏊‍♂️', '🏴‍☠️', '🐻‍❄️', '👨‍⚕️', '👨‍⚖️', '👨‍✈️', '👩‍⚕️', '👩‍⚖️', '👩‍✈️', '👮‍♀️', '👮‍♂️', '👯‍♀️', '👯‍♂️', '👰‍♀️', '👰‍♂️', '👱‍♀️', '👱‍♂️', '👳‍♀️', '👳‍♂️', '👷‍♀️', '👷‍♂️', '💁‍♀️', '💁‍♂️', '💂‍♀️', '💂‍♂️', '💆‍♀️', '💆‍♂️', '💇‍♀️', '💇‍♂️', '🙂‍↔️', '🙂‍↕️', '🙅‍♀️', '🙅‍♂️', '🙆‍♀️', '🙆‍♂️', '🙇‍♀️', '🙇‍♂️', '🙋‍♀️', '🙋‍♂️', '🙍‍♀️', '🙍‍♂️', '🙎‍♀️', '🙎‍♂️', '🚣‍♀️', '🚣‍♂️', '🚴‍♀️', '🚴‍♂️', '🚵‍♀️', '🚵‍♂️', '🚶‍♀️', '🚶‍♂️', '🚶‍➡️', '🤦‍♀️', '🤦‍♂️', '🤵‍♀️', '🤵‍♂️', '🤷‍♀️', '🤷‍♂️', '🤸‍♀️', '🤸‍♂️', '🤹‍♀️', '🤹‍♂️', '🤼‍♀️', '🤼‍♂️', '🤽‍♀️', '🤽‍♂️', '🤾‍♀️', '🤾‍♂️', '🦸‍♀️', '🦸‍♂️', '🦹‍♀️', '🦹‍♂️', '🧍‍♀️', '🧍‍♂️', '🧎‍♀️', '🧎‍♂️', '🧎‍➡️', '🧏‍♀️', '🧏‍♂️', '🧑‍⚕️', '🧑‍⚖️', '🧑‍✈️', '🧔‍♀️', '🧔‍♂️', '🧖‍♀️', '🧖‍♂️', '🧗‍♀️', '🧗‍♂️', '🧘‍♀️', '🧘‍♂️', '🧙‍♀️', '🧙‍♂️', '🧚‍♀️', '🧚‍♂️', '🧛‍♀️', '🧛‍♂️', '🧜‍♀️', '🧜‍♂️', '🧝‍♀️', '🧝‍♂️', '🧞‍♀️', '🧞‍♂️', '🧟‍♀️', '🧟‍♂️', '⛓️‍💥', '❤️‍🔥', '❤️‍🩹', '🍄‍🟫', '🍋‍🟩', '🐕‍🦺', '🐦‍🔥', '👁‍🗨', '👨‍🌾', '👨‍🍳', '👨‍🍼', '👨‍🎄', '👨‍🎓', '👨‍🎤', '👨‍🎨', '👨‍🏫', '👨‍🏭', '👨‍👦', '👨‍👧', '👨‍💻', '👨‍💼', '👨‍🔧', '👨‍🔬', '👨‍🚀', '👨‍🚒', '👨‍🦯', '👨‍🦰', '👨‍🦱', '👨‍🦲', '👨‍🦳', '👨‍🦼', '👨‍🦽', '👩‍🌾', '👩‍🍳', '👩‍🍼', '👩‍🎄', '👩‍🎓', '👩‍🎤', '👩‍🎨', '👩‍🏫', '👩‍🏭', '👩‍👦', '👩‍👧', '👩‍💻', '👩‍💼', '👩‍🔧', '👩‍🔬', '👩‍🚀', '👩‍🚒', '👩‍🦯', '👩‍🦰', '👩‍🦱', '👩‍🦲', '👩‍🦳', '👩‍🦼', '👩‍🦽', '😮‍💨', '😵‍💫', '🧑‍🌾', '🧑‍🍳', '🧑‍🍼', '🧑‍🎄', '🧑‍🎓', '🧑‍🎤', '🧑‍🎨', '🧑‍🏫', '🧑‍🏭', '🧑‍💻', '🧑‍💼', '🧑‍🔧', '🧑‍🔬', '🧑‍🚀', '🧑‍🚒', '🧑‍🦯', '🧑‍🦰', '🧑‍🦱', '🧑‍🦲', '🧑‍🦳', '🧑‍🦼', '🧑‍🦽', '🧑‍🧒', '🧑‍🩰', '🐈‍⬛', '🐦‍⬛', '🇦🇨', '🇦🇩', '🇦🇪', '🇦🇫', '🇦🇬', '🇦🇮', '🇦🇱', '🇦🇲', '🇦🇴', '🇦🇶', '🇦🇷', '🇦🇸', '🇦🇹', '🇦🇺', '🇦🇼', '🇦🇽', '🇦🇿', '🇧🇦', '🇧🇧', '🇧🇩', '🇧🇪', '🇧🇫', '🇧🇬', '🇧🇭', '🇧🇮', '🇧🇯', '🇧🇱', '🇧🇲', '🇧🇳', '🇧🇴', '🇧🇶', '🇧🇷', '🇧🇸', '🇧🇹', '🇧🇻', '🇧🇼', '🇧🇾', '🇧🇿', '🇨🇦', '🇨🇨', '🇨🇩', '🇨🇫', '🇨🇬', '🇨🇭', '🇨🇮', '🇨🇰', '🇨🇱', '🇨🇲', '🇨🇳', '🇨🇴', '🇨🇵', '🇨🇶', '🇨🇷', '🇨🇺', '🇨🇻', '🇨🇼', '🇨🇽', '🇨🇾', '🇨🇿', '🇩🇪', '🇩🇬', '🇩🇯', '🇩🇰', '🇩🇲', '🇩🇴', '🇩🇿', '🇪🇦', '🇪🇨', '🇪🇪', '🇪🇬', '🇪🇭', '🇪🇷', '🇪🇸', '🇪🇹', '🇪🇺', '🇫🇮', '🇫🇯', '🇫🇰', '🇫🇲', '🇫🇴', '🇫🇷', '🇬🇦', '🇬🇧', '🇬🇩', '🇬🇪', '🇬🇫', '🇬🇬', '🇬🇭', '🇬🇮', '🇬🇱', '🇬🇲', '🇬🇳', '🇬🇵', '🇬🇶', '🇬🇷', '🇬🇸', '🇬🇹', '🇬🇺', '🇬🇼', '🇬🇾', '🇭🇰', '🇭🇲', '🇭🇳', '🇭🇷', '🇭🇹', '🇭🇺', '🇮🇨', '🇮🇩', '🇮🇪', '🇮🇱', '🇮🇲', '🇮🇳', '🇮🇴', '🇮🇶', '🇮🇷', '🇮🇸', '🇮🇹', '🇯🇪', '🇯🇲', '🇯🇴', '🇯🇵', '🇰🇪', '🇰🇬', '🇰🇭', '🇰🇮', '🇰🇲', '🇰🇳', '🇰🇵', '🇰🇷', '🇰🇼', '🇰🇾', '🇰🇿', '🇱🇦', '🇱🇧', '🇱🇨', '🇱🇮', '🇱🇰', '🇱🇷', '🇱🇸', '🇱🇹', '🇱🇺', '🇱🇻', '🇱🇾', '🇲🇦', '🇲🇨', '🇲🇩', '🇲🇪', '🇲🇫', '🇲🇬', '🇲🇭', '🇲🇰', '🇲🇱', '🇲🇲', '🇲🇳', '🇲🇴', '🇲🇵', '🇲🇶', '🇲🇷', '🇲🇸', '🇲🇹', '🇲🇺', '🇲🇻', '🇲🇼', '🇲🇽', '🇲🇾', '🇲🇿', '🇳🇦', '🇳🇨', '🇳🇪', '🇳🇫', '🇳🇬', '🇳🇮', '🇳🇱', '🇳🇴', '🇳🇵', '🇳🇷', '🇳🇺', '🇳🇿', '🇴🇲', '🇵🇦', '🇵🇪', '🇵🇫', '🇵🇬', '🇵🇭', '🇵🇰', '🇵🇱', '🇵🇲', '🇵🇳', '🇵🇷', '🇵🇸', '🇵🇹', '🇵🇼', '🇵🇾', '🇶🇦', '🇷🇪', '🇷🇴', '🇷🇸', '🇷🇺', '🇷🇼', '🇸🇦', '🇸🇧', '🇸🇨', '🇸🇩', '🇸🇪', '🇸🇬', '🇸🇭', '🇸🇮', '🇸🇯', '🇸🇰', '🇸🇱', '🇸🇲', '🇸🇳', '🇸🇴', '🇸🇷', '🇸🇸', '🇸🇹', '🇸🇻', '🇸🇽', '🇸🇾', '🇸🇿', '🇹🇦', '🇹🇨', '🇹🇩', '🇹🇫', '🇹🇬', '🇹🇭', '🇹🇯', '🇹🇰', '🇹🇱', '🇹🇲', '🇹🇳', '🇹🇴', '🇹🇷', '🇹🇹', '🇹🇻', '🇹🇼', '🇹🇿', '🇺🇦', '🇺🇬', '🇺🇲', '🇺🇳', '🇺🇸', '🇺🇾', '🇺🇿', '🇻🇦', '🇻🇨', '🇻🇪', '🇻🇬', '🇻🇮', '🇻🇳', '🇻🇺', '🇼🇫', '🇼🇸', '🇽🇰', '🇾🇪', '🇾🇹', '🇿🇦', '🇿🇲', '🇿🇼', '🎅🏻', '🎅🏼', '🎅🏽', '🎅🏾', '🎅🏿', '🏂🏻', '🏂🏼', '🏂🏽', '🏂🏾', '🏂🏿', '🏃🏻', '🏃🏼', '🏃🏽', '🏃🏾', '🏃🏿', '🏄🏻', '🏄🏼', '🏄🏽', '🏄🏾', '🏄🏿', '🏇🏻', '🏇🏼', '🏇🏽', '🏇🏾', '🏇🏿', '🏊🏻', '🏊🏼', '🏊🏽', '🏊🏾', '🏊🏿', '🏋🏻', '🏋🏼', '🏋🏽', '🏋🏾', '🏋🏿', '🏌🏻', '🏌🏼', '🏌🏽', '🏌🏾', '🏌🏿', '👂🏻', '👂🏼', '👂🏽', '👂🏾', '👂🏿', '👃🏻', '👃🏼', '👃🏽', '👃🏾', '👃🏿', '👆🏻', '👆🏼', '👆🏽', '👆🏾', '👆🏿', '👇🏻', '👇🏼', '👇🏽', '👇🏾', '👇🏿', '👈🏻', '👈🏼', '👈🏽', '👈🏾', '👈🏿', '👉🏻', '👉🏼', '👉🏽', '👉🏾', '👉🏿', '👊🏻', '👊🏼', '👊🏽', '👊🏾', '👊🏿', '👋🏻', '👋🏼', '👋🏽', '👋🏾', '👋🏿', '👌🏻', '👌🏼', '👌🏽', '👌🏾', '👌🏿', '👍🏻', '👍🏼', '👍🏽', '👍🏾', '👍🏿', '👎🏻', '👎🏼', '👎🏽', '👎🏾', '👎🏿', '👏🏻', '👏🏼', '👏🏽', '👏🏾', '👏🏿', '👐🏻', '👐🏼', '👐🏽', '👐🏾', '👐🏿', '👦🏻', '👦🏼', '👦🏽', '👦🏾', '👦🏿', '👧🏻', '👧🏼', '👧🏽', '👧🏾', '👧🏿', '👨🏻', '👨🏼', '👨🏽', '👨🏾', '👨🏿', '👩🏻', '👩🏼', '👩🏽', '👩🏾', '👩🏿', '👫🏻', '👫🏼', '👫🏽', '👫🏾', '👫🏿', '👬🏻', '👬🏼', '👬🏽', '👬🏾', '👬🏿', '👭🏻', '👭🏼', '👭🏽', '👭🏾', '👭🏿', '👮🏻', '👮🏼', '👮🏽', '👮🏾', '👮🏿', '👯🏻', '👯🏼', '👯🏽', '👯🏾', '👯🏿', '👰🏻', '👰🏼', '👰🏽', '👰🏾', '👰🏿', '👱🏻', '👱🏼', '👱🏽', '👱🏾', '👱🏿', '👲🏻', '👲🏼', '👲🏽', '👲🏾', '👲🏿', '👳🏻', '👳🏼', '👳🏽', '👳🏾', '👳🏿', '👴🏻', '👴🏼', '👴🏽', '👴🏾', '👴🏿', '👵🏻', '👵🏼', '👵🏽', '👵🏾', '👵🏿', '👶🏻', '👶🏼', '👶🏽', '👶🏾', '👶🏿', '👷🏻', '👷🏼', '👷🏽', '👷🏾', '👷🏿', '👸🏻', '👸🏼', '👸🏽', '👸🏾', '👸🏿', '👼🏻', '👼🏼', '👼🏽', '👼🏾', '👼🏿', '💁🏻', '💁🏼', '💁🏽', '💁🏾', '💁🏿', '💂🏻', '💂🏼', '💂🏽', '💂🏾', '💂🏿', '💃🏻', '💃🏼', '💃🏽', '💃🏾', '💃🏿', '💅🏻', '💅🏼', '💅🏽', '💅🏾', '💅🏿', '💆🏻', '💆🏼', '💆🏽', '💆🏾', '💆🏿', '💇🏻', '💇🏼', '💇🏽', '💇🏾', '💇🏿', '💏🏻', '💏🏼', '💏🏽', '💏🏾', '💏🏿', '💑🏻', '💑🏼', '💑🏽', '💑🏾', '💑🏿', '💪🏻', '💪🏼', '💪🏽', '💪🏾', '💪🏿', '🕴🏻', '🕴🏼', '🕴🏽', '🕴🏾', '🕴🏿', '🕵🏻', '🕵🏼', '🕵🏽', '🕵🏾', '🕵🏿', '🕺🏻', '🕺🏼', '🕺🏽', '🕺🏾', '🕺🏿', '🖐🏻', '🖐🏼', '🖐🏽', '🖐🏾', '🖐🏿', '🖕🏻', '🖕🏼', '🖕🏽', '🖕🏾', '🖕🏿', '🖖🏻', '🖖🏼', '🖖🏽', '🖖🏾', '🖖🏿', '🙅🏻', '🙅🏼', '🙅🏽', '🙅🏾', '🙅🏿', '🙆🏻', '🙆🏼', '🙆🏽', '🙆🏾', '🙆🏿', '🙇🏻', '🙇🏼', '🙇🏽', '🙇🏾', '🙇🏿', '🙋🏻', '🙋🏼', '🙋🏽', '🙋🏾', '🙋🏿', '🙌🏻', '🙌🏼', '🙌🏽', '🙌🏾', '🙌🏿', '🙍🏻', '🙍🏼', '🙍🏽', '🙍🏾', '🙍🏿', '🙎🏻', '🙎🏼', '🙎🏽', '🙎🏾', '🙎🏿', '🙏🏻', '🙏🏼', '🙏🏽', '🙏🏾', '🙏🏿', '🚣🏻', '🚣🏼', '🚣🏽', '🚣🏾', '🚣🏿', '🚴🏻', '🚴🏼', '🚴🏽', '🚴🏾', '🚴🏿', '🚵🏻', '🚵🏼', '🚵🏽', '🚵🏾', '🚵🏿', '🚶🏻', '🚶🏼', '🚶🏽', '🚶🏾', '🚶🏿', '🛀🏻', '🛀🏼', '🛀🏽', '🛀🏾', '🛀🏿', '🛌🏻', '🛌🏼', '🛌🏽', '🛌🏾', '🛌🏿', '🤌🏻', '🤌🏼', '🤌🏽', '🤌🏾', '🤌🏿', '🤏🏻', '🤏🏼', '🤏🏽', '🤏🏾', '🤏🏿', '🤘🏻', '🤘🏼', '🤘🏽', '🤘🏾', '🤘🏿', '🤙🏻', '🤙🏼', '🤙🏽', '🤙🏾', '🤙🏿', '🤚🏻', '🤚🏼', '🤚🏽', '🤚🏾', '🤚🏿', '🤛🏻', '🤛🏼', '🤛🏽', '🤛🏾', '🤛🏿', '🤜🏻', '🤜🏼', '🤜🏽', '🤜🏾', '🤜🏿', '🤝🏻', '🤝🏼', '🤝🏽', '🤝🏾', '🤝🏿', '🤞🏻', '🤞🏼', '🤞🏽', '🤞🏾', '🤞🏿', '🤟🏻', '🤟🏼', '🤟🏽', '🤟🏾', '🤟🏿', '🤦🏻', '🤦🏼', '🤦🏽', '🤦🏾', '🤦🏿', '🤰🏻', '🤰🏼', '🤰🏽', '🤰🏾', '🤰🏿', '🤱🏻', '🤱🏼', '🤱🏽', '🤱🏾', '🤱🏿', '🤲🏻', '🤲🏼', '🤲🏽', '🤲🏾', '🤲🏿', '🤳🏻', '🤳🏼', '🤳🏽', '🤳🏾', '🤳🏿', '🤴🏻', '🤴🏼', '🤴🏽', '🤴🏾', '🤴🏿', '🤵🏻', '🤵🏼', '🤵🏽', '🤵🏾', '🤵🏿', '🤶🏻', '🤶🏼', '🤶🏽', '🤶🏾', '🤶🏿', '🤷🏻', '🤷🏼', '🤷🏽', '🤷🏾', '🤷🏿', '🤸🏻', '🤸🏼', '🤸🏽', '🤸🏾', '🤸🏿', '🤹🏻', '🤹🏼', '🤹🏽', '🤹🏾', '🤹🏿', '🤼🏻', '🤼🏼', '🤼🏽', '🤼🏾', '🤼🏿', '🤽🏻', '🤽🏼', '🤽🏽', '🤽🏾', '🤽🏿', '🤾🏻', '🤾🏼', '🤾🏽', '🤾🏾', '🤾🏿', '🥷🏻', '🥷🏼', '🥷🏽', '🥷🏾', '🥷🏿', '🦵🏻', '🦵🏼', '🦵🏽', '🦵🏾', '🦵🏿', '🦶🏻', '🦶🏼', '🦶🏽', '🦶🏾', '🦶🏿', '🦸🏻', '🦸🏼', '🦸🏽', '🦸🏾', '🦸🏿', '🦹🏻', '🦹🏼', '🦹🏽', '🦹🏾', '🦹🏿', '🦻🏻', '🦻🏼', '🦻🏽', '🦻🏾', '🦻🏿', '🧍🏻', '🧍🏼', '🧍🏽', '🧍🏾', '🧍🏿', '🧎🏻', '🧎🏼', '🧎🏽', '🧎🏾', '🧎🏿', '🧏🏻', '🧏🏼', '🧏🏽', '🧏🏾', '🧏🏿', '🧑🏻', '🧑🏼', '🧑🏽', '🧑🏾', '🧑🏿', '🧒🏻', '🧒🏼', '🧒🏽', '🧒🏾', '🧒🏿', '🧓🏻', '🧓🏼', '🧓🏽', '🧓🏾', '🧓🏿', '🧔🏻', '🧔🏼', '🧔🏽', '🧔🏾', '🧔🏿', '🧕🏻', '🧕🏼', '🧕🏽', '🧕🏾', '🧕🏿', '🧖🏻', '🧖🏼', '🧖🏽', '🧖🏾', '🧖🏿', '🧗🏻', '🧗🏼', '🧗🏽', '🧗🏾', '🧗🏿', '🧘🏻', '🧘🏼', '🧘🏽', '🧘🏾', '🧘🏿', '🧙🏻', '🧙🏼', '🧙🏽', '🧙🏾', '🧙🏿', '🧚🏻', '🧚🏼', '🧚🏽', '🧚🏾', '🧚🏿', '🧛🏻', '🧛🏼', '🧛🏽', '🧛🏾', '🧛🏿', '🧜🏻', '🧜🏼', '🧜🏽', '🧜🏾', '🧜🏿', '🧝🏻', '🧝🏼', '🧝🏽', '🧝🏾', '🧝🏿', '🫃🏻', '🫃🏼', '🫃🏽', '🫃🏾', '🫃🏿', '🫄🏻', '🫄🏼', '🫄🏽', '🫄🏾', '🫄🏿', '🫅🏻', '🫅🏼', '🫅🏽', '🫅🏾', '🫅🏿', '🫰🏻', '🫰🏼', '🫰🏽', '🫰🏾', '🫰🏿', '🫱🏻', '🫱🏼', '🫱🏽', '🫱🏾', '🫱🏿', '🫲🏻', '🫲🏼', '🫲🏽', '🫲🏾', '🫲🏿', '🫳🏻', '🫳🏼', '🫳🏽', '🫳🏾', '🫳🏿', '🫴🏻', '🫴🏼', '🫴🏽', '🫴🏾', '🫴🏿', '🫵🏻', '🫵🏼', '🫵🏽', '🫵🏾', '🫵🏿', '🫶🏻', '🫶🏼', '🫶🏽', '🫶🏾', '🫶🏿', '🫷🏻', '🫷🏼', '🫷🏽', '🫷🏾', '🫷🏿', '🫸🏻', '🫸🏼', '🫸🏽', '🫸🏾', '🫸🏿', '☝🏻', '☝🏼', '☝🏽', '☝🏾', '☝🏿', '⛷🏻', '⛷🏼', '⛷🏽', '⛷🏾', '⛷🏿', '⛹🏻', '⛹🏼', '⛹🏽', '⛹🏾', '⛹🏿', '✊🏻', '✊🏼', '✊🏽', '✊🏾', '✊🏿', '✋🏻', '✋🏼', '✋🏽', '✋🏾', '✋🏿', '✌🏻', '✌🏼', '✌🏽', '✌🏾', '✌🏿', '✍🏻', '✍🏼', '✍🏽', '✍🏾', '✍🏿', '#⃣', '*⃣', '0⃣', '1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮', '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷', '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '🏴', '🏵', '🏷', '🏸', '🏹', '🏺', '🏻', '🏼', '🏽', '🏾', '🏿', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '👩', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💋', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💻', '💼', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔥', '🔦', '🔧', '🔨', '🔩', '🔪', '🔫', '🔬', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗨', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚀', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚒', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛖', '🛗', '🛘', '🛜', '🛝', '🛞', '🛟', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🛻', '🛼', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟩', '🟪', '🟫', '🟰', '🤌', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤝', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥲', '🥳', '🥴', '🥵', '🥶', '🥷', '🥸', '🥹', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦣', '🦤', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦫', '🦬', '🦭', '🦮', '🦯', '🦰', '🦱', '🦲', '🦳', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦺', '🦻', '🦼', '🦽', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧋', '🧌', '🧍', '🧎', '🧏', '🧐', '🧑', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩰', '🩱', '🩲', '🩳', '🩴', '🩵', '🩶', '🩷', '🩸', '🩹', '🩺', '🩻', '🩼', '🪀', '🪁', '🪂', '🪃', '🪄', '🪅', '🪆', '🪇', '🪈', '🪉', '🪊', '🪎', '🪏', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🪖', '🪗', '🪘', '🪙', '🪚', '🪛', '🪜', '🪝', '🪞', '🪟', '🪠', '🪡', '🪢', '🪣', '🪤', '🪥', '🪦', '🪧', '🪨', '🪩', '🪪', '🪫', '🪬', '🪭', '🪮', '🪯', '🪰', '🪱', '🪲', '🪳', '🪴', '🪵', '🪶', '🪷', '🪸', '🪹', '🪺', '🪻', '🪼', '🪽', '🪾', '🪿', '🫀', '🫁', '🫂', '🫃', '🫄', '🫅', '🫆', '🫈', '🫍', '🫎', '🫏', '🫐', '🫑', '🫒', '🫓', '🫔', '🫕', '🫖', '🫗', '🫘', '🫙', '🫚', '🫛', '🫜', '🫟', '🫠', '🫡', '🫢', '🫣', '🫤', '🫥', '🫦', '🫧', '🫨', '🫩', '🫪', '🫯', '🫰', '🫱', '🫲', '🫳', '🫴', '🫵', '🫶', '🫷', '🫸', '‼', '⁉', '™', 'ℹ', '↔', '↕', '↖', '↗', '↘', '↙', '↩', '↪', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☠', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♀', '♂', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚕', '⚖', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚧', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✈', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❄', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '❤', '➕', '➖', '➗', '➡', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬛', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); 6380 $partials = array( '🀄', '🃏', '🅰', '🅱', '🅾', '🅿', '🆎', '🆑', '🆒', '🆓', '🆔', '🆕', '🆖', '🆗', '🆘', '🆙', '🆚', '🇦', '🇨', '🇩', '🇪', '🇫', '🇬', '🇮', '🇱', '🇲', '🇴', '🇶', '🇷', '🇸', '🇹', '🇺', '🇼', '🇽', '🇿', '🇧', '🇭', '🇯', '🇳', '🇻', '🇾', '🇰', '🇵', '🈁', '🈂', '🈚', '🈯', '🈲', '🈳', '🈴', '🈵', '🈶', '🈷', '🈸', '🈹', '🈺', '🉐', '🉑', '🌀', '🌁', '🌂', '🌃', '🌄', '🌅', '🌆', '🌇', '🌈', '🌉', '🌊', '🌋', '🌌', '🌍', '🌎', '🌏', '🌐', '🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', '🌙', '🌚', '🌛', '🌜', '🌝', '🌞', '🌟', '🌠', '🌡', '🌤', '🌥', '🌦', '🌧', '🌨', '🌩', '🌪', '🌫', '🌬', '🌭', '🌮', '🌯', '🌰', '🌱', '🌲', '🌳', '🌴', '🌵', '🌶', '🌷', '🌸', '🌹', '🌺', '🌻', '🌼', '🌽', '🌾', '🌿', '🍀', '🍁', '🍂', '🍃', '🍄', '‍', '🟫', '🍅', '🍆', '🍇', '🍈', '🍉', '🍊', '🍋', '🟩', '🍌', '🍍', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🍔', '🍕', '🍖', '🍗', '🍘', '🍙', '🍚', '🍛', '🍜', '🍝', '🍞', '🍟', '🍠', '🍡', '🍢', '🍣', '🍤', '🍥', '🍦', '🍧', '🍨', '🍩', '🍪', '🍫', '🍬', '🍭', '🍮', '🍯', '🍰', '🍱', '🍲', '🍳', '🍴', '🍵', '🍶', '🍷', '🍸', '🍹', '🍺', '🍻', '🍼', '🍽', '🍾', '🍿', '🎀', '🎁', '🎂', '🎃', '🎄', '🎅', '🏻', '🏼', '🏽', '🏾', '🏿', '🎆', '🎇', '🎈', '🎉', '🎊', '🎋', '🎌', '🎍', '🎎', '🎏', '🎐', '🎑', '🎒', '🎓', '🎖', '🎗', '🎙', '🎚', '🎛', '🎞', '🎟', '🎠', '🎡', '🎢', '🎣', '🎤', '🎥', '🎦', '🎧', '🎨', '🎩', '🎪', '🎫', '🎬', '🎭', '🎮', '🎯', '🎰', '🎱', '🎲', '🎳', '🎴', '🎵', '🎶', '🎷', '🎸', '🎹', '🎺', '🎻', '🎼', '🎽', '🎾', '🎿', '🏀', '🏁', '🏂', '🏃', '♀', '️', '➡', '♂', '🏄', '🏅', '🏆', '🏇', '🏈', '🏉', '🏊', '🏋', '🏌', '🏍', '🏎', '🏏', '🏐', '🏑', '🏒', '🏓', '🏔', '🏕', '🏖', '🏗', '🏘', '🏙', '🏚', '🏛', '🏜', '🏝', '🏞', '🏟', '🏠', '🏡', '🏢', '🏣', '🏤', '🏥', '🏦', '🏧', '🏨', '🏩', '🏪', '🏫', '🏬', '🏭', '🏮', '🏯', '🏰', '🏳', '⚧', '🏴', '☠', '󠁧', '󠁢', '󠁥', '󠁮', '󠁿', '󠁳', '󠁣', '󠁴', '󠁷', '󠁬', '🏵', '🏷', '🏸', '🏹', '🏺', '🐀', '🐁', '🐂', '🐃', '🐄', '🐅', '🐆', '🐇', '🐈', '⬛', '🐉', '🐊', '🐋', '🐌', '🐍', '🐎', '🐏', '🐐', '🐑', '🐒', '🐓', '🐔', '🐕', '🦺', '🐖', '🐗', '🐘', '🐙', '🐚', '🐛', '🐜', '🐝', '🐞', '🐟', '🐠', '🐡', '🐢', '🐣', '🐤', '🐥', '🐦', '🔥', '🐧', '🐨', '🐩', '🐪', '🐫', '🐬', '🐭', '🐮', '🐯', '🐰', '🐱', '🐲', '🐳', '🐴', '🐵', '🐶', '🐷', '🐸', '🐹', '🐺', '🐻', '❄', '🐼', '🐽', '🐾', '🐿', '👀', '👁', '🗨', '👂', '👃', '👄', '👅', '👆', '👇', '👈', '👉', '👊', '👋', '👌', '👍', '👎', '👏', '👐', '👑', '👒', '👓', '👔', '👕', '👖', '👗', '👘', '👙', '👚', '👛', '👜', '👝', '👞', '👟', '👠', '👡', '👢', '👣', '👤', '👥', '👦', '👧', '👨', '💻', '💼', '🔧', '🔬', '🚀', '🚒', '🤝', '🦯', '🦰', '🦱', '🦲', '🦳', '🦼', '🦽', '🫯', '⚕', '⚖', '✈', '❤', '💋', '👩', '👪', '👫', '👬', '👭', '👮', '👯', '👰', '👱', '👲', '👳', '👴', '👵', '👶', '👷', '👸', '👹', '👺', '👻', '👼', '👽', '👾', '👿', '💀', '💁', '💂', '💃', '💄', '💅', '💆', '💇', '💈', '💉', '💊', '💌', '💍', '💎', '💏', '💐', '💑', '💒', '💓', '💔', '💕', '💖', '💗', '💘', '💙', '💚', '💛', '💜', '💝', '💞', '💟', '💠', '💡', '💢', '💣', '💤', '💥', '💦', '💧', '💨', '💩', '💪', '💫', '💬', '💭', '💮', '💯', '💰', '💱', '💲', '💳', '💴', '💵', '💶', '💷', '💸', '💹', '💺', '💽', '💾', '💿', '📀', '📁', '📂', '📃', '📄', '📅', '📆', '📇', '📈', '📉', '📊', '📋', '📌', '📍', '📎', '📏', '📐', '📑', '📒', '📓', '📔', '📕', '📖', '📗', '📘', '📙', '📚', '📛', '📜', '📝', '📞', '📟', '📠', '📡', '📢', '📣', '📤', '📥', '📦', '📧', '📨', '📩', '📪', '📫', '📬', '📭', '📮', '📯', '📰', '📱', '📲', '📳', '📴', '📵', '📶', '📷', '📸', '📹', '📺', '📻', '📼', '📽', '📿', '🔀', '🔁', '🔂', '🔃', '🔄', '🔅', '🔆', '🔇', '🔈', '🔉', '🔊', '🔋', '🔌', '🔍', '🔎', '🔏', '🔐', '🔑', '🔒', '🔓', '🔔', '🔕', '🔖', '🔗', '🔘', '🔙', '🔚', '🔛', '🔜', '🔝', '🔞', '🔟', '🔠', '🔡', '🔢', '🔣', '🔤', '🔦', '🔨', '🔩', '🔪', '🔫', '🔭', '🔮', '🔯', '🔰', '🔱', '🔲', '🔳', '🔴', '🔵', '🔶', '🔷', '🔸', '🔹', '🔺', '🔻', '🔼', '🔽', '🕉', '🕊', '🕋', '🕌', '🕍', '🕎', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚', '🕛', '🕜', '🕝', '🕞', '🕟', '🕠', '🕡', '🕢', '🕣', '🕤', '🕥', '🕦', '🕧', '🕯', '🕰', '🕳', '🕴', '🕵', '🕶', '🕷', '🕸', '🕹', '🕺', '🖇', '🖊', '🖋', '🖌', '🖍', '🖐', '🖕', '🖖', '🖤', '🖥', '🖨', '🖱', '🖲', '🖼', '🗂', '🗃', '🗄', '🗑', '🗒', '🗓', '🗜', '🗝', '🗞', '🗡', '🗣', '🗯', '🗳', '🗺', '🗻', '🗼', '🗽', '🗾', '🗿', '😀', '😁', '😂', '😃', '😄', '😅', '😆', '😇', '😈', '😉', '😊', '😋', '😌', '😍', '😎', '😏', '😐', '😑', '😒', '😓', '😔', '😕', '😖', '😗', '😘', '😙', '😚', '😛', '😜', '😝', '😞', '😟', '😠', '😡', '😢', '😣', '😤', '😥', '😦', '😧', '😨', '😩', '😪', '😫', '😬', '😭', '😮', '😯', '😰', '😱', '😲', '😳', '😴', '😵', '😶', '😷', '😸', '😹', '😺', '😻', '😼', '😽', '😾', '😿', '🙀', '🙁', '🙂', '↔', '↕', '🙃', '🙄', '🙅', '🙆', '🙇', '🙈', '🙉', '🙊', '🙋', '🙌', '🙍', '🙎', '🙏', '🚁', '🚂', '🚃', '🚄', '🚅', '🚆', '🚇', '🚈', '🚉', '🚊', '🚋', '🚌', '🚍', '🚎', '🚏', '🚐', '🚑', '🚓', '🚔', '🚕', '🚖', '🚗', '🚘', '🚙', '🚚', '🚛', '🚜', '🚝', '🚞', '🚟', '🚠', '🚡', '🚢', '🚣', '🚤', '🚥', '🚦', '🚧', '🚨', '🚩', '🚪', '🚫', '🚬', '🚭', '🚮', '🚯', '🚰', '🚱', '🚲', '🚳', '🚴', '🚵', '🚶', '🚷', '🚸', '🚹', '🚺', '🚻', '🚼', '🚽', '🚾', '🚿', '🛀', '🛁', '🛂', '🛃', '🛄', '🛅', '🛋', '🛌', '🛍', '🛎', '🛏', '🛐', '🛑', '🛒', '🛕', '🛖', '🛗', '🛘', '🛜', '🛝', '🛞', '🛟', '🛠', '🛡', '🛢', '🛣', '🛤', '🛥', '🛩', '🛫', '🛬', '🛰', '🛳', '🛴', '🛵', '🛶', '🛷', '🛸', '🛹', '🛺', '🛻', '🛼', '🟠', '🟡', '🟢', '🟣', '🟤', '🟥', '🟦', '🟧', '🟨', '🟪', '🟰', '🤌', '🤍', '🤎', '🤏', '🤐', '🤑', '🤒', '🤓', '🤔', '🤕', '🤖', '🤗', '🤘', '🤙', '🤚', '🤛', '🤜', '🤞', '🤟', '🤠', '🤡', '🤢', '🤣', '🤤', '🤥', '🤦', '🤧', '🤨', '🤩', '🤪', '🤫', '🤬', '🤭', '🤮', '🤯', '🤰', '🤱', '🤲', '🤳', '🤴', '🤵', '🤶', '🤷', '🤸', '🤹', '🤺', '🤼', '🤽', '🤾', '🤿', '🥀', '🥁', '🥂', '🥃', '🥄', '🥅', '🥇', '🥈', '🥉', '🥊', '🥋', '🥌', '🥍', '🥎', '🥏', '🥐', '🥑', '🥒', '🥓', '🥔', '🥕', '🥖', '🥗', '🥘', '🥙', '🥚', '🥛', '🥜', '🥝', '🥞', '🥟', '🥠', '🥡', '🥢', '🥣', '🥤', '🥥', '🥦', '🥧', '🥨', '🥩', '🥪', '🥫', '🥬', '🥭', '🥮', '🥯', '🥰', '🥱', '🥲', '🥳', '🥴', '🥵', '🥶', '🥷', '🥸', '🥹', '🥺', '🥻', '🥼', '🥽', '🥾', '🥿', '🦀', '🦁', '🦂', '🦃', '🦄', '🦅', '🦆', '🦇', '🦈', '🦉', '🦊', '🦋', '🦌', '🦍', '🦎', '🦏', '🦐', '🦑', '🦒', '🦓', '🦔', '🦕', '🦖', '🦗', '🦘', '🦙', '🦚', '🦛', '🦜', '🦝', '🦞', '🦟', '🦠', '🦡', '🦢', '🦣', '🦤', '🦥', '🦦', '🦧', '🦨', '🦩', '🦪', '🦫', '🦬', '🦭', '🦮', '🦴', '🦵', '🦶', '🦷', '🦸', '🦹', '🦻', '🦾', '🦿', '🧀', '🧁', '🧂', '🧃', '🧄', '🧅', '🧆', '🧇', '🧈', '🧉', '🧊', '🧋', '🧌', '🧍', '🧎', '🧏', '🧐', '🧑', '🩰', '🧒', '🧓', '🧔', '🧕', '🧖', '🧗', '🧘', '🧙', '🧚', '🧛', '🧜', '🧝', '🧞', '🧟', '🧠', '🧡', '🧢', '🧣', '🧤', '🧥', '🧦', '🧧', '🧨', '🧩', '🧪', '🧫', '🧬', '🧭', '🧮', '🧯', '🧰', '🧱', '🧲', '🧳', '🧴', '🧵', '🧶', '🧷', '🧸', '🧹', '🧺', '🧻', '🧼', '🧽', '🧾', '🧿', '🩱', '🩲', '🩳', '🩴', '🩵', '🩶', '🩷', '🩸', '🩹', '🩺', '🩻', '🩼', '🪀', '🪁', '🪂', '🪃', '🪄', '🪅', '🪆', '🪇', '🪈', '🪉', '🪊', '🪎', '🪏', '🪐', '🪑', '🪒', '🪓', '🪔', '🪕', '🪖', '🪗', '🪘', '🪙', '🪚', '🪛', '🪜', '🪝', '🪞', '🪟', '🪠', '🪡', '🪢', '🪣', '🪤', '🪥', '🪦', '🪧', '🪨', '🪩', '🪪', '🪫', '🪬', '🪭', '🪮', '🪯', '🪰', '🪱', '🪲', '🪳', '🪴', '🪵', '🪶', '🪷', '🪸', '🪹', '🪺', '🪻', '🪼', '🪽', '🪾', '🪿', '🫀', '🫁', '🫂', '🫃', '🫄', '🫅', '🫆', '🫈', '🫍', '🫎', '🫏', '🫐', '🫑', '🫒', '🫓', '🫔', '🫕', '🫖', '🫗', '🫘', '🫙', '🫚', '🫛', '🫜', '🫟', '🫠', '🫡', '🫢', '🫣', '🫤', '🫥', '🫦', '🫧', '🫨', '🫩', '🫪', '🫰', '🫱', '🫲', '🫳', '🫴', '🫵', '🫶', '🫷', '🫸', '‼', '⁉', '™', 'ℹ', '↖', '↗', '↘', '↙', '↩', '↪', '⃣', '⌚', '⌛', '⌨', '⏏', '⏩', '⏪', '⏫', '⏬', '⏭', '⏮', '⏯', '⏰', '⏱', '⏲', '⏳', '⏸', '⏹', '⏺', 'Ⓜ', '▪', '▫', '▶', '◀', '◻', '◼', '◽', '◾', '☀', '☁', '☂', '☃', '☄', '☎', '☑', '☔', '☕', '☘', '☝', '☢', '☣', '☦', '☪', '☮', '☯', '☸', '☹', '☺', '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓', '♟', '♠', '♣', '♥', '♦', '♨', '♻', '♾', '♿', '⚒', '⚓', '⚔', '⚗', '⚙', '⚛', '⚜', '⚠', '⚡', '⚪', '⚫', '⚰', '⚱', '⚽', '⚾', '⛄', '⛅', '⛈', '⛎', '⛏', '⛑', '⛓', '⛔', '⛩', '⛪', '⛰', '⛱', '⛲', '⛳', '⛴', '⛵', '⛷', '⛸', '⛹', '⛺', '⛽', '✂', '✅', '✉', '✊', '✋', '✌', '✍', '✏', '✒', '✔', '✖', '✝', '✡', '✨', '✳', '✴', '❇', '❌', '❎', '❓', '❔', '❕', '❗', '❣', '➕', '➖', '➗', '➰', '➿', '⤴', '⤵', '⬅', '⬆', '⬇', '⬜', '⭐', '⭕', '〰', '〽', '㊗', '㊙', '' ); 6381 // END: emoji arrays 6382 6383 if ( 'entities' === $type ) { 6384 return $entities; 6385 } 6386 6387 return $partials; 6388 } 6389 6390 /** 6391 * Shortens a URL, to be used as link text. 6392 * 6393 * @since 1.2.0 6394 * @since 4.4.0 Moved to wp-includes/formatting.php from wp-admin/includes/misc.php and added $length param. 6395 * 6396 * @param string $url URL to shorten. 6397 * @param int $length Optional. Maximum length of the shortened URL. Default 35 characters. 6398 * @return string Shortened URL. 6399 */ 6400 function url_shorten( $url, $length = 35 ) { 6401 $stripped = str_replace( array( 'https://', 'http://', 'www.' ), '', $url ); 6402 $short_url = untrailingslashit( $stripped ); 6403 6404 if ( strlen( $short_url ) > $length ) { 6405 $short_url = substr( $short_url, 0, $length - 3 ) . '…'; 6406 } 6407 return $short_url; 6408 } 6409 6410 /** 6411 * Sanitizes a hex color. 6412 * 6413 * Returns either '', a 3 or 6 digit hex color (with #), or nothing. 6414 * For sanitizing values without a #, see sanitize_hex_color_no_hash(). 6415 * 6416 * @since 3.4.0 6417 * 6418 * @param string $color 6419 * @return string|null The sanitized hex color, or null if invalid. 6420 */ 6421 function sanitize_hex_color( $color ) { 6422 if ( '' === $color ) { 6423 return ''; 6424 } 6425 6426 // 3 or 6 hex digits, or the empty string. 6427 if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { 6428 return $color; 6429 } 6430 return null; 6431 } 6432 6433 /** 6434 * Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. 6435 * 6436 * Saving hex colors without a hash puts the burden of adding the hash on the 6437 * UI, which makes it difficult to use or upgrade to other color types such as 6438 * rgba, hsl, rgb, and HTML color names. 6439 * 6440 * Returns either '', a 3 or 6 digit hex color (without a #), or null. 6441 * 6442 * @since 3.4.0 6443 * 6444 * @param string $color The color value to sanitize. Can be with or without a #. 6445 * @return string|null The sanitized hex color without the hash prefix, 6446 * empty string if input is empty, or null if invalid. 6447 */ 6448 function sanitize_hex_color_no_hash( $color ) { 6449 $color = ltrim( $color, '#' ); 6450 6451 if ( '' === $color ) { 6452 return ''; 6453 } 6454 6455 return sanitize_hex_color( '#' . $color ) ? $color : null; 6456 } 6457 6458 /** 6459 * Ensures that any hex color is properly hashed. 6460 * Otherwise, returns value untouched. 6461 * 6462 * This method should only be necessary if using sanitize_hex_color_no_hash(). 6463 * 6464 * @since 3.4.0 6465 * 6466 * @param string $color The color value to add the hash prefix to. Can be with or without a #. 6467 * @return string The color with the hash prefix if it's a valid hex color, 6468 * otherwise the original value. 6469 */ 6470 function maybe_hash_hex_color( $color ) { 6471 $unhashed = sanitize_hex_color_no_hash( $color ); 6472 if ( $unhashed ) { 6473 return '#' . $unhashed; 6474 } 6475 6476 return $color; 6477 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Thu Nov 26 08:20:01 2026 | Cross-referenced by PHPXref |