-
+ 10526D3D84BBE766511AF25287F01BBE1125A06D18BABB93E1B7C33488C1F1DF15EA3E706848A67D36C30EDAC25D3A4DD360BC563AC21093F6BFE0183F9C4388
mp-wp/wp-includes/formatting.php
(0 . 0)(1 . 2163)
89458 <?php^M
89459 /**^M
89460 * Main Wordpress Formatting API.^M
89461 *^M
89462 * Handles many functions for formatting output.^M
89463 *^M
89464 * @package WordPress^M
89465 **/^M
89466 ^M
89467 /**^M
89468 * Replaces common plain text characters into formatted entities^M
89469 *^M
89470 * As an example,^M
89471 * <code>^M
89472 * 'cause today's effort makes it worth tomorrow's "holiday"...^M
89473 * </code>^M
89474 * Becomes:^M
89475 * <code>^M
89476 * ’cause today’s effort makes it worth tomorrow’s “holiday”…^M
89477 * </code>^M
89478 * Code within certain html blocks are skipped.^M
89479 *^M
89480 * @since 0.71^M
89481 * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases^M
89482 *^M
89483 * @param string $text The text to be formatted^M
89484 * @return string The string replaced with html entities^M
89485 */^M
89486 function wptexturize($text) {^M
89487 /* global $wp_cockneyreplace;^M
89488 $next = true;^M
89489 $has_pre_parent = false;^M
89490 $output = '';^M
89491 $curl = '';^M
89492 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);^M
89493 $stop = count($textarr);^M
89494 ^M
89495 // if a plugin has provided an autocorrect array, use it^M
89496 if ( isset($wp_cockneyreplace) ) {^M
89497 $cockney = array_keys($wp_cockneyreplace);^M
89498 $cockneyreplace = array_values($wp_cockneyreplace);^M
89499 } else {^M
89500 $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");^M
89501 $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause");^M
89502 }^M
89503 ^M
89504 $static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney);^M
89505 $static_replacements = array_merge(array('—', ' — ', '–', 'xn--', '…', '“', '’s', '”', ' ™'), $cockneyreplace);^M
89506 ^M
89507 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/');^M
89508 $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2');^M
89509 ^M
89510 for ( $i = 0; $i < $stop; $i++ ) {^M
89511 $curl = $textarr[$i];^M
89512 ^M
89513 if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag^M
89514 // static strings^M
89515 $curl = str_replace($static_characters, $static_replacements, $curl);^M
89516 // regular expressions^M
89517 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);^M
89518 } elseif (strpos($curl, '<code') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {^M
89519 $next = false;^M
89520 } elseif (strpos($curl, '<pre') !== false) {^M
89521 $has_pre_parent = true;^M
89522 } elseif (strpos($curl, '</pre>') !== false) {^M
89523 $has_pre_parent = false;^M
89524 } else {^M
89525 $next = true;^M
89526 }^M
89527 ^M
89528 $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl);^M
89529 $output .= $curl;^M
89530 }^M
89531 ^M
89532 return $output;^M
89533 */^M
89534 return $text; ^M
89535 }^M
89536 ^M
89537 /**^M
89538 * Accepts matches array from preg_replace_callback in wpautop() or a string.^M
89539 *^M
89540 * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not^M
89541 * converted into paragraphs or line-breaks.^M
89542 *^M
89543 * @since 1.2.0^M
89544 *^M
89545 * @param array|string $matches The array or string^M
89546 * @return string The pre block without paragraph/line-break conversion.^M
89547 */^M
89548 function clean_pre($matches) {^M
89549 if ( is_array($matches) )^M
89550 $text = $matches[1] . $matches[2] . "</pre>";^M
89551 else^M
89552 $text = $matches;^M
89553 ^M
89554 $text = str_replace('<br />', '', $text);^M
89555 $text = str_replace('<p>', "\n", $text);^M
89556 $text = str_replace('</p>', '', $text);^M
89557 ^M
89558 return $text;^M
89559 }^M
89560 ^M
89561 /**^M
89562 * Replaces double line-breaks with paragraph elements.^M
89563 *^M
89564 * A group of regex replaces used to identify text formatted with newlines and^M
89565 * replace double line-breaks with HTML paragraph tags. The remaining^M
89566 * line-breaks after conversion become <<br />> tags, unless $br is set to '0'^M
89567 * or 'false'.^M
89568 *^M
89569 * @since 0.71^M
89570 *^M
89571 * @param string $pee The text which has to be formatted.^M
89572 * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.^M
89573 * @return string Text which has been converted into correct paragraph tags.^M
89574 */^M
89575 function wpautop($pee, $br = 1) {^M
89576 $pee = $pee . "\n"; // just to make things a little easier, pad the end^M
89577 $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);^M
89578 // Space things out a little^M
89579 $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)';^M
89580 $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);^M
89581 $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);^M
89582 $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines^M
89583 if ( strpos($pee, '<object') !== false ) {^M
89584 $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed^M
89585 $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);^M
89586 }^M
89587 $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates^M
89588 // make paragraphs, including one at the end^M
89589 $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);^M
89590 $pee = '';^M
89591 foreach ( $pees as $tinkle )^M
89592 $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";^M
89593 $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace^M
89594 $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);^M
89595 $pee = preg_replace( '|<p>|', "$1<p>", $pee );^M
89596 $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag^M
89597 $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists^M
89598 $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);^M
89599 $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);^M
89600 $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);^M
89601 $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);^M
89602 if ($br) {^M
89603 $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $pee);^M
89604 $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks^M
89605 $pee = str_replace('<WPPreserveNewline />', "\n", $pee);^M
89606 }^M
89607 $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);^M
89608 $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);^M
89609 if (strpos($pee, '<pre') !== false)^M
89610 $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );^M
89611 $pee = preg_replace( "|\n</p>$|", '</p>', $pee );^M
89612 $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone^M
89613 ^M
89614 return $pee;^M
89615 }^M
89616 ^M
89617 /**^M
89618 * Checks to see if a string is utf8 encoded.^M
89619 *^M
89620 * @author bmorel at ssi dot fr^M
89621 *^M
89622 * @since 1.2.1^M
89623 *^M
89624 * @param string $Str The string to be checked^M
89625 * @return bool True if $Str fits a UTF-8 model, false otherwise.^M
89626 */^M
89627 function seems_utf8($Str) { # by bmorel at ssi dot fr^M
89628 $length = strlen($Str);^M
89629 for ($i=0; $i < $length; $i++) {^M
89630 if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb^M
89631 elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb^M
89632 elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb^M
89633 elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb^M
89634 elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb^M
89635 elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b^M
89636 else return false; # Does not match any model^M
89637 for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?^M
89638 if ((++$i == $length) || ((ord($Str[$i]) & 0xC0) != 0x80))^M
89639 return false;^M
89640 }^M
89641 }^M
89642 return true;^M
89643 }^M
89644 ^M
89645 /**^M
89646 * Converts a number of special characters into their HTML entities.^M
89647 *^M
89648 * Differs from htmlspecialchars as existing HTML entities will not be encoded.^M
89649 * Specifically changes: & to &, < to < and > to >.^M
89650 *^M
89651 * $quotes can be set to 'single' to encode ' to ', 'double' to encode " to^M
89652 * ", or '1' to do both. Default is 0 where no quotes are encoded.^M
89653 *^M
89654 * @since 1.2.2^M
89655 *^M
89656 * @param string $text The text which is to be encoded.^M
89657 * @param mixed $quotes Optional. Converts single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default 0.^M
89658 * @return string The encoded text with HTML entities.^M
89659 */^M
89660 function wp_specialchars( $text, $quotes = 0 ) {^M
89661 // Like htmlspecialchars except don't double-encode HTML entities^M
89662 $text = str_replace('&&', '&&', $text);^M
89663 $text = str_replace('&&', '&&', $text);^M
89664 $text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&$1', $text);^M
89665 $text = str_replace('<', '<', $text);^M
89666 $text = str_replace('>', '>', $text);^M
89667 if ( 'double' === $quotes ) {^M
89668 $text = str_replace('"', '"', $text);^M
89669 } elseif ( 'single' === $quotes ) {^M
89670 $text = str_replace("'", ''', $text);^M
89671 } elseif ( $quotes ) {^M
89672 $text = str_replace('"', '"', $text);^M
89673 $text = str_replace("'", ''', $text);^M
89674 }^M
89675 return $text;^M
89676 }^M
89677 ^M
89678 /**^M
89679 * Encode the Unicode values to be used in the URI.^M
89680 *^M
89681 * @since 1.5.0^M
89682 *^M
89683 * @param string $utf8_string^M
89684 * @param int $length Max length of the string^M
89685 * @return string String with Unicode encoded for URI.^M
89686 */^M
89687 function utf8_uri_encode( $utf8_string, $length = 0 ) {^M
89688 $unicode = '';^M
89689 $values = array();^M
89690 $num_octets = 1;^M
89691 $unicode_length = 0;^M
89692 ^M
89693 $string_length = strlen( $utf8_string );^M
89694 for ($i = 0; $i < $string_length; $i++ ) {^M
89695 ^M
89696 $value = ord( $utf8_string[ $i ] );^M
89697 ^M
89698 if ( $value < 128 ) {^M
89699 if ( $length && ( $unicode_length >= $length ) )^M
89700 break;^M
89701 $unicode .= chr($value);^M
89702 $unicode_length++;^M
89703 } else {^M
89704 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;^M
89705 ^M
89706 $values[] = $value;^M
89707 ^M
89708 if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )^M
89709 break;^M
89710 if ( count( $values ) == $num_octets ) {^M
89711 if ($num_octets == 3) {^M
89712 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);^M
89713 $unicode_length += 9;^M
89714 } else {^M
89715 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);^M
89716 $unicode_length += 6;^M
89717 }^M
89718 ^M
89719 $values = array();^M
89720 $num_octets = 1;^M
89721 }^M
89722 }^M
89723 }^M
89724 ^M
89725 return $unicode;^M
89726 }^M
89727 ^M
89728 /**^M
89729 * Converts all accent characters to ASCII characters.^M
89730 *^M
89731 * If there are no accent characters, then the string given is just returned.^M
89732 *^M
89733 * @since 1.2.1^M
89734 *^M
89735 * @param string $string Text that might have accent characters^M
89736 * @return string Filtered string with replaced "nice" characters.^M
89737 */^M
89738 function remove_accents($string) {^M
89739 if ( !preg_match('/[\x80-\xff]/', $string) )^M
89740 return $string;^M
89741 ^M
89742 if (seems_utf8($string)) {^M
89743 $chars = array(^M
89744 // Decompositions for Latin-1 Supplement^M
89745 chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',^M
89746 chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',^M
89747 chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',^M
89748 chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',^M
89749 chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',^M
89750 chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',^M
89751 chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',^M
89752 chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',^M
89753 chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',^M
89754 chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',^M
89755 chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',^M
89756 chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',^M
89757 chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',^M
89758 chr(195).chr(159) => 's', chr(195).chr(160) => 'a',^M
89759 chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',^M
89760 chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',^M
89761 chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',^M
89762 chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',^M
89763 chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',^M
89764 chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',^M
89765 chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',^M
89766 chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',^M
89767 chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',^M
89768 chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',^M
89769 chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',^M
89770 chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',^M
89771 chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',^M
89772 chr(195).chr(191) => 'y',^M
89773 // Decompositions for Latin Extended-A^M
89774 chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',^M
89775 chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',^M
89776 chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',^M
89777 chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',^M
89778 chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',^M
89779 chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',^M
89780 chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',^M
89781 chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',^M
89782 chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',^M
89783 chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',^M
89784 chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',^M
89785 chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',^M
89786 chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',^M
89787 chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',^M
89788 chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',^M
89789 chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',^M
89790 chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',^M
89791 chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',^M
89792 chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',^M
89793 chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',^M
89794 chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',^M
89795 chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',^M
89796 chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',^M
89797 chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',^M
89798 chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',^M
89799 chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',^M
89800 chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',^M
89801 chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',^M
89802 chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',^M
89803 chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',^M
89804 chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',^M
89805 chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',^M
89806 chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',^M
89807 chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',^M
89808 chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',^M
89809 chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',^M
89810 chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',^M
89811 chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',^M
89812 chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',^M
89813 chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',^M
89814 chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',^M
89815 chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',^M
89816 chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',^M
89817 chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',^M
89818 chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',^M
89819 chr(197).chr(154) => 'S',chr(197).chr(155) => 's',^M
89820 chr(197).chr(156) => 'S',chr(197).chr(157) => 's',^M
89821 chr(197).chr(158) => 'S',chr(197).chr(159) => 's',^M
89822 chr(197).chr(160) => 'S', chr(197).chr(161) => 's',^M
89823 chr(197).chr(162) => 'T', chr(197).chr(163) => 't',^M
89824 chr(197).chr(164) => 'T', chr(197).chr(165) => 't',^M
89825 chr(197).chr(166) => 'T', chr(197).chr(167) => 't',^M
89826 chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',^M
89827 chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',^M
89828 chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',^M
89829 chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',^M
89830 chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',^M
89831 chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',^M
89832 chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',^M
89833 chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',^M
89834 chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',^M
89835 chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',^M
89836 chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',^M
89837 chr(197).chr(190) => 'z', chr(197).chr(191) => 's',^M
89838 // Euro Sign^M
89839 chr(226).chr(130).chr(172) => 'E',^M
89840 // GBP (Pound) Sign^M
89841 chr(194).chr(163) => '');^M
89842 ^M
89843 $string = strtr($string, $chars);^M
89844 } else {^M
89845 // Assume ISO-8859-1 if not UTF-8^M
89846 $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)^M
89847 .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)^M
89848 .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)^M
89849 .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)^M
89850 .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)^M
89851 .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)^M
89852 .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)^M
89853 .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)^M
89854 .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)^M
89855 .chr(252).chr(253).chr(255);^M
89856 ^M
89857 $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";^M
89858 ^M
89859 $string = strtr($string, $chars['in'], $chars['out']);^M
89860 $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));^M
89861 $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');^M
89862 $string = str_replace($double_chars['in'], $double_chars['out'], $string);^M
89863 }^M
89864 ^M
89865 return $string;^M
89866 }^M
89867 ^M
89868 /**^M
89869 * Filters certain characters from the file name.^M
89870 *^M
89871 * Turns all strings to lowercase removing most characters except alphanumeric^M
89872 * with spaces, dashes and periods. All spaces and underscores are converted to^M
89873 * dashes. Multiple dashes are converted to a single dash. Finally, if the file^M
89874 * name ends with a dash, it is removed.^M
89875 *^M
89876 * @since 2.1.0^M
89877 *^M
89878 * @param string $name The file name^M
89879 * @return string Sanitized file name^M
89880 */^M
89881 function sanitize_file_name( $name ) { // Like sanitize_title, but with periods^M
89882 $name = strtolower( $name );^M
89883 $name = preg_replace('/&.+?;/', '', $name); // kill entities^M
89884 $name = str_replace( '_', '-', $name );^M
89885 $name = preg_replace('/[^a-z0-9\s-.]/', '', $name);^M
89886 $name = preg_replace('/\s+/', '-', $name);^M
89887 $name = preg_replace('|-+|', '-', $name);^M
89888 $name = trim($name, '-');^M
89889 return $name;^M
89890 }^M
89891 ^M
89892 /**^M
89893 * Sanitize username stripping out unsafe characters.^M
89894 *^M
89895 * If $strict is true, only alphanumeric characters (as well as _, space, ., -,^M
89896 * @) are returned.^M
89897 * Removes tags, octets, entities, and if strict is enabled, will remove all^M
89898 * non-ASCII characters. After sanitizing, it passes the username, raw username^M
89899 * (the username in the parameter), and the strict parameter as parameters for^M
89900 * the filter.^M
89901 *^M
89902 * @since 2.0.0^M
89903 * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username,^M
89904 * and $strict parameter.^M
89905 *^M
89906 * @param string $username The username to be sanitized.^M
89907 * @param bool $strict If set limits $username to specific characters. Default false.^M
89908 * @return string The sanitized username, after passing through filters.^M
89909 */^M
89910 function sanitize_user( $username, $strict = false ) {^M
89911 $raw_username = $username;^M
89912 $username = strip_tags($username);^M
89913 // Kill octets^M
89914 $username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);^M
89915 $username = preg_replace('/&.+?;/', '', $username); // Kill entities^M
89916 ^M
89917 // If strict, reduce to ASCII for max portability.^M
89918 if ( $strict )^M
89919 $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username);^M
89920 ^M
89921 // Consolidate contiguous whitespace^M
89922 $username = preg_replace('|\s+|', ' ', $username);^M
89923 ^M
89924 return apply_filters('sanitize_user', $username, $raw_username, $strict);^M
89925 }^M
89926 ^M
89927 /**^M
89928 * Sanitizes title or use fallback title.^M
89929 *^M
89930 * Specifically, HTML and PHP tags are stripped. Further actions can be added^M
89931 * via the plugin API. If $title is empty and $fallback_title is set, the latter^M
89932 * will be used.^M
89933 *^M
89934 * @since 1.0.0^M
89935 *^M
89936 * @param string $title The string to be sanitized.^M
89937 * @param string $fallback_title Optional. A title to use if $title is empty.^M
89938 * @return string The sanitized string.^M
89939 */^M
89940 function sanitize_title($title, $fallback_title = '') {^M
89941 $title = strip_tags($title);^M
89942 $title = apply_filters('sanitize_title', $title);^M
89943 ^M
89944 if ( '' === $title || false === $title )^M
89945 $title = $fallback_title;^M
89946 ^M
89947 return $title;^M
89948 }^M
89949 ^M
89950 /**^M
89951 * Sanitizes title, replacing whitespace with dashes.^M
89952 *^M
89953 * Limits the output to alphanumeric characters, underscore (_) and dash (-).^M
89954 * Whitespace becomes a dash.^M
89955 *^M
89956 * @since 1.2.0^M
89957 *^M
89958 * @param string $title The title to be sanitized.^M
89959 * @return string The sanitized title.^M
89960 */^M
89961 function sanitize_title_with_dashes($title) {^M
89962 $title = strip_tags($title);^M
89963 // Preserve escaped octets.^M
89964 $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);^M
89965 // Remove percent signs that are not part of an octet.^M
89966 $title = str_replace('%', '', $title);^M
89967 // Restore octets.^M
89968 $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);^M
89969 ^M
89970 $title = remove_accents($title);^M
89971 if (seems_utf8($title)) {^M
89972 if (function_exists('mb_strtolower')) {^M
89973 $title = mb_strtolower($title, 'UTF-8');^M
89974 }^M
89975 $title = utf8_uri_encode($title, 200);^M
89976 }^M
89977 ^M
89978 $title = strtolower($title);^M
89979 $title = preg_replace('/&.+?;/', '', $title); // kill entities^M
89980 $title = preg_replace('/[^%a-z0-9 _-]/', '', $title);^M
89981 $title = preg_replace('/\s+/', '-', $title);^M
89982 $title = preg_replace('|-+|', '-', $title);^M
89983 $title = trim($title, '-');^M
89984 ^M
89985 return $title;^M
89986 }^M
89987 ^M
89988 /**^M
89989 * Ensures a string is a valid SQL order by clause.^M
89990 *^M
89991 * Accepts one or more columns, with or without ASC/DESC, and also accepts^M
89992 * RAND().^M
89993 *^M
89994 * @since 2.5.1^M
89995 *^M
89996 * @param string $orderby Order by string to be checked.^M
89997 * @return string|false Returns the order by clause if it is a match, false otherwise.^M
89998 */^M
89999 function sanitize_sql_orderby( $orderby ){^M
90000 preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);^M
90001 if ( !$obmatches )^M
90002 return false;^M
90003 return $orderby;^M
90004 }^M
90005 ^M
90006 /**^M
90007 * Converts a number of characters from a string.^M
90008 *^M
90009 * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are^M
90010 * converted into correct XHTML and Unicode characters are converted to the^M
90011 * valid range.^M
90012 *^M
90013 * @since 0.71^M
90014 *^M
90015 * @param string $content String of characters to be converted.^M
90016 * @param string $deprecated Not used.^M
90017 * @return string Converted string.^M
90018 */^M
90019 function convert_chars($content, $deprecated = '') {^M
90020 // Translation of invalid Unicode references range to valid range^M
90021 $wp_htmltranswinuni = array(^M
90022 '€' => '€', // the Euro sign^M
90023 '' => '',^M
90024 '‚' => '‚', // these are Windows CP1252 specific characters^M
90025 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers^M
90026 '„' => '„',^M
90027 '…' => '…',^M
90028 '†' => '†',^M
90029 '‡' => '‡',^M
90030 'ˆ' => 'ˆ',^M
90031 '‰' => '‰',^M
90032 'Š' => 'Š',^M
90033 '‹' => '‹',^M
90034 'Œ' => 'Œ',^M
90035 '' => '',^M
90036 'Ž' => 'ž',^M
90037 '' => '',^M
90038 '' => '',^M
90039 '‘' => '‘',^M
90040 '’' => '’',^M
90041 '“' => '“',^M
90042 '”' => '”',^M
90043 '•' => '•',^M
90044 '–' => '–',^M
90045 '—' => '—',^M
90046 '˜' => '˜',^M
90047 '™' => '™',^M
90048 'š' => 'š',^M
90049 '›' => '›',^M
90050 'œ' => 'œ',^M
90051 '' => '',^M
90052 'ž' => '',^M
90053 'Ÿ' => 'Ÿ'^M
90054 );^M
90055 ^M
90056 // Remove metadata tags^M
90057 $content = preg_replace('/<title>(.+?)<\/title>/','',$content);^M
90058 $content = preg_replace('/<category>(.+?)<\/category>/','',$content);^M
90059 ^M
90060 // Converts lone & characters into & (a.k.a. &)^M
90061 $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content);^M
90062 ^M
90063 // Fix Word pasting^M
90064 $content = strtr($content, $wp_htmltranswinuni);^M
90065 ^M
90066 // Just a little XHTML help^M
90067 $content = str_replace('<br>', '<br />', $content);^M
90068 $content = str_replace('<hr>', '<hr />', $content);^M
90069 ^M
90070 return $content;^M
90071 }^M
90072 ^M
90073 /**^M
90074 * Fixes javascript bugs in browsers.^M
90075 *^M
90076 * Converts unicode characters to HTML numbered entities.^M
90077 *^M
90078 * @since 1.5.0^M
90079 * @uses $is_macIE^M
90080 * @uses $is_winIE^M
90081 *^M
90082 * @param string $text Text to be made safe.^M
90083 * @return string Fixed text.^M
90084 */^M
90085 function funky_javascript_fix($text) {^M
90086 // Fixes for browsers' javascript bugs^M
90087 global $is_macIE, $is_winIE;^M
90088 ^M
90089 /** @todo use preg_replace_callback() instead */^M
90090 if ( $is_winIE || $is_macIE )^M
90091 $text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text);^M
90092 ^M
90093 return $text;^M
90094 }^M
90095 ^M
90096 /**^M
90097 * Will only balance the tags if forced to and the option is set to balance tags.^M
90098 *^M
90099 * The option 'use_balanceTags' is used for whether the tags will be balanced.^M
90100 * Both the $force parameter and 'use_balanceTags' option will have to be true^M
90101 * before the tags will be balanced.^M
90102 *^M
90103 * @since 0.71^M
90104 *^M
90105 * @param string $text Text to be balanced^M
90106 * @param bool $force Forces balancing, ignoring the value of the option. Default false.^M
90107 * @return string Balanced text^M
90108 */^M
90109 function balanceTags( $text, $force = false ) {^M
90110 if ( !$force && get_option('use_balanceTags') == 0 )^M
90111 return $text;^M
90112 return force_balance_tags( $text );^M
90113 }^M
90114 ^M
90115 /**^M
90116 * Balances tags of string using a modified stack.^M
90117 *^M
90118 * @since 2.0.4^M
90119 *^M
90120 * @author Leonard Lin <leonard@acm.org>^M
90121 * @license GPL v2.0^M
90122 * @copyright November 4, 2001^M
90123 * @version 1.1^M
90124 * @todo Make better - change loop condition to $text in 1.2^M
90125 * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004^M
90126 * 1.1 Fixed handling of append/stack pop order of end text^M
90127 * Added Cleaning Hooks^M
90128 * 1.0 First Version^M
90129 *^M
90130 * @param string $text Text to be balanced.^M
90131 * @return string Balanced text.^M
90132 */^M
90133 function force_balance_tags( $text ) {^M
90134 $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';^M
90135 $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags^M
90136 $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves^M
90137 ^M
90138 # WP bug fix for comments - in case you REALLY meant to type '< !--'^M
90139 $text = str_replace('< !--', '< !--', $text);^M
90140 # WP bug fix for LOVE <3 (and other situations with '<' before a number)^M
90141 $text = preg_replace('#<([0-9]{1})#', '<$1', $text);^M
90142 ^M
90143 while (preg_match("/<(\/?\w*)\s*([^>]*)>/",$text,$regex)) {^M
90144 $newtext .= $tagqueue;^M
90145 ^M
90146 $i = strpos($text,$regex[0]);^M
90147 $l = strlen($regex[0]);^M
90148 ^M
90149 // clear the shifter^M
90150 $tagqueue = '';^M
90151 // Pop or Push^M
90152 if ($regex[1][0] == "/") { // End Tag^M
90153 $tag = strtolower(substr($regex[1],1));^M
90154 // if too many closing tags^M
90155 if($stacksize <= 0) {^M
90156 $tag = '';^M
90157 //or close to be safe $tag = '/' . $tag;^M
90158 }^M
90159 // if stacktop value = tag close value then pop^M
90160 else if ($tagstack[$stacksize - 1] == $tag) { // found closing tag^M
90161 $tag = '</' . $tag . '>'; // Close Tag^M
90162 // Pop^M
90163 array_pop ($tagstack);^M
90164 $stacksize--;^M
90165 } else { // closing tag not at top, search for it^M
90166 for ($j=$stacksize-1;$j>=0;$j--) {^M
90167 if ($tagstack[$j] == $tag) {^M
90168 // add tag to tagqueue^M
90169 for ($k=$stacksize-1;$k>=$j;$k--){^M
90170 $tagqueue .= '</' . array_pop ($tagstack) . '>';^M
90171 $stacksize--;^M
90172 }^M
90173 break;^M
90174 }^M
90175 }^M
90176 $tag = '';^M
90177 }^M
90178 } else { // Begin Tag^M
90179 $tag = strtolower($regex[1]);^M
90180 ^M
90181 // Tag Cleaning^M
90182 ^M
90183 // If self-closing or '', don't do anything.^M
90184 if((substr($regex[2],-1) == '/') || ($tag == '')) {^M
90185 }^M
90186 // ElseIf it's a known single-entity tag but it doesn't close itself, do so^M
90187 elseif ( in_array($tag, $single_tags) ) {^M
90188 $regex[2] .= '/';^M
90189 } else { // Push the tag onto the stack^M
90190 // If the top of the stack is the same as the tag we want to push, close previous tag^M
90191 if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) {^M
90192 $tagqueue = '</' . array_pop ($tagstack) . '>';^M
90193 $stacksize--;^M
90194 }^M
90195 $stacksize = array_push ($tagstack, $tag);^M
90196 }^M
90197 ^M
90198 // Attributes^M
90199 $attributes = $regex[2];^M
90200 if($attributes) {^M
90201 $attributes = ' '.$attributes;^M
90202 }^M
90203 $tag = '<'.$tag.$attributes.'>';^M
90204 //If already queuing a close tag, then put this tag on, too^M
90205 if ($tagqueue) {^M
90206 $tagqueue .= $tag;^M
90207 $tag = '';^M
90208 }^M
90209 }^M
90210 $newtext .= substr($text,0,$i) . $tag;^M
90211 $text = substr($text,$i+$l);^M
90212 }^M
90213 ^M
90214 // Clear Tag Queue^M
90215 $newtext .= $tagqueue;^M
90216 ^M
90217 // Add Remaining text^M
90218 $newtext .= $text;^M
90219 ^M
90220 // Empty Stack^M
90221 while($x = array_pop($tagstack)) {^M
90222 $newtext .= '</' . $x . '>'; // Add remaining tags to close^M
90223 }^M
90224 ^M
90225 // WP fix for the bug with HTML comments^M
90226 $newtext = str_replace("< !--","<!--",$newtext);^M
90227 $newtext = str_replace("< !--","< !--",$newtext);^M
90228 ^M
90229 return $newtext;^M
90230 }^M
90231 ^M
90232 /**^M
90233 * Acts on text which is about to be edited.^M
90234 *^M
90235 * Unless $richedit is set, it is simply a holder for the 'format_to_edit'^M
90236 * filter. If $richedit is set true htmlspecialchars() will be run on the^M
90237 * content, converting special characters to HTMl entities.^M
90238 *^M
90239 * @since 0.71^M
90240 *^M
90241 * @param string $content The text about to be edited.^M
90242 * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false.^M
90243 * @return string The text after the filter (and possibly htmlspecialchars()) has been run.^M
90244 */^M
90245 function format_to_edit($content, $richedit = false) {^M
90246 $content = apply_filters('format_to_edit', $content);^M
90247 if (! $richedit )^M
90248 $content = htmlspecialchars($content);^M
90249 return $content;^M
90250 }^M
90251 ^M
90252 /**^M
90253 * Holder for the 'format_to_post' filter.^M
90254 *^M
90255 * @since 0.71^M
90256 *^M
90257 * @param string $content The text to pass through the filter.^M
90258 * @return string Text returned from the 'format_to_post' filter.^M
90259 */^M
90260 function format_to_post($content) {^M
90261 $content = apply_filters('format_to_post', $content);^M
90262 return $content;^M
90263 }^M
90264 ^M
90265 /**^M
90266 * Add leading zeros when necessary.^M
90267 *^M
90268 * If you set the threshold to '4' and the number is '10', then you will get^M
90269 * back '0010'. If you set the number to '4' and the number is '5000', then you^M
90270 * will get back '5000'.^M
90271 *^M
90272 * Uses sprintf to append the amount of zeros based on the $threshold parameter^M
90273 * and the size of the number. If the number is large enough, then no zeros will^M
90274 * be appended.^M
90275 *^M
90276 * @since 0.71^M
90277 *^M
90278 * @param mixed $number Number to append zeros to if not greater than threshold.^M
90279 * @param int $threshold Digit places number needs to be to not have zeros added.^M
90280 * @return string Adds leading zeros to number if needed.^M
90281 */^M
90282 function zeroise($number, $threshold) {^M
90283 return sprintf('%0'.$threshold.'s', $number);^M
90284 }^M
90285 ^M
90286 /**^M
90287 * Adds backslashes before letters and before a number at the start of a string.^M
90288 *^M
90289 * @since 0.71^M
90290 *^M
90291 * @param string $string Value to which backslashes will be added.^M
90292 * @return string String with backslashes inserted.^M
90293 */^M
90294 function backslashit($string) {^M
90295 $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);^M
90296 $string = preg_replace('/([a-z])/i', '\\\\\1', $string);^M
90297 return $string;^M
90298 }^M
90299 ^M
90300 /**^M
90301 * Appends a trailing slash.^M
90302 *^M
90303 * Will remove trailing slash if it exists already before adding a trailing^M
90304 * slash. This prevents double slashing a string or path.^M
90305 *^M
90306 * The primary use of this is for paths and thus should be used for paths. It is^M
90307 * not restricted to paths and offers no specific path support.^M
90308 *^M
90309 * @since 1.2.0^M
90310 * @uses untrailingslashit() Unslashes string if it was slashed already.^M
90311 *^M
90312 * @param string $string What to add the trailing slash to.^M
90313 * @return string String with trailing slash added.^M
90314 */^M
90315 function trailingslashit($string) {^M
90316 return untrailingslashit($string) . '/';^M
90317 }^M
90318 ^M
90319 /**^M
90320 * Removes trailing slash if it exists.^M
90321 *^M
90322 * The primary use of this is for paths and thus should be used for paths. It is^M
90323 * not restricted to paths and offers no specific path support.^M
90324 *^M
90325 * @since 2.2.0^M
90326 *^M
90327 * @param string $string What to remove the trailing slash from.^M
90328 * @return string String without the trailing slash.^M
90329 */^M
90330 function untrailingslashit($string) {^M
90331 return rtrim($string, '/');^M
90332 }^M
90333 ^M
90334 /**^M
90335 * Adds slashes to escape strings.^M
90336 *^M
90337 * Slashes will first be removed if magic_quotes_gpc is set, see {@link^M
90338 * http://www.php.net/magic_quotes} for more details.^M
90339 *^M
90340 * @since 0.71^M
90341 *^M
90342 * @param string $gpc The string returned from HTTP request data.^M
90343 * @return string Returns a string escaped with slashes.^M
90344 */^M
90345 function addslashes_gpc($gpc) {^M
90346 global $wpdb;^M
90347 ^M
90348 if (get_magic_quotes_gpc()) {^M
90349 $gpc = stripslashes($gpc);^M
90350 }^M
90351 ^M
90352 return $wpdb->escape($gpc);^M
90353 }^M
90354 ^M
90355 /**^M
90356 * Navigates through an array and removes slashes from the values.^M
90357 *^M
90358 * If an array is passed, the array_map() function causes a callback to pass the^M
90359 * value back to the function. The slashes from this value will removed.^M
90360 *^M
90361 * @since 2.0.0^M
90362 *^M
90363 * @param array|string $value The array or string to be striped.^M
90364 * @return array|string Stripped array (or string in the callback).^M
90365 */^M
90366 function stripslashes_deep($value) {^M
90367 $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);^M
90368 return $value;^M
90369 }^M
90370 ^M
90371 /**^M
90372 * Navigates through an array and encodes the values to be used in a URL.^M
90373 *^M
90374 * Uses a callback to pass the value of the array back to the function as a^M
90375 * string.^M
90376 *^M
90377 * @since 2.2.0^M
90378 *^M
90379 * @param array|string $value The array or string to be encoded.^M
90380 * @return array|string $value The encoded array (or string from the callback).^M
90381 */^M
90382 function urlencode_deep($value) {^M
90383 $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);^M
90384 return $value;^M
90385 }^M
90386 ^M
90387 /**^M
90388 * Converts email addresses characters to HTML entities to block spam bots.^M
90389 *^M
90390 * @since 0.71^M
90391 *^M
90392 * @param string $emailaddy Email address.^M
90393 * @param int $mailto Optional. Range from 0 to 1. Used for encoding.^M
90394 * @return string Converted email address.^M
90395 */^M
90396 function antispambot($emailaddy, $mailto=0) {^M
90397 $emailNOSPAMaddy = '';^M
90398 srand ((float) microtime() * 1000000);^M
90399 for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {^M
90400 $j = floor(rand(0, 1+$mailto));^M
90401 if ($j==0) {^M
90402 $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';^M
90403 } elseif ($j==1) {^M
90404 $emailNOSPAMaddy .= substr($emailaddy,$i,1);^M
90405 } elseif ($j==2) {^M
90406 $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);^M
90407 }^M
90408 }^M
90409 $emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);^M
90410 return $emailNOSPAMaddy;^M
90411 }^M
90412 ^M
90413 /**^M
90414 * Callback to convert URI match to HTML A element.^M
90415 *^M
90416 * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link^M
90417 * make_clickable()}.^M
90418 *^M
90419 * @since 2.3.2^M
90420 * @access private^M
90421 *^M
90422 * @param array $matches Single Regex Match.^M
90423 * @return string HTML A element with URI address.^M
90424 */^M
90425 function _make_url_clickable_cb($matches) {^M
90426 $ret = '';^M
90427 $url = $matches[2];^M
90428 $url = clean_url($url);^M
90429 if ( empty($url) )^M
90430 return $matches[0];^M
90431 // removed trailing [.,;:] from URL^M
90432 if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) {^M
90433 $ret = substr($url, -1);^M
90434 $url = substr($url, 0, strlen($url)-1);^M
90435 }^M
90436 return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret;^M
90437 }^M
90438 ^M
90439 /**^M
90440 * Callback to convert URL match to HTML A element.^M
90441 *^M
90442 * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link^M
90443 * make_clickable()}.^M
90444 *^M
90445 * @since 2.3.2^M
90446 * @access private^M
90447 *^M
90448 * @param array $matches Single Regex Match.^M
90449 * @return string HTML A element with URL address.^M
90450 */^M
90451 function _make_web_ftp_clickable_cb($matches) {^M
90452 $ret = '';^M
90453 $dest = $matches[2];^M
90454 $dest = 'http://' . $dest;^M
90455 $dest = clean_url($dest);^M
90456 if ( empty($dest) )^M
90457 return $matches[0];^M
90458 // removed trailing [,;:] from URL^M
90459 if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) {^M
90460 $ret = substr($dest, -1);^M
90461 $dest = substr($dest, 0, strlen($dest)-1);^M
90462 }^M
90463 return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>" . $ret;^M
90464 }^M
90465 ^M
90466 /**^M
90467 * Callback to convert email address match to HTML A element.^M
90468 *^M
90469 * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link^M
90470 * make_clickable()}.^M
90471 *^M
90472 * @since 2.3.2^M
90473 * @access private^M
90474 *^M
90475 * @param array $matches Single Regex Match.^M
90476 * @return string HTML A element with email address.^M
90477 */^M
90478 function _make_email_clickable_cb($matches) {^M
90479 $email = $matches[2] . '@' . $matches[3];^M
90480 return $matches[1] . "<a href=\"mailto:$email\">$email</a>";^M
90481 }^M
90482 ^M
90483 /**^M
90484 * Convert plaintext URI to HTML links.^M
90485 *^M
90486 * Converts URI, www and ftp, and email addresses. Finishes by fixing links^M
90487 * within links.^M
90488 *^M
90489 * @since 0.71^M
90490 *^M
90491 * @param string $ret Content to convert URIs.^M
90492 * @return string Content with converted URIs.^M
90493 */^M
90494 function make_clickable($ret) {^M
90495 $ret = ' ' . $ret;^M
90496 // in testing, using arrays here was found to be faster^M
90497 $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret);^M
90498 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret);^M
90499 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);^M
90500 // this one is not in an array because we need it to run last, for cleanup of accidental links within links^M
90501 $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);^M
90502 $ret = trim($ret);^M
90503 return $ret;^M
90504 }^M
90505 ^M
90506 /**^M
90507 * Adds rel nofollow string to all HTML A elements in content.^M
90508 *^M
90509 * @since 1.5.0^M
90510 *^M
90511 * @param string $text Content that may contain HTML A elements.^M
90512 * @return string Converted content.^M
90513 */^M
90514 function wp_rel_nofollow( $text ) {^M
90515 global $wpdb;^M
90516 // This is a pre save filter, so text is already escaped.^M
90517 $text = stripslashes($text);^M
90518 $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);^M
90519 $text = $wpdb->escape($text);^M
90520 return $text;^M
90521 }^M
90522 ^M
90523 /**^M
90524 * Callback to used to add rel=nofollow string to HTML A element.^M
90525 *^M
90526 * Will remove already existing rel="nofollow" and rel='nofollow' from the^M
90527 * string to prevent from invalidating (X)HTML.^M
90528 *^M
90529 * @since 2.3.0^M
90530 *^M
90531 * @param array $matches Single Match^M
90532 * @return string HTML A Element with rel nofollow.^M
90533 */^M
90534 function wp_rel_nofollow_callback( $matches ) {^M
90535 $text = $matches[1];^M
90536 $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);^M
90537 return "<a $text rel=\"nofollow\">";^M
90538 }^M
90539 ^M
90540 /**^M
90541 * Convert text equivalent of smilies to images.^M
90542 *^M
90543 * Will only convert smilies if the option 'use_smilies' is true and the globals^M
90544 * used in the function aren't empty.^M
90545 *^M
90546 * @since 0.71^M
90547 * @uses $wp_smiliessearch, $wp_smiliesreplace Smiley replacement arrays.^M
90548 *^M
90549 * @param string $text Content to convert smilies from text.^M
90550 * @return string Converted content with text smilies replaced with images.^M
90551 */^M
90552 function convert_smilies($text) {^M
90553 global $wp_smiliessearch, $wp_smiliesreplace;^M
90554 $output = '';^M
90555 if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) {^M
90556 // HTML loop taken from texturize function, could possible be consolidated^M
90557 $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between^M
90558 $stop = count($textarr);// loop stuff^M
90559 for ($i = 0; $i < $stop; $i++) {^M
90560 $content = $textarr[$i];^M
90561 if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag^M
90562 $content = preg_replace($wp_smiliessearch, $wp_smiliesreplace, $content);^M
90563 }^M
90564 $output .= $content;^M
90565 }^M
90566 } else {^M
90567 // return default text.^M
90568 $output = $text;^M
90569 }^M
90570 return $output;^M
90571 }^M
90572 ^M
90573 /**^M
90574 * Checks to see if the text is a valid email address.^M
90575 *^M
90576 * @since 0.71^M
90577 *^M
90578 * @param string $user_email The email address to be checked.^M
90579 * @return bool Returns true if valid, otherwise false.^M
90580 */^M
90581 function is_email($user_email) {^M
90582 $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";^M
90583 if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) {^M
90584 if (preg_match($chars, $user_email)) {^M
90585 return true;^M
90586 } else {^M
90587 return false;^M
90588 }^M
90589 } else {^M
90590 return false;^M
90591 }^M
90592 }^M
90593 ^M
90594 /**^M
90595 * Convert to ASCII from email subjects.^M
90596 *^M
90597 * @since 1.2.0^M
90598 * @usedby wp_mail() handles charsets in email subjects^M
90599 *^M
90600 * @param string $string Subject line^M
90601 * @return string Converted string to ASCII^M
90602 */^M
90603 function wp_iso_descrambler($string) {^M
90604 /* this may only work with iso-8859-1, I'm afraid */^M
90605 if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {^M
90606 return $string;^M
90607 } else {^M
90608 $subject = str_replace('_', ' ', $matches[2]);^M
90609 /** @todo use preg_replace_callback() */^M
90610 $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);^M
90611 return $subject;^M
90612 }^M
90613 }^M
90614 ^M
90615 /**^M
90616 * Returns a date in the GMT equivalent.^M
90617 *^M
90618 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the^M
90619 * value of gmt_offset.^M
90620 *^M
90621 * @since 1.2.0^M
90622 *^M
90623 * @param string $string The date to be converted.^M
90624 * @return string GMT version of the date provided.^M
90625 */^M
90626 function get_gmt_from_date($string) {^M
90627 preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);^M
90628 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);^M
90629 $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);^M
90630 return $string_gmt;^M
90631 }^M
90632 ^M
90633 /**^M
90634 * Converts a GMT date into the correct format for the blog.^M
90635 *^M
90636 * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of^M
90637 * gmt_offset.^M
90638 *^M
90639 * @since 1.2.0^M
90640 *^M
90641 * @param string $string The date to be converted.^M
90642 * @return string Formatted date relative to the GMT offset.^M
90643 */^M
90644 function get_date_from_gmt($string) {^M
90645 preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);^M
90646 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);^M
90647 $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);^M
90648 return $string_localtime;^M
90649 }^M
90650 ^M
90651 /**^M
90652 * Computes an offset in seconds from an iso8601 timezone.^M
90653 *^M
90654 * @since 1.5.0^M
90655 *^M
90656 * @param string $timezone Either 'Z' for 0 offset or 'hhmm'.^M
90657 * @return int|float The offset in seconds.^M
90658 */^M
90659 function iso8601_timezone_to_offset($timezone) {^M
90660 // $timezone is either 'Z' or '[+|-]hhmm'^M
90661 if ($timezone == 'Z') {^M
90662 $offset = 0;^M
90663 } else {^M
90664 $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;^M
90665 $hours = intval(substr($timezone, 1, 2));^M
90666 $minutes = intval(substr($timezone, 3, 4)) / 60;^M
90667 $offset = $sign * 3600 * ($hours + $minutes);^M
90668 }^M
90669 return $offset;^M
90670 }^M
90671 ^M
90672 /**^M
90673 * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].^M
90674 *^M
90675 * @since 1.5.0^M
90676 *^M
90677 * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.^M
90678 * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.^M
90679 * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.^M
90680 */^M
90681 function iso8601_to_datetime($date_string, $timezone = 'user') {^M
90682 $timezone = strtolower($timezone);^M
90683 ^M
90684 if ($timezone == 'gmt') {^M
90685 ^M
90686 preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);^M
90687 ^M
90688 if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset^M
90689 $offset = iso8601_timezone_to_offset($date_bits[7]);^M
90690 } else { // we don't have a timezone, so we assume user local timezone (not server's!)^M
90691 $offset = 3600 * get_option('gmt_offset');^M
90692 }^M
90693 ^M
90694 $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);^M
90695 $timestamp -= $offset;^M
90696 ^M
90697 return gmdate('Y-m-d H:i:s', $timestamp);^M
90698 ^M
90699 } else if ($timezone == 'user') {^M
90700 return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);^M
90701 }^M
90702 }^M
90703 ^M
90704 /**^M
90705 * Adds a element attributes to open links in new windows.^M
90706 *^M
90707 * Comment text in popup windows should be filtered through this. Right now it's^M
90708 * a moderately dumb function, ideally it would detect whether a target or rel^M
90709 * attribute was already there and adjust its actions accordingly.^M
90710 *^M
90711 * @since 0.71^M
90712 *^M
90713 * @param string $text Content to replace links to open in a new window.^M
90714 * @return string Content that has filtered links.^M
90715 */^M
90716 function popuplinks($text) {^M
90717 $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);^M
90718 return $text;^M
90719 }^M
90720 ^M
90721 /**^M
90722 * Strips out all characters that are not allowable in an email.^M
90723 *^M
90724 * @since 1.5.0^M
90725 *^M
90726 * @param string $email Email address to filter.^M
90727 * @return string Filtered email address.^M
90728 */^M
90729 function sanitize_email($email) {^M
90730 return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);^M
90731 }^M
90732 ^M
90733 /**^M
90734 * Determines the difference between two timestamps.^M
90735 *^M
90736 * The difference is returned in a human readable format such as "1 hour",^M
90737 * "5 mins", "2 days".^M
90738 *^M
90739 * @since 1.5.0^M
90740 *^M
90741 * @param int $from Unix timestamp from which the difference begins.^M
90742 * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.^M
90743 * @return string Human readable time difference.^M
90744 */^M
90745 function human_time_diff( $from, $to = '' ) {^M
90746 if ( empty($to) )^M
90747 $to = time();^M
90748 $diff = (int) abs($to - $from);^M
90749 if ($diff <= 3600) {^M
90750 $mins = round($diff / 60);^M
90751 if ($mins <= 1) {^M
90752 $mins = 1;^M
90753 }^M
90754 $since = sprintf(__ngettext('%s min', '%s mins', $mins), $mins);^M
90755 } else if (($diff <= 86400) && ($diff > 3600)) {^M
90756 $hours = round($diff / 3600);^M
90757 if ($hours <= 1) {^M
90758 $hours = 1;^M
90759 }^M
90760 $since = sprintf(__ngettext('%s hour', '%s hours', $hours), $hours);^M
90761 } elseif ($diff >= 86400) {^M
90762 $days = round($diff / 86400);^M
90763 if ($days <= 1) {^M
90764 $days = 1;^M
90765 }^M
90766 $since = sprintf(__ngettext('%s day', '%s days', $days), $days);^M
90767 }^M
90768 return $since;^M
90769 }^M
90770 ^M
90771 /**^M
90772 * Generates an excerpt from the content, if needed.^M
90773 *^M
90774 * The excerpt word amount will be 55 words and if the amount is greater than^M
90775 * that, then the string '[...]' will be appended to the excerpt. If the string^M
90776 * is less than 55 words, then the content will be returned as is.^M
90777 *^M
90778 * @since 1.5.0^M
90779 *^M
90780 * @param string $text The exerpt. If set to empty an excerpt is generated.^M
90781 * @return string The excerpt.^M
90782 */^M
90783 function wp_trim_excerpt($text) {^M
90784 if ( '' == $text ) {^M
90785 $text = get_the_content('');^M
90786 ^M
90787 $text = strip_shortcodes( $text );^M
90788 ^M
90789 $text = apply_filters('the_content', $text);^M
90790 $text = str_replace(']]>', ']]>', $text);^M
90791 $text = strip_tags($text);^M
90792 $excerpt_length = apply_filters('excerpt_length', 55);^M
90793 $words = explode(' ', $text, $excerpt_length + 1);^M
90794 if (count($words) > $excerpt_length) {^M
90795 array_pop($words);^M
90796 array_push($words, '[...]');^M
90797 $text = implode(' ', $words);^M
90798 }^M
90799 }^M
90800 return $text;^M
90801 }^M
90802 ^M
90803 /**^M
90804 * Converts named entities into numbered entities.^M
90805 *^M
90806 * @since 1.5.1^M
90807 *^M
90808 * @param string $text The text within which entities will be converted.^M
90809 * @return string Text with converted entities.^M
90810 */^M
90811 function ent2ncr($text) {^M
90812 $to_ncr = array(^M
90813 '"' => '"',^M
90814 '&' => '&',^M
90815 '⁄' => '/',^M
90816 '<' => '<',^M
90817 '>' => '>',^M
90818 '|' => '|',^M
90819 ' ' => ' ',^M
90820 '¡' => '¡',^M
90821 '¢' => '¢',^M
90822 '£' => '£',^M
90823 '¤' => '¤',^M
90824 '¥' => '¥',^M
90825 '¦' => '¦',^M
90826 '&brkbar;' => '¦',^M
90827 '§' => '§',^M
90828 '¨' => '¨',^M
90829 '¨' => '¨',^M
90830 '©' => '©',^M
90831 'ª' => 'ª',^M
90832 '«' => '«',^M
90833 '¬' => '¬',^M
90834 '­' => '­',^M
90835 '®' => '®',^M
90836 '¯' => '¯',^M
90837 '&hibar;' => '¯',^M
90838 '°' => '°',^M
90839 '±' => '±',^M
90840 '²' => '²',^M
90841 '³' => '³',^M
90842 '´' => '´',^M
90843 'µ' => 'µ',^M
90844 '¶' => '¶',^M
90845 '·' => '·',^M
90846 '¸' => '¸',^M
90847 '¹' => '¹',^M
90848 'º' => 'º',^M
90849 '»' => '»',^M
90850 '¼' => '¼',^M
90851 '½' => '½',^M
90852 '¾' => '¾',^M
90853 '¿' => '¿',^M
90854 'À' => 'À',^M
90855 'Á' => 'Á',^M
90856 'Â' => 'Â',^M
90857 'Ã' => 'Ã',^M
90858 'Ä' => 'Ä',^M
90859 'Å' => 'Å',^M
90860 'Æ' => 'Æ',^M
90861 'Ç' => 'Ç',^M
90862 'È' => 'È',^M
90863 'É' => 'É',^M
90864 'Ê' => 'Ê',^M
90865 'Ë' => 'Ë',^M
90866 'Ì' => 'Ì',^M
90867 'Í' => 'Í',^M
90868 'Î' => 'Î',^M
90869 'Ï' => 'Ï',^M
90870 'Ð' => 'Ð',^M
90871 'Ñ' => 'Ñ',^M
90872 'Ò' => 'Ò',^M
90873 'Ó' => 'Ó',^M
90874 'Ô' => 'Ô',^M
90875 'Õ' => 'Õ',^M
90876 'Ö' => 'Ö',^M
90877 '×' => '×',^M
90878 'Ø' => 'Ø',^M
90879 'Ù' => 'Ù',^M
90880 'Ú' => 'Ú',^M
90881 'Û' => 'Û',^M
90882 'Ü' => 'Ü',^M
90883 'Ý' => 'Ý',^M
90884 'Þ' => 'Þ',^M
90885 'ß' => 'ß',^M
90886 'à' => 'à',^M
90887 'á' => 'á',^M
90888 'â' => 'â',^M
90889 'ã' => 'ã',^M
90890 'ä' => 'ä',^M
90891 'å' => 'å',^M
90892 'æ' => 'æ',^M
90893 'ç' => 'ç',^M
90894 'è' => 'è',^M
90895 'é' => 'é',^M
90896 'ê' => 'ê',^M
90897 'ë' => 'ë',^M
90898 'ì' => 'ì',^M
90899 'í' => 'í',^M
90900 'î' => 'î',^M
90901 'ï' => 'ï',^M
90902 'ð' => 'ð',^M
90903 'ñ' => 'ñ',^M
90904 'ò' => 'ò',^M
90905 'ó' => 'ó',^M
90906 'ô' => 'ô',^M
90907 'õ' => 'õ',^M
90908 'ö' => 'ö',^M
90909 '÷' => '÷',^M
90910 'ø' => 'ø',^M
90911 'ù' => 'ù',^M
90912 'ú' => 'ú',^M
90913 'û' => 'û',^M
90914 'ü' => 'ü',^M
90915 'ý' => 'ý',^M
90916 'þ' => 'þ',^M
90917 'ÿ' => 'ÿ',^M
90918 'Œ' => 'Œ',^M
90919 'œ' => 'œ',^M
90920 'Š' => 'Š',^M
90921 'š' => 'š',^M
90922 'Ÿ' => 'Ÿ',^M
90923 'ƒ' => 'ƒ',^M
90924 'ˆ' => 'ˆ',^M
90925 '˜' => '˜',^M
90926 'Α' => 'Α',^M
90927 'Β' => 'Β',^M
90928 'Γ' => 'Γ',^M
90929 'Δ' => 'Δ',^M
90930 'Ε' => 'Ε',^M
90931 'Ζ' => 'Ζ',^M
90932 'Η' => 'Η',^M
90933 'Θ' => 'Θ',^M
90934 'Ι' => 'Ι',^M
90935 'Κ' => 'Κ',^M
90936 'Λ' => 'Λ',^M
90937 'Μ' => 'Μ',^M
90938 'Ν' => 'Ν',^M
90939 'Ξ' => 'Ξ',^M
90940 'Ο' => 'Ο',^M
90941 'Π' => 'Π',^M
90942 'Ρ' => 'Ρ',^M
90943 'Σ' => 'Σ',^M
90944 'Τ' => 'Τ',^M
90945 'Υ' => 'Υ',^M
90946 'Φ' => 'Φ',^M
90947 'Χ' => 'Χ',^M
90948 'Ψ' => 'Ψ',^M
90949 'Ω' => 'Ω',^M
90950 'α' => 'α',^M
90951 'β' => 'β',^M
90952 'γ' => 'γ',^M
90953 'δ' => 'δ',^M
90954 'ε' => 'ε',^M
90955 'ζ' => 'ζ',^M
90956 'η' => 'η',^M
90957 'θ' => 'θ',^M
90958 'ι' => 'ι',^M
90959 'κ' => 'κ',^M
90960 'λ' => 'λ',^M
90961 'μ' => 'μ',^M
90962 'ν' => 'ν',^M
90963 'ξ' => 'ξ',^M
90964 'ο' => 'ο',^M
90965 'π' => 'π',^M
90966 'ρ' => 'ρ',^M
90967 'ς' => 'ς',^M
90968 'σ' => 'σ',^M
90969 'τ' => 'τ',^M
90970 'υ' => 'υ',^M
90971 'φ' => 'φ',^M
90972 'χ' => 'χ',^M
90973 'ψ' => 'ψ',^M
90974 'ω' => 'ω',^M
90975 'ϑ' => 'ϑ',^M
90976 'ϒ' => 'ϒ',^M
90977 'ϖ' => 'ϖ',^M
90978 ' ' => ' ',^M
90979 ' ' => ' ',^M
90980 ' ' => ' ',^M
90981 '‌' => '‌',^M
90982 '‍' => '‍',^M
90983 '‎' => '‎',^M
90984 '‏' => '‏',^M
90985 '–' => '–',^M
90986 '—' => '—',^M
90987 '‘' => '‘',^M
90988 '’' => '’',^M
90989 '‚' => '‚',^M
90990 '“' => '“',^M
90991 '”' => '”',^M
90992 '„' => '„',^M
90993 '†' => '†',^M
90994 '‡' => '‡',^M
90995 '•' => '•',^M
90996 '…' => '…',^M
90997 '‰' => '‰',^M
90998 '′' => '′',^M
90999 '″' => '″',^M
91000 '‹' => '‹',^M
91001 '›' => '›',^M
91002 '‾' => '‾',^M
91003 '⁄' => '⁄',^M
91004 '€' => '€',^M
91005 'ℑ' => 'ℑ',^M
91006 '℘' => '℘',^M
91007 'ℜ' => 'ℜ',^M
91008 '™' => '™',^M
91009 'ℵ' => 'ℵ',^M
91010 '↵' => '↵',^M
91011 '⇐' => '⇐',^M
91012 '⇑' => '⇑',^M
91013 '⇒' => '⇒',^M
91014 '⇓' => '⇓',^M
91015 '⇔' => '⇔',^M
91016 '∀' => '∀',^M
91017 '∂' => '∂',^M
91018 '∃' => '∃',^M
91019 '∅' => '∅',^M
91020 '∇' => '∇',^M
91021 '∈' => '∈',^M
91022 '∉' => '∉',^M
91023 '∋' => '∋',^M
91024 '∏' => '∏',^M
91025 '∑' => '∑',^M
91026 '−' => '−',^M
91027 '∗' => '∗',^M
91028 '√' => '√',^M
91029 '∝' => '∝',^M
91030 '∞' => '∞',^M
91031 '∠' => '∠',^M
91032 '∧' => '∧',^M
91033 '∨' => '∨',^M
91034 '∩' => '∩',^M
91035 '∪' => '∪',^M
91036 '∫' => '∫',^M
91037 '∴' => '∴',^M
91038 '∼' => '∼',^M
91039 '≅' => '≅',^M
91040 '≈' => '≈',^M
91041 '≠' => '≠',^M
91042 '≡' => '≡',^M
91043 '≤' => '≤',^M
91044 '≥' => '≥',^M
91045 '⊂' => '⊂',^M
91046 '⊃' => '⊃',^M
91047 '⊄' => '⊄',^M
91048 '⊆' => '⊆',^M
91049 '⊇' => '⊇',^M
91050 '⊕' => '⊕',^M
91051 '⊗' => '⊗',^M
91052 '⊥' => '⊥',^M
91053 '⋅' => '⋅',^M
91054 '⌈' => '⌈',^M
91055 '⌉' => '⌉',^M
91056 '⌊' => '⌊',^M
91057 '⌋' => '⌋',^M
91058 '⟨' => '〈',^M
91059 '⟩' => '〉',^M
91060 '←' => '←',^M
91061 '↑' => '↑',^M
91062 '→' => '→',^M
91063 '↓' => '↓',^M
91064 '↔' => '↔',^M
91065 '◊' => '◊',^M
91066 '♠' => '♠',^M
91067 '♣' => '♣',^M
91068 '♥' => '♥',^M
91069 '♦' => '♦'^M
91070 );^M
91071 ^M
91072 return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );^M
91073 }^M
91074 ^M
91075 /**^M
91076 * Formats text for the rich text editor.^M
91077 *^M
91078 * The filter 'richedit_pre' is applied here. If $text is empty the filter will^M
91079 * be applied to an empty string.^M
91080 *^M
91081 * @since 2.0.0^M
91082 *^M
91083 * @param string $text The text to be formatted.^M
91084 * @return string The formatted text after filter is applied.^M
91085 */^M
91086 function wp_richedit_pre($text) {^M
91087 // Filtering a blank results in an annoying <br />\n^M
91088 if ( empty($text) ) return apply_filters('richedit_pre', '');^M
91089 ^M
91090 $output = convert_chars($text);^M
91091 $output = wpautop($output);^M
91092 $output = htmlspecialchars($output, ENT_NOQUOTES);^M
91093 ^M
91094 return apply_filters('richedit_pre', $output);^M
91095 }^M
91096 ^M
91097 /**^M
91098 * Formats text for the HTML editor.^M
91099 *^M
91100 * Unless $output is empty it will pass through htmlspecialchars before the^M
91101 * 'htmledit_pre' filter is applied.^M
91102 *^M
91103 * @since 2.5.0^M
91104 *^M
91105 * @param string $output The text to be formatted.^M
91106 * @return string Formatted text after filter applied.^M
91107 */^M
91108 function wp_htmledit_pre($output) {^M
91109 if ( !empty($output) )^M
91110 $output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > &^M
91111 ^M
91112 return apply_filters('htmledit_pre', $output);^M
91113 }^M
91114 ^M
91115 /**^M
91116 * Checks and cleans a URL.^M
91117 *^M
91118 * A number of characters are removed from the URL. If the URL is for displaying^M
91119 * (the default behaviour) amperstands are also replaced. The 'clean_url' filter^M
91120 * is applied to the returned cleaned URL.^M
91121 *^M
91122 * @since 1.2.0^M
91123 * @uses wp_kses_bad_protocol() To only permit protocols in the URL set^M
91124 * via $protocols or the common ones set in the function.^M
91125 *^M
91126 * @param string $url The URL to be cleaned.^M
91127 * @param array $protocols Optional. An array of acceptable protocols.^M
91128 * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.^M
91129 * @param string $context Optional. How the URL will be used. Default is 'display'.^M
91130 * @return string The cleaned $url after the 'cleaned_url' filter is applied.^M
91131 */^M
91132 function clean_url( $url, $protocols = null, $context = 'display' ) {^M
91133 $original_url = $url;^M
91134 ^M
91135 if ('' == $url) return $url;^M
91136 $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$*\'()\\x80-\\xff]|i', '', $url);^M
91137 $strip = array('%0d', '%0a');^M
91138 $url = str_replace($strip, '', $url);^M
91139 $url = str_replace(';//', '://', $url);^M
91140 /* If the URL doesn't appear to contain a scheme, we^M
91141 * presume it needs http:// appended (unless a relative^M
91142 * link starting with / or a php file).^M
91143 */^M
91144 if ( strpos($url, ':') === false &&^M
91145 substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )^M
91146 $url = 'http://' . $url;^M
91147 ^M
91148 // Replace ampersands and single quotes only when displaying.^M
91149 if ( 'display' == $context ) {^M
91150 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);^M
91151 $url = str_replace( "'", ''', $url );^M
91152 }^M
91153 ^M
91154 if ( !is_array($protocols) )^M
91155 $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');^M
91156 if ( wp_kses_bad_protocol( $url, $protocols ) != $url )^M
91157 return '';^M
91158 ^M
91159 return apply_filters('clean_url', $url, $original_url, $context);^M
91160 }^M
91161 ^M
91162 /**^M
91163 * Performs clean_url() for database usage.^M
91164 *^M
91165 * @see clean_url()^M
91166 *^M
91167 * @since 2.3.1^M
91168 *^M
91169 * @param string $url The URL to be cleaned.^M
91170 * @param array $protocols An array of acceptable protocols.^M
91171 * @return string The cleaned URL.^M
91172 */^M
91173 function sanitize_url( $url, $protocols = null ) {^M
91174 return clean_url( $url, $protocols, 'db' );^M
91175 }^M
91176 ^M
91177 /**^M
91178 * Convert entities, while preserving already-encoded entities.^M
91179 *^M
91180 * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.^M
91181 *^M
91182 * @since 1.2.2^M
91183 *^M
91184 * @param string $myHTML The text to be converted.^M
91185 * @return string Converted text.^M
91186 */^M
91187 function htmlentities2($myHTML) {^M
91188 $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );^M
91189 $translation_table[chr(38)] = '&';^M
91190 return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table) );^M
91191 }^M
91192 ^M
91193 /**^M
91194 * Escape single quotes, specialchar double quotes, and fix line endings.^M
91195 *^M
91196 * The filter 'js_escape' is also applied here.^M
91197 *^M
91198 * @since 2.0.4^M
91199 *^M
91200 * @param string $text The text to be escaped.^M
91201 * @return string Escaped text.^M
91202 */^M
91203 function js_escape($text) {^M
91204 $safe_text = wp_specialchars($text, 'double');^M
91205 $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));^M
91206 $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));^M
91207 return apply_filters('js_escape', $safe_text, $text);^M
91208 }^M
91209 ^M
91210 /**^M
91211 * Escaping for HTML attributes.^M
91212 *^M
91213 * @since 2.0.6^M
91214 *^M
91215 * @param string $text^M
91216 * @return string^M
91217 */^M
91218 function attribute_escape($text) {^M
91219 $safe_text = wp_specialchars($text, true);^M
91220 return apply_filters('attribute_escape', $safe_text, $text);^M
91221 }^M
91222 ^M
91223 /**^M
91224 * Escape a HTML tag name.^M
91225 *^M
91226 * @since 2.5.0^M
91227 *^M
91228 * @param string $tag_name^M
91229 * @return string^M
91230 */^M
91231 function tag_escape($tag_name) {^M
91232 $safe_tag = strtolower( preg_replace('[^a-zA-Z_:]', '', $tag_name) );^M
91233 return apply_filters('tag_escape', $safe_tag, $tag_name);^M
91234 }^M
91235 ^M
91236 /**^M
91237 * Escapes text for SQL LIKE special characters % and _.^M
91238 *^M
91239 * @since 2.5.0^M
91240 *^M
91241 * @param string $text The text to be escaped.^M
91242 * @return string text, safe for inclusion in LIKE query.^M
91243 */^M
91244 function like_escape($text) {^M
91245 return str_replace(array("%", "_"), array("\\%", "\\_"), $text);^M
91246 }^M
91247 ^M
91248 /**^M
91249 * Convert full URL paths to absolute paths.^M
91250 *^M
91251 * Removes the http or https protocols and the domain. Keeps the path '/' at the^M
91252 * beginning, so it isn't a true relative link, but from the web root base.^M
91253 *^M
91254 * @since 2.1.0^M
91255 *^M
91256 * @param string $link Full URL path.^M
91257 * @return string Absolute path.^M
91258 */^M
91259 function wp_make_link_relative( $link ) {^M
91260 return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );^M
91261 }^M
91262 ^M
91263 /**^M
91264 * Sanitises various option values based on the nature of the option.^M
91265 *^M
91266 * This is basically a switch statement which will pass $value through a number^M
91267 * of functions depending on the $option.^M
91268 *^M
91269 * @since 2.0.5^M
91270 *^M
91271 * @param string $option The name of the option.^M
91272 * @param string $value The unsanitised value.^M
91273 * @return string Sanitized value.^M
91274 */^M
91275 function sanitize_option($option, $value) {^M
91276 ^M
91277 switch ($option) {^M
91278 case 'admin_email':^M
91279 $value = sanitize_email($value);^M
91280 break;^M
91281 ^M
91282 case 'thumbnail_size_w':^M
91283 case 'thumbnail_size_h':^M
91284 case 'medium_size_w':^M
91285 case 'medium_size_h':^M
91286 case 'large_size_w':^M
91287 case 'large_size_h':^M
91288 case 'default_post_edit_rows':^M
91289 case 'mailserver_port':^M
91290 case 'comment_max_links':^M
91291 case 'page_on_front':^M
91292 case 'rss_excerpt_length':^M
91293 case 'default_category':^M
91294 case 'default_email_category':^M
91295 case 'default_link_category':^M
91296 case 'close_comments_days_old':^M
91297 case 'comments_per_page':^M
91298 case 'thread_comments_depth':^M
91299 $value = abs((int) $value);^M
91300 break;^M
91301 ^M
91302 case 'posts_per_page':^M
91303 case 'posts_per_rss':^M
91304 $value = (int) $value;^M
91305 if ( empty($value) ) $value = 1;^M
91306 if ( $value < -1 ) $value = abs($value);^M
91307 break;^M
91308 ^M
91309 case 'default_ping_status':^M
91310 case 'default_comment_status':^M
91311 // Options that if not there have 0 value but need to be something like "closed"^M
91312 if ( $value == '0' || $value == '')^M
91313 $value = 'closed';^M
91314 break;^M
91315 ^M
91316 case 'blogdescription':^M
91317 case 'blogname':^M
91318 $value = addslashes($value);^M
91319 $value = wp_filter_post_kses( $value ); // calls stripslashes then addslashes^M
91320 $value = stripslashes($value);^M
91321 $value = wp_specialchars( $value );^M
91322 break;^M
91323 ^M
91324 case 'blog_charset':^M
91325 $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes^M
91326 break;^M
91327 ^M
91328 case 'date_format':^M
91329 case 'time_format':^M
91330 case 'mailserver_url':^M
91331 case 'mailserver_login':^M
91332 case 'mailserver_pass':^M
91333 case 'ping_sites':^M
91334 case 'upload_path':^M
91335 $value = strip_tags($value);^M
91336 $value = addslashes($value);^M
91337 $value = wp_filter_kses($value); // calls stripslashes then addslashes^M
91338 $value = stripslashes($value);^M
91339 break;^M
91340 ^M
91341 case 'gmt_offset':^M
91342 $value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes^M
91343 break;^M
91344 ^M
91345 case 'siteurl':^M
91346 case 'home':^M
91347 $value = stripslashes($value);^M
91348 $value = clean_url($value);^M
91349 break;^M
91350 default :^M
91351 $value = apply_filters("sanitize_option_{$option}", $value, $option);^M
91352 break;^M
91353 }^M
91354 ^M
91355 return $value;^M
91356 }^M
91357 ^M
91358 /**^M
91359 * Parses a string into variables to be stored in an array.^M
91360 *^M
91361 * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if^M
91362 * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.^M
91363 *^M
91364 * @since 2.2.1^M
91365 * @uses apply_filters() for the 'wp_parse_str' filter.^M
91366 *^M
91367 * @param string $string The string to be parsed.^M
91368 * @param array $array Variables will be stored in this array.^M
91369 */^M
91370 function wp_parse_str( $string, &$array ) {^M
91371 parse_str( $string, $array );^M
91372 if ( get_magic_quotes_gpc() )^M
91373 $array = stripslashes_deep( $array );^M
91374 $array = apply_filters( 'wp_parse_str', $array );^M
91375 }^M
91376 ^M
91377 /**^M
91378 * Convert lone less than signs.^M
91379 *^M
91380 * KSES already converts lone greater than signs.^M
91381 *^M
91382 * @uses wp_pre_kses_less_than_callback in the callback function.^M
91383 * @since 2.3.0^M
91384 *^M
91385 * @param string $text Text to be converted.^M
91386 * @return string Converted text.^M
91387 */^M
91388 function wp_pre_kses_less_than( $text ) {^M
91389 return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);^M
91390 }^M
91391 ^M
91392 /**^M
91393 * Callback function used by preg_replace.^M
91394 *^M
91395 * @uses wp_specialchars to format the $matches text.^M
91396 * @since 2.3.0^M
91397 *^M
91398 * @param array $matches Populated by matches to preg_replace.^M
91399 * @return string The text returned after wp_specialchars if needed.^M
91400 */^M
91401 function wp_pre_kses_less_than_callback( $matches ) {^M
91402 if ( false === strpos($matches[0], '>') )^M
91403 return wp_specialchars($matches[0]);^M
91404 return $matches[0];^M
91405 }^M
91406 ^M
91407 /**^M
91408 * WordPress implementation of PHP sprintf() with filters.^M
91409 *^M
91410 * @since 2.5.0^M
91411 * @link http://www.php.net/sprintf^M
91412 *^M
91413 * @param string $pattern The string which formatted args are inserted.^M
91414 * @param mixed $args,... Arguments to be formatted into the $pattern string.^M
91415 * @return string The formatted string.^M
91416 */^M
91417 function wp_sprintf( $pattern ) {^M
91418 $args = func_get_args( );^M
91419 $len = strlen($pattern);^M
91420 $start = 0;^M
91421 $result = '';^M
91422 $arg_index = 0;^M
91423 while ( $len > $start ) {^M
91424 // Last character: append and break^M
91425 if ( strlen($pattern) - 1 == $start ) {^M
91426 $result .= substr($pattern, -1);^M
91427 break;^M
91428 }^M
91429 ^M
91430 // Literal %: append and continue^M
91431 if ( substr($pattern, $start, 2) == '%%' ) {^M
91432 $start += 2;^M
91433 $result .= '%';^M
91434 continue;^M
91435 }^M
91436 ^M
91437 // Get fragment before next %^M
91438 $end = strpos($pattern, '%', $start + 1);^M
91439 if ( false === $end )^M
91440 $end = $len;^M
91441 $fragment = substr($pattern, $start, $end - $start);^M
91442 ^M
91443 // Fragment has a specifier^M
91444 if ( $pattern{$start} == '%' ) {^M
91445 // Find numbered arguments or take the next one in order^M
91446 if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) {^M
91447 $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : '';^M
91448 $fragment = str_replace("%{$matches[1]}$", '%', $fragment);^M
91449 } else {^M
91450 ++$arg_index;^M
91451 $arg = isset($args[$arg_index]) ? $args[$arg_index] : '';^M
91452 }^M
91453 ^M
91454 // Apply filters OR sprintf^M
91455 $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );^M
91456 if ( $_fragment != $fragment )^M
91457 $fragment = $_fragment;^M
91458 else^M
91459 $fragment = sprintf($fragment, strval($arg) );^M
91460 }^M
91461 ^M
91462 // Append to result and move to next fragment^M
91463 $result .= $fragment;^M
91464 $start = $end;^M
91465 }^M
91466 return $result;^M
91467 }^M
91468 ^M
91469 /**^M
91470 * Localize list items before the rest of the content.^M
91471 *^M
91472 * The '%l' must be at the first characters can then contain the rest of the^M
91473 * content. The list items will have ', ', ', and', and ' and ' added depending^M
91474 * on the amount of list items in the $args parameter.^M
91475 *^M
91476 * @since 2.5.0^M
91477 *^M
91478 * @param string $pattern Content containing '%l' at the beginning.^M
91479 * @param array $args List items to prepend to the content and replace '%l'.^M
91480 * @return string Localized list items and rest of the content.^M
91481 */^M
91482 function wp_sprintf_l($pattern, $args) {^M
91483 // Not a match^M
91484 if ( substr($pattern, 0, 2) != '%l' )^M
91485 return $pattern;^M
91486 ^M
91487 // Nothing to work with^M
91488 if ( empty($args) )^M
91489 return '';^M
91490 ^M
91491 // Translate and filter the delimiter set (avoid ampersands and entities here)^M
91492 $l = apply_filters('wp_sprintf_l', array(^M
91493 'between' => _c(', |between list items'),^M
91494 'between_last_two' => _c(', and |between last two list items'),^M
91495 'between_only_two' => _c(' and |between only two list items'),^M
91496 ));^M
91497 ^M
91498 $args = (array) $args;^M
91499 $result = array_shift($args);^M
91500 if ( count($args) == 1 )^M
91501 $result .= $l['between_only_two'] . array_shift($args);^M
91502 // Loop when more than two args^M
91503 $i = count($args);^M
91504 while ( $i ) {^M
91505 $arg = array_shift($args);^M
91506 $i--;^M
91507 if ( $i == 1 )^M
91508 $result .= $l['between_last_two'] . $arg;^M
91509 else^M
91510 $result .= $l['between'] . $arg;^M
91511 }^M
91512 return $result . substr($pattern, 2);^M
91513 }^M
91514 ^M
91515 /**^M
91516 * Safely extracts not more than the first $count characters from html string.^M
91517 *^M
91518 * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*^M
91519 * be counted as one character. For example & will be counted as 4, < as^M
91520 * 3, etc.^M
91521 *^M
91522 * @since 2.5.0^M
91523 *^M
91524 * @param integer $str String to get the excerpt from.^M
91525 * @param integer $count Maximum number of characters to take.^M
91526 * @return string The excerpt.^M
91527 */^M
91528 function wp_html_excerpt( $str, $count ) {^M
91529 $str = strip_tags( $str );^M
91530 $str = mb_strcut( $str, 0, $count );^M
91531 // remove part of an entity at the end^M
91532 $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str );^M
91533 return $str;^M
91534 }^M
91535 ^M
91536 /**^M
91537 * Add a Base url to relative links in passed content.^M
91538 *^M
91539 * By default it supports the 'src' and 'href' attributes. However this can be^M
91540 * changed via the 3rd param.^M
91541 *^M
91542 * @since 2.7.0^M
91543 *^M
91544 * @param string $content String to search for links in.^M
91545 * @param string $base The base URL to prefix to links.^M
91546 * @param array $attrs The attributes which should be processed.^M
91547 * @return string The processed content.^M
91548 */^M
91549 function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {^M
91550 $attrs = implode('|', (array)$attrs);^M
91551 return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i",^M
91552 create_function('$m', 'return _links_add_base($m, "' . $base . '");'),^M
91553 $content);^M
91554 }^M
91555 ^M
91556 /**^M
91557 * Callback to add a base url to relative links in passed content.^M
91558 *^M
91559 * @since 2.7.0^M
91560 * @access private^M
91561 *^M
91562 * @param string $m The matched link.^M
91563 * @param string $base The base URL to prefix to links.^M
91564 * @return string The processed link.^M
91565 */^M
91566 function _links_add_base($m, $base) {^M
91567 //1 = attribute name 2 = quotation mark 3 = URL^M
91568 return $m[1] . '=' . $m[2] .^M
91569 (strpos($m[3], 'http://') === false ?^M
91570 path_join($base, $m[3]) :^M
91571 $m[3])^M
91572 . $m[2];^M
91573 }^M
91574 ^M
91575 /**^M
91576 * Adds a Target attribute to all links in passed content.^M
91577 *^M
91578 * This function by default only applies to <a> tags, however this can be^M
91579 * modified by the 3rd param.^M
91580 *^M
91581 * <b>NOTE:</b> Any current target attributed will be striped and replaced.^M
91582 *^M
91583 * @since 2.7.0^M
91584 *^M
91585 * @param string $content String to search for links in.^M
91586 * @param string $target The Target to add to the links.^M
91587 * @param array $tags An array of tags to apply to.^M
91588 * @return string The processed content.^M
91589 */^M
91590 function links_add_target( $content, $target = '_blank', $tags = array('a') ) {^M
91591 $tags = implode('|', (array)$tags);^M
91592 return preg_replace_callback("!<($tags)(.+?)>!i",^M
91593 create_function('$m', 'return _links_add_target($m, "' . $target . '");'),^M
91594 $content);^M
91595 }^M
91596 /**^M
91597 * Callback to add a target attribute to all links in passed content.^M
91598 *^M
91599 * @since 2.7.0^M
91600 * @access private^M
91601 *^M
91602 * @param string $m The matched link.^M
91603 * @param string $target The Target to add to the links.^M
91604 * @return string The processed link.^M
91605 */^M
91606 function _links_add_target( $m, $target ) {^M
91607 $tag = $m[1];^M
91608 $link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]);^M
91609 return '<' . $tag . $link . ' target="' . $target . '">';^M
91610 }^M
91611 ^M
91612 // normalize EOL characters and strip duplicate whitespace^M
91613 function normalize_whitespace( $str ) {^M
91614 $str = trim($str);^M
91615 $str = str_replace("\r", "\n", $str);^M
91616 $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );^M
91617 return $str;^M
91618 }^M
91619 ^M
91620 ?>^M