Templates
Table of Contents
Functions
- cb_templates_get_text_input() : mixed
- CB Templates Get Text Input
- cb_text_input() : mixed
- CB Text Input
- cb_templates_get_select_input() : mixed
- CB Templates Get Select Input
- cb_templates_get_select_options() : mixed
- CB Templates Get Select Options
- cb_select_input() : mixed
- Confetti Bits Select Input
- cb_templates_get_number_input() : mixed
- CB Templates Get Number Input
- cb_number_input() : mixed
- CB Number Input
- cb_templates_get_file_input() : mixed
- Confetti Bits Get File Input.
- cb_file_input() : mixed
- Confetti Bits File Input
- cb_templates_get_submit_input() : mixed
- CB Templates Get Submit Input.
- cb_submit_input() : mixed
- CB Submit Input
- cb_templates_get_hidden_input() : mixed
- CB Templates Get Hidden Input
- cb_hidden_input() : mixed
- CB Hidden Input
- cb_templates_get_checkbox_input() : mixed
- CB Templates Get Checkbox Input
- cb_checkbox_input() : mixed
- CB Checkbox Input
- cb_templates_get_dropzone_input() : mixed
- CB Format Dropzone Input
- cb_dropzone_input() : mixed
- CB Dropzone Input
- cb_templates_get_toggle_switch() : mixed
- Alias for cb_templates_get_toggle_switch_input().
- cb_templates_get_toggle_switch_input() : string
- Gets markup for a toggle switch input.
- cb_toggle_switch() : mixed
- CB Toggle Switch
- cb_templates_get_form() : string
- CB Templates Get Form
- cb_form() : mixed
- Outputs the markup for a form element.
- cb_templates_get_form_module() : string
- Gets the markup for a form module.
- cb_templates_get_form_button() : string
- Returns formatted markup for a form button. Note that this should not be used as a submit button; we typically use input[type=submit] for that functionality. Here we'll default to button[type=button] to ensure that we can have it do what we want and not make the app have a heart attack.
- cb_form_module() : mixed
- Outputs the form module's markup.
- cb_templates_recursive_helper() : string
- A recursive helper function to help us process complex content trees.
- cb_templates_get_time_picker_input() : string
- Gets markup for a time picker.
- cb_time_picker_input() : mixed
- Outputs markup for a time picker.
- cb_templates_get_date_picker_input() : string
- Gets markup for a date picker input.
- cb_templates_get_datetime_picker_input() : string
- Gets markup for both date and time inputs on one line.
- cb_datetime_picker() : mixed
- Outputs markup for a datetime picker input.
- cb_templates_get_datetime_local_input() : string
- Formats markup for a datetime-local input.
- cb_datetime_local_input() : mixed
- Outputs markup for a datetime-local input.
- cb_date_input() : mixed
- Outputs markup for a pretty date input.
- 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_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
- cb_templates_get_admin_page() : string
- Formats markup for our admin settings page.
- cb_core_admin_page() : mixed
- Outputs markup for our admin settings page.
Functions
cb_templates_get_text_input()
CB Templates Get Text Input
cb_templates_get_text_input([array<string|int, mixed> $args = [] ]) : mixed
Formats a text input that plays nice with our scripts.
Parameters
- $args : array<string|int, mixed> = []
-
A list of arguments {
Tags
cb_text_input()
CB Text Input
cb_text_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the text input.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_select_input()
CB Templates Get Select Input
cb_templates_get_select_input([array<string|int, mixed> $args = array() ]) : mixed
Creates a select input element.
Parameters
- $args : array<string|int, mixed> = array()
-
Accepts a bunch of optional arguments.
Tags
cb_templates_get_select_options()
CB Templates Get Select Options
cb_templates_get_select_options([array<string|int, mixed> $args = [] ]) : mixed
Takes care of some of the business for making select inputs.
Parameters
- $args : array<string|int, mixed> = []
-
Arguments for the select input, listed below. Required. @type string $name The name of the option. Required. @type array $options The input values, and whether they are disabled or selected. @type string $value The value for the option. Required. @type bool $disabled Whether the option is disabled or not. Optional. @type bool $selected Whether the option is selected by default. Optional.
Tags
cb_select_input()
Confetti Bits Select Input
cb_select_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the select input.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_number_input()
CB Templates Get Number Input
cb_templates_get_number_input([array<string|int, mixed> $args = [] ]) : mixed
Use this to create a number input element.
Parameters
- $args : array<string|int, mixed> = []
-
An array of arguments for the input element. Details below. All settings are optional.
Tags
cb_number_input()
CB Number Input
cb_number_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the number input.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_file_input()
Confetti Bits Get File Input.
cb_templates_get_file_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a file input element that accepts the specified filetypes.
Parameters
- $args : array<string|int, mixed> = []
-
An array of arguments for the input element. All optional.
@type string $label The label for the input. Default 'Upload a File'. @type string $class Custom class attribute for file input. @type string $name The value used in the for attribute of the label and the name and id attributes of the input. Default 'cb_file_upload'. @type bool $required Whether or not the field is required. Default false. @type bool $multiple Whether or not the field allows multiple files. Default false. @type bool $capture Whether or not the field allows the use of a camera. Default false. @type bool $disabled Whether or not the field is disabled. Default false. @type array $accepts An array of filetypes that the input accepts. Accepts either MIME type structures or filetype structures. Should be compliant with your Wordpress configuration. Default empty.
Tags
cb_file_input()
Confetti Bits File Input
cb_file_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the file input.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_submit_input()
CB Templates Get Submit Input.
cb_templates_get_submit_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a submit input element that submits a form.
Parameters
- $args : array<string|int, mixed> = []
-
An array of arguments for the input element. All optional.
@type string $id The value used in the id attribute of the input. Default empty. @type value $value Value for the submit input. Default "Submit". @type bool $disabled Whether or not the field is disabled. Default false.
Tags
cb_submit_input()
CB Submit Input
cb_submit_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the submit input markup.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_hidden_input()
CB Templates Get Hidden Input
cb_templates_get_hidden_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a hidden input that's either ready to receive a value or has a preset value.
Suggested utilities are getting things like user ids, logged-in usernames, emails, or empty inputs that get calculated on the page via javascript. We probably haven't written things like that yet, so you may have to set it up for your needs.
Parameters
- $args : array<string|int, mixed> = []
-
An array of arguments for the input. Name, id, value, disabled, multiple.
Tags
cb_hidden_input()
CB Hidden Input
cb_hidden_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the hidden input markup.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_checkbox_input()
CB Templates Get Checkbox Input
cb_templates_get_checkbox_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a checkbox input with a label and as many options as you want.
Parameters
- $args : array<string|int, mixed> = []
-
An array of options for each input you want to include, structured in a 2D array of option names => array of option parameters. {
@type string $name The value used in the for, name, and id attributes. @type string $label The label for the option. @type string $value The value of the option. @type bool $checked Whether the field is checked or not. @type bool $disabled Whether the field is disabled or not.
}
Tags
cb_checkbox_input()
CB Checkbox Input
cb_checkbox_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the checkbox input markup.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_dropzone_input()
CB Format Dropzone Input
cb_templates_get_dropzone_input([array<string|int, mixed> $args = [] ]) : mixed
Creates a hidden input and a container that can be used for drag-and-drop file uploads.
Parameters
- $args : array<string|int, mixed> = []
-
An array of arguments for the input. Name, id, value, disabled, multiple, etc.
Tags
cb_dropzone_input()
CB Dropzone Input
cb_dropzone_input([array<string|int, mixed> $args = [] ]) : mixed
Outputs the hidden input markup.
Parameters
- $args : array<string|int, mixed> = []
-
The array of arguments that get passed to the getter. It would be wise to check what all is needed.
Tags
cb_templates_get_toggle_switch()
Alias for cb_templates_get_toggle_switch_input().
cb_templates_get_toggle_switch([mixed $args = [] ]) : mixed
Parameters
- $args : mixed = []
Tags
cb_templates_get_toggle_switch_input()
Gets markup for a toggle switch input.
cb_templates_get_toggle_switch_input([array<string|int, mixed> $args = [] ]) : string
Parameters
- $args : array<string|int, mixed> = []
-
{ An array of options for each input you want to include, structured in a 2D array of options.
@type string $name The value used in the for, name, and id attributes. @type string $label The label for the option. @type string $value The value of the option. @type bool $checked Whether the field is checked or not. @type bool $disabled Whether the field is disabled or not.
}
Tags
Return values
string —The formatted markup.
cb_toggle_switch()
CB Toggle Switch
cb_toggle_switch([array<string|int, mixed> $args = [] ]) : mixed
Outputs toggle switch markup.
Parameters
- $args : array<string|int, mixed> = []
-
An array of options for each input you want to include, structured in a 2D array of options.
@type string $name The value used in the for, name, and id attributes. @type string $label The label for the option. @type string $value The value of the option. @type bool $checked Whether the field is checked or not. @type bool $disabled Whether the field is disabled or not.
Tags
cb_templates_get_form()
CB Templates Get Form
cb_templates_get_form([mixed $args = array() ]) : string
Gets the markup for a form element.
Parameters
- $args : mixed = array()
Tags
Return values
string —The formatted markup.
cb_form()
Outputs the markup for a form element.
cb_form([mixed $args = [] ]) : mixed
Parameters
- $args : mixed = []
Tags
cb_templates_get_form_module()
Gets the markup for a form module.
cb_templates_get_form_module([array<string|int, mixed> $args = [] ]) : string
Use this when you want the whole UI kit and caboodle on the Confetti Bits dashboard (i.e., you just want a form inside of a module).
Parameters
- $args : array<string|int, mixed> = []
-
{ An array of arguments.
@type string $component The name of the component. @type string $method The form method. @type array $classes Classes for the form element. @type string $action The URL for the form handler. @type string $output The markup that goes into the form. @type string $enctype The encoding for the form. @type string $autocomplete Whether the form should include autocomplete features.
}
Tags
Return values
string —The formatted markup of the form module.
cb_templates_get_form_button()
Returns formatted markup for a form button. Note that this should not be used as a submit button; we typically use input[type=submit] for that functionality. Here we'll default to button[type=button] to ensure that we can have it do what we want and not make the app have a heart attack.
cb_templates_get_form_button([array<string|int, mixed> $args = [] ]) : string
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments. Accepts various attributes of button elements, with support for your own custom attributes as well. }
Tags
Return values
string —The formatted markup.
cb_form_module()
Outputs the form module's markup.
cb_form_module([array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $args : array<string|int, mixed> = []
-
{ @see cb_templates_get_form_module() }
Tags
cb_templates_recursive_helper()
A recursive helper function to help us process complex content trees.
cb_templates_recursive_helper([mixed $node = [] ]) : string
It'll recurse through each node that's labeled as a 'new_node' and return a string of content that's ready to echo out into the world.
Parameters
- $node : mixed = []
Tags
Return values
string —The glorious content.
cb_templates_get_time_picker_input()
Gets markup for a time picker.
cb_templates_get_time_picker_input([array<string|int, mixed> $args = [] ]) : string
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments for the time picker.
@type string $name The name attribute for the input. @type string $label The label for the input.
@type string $classes The classes for the input. @type string $value The value for the input. @type string $placeholder The placeholder for the input. @type string $min The minimum time for the input. @type string $max The maximum time for the input. @type string $step The step for the input.
}
Tags
Return values
string —The markup for the time picker input.
cb_time_picker_input()
Outputs markup for a time picker.
cb_time_picker_input([mixed $args = [] ]) : mixed
Parameters
- $args : mixed = []
Tags
cb_templates_get_date_picker_input()
Gets markup for a date picker input.
cb_templates_get_date_picker_input([array<string|int, mixed> $args = [] ]) : string
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments for the inputs.
@type string $label A label for the input. @type string $name The name attribute for the input. Required. @type string $placeholder A placeholder date string. Default current date, formatted 'm/d/Y'. @type string $value A preset value for the input. @type bool $disabled Whether the input should be disabled by default. Default false. @type bool $hidden Whether the input should be hidden by default. Default false. @type bool $required Whether the input should be required by default. Default false. @type string|array $classes An array of classes that will be added to the container element. Default ['cb-date-picker'].
}
Tags
Return values
string —The formatted markup for the inputs.
cb_templates_get_datetime_picker_input()
Gets markup for both date and time inputs on one line.
cb_templates_get_datetime_picker_input([array<string|int, mixed> $args = [] ]) : string
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments for the inputs.
@type array $date { @see cb_templates_get_date_picker_input() } @type array $time { @see cb_templates_get_time_picker_input() }
}
Tags
Return values
string —The formatted markup for the inputs.
cb_datetime_picker()
Outputs markup for a datetime picker input.
cb_datetime_picker([mixed $args = [] ]) : mixed
Parameters
- $args : mixed = []
Tags
cb_templates_get_datetime_local_input()
Formats markup for a datetime-local input.
cb_templates_get_datetime_local_input([array<string|int, mixed> $args = [] ]) : string
I cannot believe I didn't know this existed until so recently.
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments.
@type string $label A label for the input. @type string $name A name for the input. @type string $placeholder A placeholder for the input. @type string $value A default value for the input. @type bool $disabled Whether the input is disabled by default. @type bool $hidden Whether the input is hidden by default. @type bool $required Whether the input is required by default. @type array $classes An array of class selectors to give the input.
}
Tags
Return values
string —The formatted markup.
cb_datetime_local_input()
Outputs markup for a datetime-local input.
cb_datetime_local_input([mixed $args = [] ]) : mixed
Parameters
- $args : mixed = []
Tags
cb_date_input()
Outputs markup for a pretty date input.
cb_date_input([mixed $args = [] ]) : mixed
Parameters
- $args : mixed = []
Tags
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_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.
cb_templates_get_admin_page()
Formats markup for our admin settings page.
cb_templates_get_admin_page() : string
Tags
Return values
string —The formatted page markup.
cb_core_admin_page()
Outputs markup for our admin settings page.
cb_core_admin_page() : mixed