Learn icon indicating copy to clipboard operation
Learn copied to clipboard

Standardise taxonomies across post types

Open adamwoodnz opened this issue 3 years ago • 2 comments

See #1009

This PR sets up the new taxonomies we will be using across all post types:

  1. A new wporg_language taxonomy to be populated with all the possible locales
  2. Extends the topic taxonomy (currently only applied to tutorials) to all post types

Once these are in place we can start migrating all the post content to use them:

  • Lesson plan category -> topic
  • Tutorial video_language meta field -> wporg_language
  • Course course-category -> topic

After that the old taxonomies and meta fields can be removed (or possibly hidden from the UI if there is any value in keeping them around).

A number of frontend tasks will then follow to switch filters and queries to use the new taxonomies.

Screenshots

Admin tables

Lesson Plans Languages
Screen Shot 2022-10-20 at 2 16 16 PM Screen Shot 2022-10-20 at 2 16 43 PM

Posts

Lesson Plan Tutorial
Screen Shot 2022-10-20 at 2 25 20 PM Screen Shot 2022-10-20 at 2 26 26 PM

How to test

  1. Load the admin and check that Lesson Plans, Tutorials, Meetings and Courses all have Topic and Language taxonomies.
  2. Edit different post types adding Languages (see screenshots above for proposed data), and Topics (should already be plenty of terms from Tutorials).
  3. Smoke test frontend after adding new terms to post content.

adamwoodnz avatar Oct 18 '22 02:10 adamwoodnz

Sorry for un-approving, but I went back to the original locale PR. In #112, the wporg locales plugin was added to handle generating the locale names based on the standardized languages set in GlotPress (see pub/locales.php & pub/locales/locales.php). This is kept up to date with the GlotPress projects, so when new languages are added (or if a language name updates), they're populated throughout the site. If the language is added as a separate taxonomy here, it will probably become unsynced from that list at some point.

I also found the code I was thinking of when we spoke in slack – in wporg_archive_query_prioritize_locale, the language is used to sort workshops.

In order to show all workshops, but with the ones that are presented/captioned in the user's locale shown first, we need to modify the posts query in ways that can't be done through the WP_Query or WP_Meta_Query APIs. Instead, here, we're filtering the individual clauses of the query to add the pieces we need.

I'm not sure if it's working, or if you want it to keep working this way, but the way the taxonomy tables are set up would make this impossible (or at least much more complex).

You might be better off trying to expand the current language meta to the other post types after all.

ryelle avatar Oct 20 '22 22:10 ryelle

I'm not sure if it's working, or if you want it to keep working this way, but the way the taxonomy tables are set up would make this impossible (or at least much more complex).

Yeah I think this is something I don't want to mess with! Thanks for alerting me to this.

@hlashbrooke here is the use case for sorting by language. I think we should change tack and add more meta fields to the other post types using the same code.

adamwoodnz avatar Oct 21 '22 02:10 adamwoodnz

UPDATE: The Language taxonomy has now been dropped in favour of a new language meta field available on all post types. This is visible as a column on the admin tables and is editable via a post setting:

Screen Shot 2022-10-28 at 3 13 43 PM

This can be tested by editing, refreshing and returning to the admin table. meeting needs to be tested in sandbox.

NOTE: Tutorials already have a video_language meta field so that hasn't been touched. Next step for this is to migrate the data from the old field to the new and then update all the filtering and querying references to use the new field.

adamwoodnz avatar Oct 28 '22 02:10 adamwoodnz