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