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