From af83fe7fb9e963325b8cff02058a476bdd06318a Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 12 Oct 2017 05:10:50 +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. Built from https://develop.svn.wordpress.org/trunk@41844 git-svn-id: http://core.svn.wordpress.org/trunk@41678 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/script-loader.php | 19 ++++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index c1f69b6e0e..e259b79576 100644 --- a/wp-includes/script-loader.php +++ b/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() + ) ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index a51bed5c4f..c58f343e50 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.