Editor: Improve the accuracy of the list of shortcodes that the word count ignores.

Previously, shortcodes were being counted when the `init` action fired, even though it's possible for shortcodes to be registered later than that.

By leaving the counting until just before the script is printed, we get a more accurate list of shortcodes.

Props ocean90.
Fixes #41917.


Built from https://develop.svn.wordpress.org/trunk@41844


git-svn-id: http://core.svn.wordpress.org/trunk@41678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2017-10-12 05:10:50 +00:00
parent a9d38090ac
commit af83fe7fb9
2 changed files with 11 additions and 10 deletions

View File

@ -528,15 +528,6 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), 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(
/*
* translators: If your word count is based on single characters (e.g. East Asian characters),
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
* Do not translate into your own language.
*/
'type' => _x( 'words', 'Word count type. Do not translate!' ),
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
) );
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
@ -1073,6 +1064,16 @@ function wp_just_in_time_script_localization() {
wp_localize_script( 'mce-view', 'mceViewL10n', array(
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
) );
wp_localize_script( 'word-count', 'wordCountL10n', array(
/*
* translators: If your word count is based on single characters (e.g. East Asian characters),
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
* Do not translate into your own language.
*/
'type' => _x( 'words', 'Word count type. Do not translate!' ),
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
) );
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta1-41843';
$wp_version = '4.9-beta1-41844';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.