Ticket #5638: 5638.r8780.diff
File 5638.r8780.diff, 20.0 KB (added by , 16 years ago) |
---|
-
formatting.php
51 51 $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); 52 52 53 53 for ( $i = 0; $i < $stop; $i++ ) { 54 54 $curl = $textarr[$i]; 55 55 56 56 if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag 57 57 // static strings … … 72 72 $output .= $curl; 73 73 } 74 74 75 75 return $output; 76 76 } 77 77 78 78 /** … … 105 105 * A group of regex replaces used to identify text formatted with newlines and 106 106 * replace double line-breaks with HTML paragraph tags. The remaining 107 107 * line-breaks after conversion become <<br />> tags, unless $br is set to '0' 108 * 108 * or 'false'. 109 109 * 110 110 * @since 0.71 111 111 * … … 154 154 /** 155 155 * Checks to see if a string is utf8 encoded. 156 156 * 157 * {@internal Missing Long Description}}158 *159 157 * @since 1.2.1 160 158 * 161 159 * @param string $Str The string to be checked … … 183 181 * Converts a number of special characters into their HTML entities. 184 182 * 185 183 * Differs from htmlspecialchars as existing HTML entities will not be encoded. 186 * Specific ically changes: & to &, < to < and > to >.184 * Specifically changes: & to &, < to < and > to >. 187 185 * 188 186 * $quotes can be set to 'single' to encode ' to ', 'double' to encode " to 189 187 * ", or '1' to do both. Default is 0 where no quotes are encoded. … … 267 265 /** 268 266 * Replaces accents in a string. 269 267 * 270 * {@internal Missing Long Description}}271 *272 268 * @since 1.2.1 273 269 * 274 270 * @param string $string The text to be filtered. … … 423 419 $name = preg_replace('|-+|', '-', $name); 424 420 $name = trim($name, '-'); 425 421 return $name; 426 427 422 } 428 423 429 424 /** 430 * Removes characters from the username.425 * Sanitize username stripping out unsafe characters. 431 426 * 432 427 * If $strict is true, only alphanumeric characters (as well as _, space, ., -, 433 428 * @) are returned. … … 456 451 } 457 452 458 453 /** 459 * Returns a string which has been sanitized.454 * Sanitizes title or use fallback title. 460 455 * 461 456 * Specifically, HTML and PHP tags are stripped. Further actions can be added 462 457 * via the plugin API. If $title is empty and $fallback_title is set, the latter … … 479 474 } 480 475 481 476 /** 482 * Replaces the string with safe characters. Whitespace becomes a dash.477 * Sanitizes title, replacing whitespace with dashes. 483 478 * 484 479 * Limits the output to alphanumeric characters, underscore (_) and dash (-). 480 * Whitespace becomes a dash. 485 481 * 486 482 * @since 1.2.0 487 483 * … … 603 599 /** 604 600 * Fixes javascript bugs in browsers. 605 601 * 606 * {@internal Missing Long Description}}602 * Converts unicode characters to HTML numbered entities. 607 603 * 608 604 * @since 1.5.0 609 605 * @uses $is_macIE … … 616 612 // Fixes for browsers' javascript bugs 617 613 global $is_macIE, $is_winIE; 618 614 615 /** @todo use preg_replace_callback() instead */ 619 616 if ( $is_winIE || $is_macIE ) 620 617 $text = preg_replace("/\%u([0-9A-F]{4,4})/e", "'&#'.base_convert('\\1',16,10).';'", $text); 621 618 … … 623 620 } 624 621 625 622 /** 626 * balanceTags() - {@internal Missing Short Description}}623 * Will only balance the tags if forced to and the option is set to balance tags. 627 624 * 628 * {@internal Missing Long Description}} 625 * The option 'use_balanceTags' is used for whether the tags will be balanced. 626 * Both the $force parameter and 'use_balanceTags' option will have to be true 627 * before the tags will be balanced. 629 628 * 630 629 * @since 0.71 631 630 * … … 796 795 /** 797 796 * Add leading zeros when necessary. 798 797 * 799 * {@internal Missing Long Description}} 798 * If you set the threshold to '4' and the number is '10', then you will get 799 * back '0010'. If you set the number to '4' and the number is '5000', then you 800 * will get back '5000'. 800 801 * 801 802 * @since 0.71 802 803 * … … 804 805 * @param int $threshold Amount of digits 805 806 * @return string Adds leading zeros to number if needed 806 807 */ 807 function zeroise($number, $threshold) {808 function zeroise($number, $threshold) { 808 809 return sprintf('%0'.$threshold.'s', $number); 809 810 } 810 811 811 812 /** 812 813 * Adds backslashes before letters and before a number at the start of a string. 813 814 * 814 * {@internal Missing Long Description}}815 *816 815 * @since 0.71 817 816 * 818 817 * @param string $string Value to which backslashes will be added. … … 861 860 /** 862 861 * Adds slashes to escape strings. 863 862 * 864 * Slashes will first be removed if magic_quotes_gpc is set, 865 * see {@link http://www.php.net/magic_quotes} for more details.863 * Slashes will first be removed if magic_quotes_gpc is set, see {@link 864 * http://www.php.net/magic_quotes} for more details. 866 865 * 867 866 * @since 0.71 868 867 * … … 882 881 /** 883 882 * Navigates through an array and removes slashes from the values. 884 883 * 885 * If an array is passed, the array_map() function causes a callback to 886 * pass the value back to the function. The slashes from this value will 887 * removed. 884 * If an array is passed, the array_map() function causes a callback to pass the 885 * value back to the function. The slashes from this value will removed. 888 886 * 889 887 * @since 2.0.0 890 888 * … … 892 890 * @return array|string Stripped array (or string in the callback). 893 891 */ 894 892 function stripslashes_deep($value) { 895 $value = is_array($value) ? 896 array_map('stripslashes_deep', $value) : 897 stripslashes($value); 898 899 return $value; 893 $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); 894 return $value; 900 895 } 901 896 902 897 /** … … 911 906 * @return array|string $value The encoded array (or string from the callback). 912 907 */ 913 908 function urlencode_deep($value) { 914 $value = is_array($value) ? 915 array_map('urlencode_deep', $value) : 916 urlencode($value); 917 918 return $value; 909 $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value); 910 return $value; 919 911 } 920 912 921 913 /** … … 947 939 } 948 940 949 941 /** 950 * _make_url_clickable_cb() - {@internal Missing Short Description}}942 * Callback to convert URI match to HTML A element. 951 943 * 952 * {@internal Missing Long Description}} 944 * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link 945 * make_clickable()}. 953 946 * 954 * @since 2. 5.0947 * @since 2.3.2 955 948 * @access private 956 949 * 957 * @param unknown_type $matches958 * @return unknown950 * @param array $matches Single Regex Match. 951 * @return string HTML A element with URI address. 959 952 */ 960 953 function _make_url_clickable_cb($matches) { 961 954 $ret = ''; … … 972 965 } 973 966 974 967 /** 975 * _make_web_ftp_clickable_cb() - {@internal Missing Short Description}}968 * Callback to convert URL match to HTML A element. 976 969 * 977 * {@internal Missing Long Description}} 970 * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link 971 * make_clickable()}. 978 972 * 979 * @since 2. 5.0973 * @since 2.3.2 980 974 * @access private 981 975 * 982 * @param unknown_type $matches983 * @return unknown976 * @param array $matches Single Regex Match. 977 * @return string HTML A element with URL address. 984 978 */ 985 979 function _make_web_ftp_clickable_cb($matches) { 986 980 $ret = ''; … … 998 992 } 999 993 1000 994 /** 1001 * _make_email_clickable_cb() - {@internal Missing Short Description}}995 * Callback to convert email address match to HTML A element. 1002 996 * 1003 * {@internal Missing Long Description}} 997 * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link 998 * make_clickable()}. 1004 999 * 1005 * @since 2. 5.01000 * @since 2.3.2 1006 1001 * @access private 1007 1002 * 1008 * @param unknown_type $matches1009 * @return unknown1003 * @param array $matches Single Regex Match. 1004 * @return string HTML A element with email address. 1010 1005 */ 1011 1006 function _make_email_clickable_cb($matches) { 1012 1007 $email = $matches[2] . '@' . $matches[3]; … … 1014 1009 } 1015 1010 1016 1011 /** 1017 * make_clickable() - {@internal Missing Short Description}}1012 * Convert plaintext URI to HTML links. 1018 1013 * 1019 * {@internal Missing Long Description}} 1014 * Converts URI, www and ftp, and email addresses. Finishes by fixing links 1015 * within links. 1020 1016 * 1021 1017 * @since 0.71 1022 1018 * 1023 * @param unknown_type $ret1024 * @return unknown1019 * @param string $ret Content to convert URIs. 1020 * @return string Content with converted URIs. 1025 1021 */ 1026 1022 function make_clickable($ret) { 1027 1023 $ret = ' ' . $ret; … … 1077 1073 * 1078 1074 * @since 0.71 1079 1075 * 1080 * @param unknown_type$text1081 * @return unknown1076 * @param string $text 1077 * @return string 1082 1078 */ 1083 1079 function convert_smilies($text) { 1084 1080 global $wp_smiliessearch, $wp_smiliesreplace; … … 1104 1100 /** 1105 1101 * Checks to see if the text is a valid email address. 1106 1102 * 1107 * {@internal Missing Long Description}}1108 *1109 1103 * @since 0.71 1110 1104 * 1111 1105 * @param string $user_email The email address to be checked. … … 1149 1143 /** 1150 1144 * Returns a date in the GMT equivalent. 1151 1145 * 1152 * Requires and returns a date in the Y-m-d H:i:s format. 1153 * Simply subtracts thevalue of gmt_offset.1146 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the 1147 * value of gmt_offset. 1154 1148 * 1155 1149 * @since 1.2.0 1156 1150 * … … 1167 1161 /** 1168 1162 * Converts a GMT date into the correct format for the blog. 1169 1163 * 1170 * Requires and returns in the Y-m-d H:i:s format. Simply 1171 * adds the value ofgmt_offset.1164 * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of 1165 * gmt_offset. 1172 1166 * 1173 1167 * @since 1.2.0 1174 1168 * … … 1185 1179 /** 1186 1180 * Computes an offset in seconds from an iso8601 timezone. 1187 1181 * 1188 * {@internal Missing Long Description}}1189 *1190 1182 * @since 1.5.0 1191 1183 * 1192 1184 * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. … … 1208 1200 /** 1209 1201 * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. 1210 1202 * 1211 * {@internal Missing Long Description}}1212 *1213 1203 * @since 1.5.0 1214 1204 * 1215 1205 * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}. 1216 * @param unknown_type $timezone Optional. If set to GMT returns the time minus gmt_offset. Default USER.1206 * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'. 1217 1207 * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. 1218 1208 */ 1219 function iso8601_to_datetime($date_string, $timezone = USER) {1220 if ($timezone == GMT) {1209 function iso8601_to_datetime($date_string, $timezone = 'user') { 1210 $timezone = strtolower($timezone); 1221 1211 1212 if ($timezone == 'gmt') { 1213 1222 1214 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); 1223 1215 1224 1216 if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset … … 1232 1224 1233 1225 return gmdate('Y-m-d H:i:s', $timestamp); 1234 1226 1235 } else if ($timezone == USER) {1227 } else if ($timezone == 'user') { 1236 1228 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); 1237 1229 } 1238 1230 } … … 1269 1261 /** 1270 1262 * Determines the difference between two timestamps. 1271 1263 * 1272 * The difference is returned in a human readable format such as 1273 * " 1 hour", "5 mins", "2 days".1264 * The difference is returned in a human readable format such as "1 hour", 1265 * "5 mins", "2 days". 1274 1266 * 1275 1267 * @since 1.5.0 1276 1268 * … … 1305 1297 } 1306 1298 1307 1299 /** 1308 * Generates an excerpt from the content if needed.1300 * Generates an excerpt from the content, if needed. 1309 1301 * 1310 * {@internal Missing Long Description}} 1302 * The excerpt word amount will be 55 words and if the amount is greater than 1303 * that, then the string '[...]' will be appended to the excerpt. If the string 1304 * is less than 55 words, then the content will be returned as is. 1311 1305 * 1312 1306 * @since 1.5.0 1313 1307 * 1314 1308 * @param string $text The exerpt. If set to empty an excerpt is generated. 1315 1309 * @return string The excerpt. 1316 1310 */ 1317 function wp_trim_excerpt($text) { // Fakes an excerpt if needed1311 function wp_trim_excerpt($text) { 1318 1312 if ( '' == $text ) { 1319 1313 $text = get_the_content(''); 1320 1314 … … 1337 1331 /** 1338 1332 * Converts named entities into numbered entities. 1339 1333 * 1340 * {@internal Missing Long Description}}1341 *1342 1334 * @since 1.5.1 1343 1335 * 1344 1336 * @param string $text The text within which entities will be converted. … … 1609 1601 } 1610 1602 1611 1603 /** 1612 * Formats text for the rich text editor and applies filter.1604 * Formats text for the rich text editor. 1613 1605 * 1614 * The filter 'richedit_pre' is applied here. If $text is empty 1615 * the filter willbe applied to an empty string.1606 * The filter 'richedit_pre' is applied here. If $text is empty the filter will 1607 * be applied to an empty string. 1616 1608 * 1617 1609 * @since 2.0.0 1618 1610 * … … 1631 1623 } 1632 1624 1633 1625 /** 1634 * Formats text for the HTML editor and applies a filter.1626 * Formats text for the HTML editor. 1635 1627 * 1636 * Unless $output is empty it will pass through htmlspecialchars 1637 * before the'htmledit_pre' filter is applied.1628 * Unless $output is empty it will pass through htmlspecialchars before the 1629 * 'htmledit_pre' filter is applied. 1638 1630 * 1639 * @since unknown1631 * @since 2.5.0 1640 1632 * 1641 1633 * @param string $output The text to be formatted. 1642 1634 * @return string Formatted text after filter applied. … … 1651 1643 /** 1652 1644 * Checks and cleans a URL. 1653 1645 * 1654 * A number of characters are removed from the URL. If the URL is 1655 * for displaying (the default behaviour) amperstands are also replaced.1656 * The 'clean_url' filteris applied to the returned cleaned URL.1646 * A number of characters are removed from the URL. If the URL is for displaying 1647 * (the default behaviour) amperstands are also replaced. The 'clean_url' filter 1648 * is applied to the returned cleaned URL. 1657 1649 * 1658 1650 * @since 1.2.0 1659 1651 * @uses wp_kses_bad_protocol() To only permit protocols in the URL set 1660 * via $protocols or the common ones set in the function.1652 * via $protocols or the common ones set in the function. 1661 1653 * 1662 1654 * @param string $url The URL to be cleaned. 1663 1655 * @param array $protocols Optional. An array of acceptable protocols. … … 1711 1703 /** 1712 1704 * Convert entities, while preserving already-encoded entities. 1713 1705 * 1714 * {@internal Missing Long Description}}1715 *1716 1706 * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes. 1717 1707 * 1718 1708 * @since 1.2.2 … … 1746 1736 /** 1747 1737 * Escaping for HTML attributes. 1748 1738 * 1749 * @since unknown1739 * @since 2.0.6 1750 1740 * 1751 1741 * @param string $text 1752 1742 * @return string … … 1759 1749 /** 1760 1750 * Escape a HTML tag name. 1761 1751 * 1762 * @since unknown1752 * @since 2.5.0 1763 1753 * 1764 1754 * @param string $tag_name 1765 1755 * @return string … … 1772 1762 /** 1773 1763 * Escapes text for SQL LIKE special characters % and _. 1774 1764 * 1775 * @since unknown1765 * @since 2.5.0 1776 1766 * 1777 1767 * @param string $text The text to be escaped. 1778 1768 * @return string text, safe for inclusion in LIKE query. … … 1782 1772 } 1783 1773 1784 1774 /** 1785 * {@internal Missing Short Description}}1775 * Convert full URL paths to absolute paths. 1786 1776 * 1787 * @since unknown 1777 * Removes the http or https protocols and the domain. Keeps the path '/' at the 1778 * beginning, so it isn't a true relative link, but from the web root base. 1788 1779 * 1789 * @param string $link 1790 * @return string 1780 * @since 2.1.0 1781 * 1782 * @param string $link Full URL path. 1783 * @return string Absolute path. 1791 1784 */ 1792 1785 function wp_make_link_relative( $link ) { 1793 return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );1786 return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link ); 1794 1787 } 1795 1788 1796 1789 /** 1797 1790 * Sanitises various option values based on the nature of the option. 1798 1791 * 1799 * This is basically a switch statement which will pass $value through 1800 * a numberof functions depending on the $option.1792 * This is basically a switch statement which will pass $value through a number 1793 * of functions depending on the $option. 1801 1794 * 1802 1795 * @since 2.0.5 1803 1796 * … … 1805 1798 * @param string $value The unsanitised value. 1806 1799 * @return string Sanitized value. 1807 1800 */ 1808 function sanitize_option($option, $value) { // Remember to call stripslashes!1801 function sanitize_option($option, $value) { 1809 1802 1810 1803 switch ($option) { 1811 1804 case 'admin_email': … … 1882 1875 /** 1883 1876 * Parses a string into variables to be stored in an array. 1884 1877 * 1885 * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes 1886 * if{@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.1878 * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if 1879 * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on. 1887 1880 * 1888 1881 * @since 2.2.1 1889 1882 * @uses apply_filters() for the 'wp_parse_str' filter. … … 1904 1897 * KSES already converts lone greater than signs. 1905 1898 * 1906 1899 * @uses wp_pre_kses_less_than_callback in the callback function. 1907 * @since unknown1900 * @since 2.3.0 1908 1901 * 1909 1902 * @param string $text Text to be converted. 1910 1903 * @return string Converted text. … … 1916 1909 /** 1917 1910 * Callback function used by preg_replace. 1918 1911 * 1919 * @since unknown1920 1912 * @uses wp_specialchars to format the $matches text. 1913 * @since 2.3.0 1921 1914 * 1922 1915 * @param array $matches Populated by matches to preg_replace. 1923 1916 * @return string The text returned after wp_specialchars if needed. … … 1931 1924 /** 1932 1925 * WordPress implementation of PHP sprintf() with filters. 1933 1926 * 1934 * @since unknown1927 * @since 2.5.0 1935 1928 * @link http://www.php.net/sprintf 1936 1929 * 1937 1930 * @param string $pattern The string which formatted args are inserted. … … 1991 1984 } 1992 1985 1993 1986 /** 1994 * L ist specifier %l for wp_sprintf.1987 * Localize list items before the rest of the content. 1995 1988 * 1996 * @since unknown 1989 * The '%l' must be at the first characters can then contain the rest of the 1990 * content. The list items will have ', ', ', and', and ' and ' added depending 1991 * on the amount of list items in the $args parameter. 1997 1992 * 1998 * @param unknown_type $pattern 1999 * @param unknown_type $args 2000 * @return unknown 1993 * @since 2.5.0 1994 * 1995 * @param string $pattern Content containing '%l' at the beginning. 1996 * @param array $args List items to prepend to the content and replace '%l'. 1997 * @return string Localized list items and rest of the content. 2001 1998 */ 2002 1999 function wp_sprintf_l($pattern, $args) { 2003 2000 // Not a match … … 2020 2017 if ( count($args) == 1 ) 2021 2018 $result .= $l['between_only_two'] . array_shift($args); 2022 2019 // Loop when more than two args 2023 while ( count($args) ) { 2020 // There is a bug in this code that doesn't meet the above comment's 2021 // requirements. 2022 while ( $i = count($args) ) { 2024 2023 $arg = array_shift($args); 2025 2024 if ( $i == 1 ) 2026 2025 $result .= $l['between_last_two'] . $arg; … … 2037 2036 * be counted as one character. For example & will be counted as 4, < as 2038 2037 * 3, etc. 2039 2038 * 2039 * @since 2.5.0 2040 * 2040 2041 * @param integer $str String to get the excerpt from. 2041 2042 * @param integer $count Maximum number of characters to take. 2042 2043 * @return string The excerpt. … … 2052 2053 /** 2053 2054 * Add a Base url to relative links in passed content. 2054 2055 * 2055 * By default it supports the 'src' and 'href' attributes ,2056 * However this may bechanged via the 3rd param.2056 * By default it supports the 'src' and 'href' attributes. However this can be 2057 * changed via the 3rd param. 2057 2058 * 2058 * @package WordPress 2059 * @since 2.7 2059 * @since 2.7.0 2060 2060 * 2061 2061 * @param string $content String to search for links in. 2062 2062 * @param string $base The base URL to prefix to links. … … 2073 2073 /** 2074 2074 * Callback to add a base url to relative links in passed content. 2075 2075 * 2076 * @since 2.7.0 2077 * @access private 2076 2078 * 2077 * @package WordPress2078 * @since 2.72079 *2080 2079 * @param string $m The matched link. 2081 2080 * @param string $base The base URL to prefix to links. 2082 2081 * @return string The processed link. … … 2093 2092 /** 2094 2093 * Adds a Target attribute to all links in passed content. 2095 2094 * 2096 * This function by default only applies to <a> tags, 2097 * however this can be modified by the 3rd param. 2098 * NOTE: Any current target attributed will be striped and replaced. 2095 * This function by default only applies to <a> tags, however this can be 2096 * modified by the 3rd param. 2099 2097 * 2100 * @package WordPress 2101 * @since 2.7 2098 * <b>NOTE:</b> Any current target attributed will be striped and replaced. 2102 2099 * 2100 * @since 2.7.0 2101 * 2103 2102 * @param string $content String to search for links in. 2104 2103 * @param string $target The Target to add to the links. 2105 2104 * @param array $tags An array of tags to apply to. … … 2114 2113 /** 2115 2114 * Callback to add a target attribute to all links in passed content. 2116 2115 * 2116 * @since 2.7.0 2117 * @access private 2117 2118 * 2118 * @package WordPress2119 * @since 2.72120 *2121 2119 * @param string $m The matched link. 2122 2120 * @param string $target The Target to add to the links. 2123 2121 * @return string The processed link.