Make WordPress Core


Ignore:
Timestamp:
06/19/2015 10:34:59 AM (10 years ago)
Author:
iseulde
Message:

Editor: restructure word count

  • The WordCounter should only do one thing: count words. This makes it also easier to test.
  • Add some really basic unit tests.
  • Instead of only refreshing the count on enter and delete, refresh the count when the user stops typing. Also look at paste and content changes in TinyMCE.
  • Use match instead of replace when it is appropriate.
  • More readable code.

See #30966. Fixes #26620.

File:
1 edited

Legend:

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

    r32843 r32856  
    372372    $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
    373373
    374     $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), false, 1 );
     374    $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
    375375    did_action( 'init' ) && $scripts->localize( 'word-count', 'wordCountL10n', array(
    376376        /* translators: If your word count is based on single characters (East Asian characters),
    377377           enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
    378         'type' => 'characters' == _x( 'words', 'word count: words or characters?' ) ? 'c' : 'w',
     378        'type' => _x( 'words', 'word count: words or characters?' )
    379379    ) );
    380380
     
    452452        ) );
    453453
    454         $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box' ), false, 1 );
     454        $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count' ), false, 1 );
    455455        did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array(
    456456            'ok' => __('OK'),
Note: See TracChangeset for help on using the changeset viewer.