Opened 3 years ago

Last modified 12 months ago

#14691 new enhancement

Allow commas in tag names

Reported by: mdawaffe Owned by:
Priority: normal Milestone: Future Release
Component: Taxonomy Version: 3.0.1
Severity: normal Keywords: has-patch needs-testing needs-unit-tests
Cc: ngomau@…, abackstrom

Description

Adding tags to posts via the web interface involves a lot of what boils down to

explode( ',', join( ',', array( $tag_name, ... ) ) );

both in PHP and JS.

We settled on commas so we could have tags with spaces in them (see #10320, for example).

It'd be nice if tags (and other taxonomies) could have commas in them, though. Example use case: normalized locations ("Portland, OR"). Admittedly, commas in tag names is an edge case.

The attached treats tag inputs as "real" CSV strings instead of just exploding by commas.

That way, you can enter:

hello, "hello, world"

in the tags input field and the following tags would be added to the post.

  • hello
  • hello, world

This addresses commas in tag names but makes entering double quotes in tag names more annoying. If you wanted a tag named double"quote, you'd have to enter the following.

"double""quote"

This may also help with #7897.

Attachments (1)

14691.diff (14.5 KB) - added by mdawaffe 3 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 follow-up: ↓ 6   mdawaffe3 years ago

The patch makes use of a slightly modified version of http://www.bennadel.com/blog/1504-Ask-Ben-Parsing-CSV-Strings-With-Javascript-Exec-Regular-Expression-Command.htm

I've emailed the author asking him under what license the code was released.

Pretty neat solution.

  • Keywords needs-unit-tests added

comment:5 in reply to: ↑ 3   mdawaffe3 years ago

Replying to Denis-de-Bernardy:

http://bugs.php.net/bug.php?id=50686

I'm not too worried if fgetcsv/fputcsv don't quite meet the spec as long as they're each other's inverses and that the JS code is compatible enough. I don't know if either is the case.

I agree it needs unit testing, thanks for the tag.

comment:6 in reply to: ↑ 1   mdawaffe3 years ago

Replying to mdawaffe:

The patch makes use of a slightly modified version of http://www.bennadel.com/blog/1504-Ask-Ben-Parsing-CSV-Strings-With-Javascript-Exec-Regular-Expression-Command.htm

I've emailed the author asking him under what license the code was released.

Ben Nadel, the author, says the code can be used however WP may like to use it. If WP needs an explicit license, he's happy to give it.

  • Milestone changed from Awaiting Review to Future Release
  • Cc ngomau@… added
  • Cc abackstrom added
Note: See TracTickets for help on using tickets.