Changeset 4495 for trunk/wp-includes/formatting.php
- Timestamp:
- 11/19/2006 07:56:05 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/formatting.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r4451 r4495 66 66 $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 67 67 // Space things out a little 68 $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee); 68 $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee); 69 69 $pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n\n", $pee); 70 $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines 70 $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines 71 71 $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates 72 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end 73 $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 72 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end 73 $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 74 74 $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag 75 75 $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists … … 77 77 $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); 78 78 $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee); 79 $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); 79 $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); 80 80 if ($br) { 81 81 $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee); … … 87 87 $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee); 88 88 89 return $pee; 89 return $pee; 90 90 } 91 91 … … 127 127 128 128 function utf8_uri_encode( $utf8_string ) { 129 $unicode = ''; 130 $values = array(); 131 $num_octets = 1; 132 133 for ($i = 0; $i < strlen( $utf8_string ); $i++ ) { 134 135 $value = ord( $utf8_string[ $i ] ); 136 137 if ( $value < 128 ) { 138 $unicode .= chr($value); 139 } else { 140 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3; 141 142 $values[] = $value; 143 144 if ( count( $values ) == $num_octets ) { 145 if ($num_octets == 3) { 146 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); 147 } else { 148 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); 149 } 150 129 $unicode = ''; 151 130 $values = array(); 152 131 $num_octets = 1; 153 } 154 } 155 } 156 157 return $unicode; 132 133 for ($i = 0; $i < strlen( $utf8_string ); $i++ ) { 134 135 $value = ord( $utf8_string[ $i ] ); 136 137 if ( $value < 128 ) { 138 $unicode .= chr($value); 139 } else { 140 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3; 141 142 $values[] = $value; 143 144 if ( count( $values ) == $num_octets ) { 145 if ($num_octets == 3) { 146 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); 147 } else { 148 $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); 149 } 150 151 $values = array(); 152 $num_octets = 1; 153 } 154 } 155 } 156 157 return $unicode; 158 158 } 159 159 … … 340 340 } 341 341 342 function convert_chars($content, $flag = 'obsolete') { 342 function convert_chars($content, $flag = 'obsolete') { 343 343 // Translation of invalid Unicode references range to valid range 344 344 $wp_htmltranswinuni = array( … … 406 406 /* 407 407 balanceTags 408 408 409 409 Balances Tags of string using a modified stack. 410 410 411 411 @param text Text to be balanced 412 412 @return Returns balanced text … … 415 415 @date November 4, 2001 416 416 @license GPL v2.0 417 @notes 418 @changelog 417 @notes 418 @changelog 419 419 --- Modified by Scott Reilly (coffee2code) 02 Aug 2004 420 1.2 ***TODO*** Make better - change loop condition to $text421 1.1 Fixed handling of append/stack pop order of end text422 Added Cleaning Hooks423 1.0 First Version420 1.2 ***TODO*** Make better - change loop condition to $text 421 1.1 Fixed handling of append/stack pop order of end text 422 Added Cleaning Hooks 423 1.0 First Version 424 424 */ 425 425 function balanceTags($text, $is_comment = 0, $force = false) { … … 447 447 $tag = strtolower(substr($regex[1],1)); 448 448 // if too many closing tags 449 if($stacksize <= 0) { 449 if($stacksize <= 0) { 450 450 $tag = ''; 451 451 //or close to be safe $tag = '/' . $tag; … … 504 504 $newtext .= substr($text,0,$i) . $tag; 505 505 $text = substr($text,$i+$l); 506 } 506 } 507 507 508 508 // Clear Tag Queue … … 553 553 554 554 function trailingslashit($string) { 555 if ( '/' != substr($string, -1)) {556 $string .= '/';557 }558 return $string;555 if ( '/' != substr($string, -1)) { 556 $string .= '/'; 557 } 558 return $string; 559 559 } 560 560 … … 572 572 function stripslashes_deep($value) 573 573 { 574 $value = is_array($value) ?575 array_map('stripslashes_deep', $value) :576 stripslashes($value);577 578 return $value;574 $value = is_array($value) ? 575 array_map('stripslashes_deep', $value) : 576 stripslashes($value); 577 578 return $value; 579 579 } 580 580 … … 732 732 } 733 733 734 function human_time_diff( $from, $to = '' ) { 734 function human_time_diff( $from, $to = '' ) { 735 735 if ( empty($to) ) 736 736 $to = time(); … … 746 746 if ($hours <= 1) 747 747 $since = __('1 hour'); 748 else 748 else 749 749 $since = sprintf( __('%s hours'), $hours ); 750 750 } elseif ($diff >= 86400) {
Note: See TracChangeset
for help on using the changeset viewer.