Changeset 33440
- Timestamp:
- 07/27/2015 11:18:55 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/word-count.js
r33344 r33440 62 62 astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 63 63 wordsRegExp: /\S\s+/g, 64 characters RegExp: /\S/g,65 allRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g,64 characters_excluding_spacesRegExp: /\S/g, 65 characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g, 66 66 l10n: window.wordCountL10n || {} 67 67 }; … … 72 72 type = type || this.settings.l10n.type; 73 73 74 if ( type !== 'characters ' && type !== 'all' ) {74 if ( type !== 'characters_excluding_spaces' && type !== 'characters_including_spaces' ) { 75 75 type = 'words'; 76 76 } -
trunk/src/wp-includes/formatting.php
r33411 r33440 2813 2813 */ 2814 2814 function wp_trim_words( $text, $num_words = 55, $more = null ) { 2815 if ( null === $more ) 2815 if ( null === $more ) { 2816 2816 $more = __( '…' ); 2817 } 2818 2817 2819 $original_text = $text; 2818 2820 $text = wp_strip_all_tags( $text ); 2819 /* translators: If your word count is based on single characters (East Asian characters), 2820 enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ 2821 if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { 2821 2822 /* translators: If your word count is based on single characters (e.g. East Asian characters), 2823 enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 2824 Do not translate into your own language. */ 2825 if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { 2822 2826 $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); 2823 2827 preg_match_all( '/./u', $text, $words_array ); … … 2828 2832 $sep = ' '; 2829 2833 } 2834 2830 2835 if ( count( $words_array ) > $num_words ) { 2831 2836 array_pop( $words_array ); … … 2835 2840 $text = implode( $sep, $words_array ); 2836 2841 } 2842 2837 2843 /** 2838 2844 * Filter the text content after words have been trimmed. -
trunk/src/wp-includes/script-loader.php
r33426 r33440 402 402 $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 ); 403 403 did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array( 404 /* translators: If your word count is based on single characters ( East Asian characters),405 enter 'characters ', or 'all' to include spaces. Otherwise, enter 'words'.404 /* translators: If your word count is based on single characters (e.g. East Asian characters), 405 enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 406 406 Do not translate into your own language. */ 407 'type' => _x( 'words', ' word count: words, characters or all?' ),407 'type' => _x( 'words', 'Word count type. Do not translate!' ), 408 408 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array() 409 409 ) ); -
trunk/tests/qunit/wp-admin/js/word-count.js
r33344 r33440 8 8 string: 'one two three', 9 9 words: 3, 10 characters : 11,11 all: 1310 characters_excluding_spaces: 11, 11 characters_including_spaces: 13 12 12 }, 13 13 { … … 15 15 string: 'one <em class="test">two</em><br />three', 16 16 words: 3, 17 characters : 11,18 all: 1217 characters_excluding_spaces: 11, 18 characters_including_spaces: 12 19 19 }, 20 20 { … … 22 22 string: 'one\ntwo\nthree', 23 23 words: 3, 24 characters : 11,25 all: 1124 characters_excluding_spaces: 11, 25 characters_including_spaces: 11 26 26 }, 27 27 { … … 29 29 string: 'one two three', 30 30 words: 3, 31 characters : 11,32 all: 1331 characters_excluding_spaces: 11, 32 characters_including_spaces: 13 33 33 }, 34 34 { … … 36 36 string: 'It\'s two three \u2026 4?', 37 37 words: 3, 38 characters : 15,39 all: 1938 characters_excluding_spaces: 15, 39 characters_including_spaces: 19 40 40 }, 41 41 { … … 43 43 string: 'one\u2014two--three', 44 44 words: 3, 45 characters : 14,46 all: 1445 characters_excluding_spaces: 14, 46 characters_including_spaces: 14 47 47 }, 48 48 { … … 50 50 string: 'one [shortcode attribute="value"]two[/shortcode]three', 51 51 words: 3, 52 characters : 11,53 all: 1252 characters_excluding_spaces: 11, 53 characters_including_spaces: 12 54 54 }, 55 55 { … … 57 57 string: '\uD83D\uDCA9', 58 58 words: 1, 59 characters : 1,60 all: 159 characters_excluding_spaces: 1, 60 characters_including_spaces: 1 61 61 }, 62 62 { … … 64 64 string: 'one<!-- comment -->two three', 65 65 words: 2, 66 characters : 11,67 all: 1266 characters_excluding_spaces: 11, 67 characters_including_spaces: 12 68 68 }, 69 69 { … … 71 71 string: '> test', 72 72 words: 1, 73 characters : 5,74 all: 673 characters_excluding_spaces: 5, 74 characters_including_spaces: 6 75 75 } 76 76 ], function( test ) { 77 _.each( [ 'words', 'characters ', 'all' ], function( type ) {77 _.each( [ 'words', 'characters_excluding_spaces', 'characters_including_spaces' ], function( type ) { 78 78 assert.equal( wordCounter.count( test.string, type ), test[ type ], test.message + ' (' + type + ')' ); 79 79 } );
Note: See TracChangeset
for help on using the changeset viewer.