Term_Grid
in package
Taxonomy terms grid functionality.
Provdes a grid of taxonomy terms, linked to their archive page.
Tags
Table of Contents
Constants
- CARD_DEFAULTS = array('card_level' => 2, 'description' => '', 'image_id' => 0, 'itemprop' => '', 'itemtype' => '', 'metadata' => array(), 'name' => '', 'new_tab' => false, 'url' => '')
- The default grid card display attributes.
- CONTAINER_DEFAULTS = array('itemprop' => '', 'itemtype' => '', 'metadata' => array())
- The default grid container display attributes.
- TAX_EXCERPT_KEY = 'pnet_excerpt'
- Define taxonomy term excerpt key name.
- TAX_IMAGE_KEY = 'pnet_image_id'
- Define taxonomy term image key name.
- TV_DEFAULTS = array('childless' => false, 'hide_empty' => true, 'order' => 'ASC', 'orderby' => 'name', 'parent' => '', 'taxonomy' => '')
- The default term selection query variables.
Properties
- $grid : Grid
- The instance of the Grid class.
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
- $media : Media
- The instance of the Media class.
- $taxonomy : Taxonomy
- The instance of the Taxonomy class.
- $term : Term
- The instance of the Term class.
Methods
- get_instance() : object
- Creates and/or returns the instance of this class.
- render() : void
- Render the taxonomy terms grid.
- __construct() : void
- Initialise the class and set its properties.
- get_cards() : string
- Return cards markup for each term in the selected taxonomy.
- get_terms() : array<string|int, WP_Term>
- Get the array of terms.
Constants
CARD_DEFAULTS
The default grid card display attributes.
protected
array<string|int, mixed>
CARD_DEFAULTS
= array('card_level' => 2, 'description' => '', 'image_id' => 0, 'itemprop' => '', 'itemtype' => '', 'metadata' => array(), 'name' => '', 'new_tab' => false, 'url' => '')
CARD_DEFAULTS { Default values for grid card. @type int $card_level Heading level to apply to card name (defaults to paragraph if not set). @type string $description Short description of the member. @type int $image_id The attachment ID of the image. @type string $itemprop Schema.org itemprop value for the card. @type string $itemtype URL of schema.org itemtype definition. @type array $metadata Array of itemprop key/value pairs for the card @type string $name Name of member. Used for title. @type bool $new_tab Open URL in new tab flag. @type string $url The URL the card points to. }
Tags
CONTAINER_DEFAULTS
The default grid container display attributes.
protected
array<string|int, mixed>
CONTAINER_DEFAULTS
= array('itemprop' => '', 'itemtype' => '', 'metadata' => array())
CONTAINER_DEFAULTS { Default values for card grid container. @type string $itemprop Schema.org itemprop value for the container. @type string $itemtype URL of schema.org itemtype definition. @type array $metatdata Array of itemprop key/value pairs for the container. }
Tags
TAX_EXCERPT_KEY
Define taxonomy term excerpt key name.
protected
string
TAX_EXCERPT_KEY
= 'pnet_excerpt'
Tags
TAX_IMAGE_KEY
Define taxonomy term image key name.
protected
string
TAX_IMAGE_KEY
= 'pnet_image_id'
Tags
TV_DEFAULTS
The default term selection query variables.
protected
array<string|int, mixed>
TV_DEFAULTS
= array('childless' => false, 'hide_empty' => true, 'order' => 'ASC', 'orderby' => 'name', 'parent' => '', 'taxonomy' => '')
TV_DEFAULTS{ Default term query variables. @type bool $childless Limit results to terms that have no children. @type bool $hide_empty Hide terms not assigned to any posts @type string $order Sort order. @type string $orderby The property to order by. @type string $parent The slug of the parent taxonomy term. @type string $taxonomy The name of the taxonomy to use. }
Tags
Properties
$grid
The instance of the Grid class.
protected
Grid
$grid
Tags
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
$media
The instance of the Media class.
protected
Media
$media
Tags
$taxonomy
The instance of the Taxonomy class.
protected
Taxonomy
$taxonomy
Tags
$term
The instance of the Term class.
protected
Term
$term
Tags
Methods
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
Return values
object —The instance of this class.
render()
Render the taxonomy terms grid.
public
render([array<string|int, mixed> $args = array() ]) : void
This renders a grid of cards showing terms in the selected taxonomy.
Parameters
- $args : array<string|int, mixed> = array()
-
The taxonomy grid selection arguments.
Tags
__construct()
Initialise the class and set its properties.
protected
__construct() : void
Tags
get_cards()
Return cards markup for each term in the selected taxonomy.
protected
get_cards([array<string|int, mixed> $args = array() ]) : string
Parameters
- $args : array<string|int, mixed> = array()
-
The incoming arguments to render() method.
Tags
Return values
string —The taxonomy term cards markup.
get_terms()
Get the array of terms.
protected
get_terms(array<string|int, mixed> $args) : array<string|int, WP_Term>
Parameters
- $args : array<string|int, mixed>
-
The term selection arguments.
Tags
Return values
array<string|int, WP_Term> —An array of (maybe filtered) sorted WP_Term objects or an empty array on failure.