Make WordPress Core

Ticket #5638: 5638.r8665.diff

File 5638.r8665.diff, 18.9 KB (added by santosj, 16 years ago)

Formatting.php phpdoc fixes based off of r8665

  • formatting.php

     
    11<?php
    22/**
    3  * Main Wordpress Formatting API 
     3 * Main Wordpress Formatting API.
    44 *
    5  * Handles many functions for formatting output
     5 * Handles many functions for formatting output.
    66 *
    77 * @package WordPress
    88 **/
     
    1818 * <code>
    1919 * &#8217;cause today&#8217;s effort makes it worth tomorrow&#8217;s &#8220;holiday&#8221;&#8230;
    2020 * </code>
    21  * Code within certain html blocks are skipped. 
     21 * Code within certain html blocks are skipped.
    2222 *
    2323 * @since 0.71
    2424 * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases
     
    7676}
    7777
    7878/**
    79  * Accepts matches array from preg_replace_callback in wpautop() or a string
     79 * Accepts matches array from preg_replace_callback in wpautop() or a string.
    8080 *
    81  * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not converted into paragraphs or line-breaks.
     81 * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not
     82 * converted into paragraphs or line-breaks.
    8283 *
    8384 * @since 1.2.0
    8485 *
    85  * @param array|string $matches The array or string 
     86 * @param array|string $matches The array or string
    8687 * @return string The pre block without paragraph/line-break conversion.
    8788 */
    8889function clean_pre($matches) {
     
    99100}
    100101
    101102/**
    102  * Replaces double line-breaks with paragraph elements
     103 * Replaces double line-breaks with paragraph elements.
    103104 *
    104  * A group of regex replaces used to identify text formatted with newlines and replace
    105  * double line-breaks with HTML paragraph tags. The remaining line-breaks after conversion
    106  * become <<br />> tags, unless $br is set to '0' or 'false'.
    107  *
     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'.
    108109 *
    109110 * @since 0.71
    110111 *
    111112 * @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.
    114115 */
    115116function wpautop($pee, $br = 1) {
    116117        $pee = $pee . "\n"; // just to make things a little easier, pad the end
     
    179180}
    180181
    181182/**
    182  * Converts a number of special characters into their HTML entities
     183 * Converts a number of special characters into their HTML entities.
    183184 *
    184  * Differs from htmlspecialchars as existing HTML entities will not be encoded. Specificically
    185  * changes: & to &#038;, < to &lt; and > to &gt;.
     185 * Differs from htmlspecialchars as existing HTML entities will not be encoded.
     186 * Specificically changes: & to &#038;, < to &lt; and > to &gt;.
    186187 *
    187  * $quotes can be set to 'single' to encode ' to &#039;, 'double' to encode " to &quot;, or '1' to do both.
    188  * Default is 0 where no quotes are encoded.
     188 * $quotes can be set to 'single' to encode ' to &#039;, 'double' to encode " to
     189 * &quot;, or '1' to do both. Default is 0 where no quotes are encoded.
    189190 *
    190191 * @since 1.2.2
    191192 *
    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.
    195196 */
    196197function wp_specialchars( $text, $quotes = 0 ) {
    197198        // Like htmlspecialchars except don't double-encode HTML entities
     
    264265}
    265266
    266267/**
    267  * Replaces accents in a string
     268 * Replaces accents in a string.
    268269 *
    269270 * {@internal Missing Long Description}}
    270271 *
     
    404405}
    405406
    406407/**
    407  * Filters certain characters from the file name. 
     408 * Filters certain characters from the file name.
    408409 *
    409410 * {@internal Missing Long Description}}
    410411 *
     
    426427}
    427428
    428429/**
    429  * Removes characters from the username
     430 * Removes characters from the username.
    430431 *
    431  * If $strict is true, only alphanumeric characters (as well as _, space, ., -, @) are returned.
     432 * If $strict is true, only alphanumeric characters (as well as _, space, ., -,
     433 * @) are returned.
    432434 *
    433435 * @since 2.0.0
    434436 *
    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.
    438440 */
    439441function sanitize_user( $username, $strict = false ) {
    440442        $raw_username = $username;
     
    451453}
    452454
    453455/**
    454  * Returns a string which has been sanitized. 
     456 * Returns a string which has been sanitized.
    455457 *
    456  * Specifically, HTML and PHP tags are stripped. Further actions can be added via the
    457  * plugin API. If $title is empty and $fallback_title is set, the latter will be used.
     458 * Specifically, HTML and PHP tags are stripped. Further actions can be added
     459 * via the plugin API. If $title is empty and $fallback_title is set, the latter
     460 * will be used.
    458461 *
    459462 * @since 1.0.0
    460463 *
    461  * @param string $title The string to be sanitized. 
    462  * @param string $fallback_title Optional. A title to use if $title is empty. 
    463  * @return string The sanitized string. 
     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.
    464467 */
    465468function sanitize_title($title, $fallback_title = '') {
    466469        $title = strip_tags($title);
     
    473476}
    474477
    475478/**
    476  * Replaces the string with safe characters. Whitespace becomes a dash. 
     479 * Replaces the string with safe characters. Whitespace becomes a dash.
    477480 *
    478  * Limits the output to alphanumeric characters, underscore (_) and dash (-). 
     481 * Limits the output to alphanumeric characters, underscore (_) and dash (-).
    479482 *
    480483 * @since 1.2.0
    481484 *
     
    510513}
    511514
    512515/**
    513  * Ensures a string is a valid SQL order by clause. 
     516 * Ensures a string is a valid SQL order by clause.
    514517 *
    515  * Accepts one or more columns, with or without ASC/DESC, and also accepts RAND()
     518 * Accepts one or more columns, with or without ASC/DESC, and also accepts
     519 * RAND().
    516520 *
    517521 * @since 2.5.1
    518522 *
     
    527531}
    528532
    529533/**
    530  * Converts a number of characters from a string
     534 * Converts a number of characters from a string.
    531535 *
    532  * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are converted into correct
    533  * XHTML and Unicode characters are converted to the valid range.
     536 * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are
     537 * converted into correct XHTML and Unicode characters are converted to the
     538 * valid range.
    534539 *
    535540 * @since 0.71
    536541 *
     
    593598}
    594599
    595600/**
    596  * Fixes javascript bugs in browsers. 
     601 * Fixes javascript bugs in browsers.
    597602 *
    598603 * {@internal Missing Long Description}}
    599604 *
     
    751756}
    752757
    753758/**
    754  * Acts on text which is about to be edited
     759 * Acts on text which is about to be edited.
    755760 *
    756  * Unless $richedit is set, it is simply a holder for the 'format_to_edit' filter. If $richedit
    757  * is set true htmlspecialchars() will be run on the content, converting special characters to
    758  * HTMl entities.
     761 * Unless $richedit is set, it is simply a holder for the 'format_to_edit'
     762 * filter. If $richedit is set true htmlspecialchars() will be run on the
     763 * content, converting special characters to HTMl entities.
    759764 *
    760765 * @since 0.71
    761766 *
    762  * @param string $content The text about to be edited. 
    763  * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false. 
    764  * @return string The text after the filter (and possibly htmlspecialchars()) has been run. 
     767 * @param string $content The text about to be edited.
     768 * @param bool $richedit Whether or not the $content should pass through htmlspecialchars(). Default false.
     769 * @return string The text after the filter (and possibly htmlspecialchars()) has been run.
    765770 */
    766771function format_to_edit($content, $richedit = false) {
    767772        $content = apply_filters('format_to_edit', $content);
     
    778783 * @since 0.71
    779784 *
    780785 * @param string $content The text to pass through the filter.
    781  * @return string Text returned from the 'format_to_post' filter. 
     786 * @return string Text returned from the 'format_to_post' filter.
    782787 */
    783788function format_to_post($content) {
    784789        $content = apply_filters('format_to_post', $content);
     
    786791}
    787792
    788793/**
    789  * Add leading zeros when necessary
     794 * Add leading zeros when necessary.
    790795 *
    791796 * {@internal Missing Long Description}}
    792797 *
     
    817822}
    818823
    819824/**
    820  * Appends a trailing slash
     825 * Appends a trailing slash.
    821826 *
    822  * Will remove trailing slash if it exists already before adding
    823  * a trailing slash. This prevents double slashing a string or
    824  * path.
     827 * Will remove trailing slash if it exists already before adding a trailing
     828 * slash. This prevents double slashing a string or path.
    825829 *
    826  * The primary use of this is for paths and thus should be used
    827  * for paths. It is not restricted to paths and offers no specific
    828  * path support.
     830 * The primary use of this is for paths and thus should be used for paths. It is
     831 * not restricted to paths and offers no specific path support.
    829832 *
    830833 * @since 1.2.0
    831834 * @uses untrailingslashit() Unslashes string if it was slashed already
     
    838841}
    839842
    840843/**
    841  * Removes trailing slash if it exists
     844 * Removes trailing slash if it exists.
    842845 *
    843  * The primary use of this is for paths and thus should be used
    844  * for paths. It is not restricted to paths and offers no specific
    845  * path support.
     846 * The primary use of this is for paths and thus should be used for paths. It is
     847 * not restricted to paths and offers no specific path support.
    846848 *
    847849 * @since 2.2.0
    848850 *
     
    942944 *
    943945 * {@internal Missing Long Description}}
    944946 *
    945  * @since 2.5
     947 * @since 2.5.0
    946948 * @access private
    947949 *
    948950 * @param unknown_type $matches
     
    967969 *
    968970 * {@internal Missing Long Description}}
    969971 *
    970  * @since 2.5
     972 * @since 2.5.0
    971973 * @access private
    972974 *
    973975 * @param unknown_type $matches
     
    993995 *
    994996 * {@internal Missing Long Description}}
    995997 *
    996  * @since 2.5
     998 * @since 2.5.0
    997999 * @access private
    9981000 *
    9991001 * @param unknown_type $matches
     
    11381140}
    11391141
    11401142/**
    1141  * get_gmt_from_date() - Give it a date, it will give you the same date as GMT
     1143 * Give it a date, it will give you the same date as GMT.
    11421144 *
    11431145 * {@internal Missing Long Description}}
    11441146 *
     
    11561158}
    11571159
    11581160/**
    1159  * get_date_from_gmt() - Give it a GMT date, it will give you the same date with $time_difference added
     1161 * Give it a GMT date, it will give you the same date with $time_difference added.
    11601162 *
    11611163 * {@internal Missing Long Description}}
    11621164 *
     
    11741176}
    11751177
    11761178/**
    1177  * iso8601_timezone_to_offset() - Computes an offset in seconds from an iso8601 timezone
     1179 * Computes an offset in seconds from an iso8601 timezone.
    11781180 *
    11791181 * {@internal Missing Long Description}}
    11801182 *
     
    11971199}
    11981200
    11991201/**
    1200  * iso8601_to_datetime() - Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
     1202 * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
    12011203 *
    12021204 * {@internal Missing Long Description}}
    12031205 *
     
    12291231}
    12301232
    12311233/**
    1232  * Adds a element attributes to open links in new windows
     1234 * Adds a element attributes to open links in new windows.
    12331235 *
    1234  * Comment text in popup windows should be filtered through this. Right
    1235  * now it's a moderately dumb function, ideally it would detect whether
    1236  * a target or rel attribute was already there and adjust its actions
    1237  * accordingly.
     1236 * Comment text in popup windows should be filtered through this. Right now it's
     1237 * a moderately dumb function, ideally it would detect whether a target or rel
     1238 * attribute was already there and adjust its actions accordingly.
    12381239 *
    12391240 * @since 0.71
    12401241 *
     
    12471248}
    12481249
    12491250/**
    1250  * Strips out all characters that are not allowable in an email
     1251 * Strips out all characters that are not allowable in an email.
    12511252 *
    12521253 * @since 1.5.0
    12531254 *
     
    16201621        return apply_filters('richedit_pre', $output);
    16211622}
    16221623
     1624/**
     1625 * {@internal Missing Short Description}}
     1626 *
     1627 * {@internal Missing Long Description}}
     1628 *
     1629 * @since unknown
     1630 *
     1631 * @param string $output {@internal Missing Description}}
     1632 * @return string {@internal Missing Description}}
     1633 */
    16231634function wp_htmledit_pre($output) {
    16241635        if ( !empty($output) )
    16251636                $output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > &
     
    16831694}
    16841695
    16851696/**
    1686  * Convert entities, while preserving already-encoded entities
     1697 * Convert entities, while preserving already-encoded entities.
    16871698 *
    16881699 * {@internal Missing Long Description}}
    16891700 *
     
    17011712}
    17021713
    17031714/**
    1704  * Escape single quotes, specialchar double quotes, and fix line endings
     1715 * Escape single quotes, specialchar double quotes, and fix line endings.
    17051716 *
    17061717 * {@internal Missing Long Description}}
    17071718 *
     
    17171728        return apply_filters('js_escape', $safe_text, $text);
    17181729}
    17191730
    1720 // Escaping for HTML attributes
     1731/**
     1732 * Escaping for HTML attributes.
     1733 *
     1734 * @since unknown
     1735 *
     1736 * @param string $text
     1737 * @return string
     1738 */
    17211739function attribute_escape($text) {
    17221740        $safe_text = wp_specialchars($text, true);
    17231741        return apply_filters('attribute_escape', $safe_text, $text);
    17241742}
    17251743
    1726 // Escape a HTML tag name
     1744/**
     1745 * Escape a HTML tag name.
     1746 *
     1747 * @since unknown
     1748 *
     1749 * @param string $tag_name
     1750 * @return string
     1751 */
    17271752function tag_escape($tag_name) {
    17281753        $safe_tag = strtolower( preg_replace('[^a-zA-Z_:]', '', $tag_name) );
    17291754        return apply_filters('tag_escape', $safe_tag, $tag_name);
    17301755}
    17311756
    17321757/**
    1733  * Escapes text for SQL LIKE special characters % and _
     1758 * Escapes text for SQL LIKE special characters % and _.
    17341759 *
     1760 * @since unknown
     1761 *
    17351762 * @param string text the text to be escaped
    17361763 * @return string text, safe for inclusion in LIKE query
    17371764 */
     
    17391766        return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
    17401767}
    17411768
     1769/**
     1770 * {@internal Missing Short Description}}
     1771 *
     1772 * @since unknown
     1773 *
     1774 * @param string $link
     1775 * @return string
     1776 */
    17421777function wp_make_link_relative( $link ) {
    17431778        return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
    17441779}
     
    18351870        $array = apply_filters( 'wp_parse_str', $array );
    18361871}
    18371872
    1838 // Convert lone less than signs.  KSES already converts lone greater than signs.
     1873/**
     1874 * Convert lone less than signs.
     1875 *
     1876 * KSES already converts lone greater than signs.
     1877 *
     1878 * @since unknown
     1879 *
     1880 * @param string $text
     1881 * @return string
     1882 */
    18391883function wp_pre_kses_less_than( $text ) {
    18401884        return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
    18411885}
    18421886
     1887/**
     1888 * {@internal Missing Short Description}}
     1889 *
     1890 * @since unknown
     1891 *
     1892 * @param unknown_type $matches
     1893 * @return unknown
     1894 */
    18431895function wp_pre_kses_less_than_callback( $matches ) {
    18441896        if ( false === strpos($matches[0], '>') )
    18451897                return wp_specialchars($matches[0]);
     
    18471899}
    18481900
    18491901/**
    1850  * wp_sprintf() - sprintf() with filters
     1902 * WordPress implementation of PHP sprintf() with filters.
     1903 *
     1904 * @since unknown
     1905 *
     1906 * @param unknown_type $pattern
     1907 * @return unknown
    18511908 */
    18521909function wp_sprintf( $pattern ) {
    18531910        $args = func_get_args( );
     
    19021959}
    19031960
    19041961/**
    1905  * wp_sprintf_l - List specifier %l for wp_sprintf
     1962 * List specifier %l for wp_sprintf.
    19061963 *
     1964 * @since unknown
     1965 *
    19071966 * @param unknown_type $pattern
    19081967 * @param unknown_type $args
    19091968 * @return unknown
     
    19422001/**
    19432002 * Safely extracts not more than the first $count characters from html string
    19442003 *
    1945  * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* be
    1946  * counted as one character. For example &amp; will be counted as 4, &lt; as 3, etc.
     2004 * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
     2005 * be counted as one character. For example &amp; will be counted as 4, &lt; as
     2006 * 3, etc.
    19472007 *
    19482008 * @param integer $str String to get the excerpt from
    19492009 * @param integer $count Maximum number of characters to take
     
    19602020/**
    19612021 * Add a Base url to relative links in passed content.
    19622022 *
    1963  * By default it supports the 'src' and 'href' attributes,
    1964  * However this may be changed via the 3rd param.
     2023 * By default it supports the 'src' and 'href' attributes, However this may be
     2024 * changed via the 3rd param.
    19652025 *
    1966  * @package WordPress
    19672026 * @since 2.7
    19682027 *
    19692028 * @param string $content String to search for links in
    19702029 * @param string $base The base URL to prefix to links
    19712030 * @param array $attrs The attributes which should be processed.
    1972  * @eaturn string The processed content.
     2031 * @return string The processed content.
    19732032 */
    19742033function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
    19752034        $attrs = implode('|', (array)$attrs);
     
    19812040/**
    19822041 * Callback to add a base url to relative links in passed content.
    19832042 *
    1984  *
    1985  * @package WordPress
    19862043 * @since 2.7
     2044 * @access private
    19872045 *
    1988  * @internal
    19892046 * @param string $m The matched link
    19902047 * @param string $base The base URL to prefix to links
    1991  * @eaturn string The processed link
     2048 * @return string The processed link
    19922049 */
    19932050function _links_add_base($m, $base) {
    19942051        //1 = attribute name  2 = quotation mark  3 = URL
     
    20022059/**
    20032060 * Adds a Target attribute to all links in passed content.
    20042061 *
    2005  * This function by default only applies to <a> tags,
    2006  * however this can be modified by the 3rd param.
     2062 * This function by default only applies to <a> tags, however this can be
     2063 * modified by the 3rd param.
     2064 *
    20072065 * NOTE: Any current target attributed will be striped and replaced.
    20082066 *
    2009  * @package WordPress
    20102067 * @since 2.7
    20112068 *
    20122069 * @param string $content String to search for links in
    20132070 * @param string $target The Target to add to the links
    20142071 * @param array $tags An array of tags to apply to.
    2015  * @eaturn string The processed content.
     2072 * @return string The processed content.
    20162073 */
    20172074function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
    20182075        $tags = implode('|', (array)$tags);
     
    20212078                        $content);
    20222079}
    20232080/**
    2024  * Callback to add a target attribute to all links in passed content
     2081 * Callback to add a target attribute to all links in passed content.
    20252082 *
    2026  *
    2027  * @package WordPress
    20282083 * @since 2.7
     2084 * @access private
    20292085 *
    2030  * @internal
    20312086 * @param string $m The matched link
    20322087 * @param string $target The Target to add to the links
    2033  * @eaturn string The processed link.
     2088 * @return string The processed link.
    20342089 */
    20352090function _links_add_target( $m, $target ) {
    20362091        $tag = $m[1];