Editor: word count: better names for types.
Also fix it in wp_trim_words(). Fixes #30966. Built from https://develop.svn.wordpress.org/trunk@33440 git-svn-id: http://core.svn.wordpress.org/trunk@33407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b2b53fd997
commit
491c863f35
|
@ -61,8 +61,8 @@
|
||||||
].join( '' ), 'g' ),
|
].join( '' ), 'g' ),
|
||||||
astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
||||||
wordsRegExp: /\S\s+/g,
|
wordsRegExp: /\S\s+/g,
|
||||||
charactersRegExp: /\S/g,
|
characters_excluding_spacesRegExp: /\S/g,
|
||||||
allRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g,
|
characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g,
|
||||||
l10n: window.wordCountL10n || {}
|
l10n: window.wordCountL10n || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
type = type || this.settings.l10n.type;
|
type = type || this.settings.l10n.type;
|
||||||
|
|
||||||
if ( type !== 'characters' && type !== 'all' ) {
|
if ( type !== 'characters_excluding_spaces' && type !== 'characters_including_spaces' ) {
|
||||||
type = 'words';
|
type = 'words';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
!function(){function a(a){var b,c;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b]);c=this.settings.l10n.shortcodes,c&&c.length&&(this.settings.shortcodesRegExp=new RegExp("\\[\\/?(?:"+c.join("|")+")[^\\]]*?\\]","g"))}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,HTMLcommentRegExp:/<!--[\s\S]*?-->/g,spaceRegExp:/ | /gi,HTMLEntityRegExp:/&\S+?;/g,connectorRegExp:/--|\u2014/g,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),astralRegExp:/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,wordsRegExp:/\S\s+/g,charactersRegExp:/\S/g,allRegExp:/[^\f\n\r\t\v\u00AD\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type,"characters"!==b&&"all"!==b&&(b="words"),a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),a=a.replace(this.settings.HTMLcommentRegExp,""),this.settings.shortcodesRegExp&&(a=a.replace(this.settings.shortcodesRegExp,"\n")),a=a.replace(this.settings.spaceRegExp," "),"words"===b?(a=a.replace(this.settings.HTMLEntityRegExp,""),a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")):(a=a.replace(this.settings.HTMLEntityRegExp,"a"),a=a.replace(this.settings.astralRegExp,"a")),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}();
|
!function(){function a(a){var b,c;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b]);c=this.settings.l10n.shortcodes,c&&c.length&&(this.settings.shortcodesRegExp=new RegExp("\\[\\/?(?:"+c.join("|")+")[^\\]]*?\\]","g"))}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,HTMLcommentRegExp:/<!--[\s\S]*?-->/g,spaceRegExp:/ | /gi,HTMLEntityRegExp:/&\S+?;/g,connectorRegExp:/--|\u2014/g,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),astralRegExp:/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,wordsRegExp:/\S\s+/g,characters_excluding_spacesRegExp:/\S/g,characters_including_spacesRegExp:/[^\f\n\r\t\v\u00AD\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type,"characters_excluding_spaces"!==b&&"characters_including_spaces"!==b&&(b="words"),a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),a=a.replace(this.settings.HTMLcommentRegExp,""),this.settings.shortcodesRegExp&&(a=a.replace(this.settings.shortcodesRegExp,"\n")),a=a.replace(this.settings.spaceRegExp," "),"words"===b?(a=a.replace(this.settings.HTMLEntityRegExp,""),a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")):(a=a.replace(this.settings.HTMLEntityRegExp,"a"),a=a.replace(this.settings.astralRegExp,"a")),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}();
|
|
@ -2812,13 +2812,17 @@ function wp_trim_excerpt( $text = '' ) {
|
||||||
* @return string Trimmed text.
|
* @return string Trimmed text.
|
||||||
*/
|
*/
|
||||||
function wp_trim_words( $text, $num_words = 55, $more = null ) {
|
function wp_trim_words( $text, $num_words = 55, $more = null ) {
|
||||||
if ( null === $more )
|
if ( null === $more ) {
|
||||||
$more = __( '…' );
|
$more = __( '…' );
|
||||||
|
}
|
||||||
|
|
||||||
$original_text = $text;
|
$original_text = $text;
|
||||||
$text = wp_strip_all_tags( $text );
|
$text = wp_strip_all_tags( $text );
|
||||||
/* translators: If your word count is based on single characters (East Asian characters),
|
|
||||||
enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
|
/* translators: If your word count is based on single characters (e.g. East Asian characters),
|
||||||
if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
|
enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
||||||
|
Do not translate into your own language. */
|
||||||
|
if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
|
||||||
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
|
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
|
||||||
preg_match_all( '/./u', $text, $words_array );
|
preg_match_all( '/./u', $text, $words_array );
|
||||||
$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
|
$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
|
||||||
|
@ -2827,6 +2831,7 @@ function wp_trim_words( $text, $num_words = 55, $more = null ) {
|
||||||
$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
|
$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
|
||||||
$sep = ' ';
|
$sep = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count( $words_array ) > $num_words ) {
|
if ( count( $words_array ) > $num_words ) {
|
||||||
array_pop( $words_array );
|
array_pop( $words_array );
|
||||||
$text = implode( $sep, $words_array );
|
$text = implode( $sep, $words_array );
|
||||||
|
@ -2834,6 +2839,7 @@ function wp_trim_words( $text, $num_words = 55, $more = null ) {
|
||||||
} else {
|
} else {
|
||||||
$text = implode( $sep, $words_array );
|
$text = implode( $sep, $words_array );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the text content after words have been trimmed.
|
* Filter the text content after words have been trimmed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -401,10 +401,10 @@ function wp_default_scripts( &$scripts ) {
|
||||||
|
|
||||||
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
|
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
|
||||||
did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
|
did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
|
||||||
/* translators: If your word count is based on single characters (East Asian characters),
|
/* translators: If your word count is based on single characters (e.g. East Asian characters),
|
||||||
enter 'characters', or 'all' to include spaces. Otherwise, enter 'words'.
|
enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
||||||
Do not translate into your own language. */
|
Do not translate into your own language. */
|
||||||
'type' => _x( 'words', 'word count: words, characters or all?' ),
|
'type' => _x( 'words', 'Word count type. Do not translate!' ),
|
||||||
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
|
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-beta4-33439';
|
$wp_version = '4.3-beta4-33440';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue