Changes from branches/3.1/wp-includes/formatting.php at r18031 to trunk/wp-includes/formatting.php at r18159
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r18031 r18159 29 29 function wptexturize($text) { 30 30 global $wp_cockneyreplace; 31 static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 32 $output = ''; 33 $curl = ''; 34 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 35 $stop = count($textarr); 36 37 // No need to set up these variables more than once 38 if (!$static_setup) { 31 static $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 32 33 // No need to set up these static variables more than once 34 if ( empty( $opening_quote ) ) { 39 35 /* translators: opening curly quote */ 40 36 $opening_quote = _x('“', 'opening curly quote'); … … 59 55 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); 60 56 $dynamic_replacements = array('’$1','’$1', '$1‘', '$1″', '$1′', '$1’$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '’$1', '$1×$2'); 61 62 $static_setup = true;63 57 } 64 58 … … 71 65 $no_texturize_shortcodes_stack = array(); 72 66 73 for ( $i = 0; $i < $stop; $i++ ) { 74 $curl = $textarr[$i]; 75 76 if ( !empty($curl) && '<' != $curl[0] && '[' != $curl[0] 77 && empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) { 78 // This is not a tag, nor is the texturization disabled 79 // static strings 67 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 68 69 foreach ( $textarr as &$curl ) { 70 if ( empty( $curl ) ) 71 continue; 72 73 // Only call _wptexturize_pushpop_element if first char is correct tag opening 74 $first = $curl[0]; 75 if ( '<' === $first ) { 76 _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>'); 77 } elseif ( '[' === $first ) { 78 _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); 79 } elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) { 80 // This is not a tag, nor is the texturization disabled static strings 80 81 $curl = str_replace($static_characters, $static_replacements, $curl); 81 82 // regular expressions 82 83 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 83 } elseif (!empty($curl)) {84 /*85 * Only call _wptexturize_pushpop_element if first char is correct86 * tag opening87 */88 if ('<' == $curl[0])89 _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');90 elseif ('[' == $curl[0])91 _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');92 84 } 93 94 85 $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); 95 $output .= $curl; 96 } 97 98 return $output; 86 } 87 return implode( '', $textarr ); 99 88 } 100 89 … … 574 563 chr(195).chr(178) => 'o', chr(195).chr(179) => 'o', 575 564 chr(195).chr(180) => 'o', chr(195).chr(181) => 'o', 576 chr(195).chr(182) => 'o', chr(195).chr(18 2) => 'o',565 chr(195).chr(182) => 'o', chr(195).chr(184) => 'o', 577 566 chr(195).chr(185) => 'u', chr(195).chr(186) => 'u', 578 567 chr(195).chr(187) => 'u', chr(195).chr(188) => 'u', … … 877 866 * Santizes a html classname to ensure it only contains valid characters 878 867 * 879 * Strips the string down to A-Z,a-z,0-9, '-' if this results in an empty868 * Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty 880 869 * string then it will return the alternative value supplied. 881 870 * … … 891 880 function sanitize_html_class( $class, $fallback = '' ) { 892 881 //Strip out any % encoded octets 893 $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class);894 895 //Limit to A-Z,a-z,0-9, '-'896 $sanitized = preg_replace( '/[^A-Za-z0-9-]/', '', $sanitized);882 $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class ); 883 884 //Limit to A-Z,a-z,0-9,_,- 885 $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); 897 886 898 887 if ( '' == $sanitized ) … … 1239 1228 * @since 2.0.0 1240 1229 * 1241 * @param array|string $value The array or string to be strip ed.1230 * @param array|string $value The array or string to be stripped. 1242 1231 * @return array|string Stripped array (or string in the callback). 1243 1232 */ … … 1600 1589 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the 1601 1590 * value of the 'gmt_offset' option. Return format can be overridden using the 1602 * $format parameter. If PHP5 is supported, the function uses the DateTime and1603 * DateTimeZone objects to respecttime zone differences in DST.1591 * $format parameter. The DateTime and DateTimeZone classes are used to respect 1592 * time zone differences in DST. 1604 1593 * 1605 1594 * @since 1.2.0 … … 1613 1602 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); 1614 1603 $tz = get_option('timezone_string'); 1615 if( class_exists('DateTime') && $tz ) { 1616 //PHP5 1604 if ( $tz ) { 1617 1605 date_default_timezone_set( $tz ); 1618 1606 $datetime = new DateTime( $string ); … … 1623 1611 1624 1612 date_default_timezone_set('UTC'); 1625 } 1626 else { 1627 //PHP4 1613 } else { 1628 1614 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 1629 1615 $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600); … … 2679 2665 // Translate and filter the delimiter set (avoid ampersands and entities here) 2680 2666 $l = apply_filters('wp_sprintf_l', array( 2681 /* translators: used between list items, there is a space after the com a */2667 /* translators: used between list items, there is a space after the comma */ 2682 2668 'between' => __(', '), 2683 2669 /* translators: used between list items, there is a space after the and */ … … 2770 2756 * modified by the 3rd param. 2771 2757 * 2772 * <b>NOTE:</b> Any current target attributed will be strip ed and replaced.2758 * <b>NOTE:</b> Any current target attributed will be stripped and replaced. 2773 2759 * 2774 2760 * @since 2.7.0
Note: See TracChangeset
for help on using the changeset viewer.