Make WordPress Core

Changeset 41844


Ignore:
Timestamp:
10/12/2017 05:09:10 AM (7 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r41839 r41844  
    529529
    530530    $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
    531     did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
    532         /*
    533          * translators: If your word count is based on single characters (e.g. East Asian characters),
    534          * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
    535          * Do not translate into your own language.
    536          */
    537         'type' => _x( 'words', 'Word count type. Do not translate!' ),
    538         'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
    539     ) );
    540531
    541532    $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
     
    10741065        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
    10751066    ) );
     1067
     1068    wp_localize_script( 'word-count', 'wordCountL10n', array(
     1069        /*
     1070         * translators: If your word count is based on single characters (e.g. East Asian characters),
     1071         * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
     1072         * Do not translate into your own language.
     1073         */
     1074        'type' => _x( 'words', 'Word count type. Do not translate!' ),
     1075        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     1076    ) );
    10761077}
    10771078
Note: See TracChangeset for help on using the changeset viewer.