Ticket #29573: 29573.4.patch
File 29573.4.patch, 5.0 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/post.php
1205 1205 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; 1206 1206 } 1207 1207 } else { 1208 if ( function_exists( 'mb_strlen' ) &&mb_strlen( $post_name ) > 30 ) {1208 if ( mb_strlen( $post_name ) > 30 ) { 1209 1209 $post_name_abridged = mb_substr( $post_name, 0, 14 ) . '…' . mb_substr( $post_name, -14 ); 1210 } elseif ( strlen( $post_name ) > 30 ) {1211 $post_name_abridged = substr( $post_name, 0, 14 ) . '…' . substr( $post_name, -14 );1212 1210 } else { 1213 1211 $post_name_abridged = $post_name; 1214 1212 } -
src/wp-includes/compat.php
13 13 } 14 14 } 15 15 16 if ( ! function_exists('mb_substr') ):17 function mb_substr( $str, $start, $length =null, $encoding=null ) {18 return _mb_substr( $str, $start, $length, $encoding);16 if ( ! function_exists( 'mb_substr' ) ) : 17 function mb_substr( $str, $start, $length = null, $encoding = null ) { 18 return _mb_substr( $str, $start, $length, $encoding ); 19 19 } 20 20 endif; 21 21 22 function _mb_substr( $str, $start, $length =null, $encoding=null ) {23 // the solution below, works only for utf-8, so in case of a different24 // charset, just use built-in substr22 function _mb_substr( $str, $start, $length = null, $encoding = null ) { 23 // The solution below works only for UTF-8, 24 // so in case of a different charset just use built-in substr() 25 25 $charset = get_option( 'blog_charset' ); 26 if ( ! in_array( $charset, array('utf8', 'utf-8', 'UTF8', 'UTF-8') ) ) {27 return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length);26 if ( ! in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 27 return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length ); 28 28 } 29 // use the regex unicode support to separate the UTF-8 characters into an array29 // Use the regex unicode support to separate the UTF-8 characters into an array 30 30 preg_match_all( '/./us', $str, $match ); 31 $chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );31 $chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); 32 32 return implode( '', $chars ); 33 33 } 34 34 35 if ( ! function_exists( 'mb_strlen' ) ) : 36 function mb_strlen( $str, $encoding = null ) { 37 return _mb_strlen( $str, $encoding ); 38 } 39 endif; 40 41 function _mb_strlen( $str, $encoding = null ) { 42 // The solution below works only for UTF-8, 43 // so in case of a different charset just use built-in substr() 44 $charset = get_option( 'blog_charset' ); 45 if ( ! in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 46 return strlen( $str ); 47 } 48 // Use the regex unicode support to separate the UTF-8 characters into an array 49 preg_match_all( '/./us', $str, $match ); 50 return count( $match[0] ); 51 } 52 35 53 if ( !function_exists('hash_hmac') ): 36 54 function hash_hmac($algo, $data, $key, $raw_output = false) { 37 55 return _hash_hmac($algo, $data, $key, $raw_output); -
tests/phpunit/tests/post.php
499 499 } 500 500 501 501 /** 502 * @ticket 29573 503 */ 504 function test_get_sample_permalink_html_with_non_latin_slugs() { 505 $inputs = array( 506 'Αρνάκι άσπρο και παχύ της μάνας του καμάρι, και άλλα τραγούδια', 507 'Предлагаем супер металлообрабатывающее оборудование', 508 'בניית אתרי וורדפרס', 509 'This is a very long post name that is both UTF-8 and > 30 chars.', 510 ); 511 512 $outputs = array( 513 'αρνάκι-άσπρο-κ…-μάνας-του-καμ', 514 'предлагаем-суп…ллообрабатываю', 515 'בניית-אתרי-וורדפרס', 516 'this-is-a-very…8-and-30-chars', 517 ); 518 519 $old_permastruct = get_option( 'permalink_structure' ); 520 update_option( 'permalink_structure', '/%postname%/' ); 521 522 foreach ( $inputs as $k => $post_title ) { 523 $post = array( 524 'post_author' => $this->author_id, 525 'post_status' => 'publish', 526 'post_content' => rand_str(), 527 'post_title' => $post_title, 528 ); 529 530 $id = $this->post_ids[] = wp_insert_post( $post ); 531 $sample_permalink_html = get_sample_permalink_html( $id ); 532 preg_match( '#<span id="editable-post-name".*?>(.+?)</span>#', $sample_permalink_html, $matches ); 533 534 $this->assertEquals( $outputs[ $k ], $matches[1] ); 535 } 536 537 update_option( 'permalink_structure', $old_permastruct ); 538 } 539 540 /** 502 541 * @ticket 15665 503 542 */ 504 543 function test_get_page_by_path_priority() {