WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#27386 closed defect (bug) (fixed)

Editor: Word count should exclude shortcodes

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

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 7 years ago.
27386.patch (882 bytes) - added by desaiuditd 7 years ago.
27386.2.patch (2.8 KB) - added by adamsilverstein 7 years ago.
add qunit test for word count
27386.3.patch (3.9 KB) - added by adamsilverstein 7 years ago.
refresh patch, tabs not spaces in qunit index file, correct jshint error

Download all attachments as: .zip

Change History (12)

@desaiuditd
7 years ago

#1 @desaiuditd
7 years ago

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

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

#2 @adamsilverstein
7 years ago

  • Keywords needs-unit-tests added

@adamsilverstein
7 years ago

add qunit test for word count

#3 @adamsilverstein
7 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 7 years ago by adamsilverstein (previous) (diff)

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


7 years ago

#5 @johnbillion
7 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Severity changed from normal to minor
  • Version changed from trunk to 2.3

Related: #27391

@adamsilverstein
7 years ago

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

#6 @adamsilverstein
7 years ago

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

#7 @iseulde
6 years ago

  • Owner set to iseulde
  • Resolution set to fixed
  • Status changed from new to closed

In 33299:

Editor: word count: exclude shortcodes

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

#8 @iseulde
6 years ago

  • Milestone changed from Future Release to 4.3
Note: See TracTickets for help on using tickets.