Improve batch facility to set 'letter' terms #2

Open
bobbingwide opened this Issue Jan 29, 2017 · 1 comment

Projects

None yet

1 participant

@bobbingwide
Owner
bobbingwide commented Jan 29, 2017 edited

The first version of the routine to set the letter terms only supported the Letter taxonomy being set for posts. It would be nice to be able to run it to set taxonomy terms for other post types and letter based taxonomies.

Note: For bigram's taxonomies s-letter and b-letter this was implemented using the bigram-second-letters.php batch routine. Any changes to the oik-a2z functions may need to be reflected in the bigram code.

@bobbingwide bobbingwide self-assigned this Jan 29, 2017
@bobbingwide
Owner
bobbingwide commented Feb 3, 2017 edited

The logic needs to account for a first letter of &.

Since it will create a term if it doesn't exist, wp_set_object_terms() looked like a nice function to use,
Unfortunately it can't handle a value of '&' since this is not a valid slug.

It seems that we need to do the following.

  1. Ensure the term names we return from the filter are escaped, using esc_html()
  2. Convert them into term_ids(), creating any terms that are missing.

This is similar to WordPress TRAC #32248 - adding a term containing "&" and renamed.

I was toying with the idea of requesting a change but opted for my own function.
The logic only works for flat taxonomies ( ie. tags not categories ).

This logic also applies when the terms are automatically set when a post is created/updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment