Make WordPress Core

Ticket #5638: formatting.phpdoc.r6597.diff

File formatting.phpdoc.r6597.diff, 28.8 KB (added by darkdragon, 16 years ago)

Incomplete documentation for formatting.php based off of r6597

  • formatting.php

     
    11<?php
     2/**
     3 *
     4 *
     5 * @package WordPress
     6 */
    27
     8/**
     9 * wptexturize() - {@internal Missing Short Description}}
     10 *
     11 * {@internal Missing Long Description}}
     12 *
     13 * @since 0.71
     14 *
     15 * @param unknown_type $text
     16 * @return unknown
     17 */
    318function wptexturize($text) {
    419        global $wp_cockneyreplace;
    520        $next = true;
     
    2439        $dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
    2540
    2641        for ( $i = 0; $i < $stop; $i++ ) {
    27                 $curl = $textarr[$i];
     42                $curl = $textarr[$i];
    2843
    2944                if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
    3045                        // static strings
     
    4156                $output .= $curl;
    4257        }
    4358
    44         return $output;
     59        return $output;
    4560}
    4661
    47 // Accepts matches array from preg_replace_callback in wpautop()
    48 // or a string
     62/**
     63 * clean_pre() - Accepts matches array from preg_replace_callback in wpautop() or a string
     64 *
     65 * {@internal Missing Long Description}}
     66 *
     67 * @since 1.2.0
     68 *
     69 * @param unknown_type $matches
     70 * @return unknown
     71 */
    4972function clean_pre($matches) {
    5073        if ( is_array($matches) )
    5174                $text = $matches[1] . $matches[2] . "</pre>";
     
    5982        return $text;
    6083}
    6184
     85/**
     86 * wpautop() - {@internal Missing Short Description}}
     87 *
     88 * {@internal Missing Long Description}}
     89 *
     90 * @since 0.71
     91 *
     92 * @param unknown_type $pee
     93 * @param unknown_type $br
     94 * @return unknown
     95 */
    6296function wpautop($pee, $br = 1) {
    6397        $pee = $pee . "\n"; // just to make things a little easier, pad the end
    6498        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
     
    92126        return $pee;
    93127}
    94128
    95 
     129/**
     130 * seems_utf8() - {@internal Missing Short Description}}
     131 *
     132 * {@internal Missing Long Description}}
     133 *
     134 * @since 1.2.1
     135 *
     136 * @param unknown_type $Str
     137 * @return unknown
     138 */
    96139function seems_utf8($Str) { # by bmorel at ssi dot fr
    97140        $length = strlen($Str);
    98141        for ($i=0; $i < $length; $i++) {
     
    111154        return true;
    112155}
    113156
     157/**
     158 * wp_specialchars() - {@internal Missing Short Description}}
     159 *
     160 * {@internal Missing Long Description}}
     161 *
     162 * @since 1.2.2
     163 *
     164 * @param unknown_type $text
     165 * @param unknown_type $quotes
     166 * @return unknown
     167 */
    114168function wp_specialchars( $text, $quotes = 0 ) {
    115169        // Like htmlspecialchars except don't double-encode HTML entities
    116170        $text = str_replace('&&', '&#038;&', $text);
     
    129183        return $text;
    130184}
    131185
     186/**
     187 * utf8_uri_encode() - {@internal Missing Short Description}}
     188 *
     189 * {@internal Missing Long Description}}
     190 *
     191 * @since 1.5.0
     192 *
     193 * @param unknown_type $utf8_string
     194 * @param unknown_type $length
     195 * @return unknown
     196 */
    132197function utf8_uri_encode( $utf8_string, $length = 0 ) {
    133198        $unicode = '';
    134199        $values = array();
     
    170235        return $unicode;
    171236}
    172237
     238/**
     239 * remove_accents() - {@internal Missing Short Description}}
     240 *
     241 * {@internal Missing Long Description}}
     242 *
     243 * @since 1.2.1
     244 *
     245 * @param unknown_type $string
     246 * @return unknown
     247 */
    173248function remove_accents($string) {
    174249        if ( !preg_match('/[\x80-\xff]/', $string) )
    175250                return $string;
     
    300375        return $string;
    301376}
    302377
     378/**
     379 * sanitize_file_name() - {@internal Missing Short Description}}
     380 *
     381 * {@internal Missing Long Description}}
     382 *
     383 * @since 2.1.0
     384 *
     385 * @param unknown_type $name
     386 * @return unknown
     387 */
    303388function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
    304389        $name = strtolower( $name );
    305390        $name = preg_replace('/&.+?;/', '', $name); // kill entities
     
    311396        return $name;
    312397}
    313398
     399/**
     400 * sanitize_user() - {@internal Missing Short Description}}
     401 *
     402 * {@internal Missing Long Description}}
     403 *
     404 * @since 2.0.0
     405 *
     406 * @param unknown_type $username
     407 * @param unknown_type $strict
     408 * @return unknown
     409 */
    314410function sanitize_user( $username, $strict = false ) {
    315411        $raw_username = $username;
    316412        $username = strip_tags($username);
     
    325421        return apply_filters('sanitize_user', $username, $raw_username, $strict);
    326422}
    327423
     424/**
     425 * sanitize_title() - {@internal Missing Short Description}}
     426 *
     427 * {@internal Missing Long Description}}
     428 *
     429 * @since 1.0.0
     430 *
     431 * @param unknown_type $title
     432 * @param unknown_type $fallback_title
     433 * @return unknown
     434 */
    328435function sanitize_title($title, $fallback_title = '') {
    329436        $title = strip_tags($title);
    330437        $title = apply_filters('sanitize_title', $title);
     
    335442        return $title;
    336443}
    337444
     445/**
     446 * sanitize_title_with_dashes() - {@internal Missing Short Description}}
     447 *
     448 * {@internal Missing Long Description}}
     449 *
     450 * @since 1.2.0
     451 *
     452 * @param unknown_type $title
     453 * @return unknown
     454 */
    338455function sanitize_title_with_dashes($title) {
    339456        $title = strip_tags($title);
    340457        // Preserve escaped octets.
     
    362479        return $title;
    363480}
    364481
     482/**
     483 * convert_chars() - {@internal Missing Short Description}}
     484 *
     485 * {@internal Missing Long Description}}
     486 *
     487 * @since 0.71
     488 *
     489 * @param unknown_type $content
     490 * @param string $deprecated Not used
     491 * @return string
     492 */
    365493function convert_chars($content, $deprecated = '') {
    366494        // Translation of invalid Unicode references range to valid range
    367495        $wp_htmltranswinuni = array(
     
    416544        return $content;
    417545}
    418546
     547/**
     548 * funky_javascript_fix() - {@internal Missing Short Description}}
     549 *
     550 * {@internal Missing Long Description}}
     551 *
     552 * @since 1.5.0
     553 *
     554 * @param unknown_type $text
     555 * @return unknown
     556 */
    419557function funky_javascript_fix($text) {
    420558        // Fixes for browsers' javascript bugs
    421559        global $is_macIE, $is_winIE;
     
    426564        return $text;
    427565}
    428566
     567/**
     568 * balanceTags() - {@internal Missing Short Description}}
     569 *
     570 * {@internal Missing Long Description}}
     571 *
     572 * @since 0.71
     573 *
     574 * @param string $text Text to be balanced
     575 * @param bool $force Forces balancing, ignoring the value of the option
     576 * @return string Balanced text
     577 */
    429578function balanceTags( $text, $force = false ) {
    430579        if ( !$force && get_option('use_balanceTags') == 0 )
    431580                return $text;
    432581        return force_balance_tags( $text );
    433582}
    434583
    435 /*
    436  force_balance_tags
    437 
    438  Balances Tags of string using a modified stack.
    439 
    440  @param text      Text to be balanced
    441  @param force     Forces balancing, ignoring the value of the option
    442  @return          Returns balanced text
    443  @author          Leonard Lin (leonard@acm.org)
    444  @version         v1.1
    445  @date            November 4, 2001
    446  @license         GPL v2.0
    447  @notes
    448  @changelog
    449  ---  Modified by Scott Reilly (coffee2code) 02 Aug 2004
    450         1.2  ***TODO*** Make better - change loop condition to $text
    451         1.1  Fixed handling of append/stack pop order of end text
    452              Added Cleaning Hooks
    453         1.0  First Version
    454 */
     584/**
     585 * force_balance_tags() - Balances tags of string using a modified stack.
     586 *
     587 * {@internal Missing Long Description}}
     588 *
     589 * @since 2.0.4
     590 *
     591 * @author Leonard Lin <leonard@acm.org>
     592 * @license GPL v2.0
     593 * @date November 4, 2001
     594 * @version 1.1
     595 * @todo Make better - change loop condition to $text in 1.2
     596 * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
     597 *              1.1  Fixed handling of append/stack pop order of end text
     598 *                       Added Cleaning Hooks
     599 *              1.0  First Version
     600 *
     601 * @param string $text Text to be balanced
     602 * @return string Balanced text
     603 */
    455604function force_balance_tags( $text ) {
    456605        $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
    457606        $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
     
    551700        return $newtext;
    552701}
    553702
     703/**
     704 * format_to_edit() - {@internal Missing Short Description}}
     705 *
     706 * {@internal Missing Long Description}}
     707 *
     708 * @since 0.71
     709 *
     710 * @param unknown_type $content
     711 * @param unknown_type $richedit
     712 * @return unknown
     713 */
    554714function format_to_edit($content, $richedit = false) {
    555715        $content = apply_filters('format_to_edit', $content);
    556716        if (! $richedit )
     
    558718        return $content;
    559719}
    560720
     721/**
     722 * format_to_post() - {@internal Missing Short Description}}
     723 *
     724 * {@internal Missing Long Description}}
     725 *
     726 * @since 0.71
     727 *
     728 * @param unknown_type $content
     729 * @return unknown
     730 */
    561731function format_to_post($content) {
    562732        $content = apply_filters('format_to_post', $content);
    563733        return $content;
    564734}
    565735
    566 function zeroise($number,$threshold) { // function to add leading zeros when necessary
     736/**
     737 * zeroise() - Add leading zeros when necessary
     738 *
     739 * {@internal Missing Long Description}}
     740 *
     741 * @since 0.71
     742 *
     743 * @param mixed $number Will convert to string and add zeros
     744 * @param int $threshold Amount of digits
     745 * @return string Adds leading zeros to number if needed
     746 */
     747function zeroise($number,$threshold) {
    567748        return sprintf('%0'.$threshold.'s', $number);
    568749}
    569750
    570 
     751/**
     752 * backslashit() - {@internal Missing Short Description}}
     753 *
     754 * {@internal Missing Long Description}}
     755 *
     756 * @since 0.71
     757 *
     758 * @param unknown_type $string
     759 * @return unknown
     760 */
    571761function backslashit($string) {
    572762        $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
    573763        $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
    574764        return $string;
    575765}
    576766
     767/**
     768 * trailingslashit() - Appends a trailing slash
     769 *
     770 * Will remove trailing slash if it exists already before adding
     771 * a trailing slash. This prevents double slashing a string or
     772 * path.
     773 *
     774 * The primary use of this is for paths and thus should be used
     775 * for paths. It is not restricted to paths and offers no specific
     776 * path support.
     777 *
     778 * @since 1.2.0
     779 * @uses untrailingslashit() Unslashes string if it was slashed already
     780 *
     781 * @param string $string What to add the trailing slash to
     782 * @return string String with trailing slash added
     783 */
    577784function trailingslashit($string) {
    578785        return untrailingslashit($string) . '/';
    579786}
    580787
     788/**
     789 * untrailingslashit() - Removes trailing slash if it exists
     790 *
     791 * The primary use of this is for paths and thus should be used
     792 * for paths. It is not restricted to paths and offers no specific
     793 * path support.
     794 *
     795 * @since 2.2.0
     796 *
     797 * @param string $string What to remove the trailing slash from
     798 * @return string String without the trailing slash
     799 */
    581800function untrailingslashit($string) {
    582801        return rtrim($string, '/');
    583802}
    584803
     804/**
     805 * addslashes_gpc() - {@internal Missing Short Description}}
     806 *
     807 * {@internal Missing Long Description}}
     808 *
     809 * @since 0.71
     810 *
     811 * @param unknown_type $gpc
     812 * @return unknown
     813 */
    585814function addslashes_gpc($gpc) {
    586815        global $wpdb;
    587816
     
    592821        return $wpdb->escape($gpc);
    593822}
    594823
    595 
     824/**
     825 * stripslashes_deep() - {@internal Missing Short Description}}
     826 *
     827 * {@internal Missing Long Description}}
     828 *
     829 * @since 2.0.0
     830 *
     831 * @param unknown_type $value
     832 * @return unknown
     833 */
    596834function stripslashes_deep($value) {
    597          $value = is_array($value) ?
    598                  array_map('stripslashes_deep', $value) :
    599                  stripslashes($value);
    600 
    601          return $value;
     835        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
     836        return $value;
    602837}
    603838
     839/**
     840 * urlencode_deep() - {@internal Missing Short Description}}
     841 *
     842 * {@internal Missing Long Description}}
     843 *
     844 * @since 2.2.0
     845 *
     846 * @param unknown_type $value
     847 * @return unknown
     848 */
    604849function urlencode_deep($value) {
    605          $value = is_array($value) ?
    606                  array_map('urlencode_deep', $value) :
    607                  urlencode($value);
    608 
    609          return $value;
     850        $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
     851        return $value;
    610852}
    611853
     854/**
     855 * antispambot() - {@internal Missing Short Description}}
     856 *
     857 * {@internal Missing Long Description}}
     858 *
     859 * @since 0.71
     860 *
     861 * @param unknown_type $emailaddy
     862 * @param unknown_type $mailto
     863 * @return unknown
     864 */
    612865function antispambot($emailaddy, $mailto=0) {
    613866        $emailNOSPAMaddy = '';
    614867        srand ((float) microtime() * 1000000);
     
    626879        return $emailNOSPAMaddy;
    627880}
    628881
     882/**
     883 * _make_url_clickable_cb() - {@internal Missing Short Description}}
     884 *
     885 * {@internal Missing Long Description}}
     886 *
     887 * @since 2.5
     888 * @access private
     889 *
     890 * @param unknown_type $matches
     891 * @return unknown
     892 */
    629893function _make_url_clickable_cb($matches) {
    630894        $url = $matches[2];
    631895        $url = clean_url($url);
     
    634898        return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>";
    635899}
    636900
     901/**
     902 * _make_web_ftp_clickable_cb() - {@internal Missing Short Description}}
     903 *
     904 * {@internal Missing Long Description}}
     905 *
     906 * @since 2.5
     907 * @access private
     908 *
     909 * @param unknown_type $matches
     910 * @return unknown
     911 */
    637912function _make_web_ftp_clickable_cb($matches) {
    638913        $dest = $matches[2];
    639914        $dest = 'http://' . $dest;
     
    644919        return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>";
    645920}
    646921
     922/**
     923 * _make_email_clickable_cb() - {@internal Missing Short Description}}
     924 *
     925 * {@internal Missing Long Description}}
     926 *
     927 * @since 2.5
     928 * @access private
     929 *
     930 * @param unknown_type $matches
     931 * @return unknown
     932 */
    647933function _make_email_clickable_cb($matches) {
    648934        $email = $matches[2] . '@' . $matches[3];
    649935        return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
    650936}
    651937
     938/**
     939 * make_clickable() - {@internal Missing Short Description}}
     940 *
     941 * {@internal Missing Long Description}}
     942 *
     943 * @since 0.71
     944 *
     945 * @param unknown_type $ret
     946 * @return unknown
     947 */
    652948function make_clickable($ret) {
    653949        $ret = ' ' . $ret;
    654950        // in testing, using arrays here was found to be faster
     
    661957        return $ret;
    662958}
    663959
     960/**
     961 * wp_rel_nofollow() - {@internal Missing Short Description}}
     962 *
     963 * {@internal Missing Long Description}}
     964 *
     965 * @since 1.5.0
     966 *
     967 * @param unknown_type $text
     968 * @return unknown
     969 */
    664970function wp_rel_nofollow( $text ) {
    665971        global $wpdb;
    666972        // This is a pre save filter, so text is already escaped.
     
    670976        return $text;
    671977}
    672978
     979/**
     980 * wp_rel_nofollow_callback() - {@internal Missing Short Description}}
     981 *
     982 * {@internal Missing Long Description}}
     983 *
     984 * @since 2.3.0
     985 *
     986 * @param unknown_type $matches
     987 * @return unknown
     988 */
    673989function wp_rel_nofollow_callback( $matches ) {
    674990        $text = $matches[1];
    675991        $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
    676992        return "<a $text rel=\"nofollow\">";
    677993}
    678994
     995/**
     996 * convert_smilies() - {@internal Missing Short Description}}
     997 *
     998 * {@internal Missing Long Description}}
     999 *
     1000 * @since 0.71
     1001 *
     1002 * @param unknown_type $text
     1003 * @return unknown
     1004 */
    6791005function convert_smilies($text) {
    6801006        global $wp_smiliessearch, $wp_smiliesreplace;
    681     $output = '';
     1007        $output = '';
    6821008        if ( get_option('use_smilies') && !empty($wp_smiliessearch) && !empty($wp_smiliesreplace) ) {
    6831009                // HTML loop taken from texturize function, could possible be consolidated
    6841010                $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
     
    6971023        return $output;
    6981024}
    6991025
    700 
     1026/**
     1027 * is_email() - {@internal Missing Short Description}}
     1028 *
     1029 * {@internal Missing Long Description}}
     1030 *
     1031 * @since 0.71
     1032 *
     1033 * @param unknown_type $user_email
     1034 * @return unknown
     1035 */
    7011036function is_email($user_email) {
    7021037        $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
    7031038        if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) {
     
    7111046        }
    7121047}
    7131048
    714 // used by wp-mail to handle charsets in email subjects
     1049/**
     1050 * wp_iso_descrambler() - {@internal Missing Short Description}}
     1051 *
     1052 * {@internal Missing Long Description}}
     1053 *
     1054 * @since 1.2.0
     1055 * @usedby wp_mail() handles charsets in email subjects
     1056 *
     1057 * @param unknown_type $string
     1058 * @return unknown
     1059 */
    7151060function wp_iso_descrambler($string) {
    716   /* this may only work with iso-8859-1, I'm afraid */
    717   if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
    718     return $string;
    719   } else {
    720     $subject = str_replace('_', ' ', $matches[2]);
    721     $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
    722     return $subject;
    723   }
     1061        /* this may only work with iso-8859-1, I'm afraid */
     1062        if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
     1063                return $string;
     1064        } else {
     1065                $subject = str_replace('_', ' ', $matches[2]);
     1066                $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
     1067                return $subject;
     1068        }
    7241069}
    7251070
    726 
    727 // give it a date, it will give you the same date as GMT
     1071/**
     1072 * get_gmt_from_date() - Give it a date, it will give you the same date as GMT
     1073 *
     1074 * {@internal Missing Long Description}}
     1075 *
     1076 * @since 1.2.0
     1077 *
     1078 * @param unknown_type $string
     1079 * @return unknown
     1080 */
    7281081function get_gmt_from_date($string) {
    729   // note: this only substracts $time_difference from the given date
    730   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);
    731   $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
    732   $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
    733   return $string_gmt;
     1082        // note: this only substracts $time_difference from the given date
     1083        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);
     1084        $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
     1085        $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
     1086        return $string_gmt;
    7341087}
    7351088
    736 // give it a GMT date, it will give you the same date with $time_difference added
     1089/**
     1090 * get_date_from_gmt() - Give it a GMT date, it will give you the same date with $time_difference added
     1091 *
     1092 * {@internal Missing Long Description}}
     1093 *
     1094 * @since 1.2.0
     1095 *
     1096 * @param unknown_type $string
     1097 * @return unknown
     1098 */
    7371099function get_date_from_gmt($string) {
    738   // note: this only adds $time_difference to the given date
    739   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);
    740   $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
    741   $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
    742   return $string_localtime;
     1100        // note: this only adds $time_difference to the given date
     1101        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);
     1102        $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
     1103        $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
     1104        return $string_localtime;
    7431105}
    7441106
    745 // computes an offset in seconds from an iso8601 timezone
     1107/**
     1108 * iso8601_timezone_to_offset() - Computes an offset in seconds from an iso8601 timezone
     1109 *
     1110 * {@internal Missing Long Description}}
     1111 *
     1112 * @since 1.5.0
     1113 *
     1114 * @param unknown_type $timezone
     1115 * @return unknown
     1116 */
    7461117function iso8601_timezone_to_offset($timezone) {
    747   // $timezone is either 'Z' or '[+|-]hhmm'
    748   if ($timezone == 'Z') {
    749     $offset = 0;
    750   } else {
    751     $sign    = (substr($timezone, 0, 1) == '+') ? 1 : -1;
    752     $hours   = intval(substr($timezone, 1, 2));
    753     $minutes = intval(substr($timezone, 3, 4)) / 60;
    754     $offset  = $sign * 3600 * ($hours + $minutes);
    755   }
    756   return $offset;
     1118        // $timezone is either 'Z' or '[+|-]hhmm'
     1119        if ($timezone == 'Z') {
     1120                $offset = 0;
     1121        } else {
     1122                $sign    = (substr($timezone, 0, 1) == '+') ? 1 : -1;
     1123                $hours   = intval(substr($timezone, 1, 2));
     1124                $minutes = intval(substr($timezone, 3, 4)) / 60;
     1125                $offset  = $sign * 3600 * ($hours + $minutes);
     1126        }
     1127        return $offset;
    7571128}
    7581129
    759 // converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
     1130/**
     1131 * iso8601_to_datetime() - Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]
     1132 *
     1133 * {@internal Missing Long Description}}
     1134 *
     1135 * @since 1.5.0
     1136 *
     1137 * @param unknown_type $date_string
     1138 * @param unknown_type $timezone
     1139 * @return unknown
     1140 */
    7601141function iso8601_to_datetime($date_string, $timezone = USER) {
    761   if ($timezone == GMT) {
    762     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);
    763     if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
    764       $offset = iso8601_timezone_to_offset($date_bits[7]);
    765     } else { // we don't have a timezone, so we assume user local timezone (not server's!)
    766       $offset = 3600 * get_option('gmt_offset');
    767     }
    768     $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
    769     $timestamp -= $offset;
    770     return gmdate('Y-m-d H:i:s', $timestamp);
    771   } elseif ($timezone == USER) {
    772     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);
    773   }
     1142        if ($timezone == GMT) {
     1143
     1144                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);
     1145
     1146                if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
     1147                        $offset = iso8601_timezone_to_offset($date_bits[7]);
     1148                } else { // we don't have a timezone, so we assume user local timezone (not server's!)
     1149                        $offset = 3600 * get_option('gmt_offset');
     1150                }
     1151
     1152                $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
     1153                $timestamp -= $offset;
     1154
     1155                return gmdate('Y-m-d H:i:s', $timestamp);
     1156
     1157        } else if ($timezone == USER) {
     1158                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);
     1159        }
    7741160}
    7751161
     1162/**
     1163 * popuplinks() - Adds a element attributes to open links in new windows
     1164 *
     1165 * Comment text in popup windows should be filtered through this. Right
     1166 * now it's a moderately dumb function, ideally it would detect whether
     1167 * a target or rel attribute was already there and adjust its actions
     1168 * accordingly.
     1169 *
     1170 * @since 0.71
     1171 *
     1172 * @param string $text Content to replace links to open in a new window
     1173 * @return string Content that has filtered links
     1174 */
    7761175function popuplinks($text) {
    777         // Comment text in popup windows should be filtered through this.
    778         // Right now it's a moderately dumb function, ideally it would detect whether
    779         // a target or rel attribute was already there and adjust its actions accordingly.
    7801176        $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
    7811177        return $text;
    7821178}
    7831179
     1180/**
     1181 * sanitize_email() - Strips out all characters that are not allowable in an email
     1182 *
     1183 * @since 1.5.0
     1184 *
     1185 * @param string $email Email address to filter
     1186 * @return string Filtered email address
     1187 */
    7841188function sanitize_email($email) {
    7851189        return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
    7861190}
    7871191
     1192/**
     1193 * human_time_diff() - {@internal Missing Short Description}}
     1194 *
     1195 * {@internal Missing Long Description}}
     1196 *
     1197 * @since 1.5.0
     1198 *
     1199 * @param unknown_type $from
     1200 * @param unknown_type $to
     1201 * @return unknown
     1202 */
    7881203function human_time_diff( $from, $to = '' ) {
    7891204        if ( empty($to) )
    7901205                $to = time();
     
    8111226        return $since;
    8121227}
    8131228
     1229/**
     1230 * wp_trim_excerpt() - {@internal Missing Short Description}}
     1231 *
     1232 * {@internal Missing Long Description}}
     1233 *
     1234 * @since 1.5.0
     1235 *
     1236 * @param unknown_type $text
     1237 * @return unknown
     1238 */
    8141239function wp_trim_excerpt($text) { // Fakes an excerpt if needed
    8151240        if ( '' == $text ) {
    8161241                $text = get_the_content('');
     
    8281253        return $text;
    8291254}
    8301255
     1256/**
     1257 * ent2ncr() - {@internal Missing Short Description}}
     1258 *
     1259 * {@internal Missing Long Description}}
     1260 *
     1261 * @since 1.5.1
     1262 *
     1263 * @param unknown_type $text
     1264 * @return unknown
     1265 */
    8311266function ent2ncr($text) {
    8321267        $to_ncr = array(
    8331268                '&quot;' => '&#34;',
     
    10921527        return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
    10931528}
    10941529
     1530/**
     1531 * wp_richedit_pre() - {@internal Missing Short Description}}
     1532 *
     1533 * {@internal Missing Long Description}}
     1534 *
     1535 * @since 2.0.0
     1536 *
     1537 * @param unknown_type $text
     1538 * @return unknown
     1539 */
    10951540function wp_richedit_pre($text) {
    10961541        // Filtering a blank results in an annoying <br />\n
    10971542        if ( empty($text) ) return apply_filters('richedit_pre', '');
     
    11071552        return apply_filters('richedit_pre', $output);
    11081553}
    11091554
     1555/**
     1556 * clean_url() - {@internal Missing Short Description}}
     1557 *
     1558 * {@internal Missing Long Description}}
     1559 *
     1560 * @since 1.2.0
     1561 *
     1562 * @param unknown_type $url
     1563 * @param unknown_type $protocols
     1564 * @param unknown_type $context
     1565 * @return unknown
     1566 */
    11101567function clean_url( $url, $protocols = null, $context = 'display' ) {
    11111568        $original_url = $url;
    11121569
     
    11181575        /* If the URL doesn't appear to contain a scheme, we
    11191576         * presume it needs http:// appended (unless a relative
    11201577         * link starting with / or a php file).
    1121         */
     1578         */
    11221579        if ( strpos($url, ':') === false &&
    11231580                substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
    11241581                $url = 'http://' . $url;
     
    11351592        return apply_filters('clean_url', $url, $original_url, $context);
    11361593}
    11371594
     1595/**
     1596 * sanitize_url() - {@internal Missing Short Description}}
     1597 *
     1598 * {@internal Missing Long Description}}
     1599 *
     1600 * @since 2.3.1
     1601 *
     1602 * @param unknown_type $url
     1603 * @param unknown_type $protocols
     1604 * @return unknown
     1605 */
    11381606function sanitize_url( $url, $protocols = null ) {
    1139         return clean_url( $url, $protocols, 'db');
     1607        return clean_url( $url, $protocols, 'db' );
    11401608}
    11411609
    1142 // Borrowed from the PHP Manual user notes. Convert entities, while
    1143 // preserving already-encoded entities:
     1610/**
     1611 * htmlentities2() - Convert entities, while preserving already-encoded entities
     1612 *
     1613 * {@internal Missing Long Description}}
     1614 *
     1615 * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
     1616 *
     1617 * @since 1.2.2
     1618 *
     1619 * @param unknown_type $myHTML
     1620 * @return unknown
     1621 */
    11441622function htmlentities2($myHTML) {
    1145         $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
     1623        $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
    11461624        $translation_table[chr(38)] = '&';
    1147         return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($myHTML, $translation_table));
     1625        return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr($myHTML, $translation_table) );
    11481626}
    11491627
    1150 // Escape single quotes, specialchar double quotes, and fix line endings.
     1628/**
     1629 * js_escape() - Escape single quotes, specialchar double quotes, and fix line endings
     1630 *
     1631 * {@internal Missing Long Description}}
     1632 *
     1633 * @since 2.0.4
     1634 *
     1635 * @param string $text
     1636 * @return unknown
     1637 */
    11511638function js_escape($text) {
    11521639        $safe_text = wp_specialchars($text, 'double');
    11531640        $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
     
    11551642        return apply_filters('js_escape', $safe_text, $text);
    11561643}
    11571644
    1158 // Escaping for HTML attributes
     1645/**
     1646 * attribute_escape() - Escaping for HTML attributes
     1647 *
     1648 * {@internal Missing Long Description}}
     1649 *
     1650 * @since 2.0.6
     1651 *
     1652 * @param unknown_type $text
     1653 * @return unknown
     1654 */
    11591655function attribute_escape($text) {
    11601656        $safe_text = wp_specialchars($text, true);
    11611657        return apply_filters('attribute_escape', $safe_text, $text);
    11621658}
    11631659
     1660/**
     1661 * wp_make_link_relative() - {@internal Missing Short Description}}
     1662 *
     1663 * {@internal Missing Long Description}}
     1664 *
     1665 * @since 2.1.0
     1666 *
     1667 * @param unknown_type $link
     1668 * @return unknown
     1669 */
    11641670function wp_make_link_relative( $link ) {
    1165         return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
     1671        return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );
    11661672}
    11671673
    1168 function sanitize_option($option, $value) { // Remember to call stripslashes!
     1674/**
     1675 * sanitize_option() - {@internal Missing Short Description}}
     1676 *
     1677 * {@internal Missing Long Description}}
     1678 * Remember to call stripslashes!
     1679 *
     1680 * @since 2.0.5
     1681 *
     1682 * @param unknown_type $option
     1683 * @param unknown_type $value
     1684 * @return unknown
     1685 */
     1686function sanitize_option($option, $value) {
    11691687
    11701688        switch ($option) {
    11711689                case 'admin_email':
     
    12391757        return $value;
    12401758}
    12411759
     1760/**
     1761 * wp_parse_str() - {@internal Missing Short Description}}
     1762 *
     1763 * {@internal Missing Long Description}}
     1764 *
     1765 * @since 2.2.1
     1766 * @uses apply_filters()
     1767 *
     1768 * @param string $string
     1769 * @param array $array
     1770 */
    12421771function wp_parse_str( $string, &$array ) {
    12431772        parse_str( $string, $array );
    12441773        if ( get_magic_quotes_gpc() )
     
    12461775        $array = apply_filters( 'wp_parse_str', $array );
    12471776}
    12481777
    1249 // Convert lone less than signs.  KSES already converts lone greater than signs.
     1778/**
     1779 * wp_pre_kses_less_than() - Convert lone less than signs.
     1780 *
     1781 * KSES already converts lone greater than signs.
     1782 * {@internal Missing Long Description}}
     1783 *
     1784 * @since 2.3.0
     1785 *
     1786 * @param string $text
     1787 * @return unknown
     1788 */
    12501789function wp_pre_kses_less_than( $text ) {
    12511790        return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
    12521791}
    12531792
     1793/**
     1794 * wp_pre_kses_less_than_callback() - {@internal Missing Short Description}}
     1795 *
     1796 * {@internal Missing Long Description}}
     1797 *
     1798 * @since 2.3.0
     1799 *
     1800 * @param unknown_type $matches
     1801 * @return unknown
     1802 */
    12541803function wp_pre_kses_less_than_callback( $matches ) {
    12551804        if ( false === strpos($matches[0], '>') )
    12561805                return wp_specialchars($matches[0]);
    12571806        return $matches[0];
    12581807}
    12591808
    1260 ?>
     1809?>
     1810 No newline at end of file