pfeifferNet

Chapter
in package

Define cookbook chapters functionality.

  • Provide methods to return posts and recipes in taxonomy.
  • Provide a grid of chapter cards.
Tags
since
5.4.0
since
5.5.0

Inherit standard singleton class.

since
5.11.0

Deprecated global singleton.

used-by
Printing::__construct()

Table of Contents

Constants

DEFAULT_CHAPTER_GRID_ATTS  = array( 'action' => '', 'childless' => true, 'hide_empty' => true, 'meta_key' => '', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key 'order' => 'ASC', 'orderby' => 'preferred', 'parent' => '', 'taxonomy' => '', )
Chapter grid attributes.
DEFAULT_CHAPTER_POST_ARGS  = array('tid' => 0, 'order' => 'ASC', 'orderby' => 'name')
Chapter post default selection attributes.
TAX_EXCERPT_KEY  = 'pnet_excerpt'
Define taxonomy term excerpt key name.
TAX_IMAGE_KEY  = 'pnet_image_id'
Define taxonomy image key name.
TAX_SEQUENCE_KEY  = 'pnet_sequence'
Define taxonomy term preferred sequence key name.

Properties

$chapters  : Chapters
The instance of the Chapters class.
$instances  : array<string|int, object>
The array of instances of this class and sub-classes.
$taxonomy  : Taxonomy
The instance of the taxonomy class.
$term  : Term
The instance of the Term class.

Methods

get_chapters()  : array<string|int, mixed>
Get chapters in slug sequence.
get_data()  : array<string|int, mixed>
Return the chapter metadata.
get_instance()  : object
Creates and/or returns the instance of this class.
get_post_ids()  : array<string|int, int>
Get post_ids in a chapter.
get_posts()  : array<string|int, mixed>
Get posts in a chapter.
get_recipe_ids()  : array<string|int, int>
Get recipe ids in a chapter.
render_grid()  : void
Render the grid of chapter cards.
__construct()  : void
Initialise the class and set its properties.
get_chapter_cards()  : string
Return chapter cards.
set_post_order()  : array<string|int, mixed>
Override the display order within some chapters.

Constants

DEFAULT_CHAPTER_GRID_ATTS

Chapter grid attributes.

protected array<string|int, mixed> DEFAULT_CHAPTER_GRID_ATTS = array( 'action' => '', 'childless' => true, 'hide_empty' => true, 'meta_key' => '', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key 'order' => 'ASC', 'orderby' => 'preferred', 'parent' => '', 'taxonomy' => '', )
  • Set some sane defaults.

{ Default settings for the chapter grid display. @type string $action The action to take when card is clicked. @type bool $childless Flag to indicate whewhether to return chapers with no children. Default true. @type bool $hide_empty Flag to indicate whether to hide chapters with no posts. Default true. @type string $meta_key The meta key to use for ordering. @type string $order The chapter sort order. Defaults to ascending. @type string $orderby The chapter sort key. Defaults to the preferred sequence, set in the taxonomy. @type string $parent The top level item to restrict items by. @type string $taxonomy The taxonomy to get the chapters from. }

Tags
since
5.4.0

DEFAULT_CHAPTER_POST_ARGS

Chapter post default selection attributes.

protected array<string|int, mixed> DEFAULT_CHAPTER_POST_ARGS = array('tid' => 0, 'order' => 'ASC', 'orderby' => 'name')

{ Default settings for the chapter post selection. @type int|string $tid The term id of the chapter to use. @type string $order The post sort order. @type string $orderby The posts sort key. }

Tags
since
5.7.0

TAX_EXCERPT_KEY

Define taxonomy term excerpt key name.

protected string TAX_EXCERPT_KEY = 'pnet_excerpt'
Tags
since
5.13.0

TAX_IMAGE_KEY

Define taxonomy image key name.

protected string TAX_IMAGE_KEY = 'pnet_image_id'
Tags
since
5.4.0

TAX_SEQUENCE_KEY

Define taxonomy term preferred sequence key name.

protected array<string|int, mixed> TAX_SEQUENCE_KEY = 'pnet_sequence'
Tags
since
5.13.0

Properties

$instances

The array of instances of this class and sub-classes.

protected static array<string|int, object> $instances = array()
Tags
since
5.11.0

Methods

get_chapters()

Get chapters in slug sequence.

public get_chapters([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

The chapter request arguments.

Tags
since
5.4.0
since
5.13.0

Use taxonomy get_term method.

uses
Chapters::get_name()
uses
Taxonomy::get_terms()
see
Chapter::DEFAULT_CHAPTER_GRID_ATTS
Return values
array<string|int, mixed>

An array of chapter terms.

get_data()

Return the chapter metadata.

public get_data([int|string $chapter_id = 0 ]) : array<string|int, mixed>
Parameters
$chapter_id : int|string = 0

The chapter id to use.

Tags
since
5.12.0
since
5.13.0

Refactor to use term class.

uses
Term::get_data()
Return values
array<string|int, mixed>

The chapter term data and metadata.

get_instance()

Creates and/or returns the instance of this class.

public static get_instance() : object
Tags
since
5.11.0
Return values
object

The instance of this class.

get_post_ids()

Get post_ids in a chapter.

public get_post_ids([int $chapter_id = 0 ]) : array<string|int, int>
Parameters
$chapter_id : int = 0

The chapter id to search. If empty return all recipe chapters.

Tags
since
5.4.0
used-by
Printing::render()
Return values
array<string|int, int>

The post ids within the chapter in slug sequence.

get_posts()

Get posts in a chapter.

public get_posts([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

The chapter post selection criteria.

Tags
since
5.4.0
see
Chapter::DEFAULT_CHAPTER_POST_ARGS
Return values
array<string|int, mixed>

An array of post objects within the chapter in required sequence.

get_recipe_ids()

Get recipe ids in a chapter.

public get_recipe_ids([int $chapter_id = 0 ]) : array<string|int, int>
Parameters
$chapter_id : int = 0

The chapter id to search. If empty return all recipe chapters.

Tags
since
5.4.0
uses
Recipe
Return values
array<string|int, int>

The recipe ids within the chapter in slug sequence.

set_post_order()

Override the display order within some chapters.

protected set_post_order(array<string|int, mixed> $qv, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$qv : array<string|int, mixed>

The query variables.

$args : array<string|int, mixed>

The args given to the calling function.

Tags
since
5.9.0
see
Chapter::get_posts()
see
Chapter::DEFAULT_CHAPTER_POST_ARGS
Return values
array<string|int, mixed>

The modified query variables.


        
On this page

Search results