Changeset 8743 for trunk/wp-includes/formatting.php
- Timestamp:
- 08/27/2008 06:49:21 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r8704 r8743 1 1 <?php 2 2 /** 3 * Main Wordpress Formatting API 4 * 5 * Handles many functions for formatting output 3 * Main Wordpress Formatting API. 4 * 5 * Handles many functions for formatting output. 6 6 * 7 7 * @package WordPress … … 19 19 * ’cause today’s effort makes it worth tomorrow’s “holiday”… 20 20 * </code> 21 * Code within certain html blocks are skipped. 21 * Code within certain html blocks are skipped. 22 22 * 23 23 * @since 0.71 … … 77 77 78 78 /** 79 * Accepts matches array from preg_replace_callback in wpautop() or a string 80 * 81 * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not converted into paragraphs or line-breaks. 79 * Accepts matches array from preg_replace_callback in wpautop() or a string. 80 * 81 * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not 82 * converted into paragraphs or line-breaks. 82 83 * 83 84 * @since 1.2.0 84 85 * 85 * @param array|string $matches The array or string 86 * @param array|string $matches The array or string 86 87 * @return string The pre block without paragraph/line-break conversion. 87 88 */ … … 100 101 101 102 /** 102 * Replaces double line-breaks with paragraph elements 103 * 104 * A group of regex replaces used to identify text formatted with newlines and replace105 * double line-breaks with HTML paragraph tags. The remaining line-breaks after conversion106 * become <<br />> tags, unless $br is set to '0' or 'false'.107 * 103 * Replaces double line-breaks with paragraph elements. 104 * 105 * A group of regex replaces used to identify text formatted with newlines and 106 * replace double line-breaks with HTML paragraph tags. The remaining 107 * line-breaks after conversion become <<br />> tags, unless $br is set to '0' 108 * or 'false'. 108 109 * 109 110 * @since 0.71 110 111 * 111 112 * @param string $pee The text which has to be formatted. 112 * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. 113 * @return string Text which has been converted into correct paragraph tags. 113 * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. 114 * @return string Text which has been converted into correct paragraph tags. 114 115 */ 115 116 function wpautop($pee, $br = 1) { … … 180 181 181 182 /** 182 * Converts a number of special characters into their HTML entities 183 * 184 * Differs from htmlspecialchars as existing HTML entities will not be encoded. Specificically185 * changes: & to &, < to < and > to >.186 * 187 * $quotes can be set to 'single' to encode ' to ', 'double' to encode " to ", or '1' to do both.188 * Default is 0 where no quotes are encoded.183 * Converts a number of special characters into their HTML entities. 184 * 185 * Differs from htmlspecialchars as existing HTML entities will not be encoded. 186 * Specificically changes: & to &, < to < and > to >. 187 * 188 * $quotes can be set to 'single' to encode ' to ', 'double' to encode " to 189 * ", or '1' to do both. Default is 0 where no quotes are encoded. 189 190 * 190 191 * @since 1.2.2 191 192 * 192 * @param string $text The text which is to be encoded 193 * @param mixed $quotes Optional. Converts single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default 0. 194 * @return string The encoded text with HTML entities. 193 * @param string $text The text which is to be encoded. 194 * @param mixed $quotes Optional. Converts single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default 0. 195 * @return string The encoded text with HTML entities. 195 196 */ 196 197 function wp_specialchars( $text, $quotes = 0 ) { … … 265 266 266 267 /** 267 * Replaces accents in a string 268 * Replaces accents in a string. 268 269 * 269 270 * {@internal Missing Long Description}} … … 272 273 * 273 274 * @param string $string The text to be filtered. 274 * @return string Filtered string with replaced "nice" characters 275 * @return string Filtered string with replaced "nice" characters. 275 276 */ 276 277 function remove_accents($string) { … … 405 406 406 407 /** 407 * Filters certain characters from the file name. 408 * Filters certain characters from the file name. 408 409 * 409 410 * {@internal Missing Long Description}} … … 411 412 * @since 2.1.0 412 413 * 413 * @param string $name The string to be sanitized 414 * @return string Sanitized string 414 * @param string $name The string to be sanitized. 415 * @return string Sanitized string. 415 416 */ 416 417 function sanitize_file_name( $name ) { // Like sanitize_title, but with periods … … 427 428 428 429 /** 429 * Removes characters from the username 430 * 431 * If $strict is true, only alphanumeric characters (as well as _, space, ., -, @) are returned. 430 * Removes characters from the username. 431 * 432 * If $strict is true, only alphanumeric characters (as well as _, space, ., -, 433 * @) are returned. 432 434 * 433 435 * @since 2.0.0 434 436 * 435 * @param string $username The username to be sanitized. 436 * @param bool $strict If set limits $username to specific characters. Default false. 437 * @return string The sanitized username, after passing through filters. 437 * @param string $username The username to be sanitized. 438 * @param bool $strict If set limits $username to specific characters. Default false. 439 * @return string The sanitized username, after passing through filters. 438 440 */ 439 441 function sanitize_user( $username, $strict = false ) { … … 455 457 456 458 /** 457 * Returns a string which has been sanitized. 458 * 459 * Specifically, HTML and PHP tags are stripped. Further actions can be added via the 460 * plugin API. If $title is empty and $fallback_title is set, the latter will be used. 459 * Returns a string which has been sanitized. 460 * 461 * Specifically, HTML and PHP tags are stripped. Further actions can be added 462 * via the plugin API. If $title is empty and $fallback_title is set, the latter 463 * will be used. 461 464 * 462 465 * @since 1.0.0 463 466 * 464 * @param string $title The string to be sanitized. 465 * @param string $fallback_title Optional. A title to use if $title is empty. 466 * @return string The sanitized string. 467 * @param string $title The string to be sanitized. 468 * @param string $fallback_title Optional. A title to use if $title is empty. 469 * @return string The sanitized string. 467 470 */ 468 471 function sanitize_title($title, $fallback_title = '') { … … 477 480 478 481 /** 479 * Replaces the string with safe characters. Whitespace becomes a dash. 480 * 481 * Limits the output to alphanumeric characters, underscore (_) and dash (-). 482 * Replaces the string with safe characters. Whitespace becomes a dash. 483 * 484 * Limits the output to alphanumeric characters, underscore (_) and dash (-). 482 485 * 483 486 * @since 1.2.0 484 487 * 485 * @param string $title The title to be sanitized 486 * @return string The sanitized title 488 * @param string $title The title to be sanitized. 489 * @return string The sanitized title. 487 490 */ 488 491 function sanitize_title_with_dashes($title) { … … 514 517 515 518 /** 516 * Ensures a string is a valid SQL order by clause. 517 * 518 * Accepts one or more columns, with or without ASC/DESC, and also accepts RAND() 519 * Ensures a string is a valid SQL order by clause. 520 * 521 * Accepts one or more columns, with or without ASC/DESC, and also accepts 522 * RAND(). 519 523 * 520 524 * @since 2.5.1 521 525 * 522 * @param string $orderby Order by string to be checked 526 * @param string $orderby Order by string to be checked. 523 527 * @return string|false Returns the order by clause if it is a match, false otherwise. 524 528 */ … … 531 535 532 536 /** 533 * Converts a number of characters from a string 534 * 535 * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are converted into correct 536 * XHTML and Unicode characters are converted to the valid range. 537 * Converts a number of characters from a string. 538 * 539 * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are 540 * converted into correct XHTML and Unicode characters are converted to the 541 * valid range. 537 542 * 538 543 * @since 0.71 539 544 * 540 * @param string $content String of characters to be converted 541 * @param string $deprecated Not used 545 * @param string $content String of characters to be converted. 546 * @param string $deprecated Not used. 542 547 * @return string Converted string. 543 548 */ … … 597 602 598 603 /** 599 * Fixes javascript bugs in browsers. 604 * Fixes javascript bugs in browsers. 600 605 * 601 606 * {@internal Missing Long Description}} … … 605 610 * @uses $is_winIE 606 611 * 607 * @param string $text Text to be made safe 608 * @return string Fixed text 612 * @param string $text Text to be made safe. 613 * @return string Fixed text. 609 614 */ 610 615 function funky_javascript_fix($text) { … … 652 657 * 1.0 First Version 653 658 * 654 * @param string $text Text to be balanced 655 * @return string Balanced text 659 * @param string $text Text to be balanced. 660 * @return string Balanced text. 656 661 */ 657 662 function force_balance_tags( $text ) { … … 755 760 756 761 /** 757 * Acts on text which is about to be edited 758 * 759 * Unless $richedit is set, it is simply a holder for the 'format_to_edit' filter. If $richedit760 * is set true htmlspecialchars() will be run on the content, converting special characters to761 * HTMl entities.762 * Acts on text which is about to be edited. 763 * 764 * Unless $richedit is set, it is simply a holder for the 'format_to_edit' 765 * filter. If $richedit is set true htmlspecialchars() will be run on the 766 * content, converting special characters to HTMl entities. 762 767 * 763 768 * @since 0.71 764 769 * 765 * @param string $content The text about to be edited. 766 * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false. 767 * @return string The text after the filter (and possibly htmlspecialchars()) has been run. 770 * @param string $content The text about to be edited. 771 * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false. 772 * @return string The text after the filter (and possibly htmlspecialchars()) has been run. 768 773 */ 769 774 function format_to_edit($content, $richedit = false) { … … 782 787 * 783 788 * @param string $content The text to pass through the filter. 784 * @return string Text returned from the 'format_to_post' filter. 789 * @return string Text returned from the 'format_to_post' filter. 785 790 */ 786 791 function format_to_post($content) { … … 790 795 791 796 /** 792 * Add leading zeros when necessary 797 * Add leading zeros when necessary. 793 798 * 794 799 * {@internal Missing Long Description}} … … 821 826 822 827 /** 823 * Appends a trailing slash 824 * 825 * Will remove trailing slash if it exists already before adding 826 * a trailing slash. This prevents double slashing a string or 827 * path. 828 * 829 * The primary use of this is for paths and thus should be used 830 * for paths. It is not restricted to paths and offers no specific 831 * path support. 828 * Appends a trailing slash. 829 * 830 * Will remove trailing slash if it exists already before adding a trailing 831 * slash. This prevents double slashing a string or path. 832 * 833 * The primary use of this is for paths and thus should be used for paths. It is 834 * not restricted to paths and offers no specific path support. 832 835 * 833 836 * @since 1.2.0 834 * @uses untrailingslashit() Unslashes string if it was slashed already 835 * 836 * @param string $string What to add the trailing slash to 837 * @return string String with trailing slash added 837 * @uses untrailingslashit() Unslashes string if it was slashed already. 838 * 839 * @param string $string What to add the trailing slash to. 840 * @return string String with trailing slash added. 838 841 */ 839 842 function trailingslashit($string) { … … 842 845 843 846 /** 844 * Removes trailing slash if it exists 845 * 846 * The primary use of this is for paths and thus should be used 847 * for paths. It is not restricted to paths and offers no specific 848 * path support. 847 * Removes trailing slash if it exists. 848 * 849 * The primary use of this is for paths and thus should be used for paths. It is 850 * not restricted to paths and offers no specific path support. 849 851 * 850 852 * @since 2.2.0 851 853 * 852 * @param string $string What to remove the trailing slash from 853 * @return string String without the trailing slash 854 * @param string $string What to remove the trailing slash from. 855 * @return string String without the trailing slash. 854 856 */ 855 857 function untrailingslashit($string) { … … 858 860 859 861 /** 860 * addslashes_gpc() - {@internal Missing Short Description}} 861 * 862 * {@internal Missing Long Description}} 862 * Adds slashes to escape strings. 863 * 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 866 * 864 867 * @since 0.71 865 868 * 866 * @param unknown_type $gpc867 * @return unknown869 * @param string $gpc The string returned from HTTP request data. 870 * @return string Returns a string escaped with slashes. 868 871 */ 869 872 function addslashes_gpc($gpc) { … … 878 881 879 882 /** 880 * stripslashes_deep() - {@internal Missing Short Description}} 881 * 882 * {@internal Missing Long Description}} 883 * Navigates through an array and removes slashes from the values. 884 * 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. 883 888 * 884 889 * @since 2.0.0 885 890 * 886 * @param unknown_type $value887 * @return unknown891 * @param array|string $value The array or string to be striped. 892 * @return array|string Stripped array (or string in the callback). 888 893 */ 889 894 function stripslashes_deep($value) { … … 896 901 897 902 /** 898 * urlencode_deep() - {@internal Missing Short Description}} 899 * 900 * {@internal Missing Long Description}} 903 * Navigates through an array and encodes the values to be used in a URL. 904 * 905 * Uses a callback to pass the value of the array back to the function as a 906 * string. 901 907 * 902 908 * @since 2.2.0 903 909 * 904 * @param unknown_type $value905 * @return unknown910 * @param array|string $value The array or string to be encoded. 911 * @return array|string $value The encoded array (or string from the callback). 906 912 */ 907 913 function urlencode_deep($value) { … … 946 952 * {@internal Missing Long Description}} 947 953 * 948 * @since 2.5 954 * @since 2.5.0 949 955 * @access private 950 956 * … … 971 977 * {@internal Missing Long Description}} 972 978 * 973 * @since 2.5 979 * @since 2.5.0 974 980 * @access private 975 981 * … … 997 1003 * {@internal Missing Long Description}} 998 1004 * 999 * @since 2.5 1005 * @since 2.5.0 1000 1006 * @access private 1001 1007 * … … 1097 1103 1098 1104 /** 1099 * is_email() - {@internal Missing Short Description}}1105 * Checks to see if the text is a valid email address. 1100 1106 * 1101 1107 * {@internal Missing Long Description}} … … 1103 1109 * @since 0.71 1104 1110 * 1105 * @param unknown_type $user_email1106 * @return unknown1111 * @param string $user_email The email address to be checked. 1112 * @return bool Returns true if valid, otherwise false. 1107 1113 */ 1108 1114 function is_email($user_email) { … … 1142 1148 1143 1149 /** 1144 * get_gmt_from_date() - Give it a date, it will give you the same date as GMT 1145 * 1146 * {@internal Missing Long Description}} 1150 * Returns a date in the GMT equivalent. 1151 * 1152 * Requires and returns a date in the Y-m-d H:i:s format. 1153 * Simply subtracts the value of gmt_offset. 1147 1154 * 1148 1155 * @since 1.2.0 1149 1156 * 1150 * @param unknown_type $string1151 * @return unknown1157 * @param string $string The date to be converted. 1158 * @return string GMT version of the date provided. 1152 1159 */ 1153 1160 function get_gmt_from_date($string) { 1154 // note: this only substracts $time_difference from the given date1155 1161 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); 1156 1162 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); … … 1160 1166 1161 1167 /** 1162 * get_date_from_gmt() - Give it a GMT date, it will give you the same date with $time_difference added 1163 * 1164 * {@internal Missing Long Description}} 1168 * Converts a GMT date into the correct format for the blog. 1169 * 1170 * Requires and returns in the Y-m-d H:i:s format. Simply 1171 * adds the value of gmt_offset. 1165 1172 * 1166 1173 * @since 1.2.0 1167 1174 * 1168 * @param unknown_type $string1169 * @return unknown1175 * @param string $string The date to be converted. 1176 * @return string Formatted date relative to the GMT offset. 1170 1177 */ 1171 1178 function get_date_from_gmt($string) { 1172 // note: this only adds $time_difference to the given date1173 1179 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); 1174 1180 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); … … 1178 1184 1179 1185 /** 1180 * iso8601_timezone_to_offset() - Computes an offset in seconds from an iso8601 timezone1186 * Computes an offset in seconds from an iso8601 timezone. 1181 1187 * 1182 1188 * {@internal Missing Long Description}} … … 1184 1190 * @since 1.5.0 1185 1191 * 1186 * @param unknown_type $timezone1187 * @return unknown1192 * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. 1193 * @return int|float The offset in seconds. 1188 1194 */ 1189 1195 function iso8601_timezone_to_offset($timezone) { … … 1201 1207 1202 1208 /** 1203 * iso8601_to_datetime() - Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]1209 * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. 1204 1210 * 1205 1211 * {@internal Missing Long Description}} … … 1207 1213 * @since 1.5.0 1208 1214 * 1209 * @param unknown_type $date_string1210 * @param unknown_type $timezone 1211 * @return unknown1215 * @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. 1217 * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. 1212 1218 */ 1213 1219 function iso8601_to_datetime($date_string, $timezone = USER) { … … 1233 1239 1234 1240 /** 1235 * Adds a element attributes to open links in new windows 1236 * 1237 * Comment text in popup windows should be filtered through this. Right 1238 * now it's a moderately dumb function, ideally it would detect whether 1239 * a target or rel attribute was already there and adjust its actions 1240 * accordingly. 1241 * Adds a element attributes to open links in new windows. 1242 * 1243 * Comment text in popup windows should be filtered through this. Right now it's 1244 * a moderately dumb function, ideally it would detect whether a target or rel 1245 * attribute was already there and adjust its actions accordingly. 1241 1246 * 1242 1247 * @since 0.71 1243 1248 * 1244 * @param string $text Content to replace links to open in a new window 1245 * @return string Content that has filtered links 1249 * @param string $text Content to replace links to open in a new window. 1250 * @return string Content that has filtered links. 1246 1251 */ 1247 1252 function popuplinks($text) { … … 1251 1256 1252 1257 /** 1253 * Strips out all characters that are not allowable in an email 1258 * Strips out all characters that are not allowable in an email. 1254 1259 * 1255 1260 * @since 1.5.0 1256 1261 * 1257 * @param string $email Email address to filter 1258 * @return string Filtered email address 1262 * @param string $email Email address to filter. 1263 * @return string Filtered email address. 1259 1264 */ 1260 1265 function sanitize_email($email) { … … 1263 1268 1264 1269 /** 1265 * human_time_diff() - {@internal Missing Short Description}} 1266 * 1267 * {@internal Missing Long Description}} 1270 * Determines the difference between two timestamps. 1271 * 1272 * The difference is returned in a human readable format such as 1273 * "1 hour", "5 mins", "2 days". 1268 1274 * 1269 1275 * @since 1.5.0 1270 1276 * 1271 * @param unknown_type $from1272 * @param unknown_type $to1273 * @return unknown1277 * @param int $from Unix timestamp from which the difference begins. 1278 * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. 1279 * @return string Human readable time difference. 1274 1280 */ 1275 1281 function human_time_diff( $from, $to = '' ) { … … 1300 1306 1301 1307 /** 1302 * wp_trim_excerpt() - {@internal Missing Short Description}}1308 * Generates an excerpt from the content if needed. 1303 1309 * 1304 1310 * {@internal Missing Long Description}} … … 1306 1312 * @since 1.5.0 1307 1313 * 1308 * @param unknown_type $text1309 * @return unknown1314 * @param string $text The exerpt. If set to empty an excerpt is generated. 1315 * @return string The excerpt. 1310 1316 */ 1311 1317 function wp_trim_excerpt($text) { // Fakes an excerpt if needed … … 1330 1336 1331 1337 /** 1332 * ent2ncr() - {@internal Missing Short Description}}1338 * Converts named entities into numbered entities. 1333 1339 * 1334 1340 * {@internal Missing Long Description}} … … 1336 1342 * @since 1.5.1 1337 1343 * 1338 * @param unknown_type $text1339 * @return unknown1344 * @param string $text The text within which entities will be converted. 1345 * @return string Text with converted entities. 1340 1346 */ 1341 1347 function ent2ncr($text) { … … 1604 1610 1605 1611 /** 1606 * wp_richedit_pre() - {@internal Missing Short Description}} 1607 * 1608 * {@internal Missing Long Description}} 1612 * Formats text for the rich text editor and applies filter. 1613 * 1614 * The filter 'richedit_pre' is applied here. If $text is empty 1615 * the filter will be applied to an empty string. 1609 1616 * 1610 1617 * @since 2.0.0 1611 1618 * 1612 * @param unknown_type $text1613 * @return unknown1619 * @param string $text The text to be formatted. 1620 * @return string The formatted text after filter is applied. 1614 1621 */ 1615 1622 function wp_richedit_pre($text) { … … 1624 1631 } 1625 1632 1633 /** 1634 * Formats text for the HTML editor and applies a filter. 1635 * 1636 * Unless $output is empty it will pass through htmlspecialchars 1637 * before the 'htmledit_pre' filter is applied. 1638 * 1639 * @since unknown 1640 * 1641 * @param string $output The text to be formatted. 1642 * @return string Formatted text after filter applied. 1643 */ 1626 1644 function wp_htmledit_pre($output) { 1627 1645 if ( !empty($output) ) … … 1632 1650 1633 1651 /** 1634 * clean_url() - {@internal Missing Short Description}} 1635 * 1636 * {@internal Missing Long Description}} 1652 * Checks and cleans a URL. 1653 * 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' filter is applied to the returned cleaned URL. 1637 1657 * 1638 1658 * @since 1.2.0 1639 * 1640 * @param unknown_type $url 1641 * @param unknown_type $protocols 1642 * @param unknown_type $context 1643 * @return unknown 1659 * @uses wp_kses_bad_protocol() To only permit protocols in the URL set 1660 * via $protocols or the common ones set in the function. 1661 * 1662 * @param string $url The URL to be cleaned. 1663 * @param array $protocols Optional. An array of acceptable protocols. 1664 * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set. 1665 * @param string $context Optional. How the URL will be used. Default is 'display'. 1666 * @return string The cleaned $url after the 'cleaned_url' filter is applied. 1644 1667 */ 1645 1668 function clean_url( $url, $protocols = null, $context = 'display' ) { … … 1659 1682 $url = 'http://' . $url; 1660 1683 1661 // Replace ampersands on y when displaying.1684 // Replace ampersands only when displaying. 1662 1685 if ( 'display' == $context ) 1663 1686 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); … … 1672 1695 1673 1696 /** 1674 * sanitize_url() - {@internal Missing Short Description}}1675 * 1676 * {@internal Missing Long Description}}1697 * Performs clean_url() for database usage. 1698 * 1699 * @see clean_url() 1677 1700 * 1678 1701 * @since 2.3.1 1679 1702 * 1680 * @param unknown_type $url1681 * @param unknown_type $protocols1682 * @return unknown1703 * @param string $url The URL to be cleaned. 1704 * @param array $protocols An array of acceptable protocols. 1705 * @return string The cleaned URL. 1683 1706 */ 1684 1707 function sanitize_url( $url, $protocols = null ) { … … 1687 1710 1688 1711 /** 1689 * Convert entities, while preserving already-encoded entities 1712 * Convert entities, while preserving already-encoded entities. 1690 1713 * 1691 1714 * {@internal Missing Long Description}} … … 1695 1718 * @since 1.2.2 1696 1719 * 1697 * @param unknown_type $myHTML1698 * @return unknown1720 * @param string $myHTML The text to be converted. 1721 * @return string Converted text. 1699 1722 */ 1700 1723 function htmlentities2($myHTML) { … … 1705 1728 1706 1729 /** 1707 * Escape single quotes, specialchar double quotes, and fix line endings 1708 * 1709 * {@internal Missing Long Description}}1730 * Escape single quotes, specialchar double quotes, and fix line endings. 1731 * 1732 * The filter 'js_escape' is also applied here. 1710 1733 * 1711 1734 * @since 2.0.4 1712 1735 * 1713 * @param string $text 1714 * @return unknown1736 * @param string $text The text to be escaped. 1737 * @return string Escaped text. 1715 1738 */ 1716 1739 function js_escape($text) { … … 1721 1744 } 1722 1745 1723 // Escaping for HTML attributes 1746 /** 1747 * Escaping for HTML attributes. 1748 * 1749 * @since unknown 1750 * 1751 * @param string $text 1752 * @return string 1753 */ 1724 1754 function attribute_escape($text) { 1725 1755 $safe_text = wp_specialchars($text, true); … … 1727 1757 } 1728 1758 1729 // Escape a HTML tag name 1759 /** 1760 * Escape a HTML tag name. 1761 * 1762 * @since unknown 1763 * 1764 * @param string $tag_name 1765 * @return string 1766 */ 1730 1767 function tag_escape($tag_name) { 1731 1768 $safe_tag = strtolower( preg_replace('[^a-zA-Z_:]', '', $tag_name) ); … … 1734 1771 1735 1772 /** 1736 * Escapes text for SQL LIKE special characters % and _ 1737 * 1738 * @param string text the text to be escaped 1739 * @return string text, safe for inclusion in LIKE query 1773 * Escapes text for SQL LIKE special characters % and _. 1774 * 1775 * @since unknown 1776 * 1777 * @param string $text The text to be escaped. 1778 * @return string text, safe for inclusion in LIKE query. 1740 1779 */ 1741 1780 function like_escape($text) { … … 1743 1782 } 1744 1783 1784 /** 1785 * {@internal Missing Short Description}} 1786 * 1787 * @since unknown 1788 * 1789 * @param string $link 1790 * @return string 1791 */ 1745 1792 function wp_make_link_relative( $link ) { 1746 1793 return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link ); 1747 1794 } 1748 1795 1796 /** 1797 * Sanitises various option values based on the nature of the option. 1798 * 1799 * This is basically a switch statement which will pass $value through 1800 * a number of functions depending on the $option. 1801 * 1802 * @since 2.0.5 1803 * 1804 * @param string $option The name of the option. 1805 * @param string $value The unsanitised value. 1806 * @return string Sanitized value. 1807 */ 1749 1808 function sanitize_option($option, $value) { // Remember to call stripslashes! 1750 1809 … … 1822 1881 1823 1882 /** 1824 * wp_parse_str() - {@internal Missing Short Description}} 1825 * 1826 * {@internal Missing Long Description}} 1883 * Parses a string into variables to be stored in an array. 1884 * 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. 1827 1887 * 1828 1888 * @since 2.2.1 1829 * @uses apply_filters() 1830 * 1831 * @param string $string 1832 * @param array $array 1889 * @uses apply_filters() for the 'wp_parse_str' filter. 1890 * 1891 * @param string $string The string to be parsed. 1892 * @param array $array Variables will be stored in this array. 1833 1893 */ 1834 1894 function wp_parse_str( $string, &$array ) { 1835 1895 parse_str( $string, $array ); 1836 1896 if ( get_magic_quotes_gpc() ) 1837 $array = stripslashes_deep( $array ); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str1897 $array = stripslashes_deep( $array ); 1838 1898 $array = apply_filters( 'wp_parse_str', $array ); 1839 1899 } 1840 1900 1841 // Convert lone less than signs. KSES already converts lone greater than signs. 1901 /** 1902 * Convert lone less than signs. 1903 * 1904 * KSES already converts lone greater than signs. 1905 * 1906 * @uses wp_pre_kses_less_than_callback in the callback function. 1907 * @since unknown 1908 * 1909 * @param string $text Text to be converted. 1910 * @return string Converted text. 1911 */ 1842 1912 function wp_pre_kses_less_than( $text ) { 1843 1913 return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text); 1844 1914 } 1845 1915 1916 /** 1917 * Callback function used by preg_replace. 1918 * 1919 * @since unknown 1920 * @uses wp_specialchars to format the $matches text. 1921 * 1922 * @param array $matches Populated by matches to preg_replace. 1923 * @return string The text returned after wp_specialchars if needed. 1924 */ 1846 1925 function wp_pre_kses_less_than_callback( $matches ) { 1847 1926 if ( false === strpos($matches[0], '>') ) … … 1851 1930 1852 1931 /** 1853 * wp_sprintf() - sprintf() with filters 1932 * WordPress implementation of PHP sprintf() with filters. 1933 * 1934 * @since unknown 1935 * @link http://www.php.net/sprintf 1936 * 1937 * @param string $pattern The string which formatted args are inserted. 1938 * @param mixed $args,... Arguments to be formatted into the $pattern string. 1939 * @return string The formatted string. 1854 1940 */ 1855 1941 function wp_sprintf( $pattern ) { … … 1906 1992 1907 1993 /** 1908 * wp_sprintf_l - List specifier %l for wp_sprintf 1994 * List specifier %l for wp_sprintf. 1995 * 1996 * @since unknown 1909 1997 * 1910 1998 * @param unknown_type $pattern … … 1944 2032 1945 2033 /** 1946 * Safely extracts not more than the first $count characters from html string 1947 * 1948 * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* be 1949 * counted as one character. For example & will be counted as 4, < as 3, etc. 1950 * 1951 * @param integer $str String to get the excerpt from 1952 * @param integer $count Maximum number of characters to take 1953 * @return string the excerpt 2034 * Safely extracts not more than the first $count characters from html string. 2035 * 2036 * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* 2037 * be counted as one character. For example & will be counted as 4, < as 2038 * 3, etc. 2039 * 2040 * @param integer $str String to get the excerpt from. 2041 * @param integer $count Maximum number of characters to take. 2042 * @return string The excerpt. 1954 2043 */ 1955 2044 function wp_html_excerpt( $str, $count ) { … … 1970 2059 * @since 2.7 1971 2060 * 1972 * @param string $content String to search for links in 1973 * @param string $base The base URL to prefix to links 2061 * @param string $content String to search for links in. 2062 * @param string $base The base URL to prefix to links. 1974 2063 * @param array $attrs The attributes which should be processed. 1975 * @ eaturn string The processed content.2064 * @return string The processed content. 1976 2065 */ 1977 2066 function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { … … 1989 2078 * @since 2.7 1990 2079 * 1991 * @internal 1992 * @param string $m The matched link 1993 * @param string $base The base URL to prefix to links 1994 * @eaturn string The processed link 2080 * @param string $m The matched link. 2081 * @param string $base The base URL to prefix to links. 2082 * @return string The processed link. 1995 2083 */ 1996 2084 function _links_add_base($m, $base) { … … 2013 2101 * @since 2.7 2014 2102 * 2015 * @param string $content String to search for links in 2016 * @param string $target The Target to add to the links 2103 * @param string $content String to search for links in. 2104 * @param string $target The Target to add to the links. 2017 2105 * @param array $tags An array of tags to apply to. 2018 * @ eaturn string The processed content.2106 * @return string The processed content. 2019 2107 */ 2020 2108 function links_add_target( $content, $target = '_blank', $tags = array('a') ) { … … 2025 2113 } 2026 2114 /** 2027 * Callback to add a target attribute to all links in passed content 2115 * Callback to add a target attribute to all links in passed content. 2028 2116 * 2029 2117 * … … 2031 2119 * @since 2.7 2032 2120 * 2033 * @internal 2034 * @param string $m The matched link 2035 * @param string $target The Target to add to the links 2036 * @eaturn string The processed link. 2121 * @param string $m The matched link. 2122 * @param string $target The Target to add to the links. 2123 * @return string The processed link. 2037 2124 */ 2038 2125 function _links_add_target( $m, $target ) {
Note: See TracChangeset
for help on using the changeset viewer.