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
This commit is contained in:
parent
a0a05744a9
commit
5e9991f7e4
@ -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()
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user