WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Meta
Unwieldy API (1 post)

  1. Rulatir
    Member
    Posted 1 year ago #

    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:

    get_tax_meta($term_id,'my_field','my_taxonomy');

    http://wordpress.org/extend/plugins/taxonomy-meta/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic