cb-templates-functions.php
Table of Contents
Functions
- cb_templates_container() : string
- CB Templates Container
- cb_templates_get_button() : string
- Formats a button element with the given arguments
- cb_templates_get_list_item() : string
- Formats a list item element with the given arguments
- cb_templates_get_link() : string
- CB Templates Get Link
- cb_templates_get_table() : mixed
- cb_templates_get_ajax_table() : string|void
- CB Templates AJAX Table
- cb_templates_ajax_table() : mixed
- Outputs markup for an AJAX table.
- cb_templates_get_pagination() : string|void
- CB Get Pagination
- cb_templates_get_heading() : string
- Formats the markup for a heading element.
- cb_templates_heading() : mixed
- CB Templates Heading
- cb_templates_get_nav_items() : string
- CB Templates Get Nav Items
- cb_templates_get_nav() : string
- CB Templates Get Nav
Functions
cb_templates_container()
CB Templates Container
cb_templates_container([array<string|int, mixed> $args = array() ]) : string
A function that lets us wrap content dynamically with the supplied arguments, so we can have more fun and less pain.
Parameters
- $args : array<string|int, mixed> = array()
-
An associative array of the following: { @var string $container The HTML tag to use for the container. Default 'div'. @var string $container_id The ID to use for the container. Default empty. @var array $container_classes An array of classes to use for the container. Default empty. @var string $output The content to wrap in the container. Default empty. }
Tags
Return values
string —The HTML markup to output.
cb_templates_get_button()
Formats a button element with the given arguments
cb_templates_get_button([array<string|int, mixed> $args = array() ]) : string
Parameters
- $args : array<string|int, mixed> = array()
-
{ @var string $id The ID of the button @var string $content The content of the button @var string $type The type of the button (button, reset, submit). Default 'button' @var array $classes An array of classes to add to the button. Default array('cb-button') }
Tags
Return values
string —The formatted button element
cb_templates_get_list_item()
Formats a list item element with the given arguments
cb_templates_get_list_item([array<string|int, mixed> $args = array() ]) : string
Parameters
- $args : array<string|int, mixed> = array()
-
{ @var string $id The ID of the item @var string $content The content of the item @var array $classes An array of classes to add to the button. Default array('cb-button') }
Tags
Return values
string —The formatted button element
cb_templates_get_link()
CB Templates Get Link
cb_templates_get_link([array<string|int, mixed> $args = array() ]) : string
Returns a formatted anchor tag.
Parameters
- $args : array<string|int, mixed> = array()
-
An array of options. { @type array $classes An array of classes to add to the element. @type string $href The href for the element. Default '#'. @type string $id The id for the element. @type string $content The text content of the element. @type array $custom_attr An array of custom data attributes for the element. }
Tags
Return values
string —The formatted anchor markup.
cb_templates_get_table()
cb_templates_get_table([mixed $component = '' ][, mixed $heading = '' ][, mixed $paginated = true ]) : mixed
Parameters
- $component : mixed = ''
- $heading : mixed = ''
- $paginated : mixed = true
cb_templates_get_ajax_table()
CB Templates AJAX Table
cb_templates_get_ajax_table([mixed $component = '' ][, mixed $heading = '' ][, mixed $paginated = true ]) : string|void
Returns a table for the specified component. Typically used for displaying items from the database that are fetched via AJAX. Optionally, a pagination bar can be displayed above and below the table.
Parameters
- $component : mixed = ''
- $heading : mixed = ''
- $paginated : mixed = true
Tags
Return values
string|void —The HTML for the table or nothing if the component is empty.
cb_templates_ajax_table()
Outputs markup for an AJAX table.
cb_templates_ajax_table([string $component = '' ][, string $heading = '' ][, bool $paginated = true ]) : mixed
Parameters
- $component : string = ''
-
The component that gets used in a pile of CSS selectors.
- $heading : string = ''
-
A heading to use for the module. Default empty.
- $paginated : bool = true
-
Whether the table should be paginated.
Tags
cb_templates_get_pagination()
CB Get Pagination
cb_templates_get_pagination([string $component = '' ]) : string|void
Returns a pagination bar for the specified component. Typically used when displaying items from the database that are fetched via AJAX.
Parameters
- $component : string = ''
-
The component to display the pagination bar for.
Tags
Return values
string|void —The HTML for the pagination bar or nothing if the component is empty.
cb_templates_get_heading()
Formats the markup for a heading element.
cb_templates_get_heading([string $content = '' ][, int $level = 4 ]) : string
Parameters
- $content : string = ''
-
The content for the heading element. Default empty.
- $level : int = 4
-
The level for the heading element. Default 4.
Tags
Return values
string —the formatted heading.
cb_templates_heading()
CB Templates Heading
cb_templates_heading([string $content = '' ][, int $level = 4 ]) : mixed
Output the markup for a heading element.
Parameters
- $content : string = ''
-
The content for the heading element. Default empty.
- $level : int = 4
-
The level for the heading element. Default 4.
Tags
cb_templates_get_nav_items()
CB Templates Get Nav Items
cb_templates_get_nav_items([string $component = '' ][, array<string|int, mixed> $items = array() ]) : string
Returns a list of dynamically populated nav items as a string.
Parameters
- $component : string = ''
-
The component whose nav we need to make.
- $items : array<string|int, mixed> = array()
-
A 2D array of items to put into the nav. { @type array $label The label that will be used in the markup acts as a key for the nav item options { @type bool $active Adds an "active" class onto the list item if true. @type array $custom_attr An optional array of key => value pairs. @type string $href An href for the anchor element that will go inside the list item. } }
Tags
Return values
string —The markup of all the collective nav items.
cb_templates_get_nav()
CB Templates Get Nav
cb_templates_get_nav([string $component = '' ][, array<string|int, mixed> $items = array() ]) : string
Returns a dynamically populated nav as a string.
Parameters
- $component : string = ''
-
The component whose nav we need to make.
- $items : array<string|int, mixed> = array()
-
A 2D array of items to put into the nav. { @type array $label The label that will be used in the markup acts as a key for the nav item options { @type bool $active Adds an "active" class onto the list item if true. @type array $custom_attr An optional array of key => value pairs. @type string $href An href for the anchor element that will go inside the list item. } }
Tags
Return values
string —The nav markup.