I have some substantial criticism of the data retrieval API you provide. In fact, my point is that you provide none. For a piece of software claimed to be “written in OOP”, not only is there no OO data retrieval API provided, but there is not even any data abstraction. You just happily hand over the internal representation.
Firstly, in order to just find the value of this meta field for this term of this taxonomy, one has to retrieve the whole “database” for the <b>meta section</b> that contains the field. This is the first big problem: “meta sections” are just groupings of widgets in the data definition UI, and the programmer querying the data shouldn’t even have to remember which field belongs to which section. A good retrieval API would completely hide this.
Then one has to explicitly perform two sanity checks and normalization (the two if… lines in the examples). The result is then keyed with the term ID, and finally with the field ID, with necessary isset checks along the way. Nowhere does the taxonomy ID come into play, and the reason why it still works in spite of that is because term IDs are globally unique, so the term ID implies the taxonomy. This is however merely a side effect of how terms and taxonomies are represented, and the API should not expose this.
All in all, a simple data retrieval requries 5 lines of code for what should be just a single API call:
- The topic ‘[Plugin: Taxonomy Meta] Unwieldy API’ is closed to new replies.