tp TouchPointWP Taxonomies - TenthPres/TouchPoint-WP GitHub Wiki

tp\TouchPointWP\Taxonomies

Everything related to the plugin's Taxonomies.

  • Class name: Taxonomies
  • Namespace: \tp\TouchPointWP
  • This is an abstract class

Constants

TAX_TENSE_PRESENT

const TAX_TENSE_PRESENT = "present"

TAX_INV_MARITAL

const TAX_INV_MARITAL = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "inv_marital"

TAX_TENSE_PAST

const TAX_TENSE_PAST = "past"

TAX_DIV

const TAX_DIV = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "div"

TAX_AGEGROUP

const TAX_AGEGROUP = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "agegroup"

TAX_RESCODE

const TAX_RESCODE = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "rescode"

TAX_CAMPUS

const TAX_CAMPUS = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "campus"

TAX_GP_CATEGORY

const TAX_GP_CATEGORY = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "partner_category"

TAX_WEEKDAY

const TAX_WEEKDAY = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "weekday"

TAX_TENSE_FUTURE

const TAX_TENSE_FUTURE = "future"

TAX_DAYTIME

const TAX_DAYTIME = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "timeOfDay"

TAX_TENSE

const TAX_TENSE = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "tense"

TAXMETA_LOOKUP_ID

const TAXMETA_LOOKUP_ID = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "lookup_id"

Properties

forceTermLookupIdUpdate

public mixed forceTermLookupIdUpdate = false
  • Visibility: public

Methods

insertTermsForArrayBasedTaxonomy

void tp\TouchPointWP\Taxonomies::insertTermsForArrayBasedTaxonomy(string[] list, string taxonomy, bool forceIdUpdate)

For the taxonomies that are based on Lookups in the TouchPoint database, insert or update the terms. Also removes any items that are no longer present in the list.

  • Visibility: public
  • This method is static.

Arguments

  • list string[] - where the slug is the key and the name is the value.
  • taxonomy string* forceIdUpdate bool

insertTermsForLookupBasedTaxonomy

void tp\TouchPointWP\Taxonomies::insertTermsForLookupBasedTaxonomy(object[] list, string taxonomy, bool forceIdUpdate)

For the taxonomies that are based on Lookups in the TouchPoint database, insert or update the terms. Also removes any items that are no longer present in the list.

  • Visibility: public
  • This method is static.

Arguments

  • list object[]* taxonomy string* forceIdUpdate bool

getTaxTermId

?int tp\TouchPointWP\Taxonomies::getTaxTermId(mixed taxonomy, mixed value)

Get the term id for a given taxonomy and value.

  • Visibility: public
  • This method is static.

Arguments

  • taxonomy mixed - string Taxonomy name
  • value mixed - int|string The Lookup ID or name or slug of the term.

Returns

  • ?int -

getTermsClauses

mixed tp\TouchPointWP\Taxonomies::getTermsClauses(mixed clauses, mixed taxonomy, mixed args)

Filter to add a tp_post_type option to get_terms that takes either a string of one post type or an array of post types.

  • Visibility: public
  • This method is static.

Arguments

  • clauses mixed* taxonomy mixed* args mixed -

Hat tip https://dfactory.eu/wp-how-to-get-terms-post-type/

Returns

  • mixed -

insertTerms

void tp\TouchPointWP\Taxonomies::insertTerms(?\tp\TouchPointWP\TouchPointWP|string instance)

Insert the terms for the registered taxonomies. (This is supposed to happen a while after the taxonomies are loaded.)

  • Visibility: public
  • This method is static.

Arguments

  • instance ?\tp\TouchPointWP\TouchPointWP|string - Default value for init call may be null or ''.

termExists

mixed tp\TouchPointWP\Taxonomies::termExists(int|string term, string taxonomy, int|null parent)

Wrapper for the WordPress term_exists function to reduce database calls

  • Visibility: public
  • This method is static.

Arguments

  • term int|string - The term to check. Accepts term ID, slug, or name.
  • taxonomy string - Optional. The taxonomy name to use.
  • parent int|null - Optional. ID of parent term under which to confine the exists search.

Returns

  • mixed - Returns null if the term does not exist. Returns the term ID if no taxonomy is specified and the term ID exists. Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists. Returns 0 if term ID 0 is passed to the function.

insertTerm

array|\WP_Error tp\TouchPointWP\Taxonomies::insertTerm(string term, string taxonomy, array|string args)

Wrapper for the WordPress wp_insert_term function to reduce database calls

Add a new term to the database.

A non-existent term is inserted in the following sequence:

  1. The term is added to the term table, then related to the taxonomy.
  2. If everything is correct, several actions are fired.
  3. The 'term_id_filter' is evaluated.
  4. The term cache is cleaned.
  5. Several more actions are fired.
  6. An array is returned containing the term_id and term_taxonomy_id.

If the 'slug' argument is not empty, then it is checked to see if the term is invalid. If it is not a valid, existing term, it is added and the term_id is given.

If the taxonomy is hierarchical, and the 'parent' argument is not empty, the term is inserted and the term_id will be given.

Error handling: If $taxonomy does not exist or $term is empty, a WP_Error object will be returned.

If the term already exists on the same hierarchical level, or the term slug and name are not unique, a WP_Error object will be returned.

  • Visibility: public
  • This method is static.

Arguments

  • term string - The term name to add.
  • taxonomy string - The taxonomy to which to add the term.
  • args array|string - { Optional. Array or query string of arguments for inserting a term.

Returns

  • array|\WP_Error - { An array of the new term data, WP_Error otherwise.

registerTaxonomies

void tp\TouchPointWP\Taxonomies::registerTaxonomies(\tp\TouchPointWP\TouchPointWP instance)

Register the taxonomies.

  • Visibility: public
  • This method is static.

Arguments