WebDevStudios / oops-wp

A collection of abstract classes, interfaces, and traits to promote object-oriented programming practices in WordPress.
57 stars 9 forks source link

Add abstract data structure for taxonomy registration #3

Closed jmichaelward closed 5 years ago

phatsk commented 5 years ago

Looking at register_taxonomy( $taxonomy, $object_type, $args );

The abstract class should define the following:

Is it worth adding the following defined "built-in" object types as class constants?

e.g. Taxonomy::TYPE_POST ("post") ?

Thoughts

I'm thinking that this should implement an interface with the public setters/getters. I'm not sure if that's overkill if those will be defined in the abstract already, but the point of interfaces is to create a common API so maybe it's fine? I also don't know that the abstract needs to actually define any abstract methods.

Also, should the abstract define a method such as register that can be hooked (or just have it implement Hookable and/or Runnable, or something similar?

jmichaelward commented 5 years ago

I created #6, which is a blocker for this issue. Ideally, the ContentType class will be developed with both PostType and Taxonomy in mind, and once we're ready for the eventual 1.0.0 release, PostType will be updated to extend it.

In terms of the Taxonomy class itself, it should support a sensible set of defaults required to register a taxonomy (e.g., a slug, an array of post types, labels), as well as a mechanism for defining the overrides, but little more. The abstract class should be opinionated enough to provide a consistent structure for registering post types easily, but not so specific that it gets in the way of registration. I have an implementation in a client project that I can bring into a branch here so we can give them a look for comparison and discuss what else is needed.

jmichaelward commented 5 years ago

8 has been merged into develop, as has this work. Closing.