Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#27386 closed defect (bug) (fixed)

Editor: Word count should exclude shortcodes

Reported by: bassgang Owned by: iseulde
Priority: normal Milestone: 4.3
Component: Editor Version: 2.3
Severity: minor Keywords: has-patch dev-feedback needs-testing
Cc: Focuses: javascript

Description

On the post edit screen the Word count includes shortcodes, but they should not be considered as normal words and so not increase the count.

Steps to reproduce:

  • Add a new post.
  • Add a gallery to the newly created post.
  • Save the post.
  • Reload the page.
  • Check "Word count" under the content textarea, it says "2".


As pointed out by azaozz: "to make that work properly we need to output an array of shortcode "names", then exclude them in the word count".

Who can provide guidance to show which is the most likely way to get this information available in JS?

Attachments (4)

word_count_shortcodes.png (99.5 KB ) - added by bassgang 12 years ago.
27386.patch (882 bytes ) - added by desaiuditd 12 years ago.
27386.2.patch (2.8 KB ) - added by adamsilverstein 12 years ago.
add qunit test for word count
27386.3.patch (3.9 KB ) - added by adamsilverstein 12 years ago.
refresh patch, tabs not spaces in qunit index file, correct jshint error

Download all attachments as: .zip

Change History (12)

@desaiuditd
12 years ago

#1 @desaiuditd
12 years ago

  • Keywords has-patch dev-feedback needs-testing added

Adding patch for 27386.
Added a Regex Check for Shortcodes.
27386.patch

#2 @adamsilverstein
12 years ago

  • Keywords needs-unit-tests added

@adamsilverstein
12 years ago

add qunit test for word count

#3 @adamsilverstein
12 years ago

  • Keywords needs-unit-tests removed

27386.2.patch adds a (QUnit) unit test to verify that the word count feature correctly skips shortcodes when counting words. The test fails without the patch in /wp-admin/js/word-count.js and passes once the file is patched. Note: the test needs to be asynchronous because the word count function includes a brief delay and would otherwise complete after the assertion ran.

Last edited 12 years ago by adamsilverstein (previous) (diff)

This ticket was mentioned in IRC in #wordpress-dev by adamsilverstein. View the logs.


12 years ago

#5 @johnbillion
12 years ago

  • Milestone Awaiting ReviewFuture Release
  • Severity normalminor
  • Version trunk2.3

Related: #27391

@adamsilverstein
12 years ago

refresh patch, tabs not spaces in qunit index file, correct jshint error

#6 @adamsilverstein
12 years ago

in 27386.3.patch correct jshint errors, refresh patch, swap tabs for spaces in qunit index file

#7 @iseulde
11 years ago

  • Owner set to iseulde
  • Resolutionfixed
  • Status newclosed

In 33299:

Editor: word count: exclude shortcodes

Props desaiuditd, adamsilverstein, azaozz and iseulde.
Fixes #27386. See #30966.

#8 @iseulde
11 years ago

  • Milestone Future Release4.3
Note: See TracTickets for help on using tickets.