Ticket #30966: 30966.12.patch
File 30966.12.patch, 2.4 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/word-count.js
1 1 ( function() { 2 2 function WordCounter( settings ) { 3 var key; 3 var key, 4 shortcodes; 4 5 5 6 if ( settings ) { 6 7 for ( key in settings ) { … … 9 10 } 10 11 } 11 12 } 13 14 shortcodes = this.settings.l10n.shortcodes; 15 16 if ( shortcodes && shortcodes.length ) { 17 this.settings.shortcodesRegExp = new RegExp( '\\[\\/?(?:' + shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'gi' ); 18 } 12 19 } 13 20 14 21 WordCounter.prototype.settings = { … … 65 72 text = text + '\n'; 66 73 67 74 text = text.replace( this.settings.HTMLRegExp, '\n' ); 75 text = text.replace( this.settings.shortcodesRegExp, '\n' ); 68 76 text = text.replace( this.settings.spaceRegExp, ' ' ); 69 77 70 78 if ( type === 'words' ) { -
src/wp-includes/script-loader.php
400 400 /* translators: If your word count is based on single characters (East Asian characters), 401 401 enter 'characters', or 'all' to include spaces. Otherwise, enter 'words'. 402 402 Do not translate into your own language. */ 403 'type' => _x( 'words', 'word count: words, characters or all?' ) 403 'type' => _x( 'words', 'word count: words, characters or all?' ), 404 'shortcodes' => array_keys( $GLOBALS['shortcode_tags'] ) 404 405 ) ); 405 406 406 407 $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); -
tests/qunit/wp-admin/js/word-count.js
44 44 words: 3, 45 45 characters: 14, 46 46 all: 14 47 }, 48 { 49 message: 'Em dash.', 50 string: 'one [shortcode attribute="value"]two[/shortcode]three', 51 words: 3, 52 characters: 11, 53 all: 12 47 54 } 48 55 ], function( test ) { 49 56 _.each( [ 'words', 'characters', 'all' ], function( type ) { … … 51 58 } ); 52 59 } ); 53 60 } ); 54 } )( window.QUnit, new window.wp.utils.WordCounter() ); 61 } )( window.QUnit, new window.wp.utils.WordCounter( { 62 l10n: { 63 shortcodes: [ 'shortcode' ] 64 } 65 } ) );