From 5e9991f7e408244db336a858d948015a6801b6e3 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 12 Oct 2017 05:09:10 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@41844 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index c1f69b6e0e..e259b79576 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -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() + ) ); } /**