Ticket #29573: 29573.3.patch
File 29573.3.patch, 3.2 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 ) { 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 ); 1208 $post_name_abridged = $post_name; 1209 1210 if ( function_exists( 'mb_strlen' ) ) { 1211 if ( mb_strlen( $post_name ) > 30 ) { 1212 $post_name_abridged = mb_substr( $post_name, 0, 14 ) . '…' . mb_substr( $post_name, -14 ); 1213 } 1214 } elseif ( preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { 1215 preg_match_all( '/./u', $post_name, $characters ); 1216 if ( count( $characters[0] ) > 30 ) { 1217 $post_name_abridged = mb_substr( $post_name, 0, 14 ) . '…' . mb_substr( $post_name, -14 ); 1218 } 1212 1219 } else { 1213 $post_name_abridged = $post_name; 1220 if ( strlen( $post_name ) > 30 ) { 1221 $post_name_abridged = substr( $post_name, 0, 14 ) . '…' . substr( $post_name, -14 ); 1222 } 1214 1223 } 1215 1224 1216 1225 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; -
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() {