Documentation

WP_Backstage_Taxonomy extends WP_Backstage_Component
in package

WP Backstage Taxonomy

Tags
since
0.0.1

Table of Contents

$args  : array<string|int, mixed>
Args
$countries  : array<string|int, mixed>
Countries
$date_format  : string
Date Format
$default_address_args  : array<string|int, mixed>
Default Address Args
$default_address_values  : array<string|int, mixed>
Default Address Values
$default_args  : array<string|int, mixed>
Default Args
$default_code_args  : array<string|int, mixed>
Default Code Args
$default_color_args  : array<string|int, mixed>
Default Color Args
$default_date_args  : array<string|int, mixed>
Default Date Args
$default_editor_args  : array<string|int, mixed>
Default Editor Args
$default_field_args  : array<string|int, mixed>
Default Field Args
$default_filter_control_args  : array<string|int, mixed>
Default Filter Control Args
$default_media_uploader_args  : array<string|int, mixed>
Default Media Uploader Args
$default_option_args  : array<string|int, mixed>
Default Option Args
$default_select_posts_args  : array<string|int, mixed>
Default Select Posts Args
$default_select_users_args  : array<string|int, mixed>
Default Select Users Args
$errors  : array<string|int, mixed>
Errors
$filterable_fields  : array<string|int, mixed>
Filterable Fields
$global_code_settings  : array<string|int, mixed>
Global Code Settings
$new  : string
New
$non_regular_text_fields  : array<string|int, mixed>
Non Regular Text Fields
$nonce_key  : string
Nonce Key
$remove_label_for_fields  : array<string|int, mixed>
Remove Label For Fields
$required_args  : array<string|int, mixed>
Required Args
$required_args_modify  : array<string|int, mixed>
Required Args - Modify
$screen_id  : string|array<string|int, mixed>
Screen ID
$slug  : string
Slug
$textarea_control_fields  : array<string|int, mixed>
Textarea Control Fields
$time_pieces  : array<string|int, mixed>
Time Pieces
$us_states  : array<string|int, mixed>
US States
__construct()  : void
Construct
add()  : WP_Backstage_Taxonomy
Add
add_field_columns()  : array<string|int, mixed>
Add Field Columns
add_help_tabs()  : void
Add Help Tabs
add_list_table_query_actions()  : void
Add List Table Query Action
add_rest_api_field_link()  : WP_REST_Response
Add REST API Field Link
has_errors()  : bool
Has Errors
init()  : void
Init
inline_code_editor_script()  : void
Inline Code Editor Script
manage_admin_column_content()  : string
Manage Admin Column Content
manage_default_hidden_columns()  : array<string|int, mixed>
Manage Default Hidden Columns
manage_filtering()  : void
Manage Filtering
manage_list_table_query()  : void
Manage List Table Query Args
manage_sortable_columns()  : array<string|int, mixed>
Manage Sortable Columns
manage_sorting()  : void
Manage Sorting
manage_term_updated_messages()  : array<string|int, mixed>
Manage Term Updated Messages
modify()  : WP_Backstage_Taxonomy
Modify
prepare_rest_term()  : WP_REST_Response
Prepare Rest Term
print_errors()  : void
Print Errors
register()  : void
Register
register_api_meta()  : void
Register API Meta
render_add_fields()  : void
Render Add Fields
render_add_nonce()  : string
Render Add nonce
render_adding_terms_help_tab()  : void
Render Adding Terms Help Tab
render_edit_fields()  : void
Render Edit Fields
render_edit_nonce()  : string
Render Edit nonce
render_overview_help_tab()  : void
Render Overview Help Tab
render_rest_api_preview()  : void
Render REST API Preview
render_rest_api_preview_help_tab()  : void
Render REST API Preview Help Tab
render_table_filter_control()  : void
Render Table Filter Control
render_table_filter_controls()  : void
Render Table Filter Controls
render_table_filter_form()  : void
Render Table Filter Form
sanitize_address()  : array<string|int, mixed>
Sanitize Address
sanitize_checkbox()  : bool
Sanitize Checkbox
sanitize_checkbox_set()  : array<string|int, mixed>
Sanitize Checkbox Set
sanitize_code()  : string
Sanitize Code
sanitize_editor()  : string
Sanitize Editor
sanitize_email()  : string
Sanitize Email
sanitize_field()  : mixed
Sanitize Field
sanitize_media()  : array<string|int, mixed>
Sanitize Media
sanitize_number()  : float
Sanitize Number
sanitize_select_posts()  : array<string|int, mixed>
Sanitize Select Posts
sanitize_select_users()  : array<string|int, mixed>
Sanitize Select Users
sanitize_text()  : string
Sanitize Text
sanitize_textarea()  : string
Sanitize Textarea
sanitize_time()  : string
Sanitize Time
sanitize_url()  : string
Sanitize URL
save()  : void
Save
validate_term()  : string|WP_Error
Validate Term
format_attrs()  : string
Format Attrs
format_field_value()  : string
Format Field Value
format_filterable_value()  : mixed
Format Filterable Value
get_field_by()  : array<string|int, mixed>
Get Field By
get_field_schema()  : array<string|int, mixed>
Get Field Schema
get_fields()  : array<string|int, mixed>
Get Fields
get_fields_by()  : array<string|int, mixed>
Get Fields By
get_fields_by_query()  : array<string|int, mixed>
Get Fields By Query
get_option_labels()  : array<string|int, mixed>
Get Option Labels
get_sanitize_callback()  : string
Get Sanitize Callback
is_screen()  : bool
Is Screen
render_address()  : void
Render Address
render_checkbox()  : void
Render Checkbox
render_checkbox_set()  : void
Render Checkbox Set
render_code()  : void
Render Code
render_color()  : void
Render Color
render_date()  : void
Render Date
render_editor()  : void
Render Editor
render_field_by_type()  : void
Render Field By Type
render_input()  : void
Render Input
render_media_uploader()  : void
Render Media Uploader
render_radio()  : void
Render Radio
render_select()  : void
Render Select
render_select_posts()  : void
Render Select Posts
render_select_users()  : void
Render Select Users
render_textarea()  : void
Render Textarea
render_time()  : void
Render Time
render_time_options()  : void
Render Time Options
set_args()  : void
Set Args
set_errors()  : void
Set Errors

Properties

$countries

Countries

protected array<string|int, mixed> $countries = array()

An array of localized countries.

Tags
since
0.0.1

$default_address_args

Default Address Args

protected array<string|int, mixed> $default_address_args = array('max_width' => '100%')

An array of default address arguments.

Tags
since
0.0.1

$default_address_values

Default Address Values

protected array<string|int, mixed> $default_address_values = array('country' => 'US', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => 'AL', 'zip' => '')

An array of default address field arguments.

Tags
since
0.0.1

$default_args

Default Args

protected array<string|int, mixed> $default_args = array('singular_name' => '', 'plural_name' => '', 'description' => '', 'public' => \true, 'hierarchical' => \true, 'with_front' => \false, 'archive_base' => '', 'rest_base' => '', 'fields' => array())

The default arguments for this instance.

Tags
since
0.0.1

$default_code_args

Default Code Args

protected array<string|int, mixed> $default_code_args = array('settings_key' => '', 'mime' => 'text/html', 'max_width' => '100%')

An array of default code editor arguments.

Tags
since
0.0.1

$default_color_args

Default Color Args

protected array<string|int, mixed> $default_color_args = array( 'mode' => '', // hsl, hsv. 'palettes' => \true, )

An array of default color field arguments.

Tags
since
0.0.1

$default_date_args

Default Date Args

protected array<string|int, mixed> $default_date_args = array('format' => 'yy-mm-dd')

An array of default date field arguments.

Tags
since
0.0.1

$default_editor_args

Default Editor Args

protected array<string|int, mixed> $default_editor_args = array('max_width' => '100%', 'format_select' => \false, 'media_buttons' => \false, 'kitchen_sink' => \false)

An array of default editor field arguments.

Tags
since
0.0.1

$default_field_args

Default Field Args

protected array<string|int, mixed> $default_field_args = array('id' => '', 'type' => 'text', 'name' => '', 'label' => '', 'title' => '', 'value' => \null, 'disabled' => \false, 'description' => '', 'help' => '', 'show_label' => \true, 'show_in_rest' => \false, 'options' => array(), 'input_attrs' => array(), 'args' => array())

An array of default field args.

Tags
since
0.0.1
since
3.4.0

Added show_in_rest argument.

$default_filter_control_args

Default Filter Control Args

protected array<string|int, mixed> $default_filter_control_args = array('id' => '', 'name' => '', 'value' => \null, 'label' => '', 'option_none_label' => '', 'options' => array())

The default filter control args for this instance.

Tags
since
0.0.1

$default_media_uploader_args

Default Media Uploader Args

protected array<string|int, mixed> $default_media_uploader_args = array('type' => '', 'multiple' => \false, 'attach' => \false)

An array of default media field arguments.

Tags
since
0.0.1

$default_option_args

Default Option Args

protected array<string|int, mixed> $default_option_args = array('value' => '', 'label' => '', 'disabled' => \false)

An array of default option arguments.

Tags
since
0.0.1

$default_select_posts_args

Default Select Posts Args

protected array<string|int, mixed> $default_select_posts_args = array('option_none_label' => '', 'query' => array('posts_per_page' => -1, 'post_type' => 'page', 'post_status' => 'any'))

An array of default select posts arguments.

Tags
since
3.0.0
since
3.1.0

Allows for full query args to be passed.

$default_select_users_args

Default Select Users Args

protected array<string|int, mixed> $default_select_users_args = array('option_none_label' => '', 'query' => array('number' => -1, 'count' => \false))

An array of default select users arguments.

Tags
since
3.0.0

$errors

Errors

protected array<string|int, mixed> $errors = array()

The array of all errors on the instance.

Tags
since
0.0.1

$filterable_fields

Filterable Fields

protected array<string|int, mixed> $filterable_fields = array('select', 'radio', 'select_posts', 'select_users')

Field types that should have the for attribute removed labels.

Tags
since
0.0.1

$new

New

protected string $new = \true

Whether the instance is creating a new taxonomy or modifying an existing one.

Tags
since
2.0.0

$non_regular_text_fields

Non Regular Text Fields

protected array<string|int, mixed> $non_regular_text_fields = array('number', 'textarea', 'editor', 'select', 'checkbox', 'checkbox_set', 'radio', 'media', 'code', 'date', 'time', 'address', 'select_posts', 'select_users')

Field types that do not include text-style inputs.

Tags
since
0.0.1

$remove_label_for_fields

Remove Label For Fields

protected array<string|int, mixed> $remove_label_for_fields = array('radio', 'checkbox_set', 'time', 'address')

Field types that should have the for attribute removed labels.

Tags
since
0.0.1

$required_args

Required Args

protected array<string|int, mixed> $required_args = array('singular_name', 'plural_name')

The required argument keys for this instance.

Tags
since
0.0.1

$required_args_modify

Required Args - Modify

protected array<string|int, mixed> $required_args_modify = array()

The required argument keys for this instance if modifying.

Tags
since
2.0.0

$slug

Slug

protected string $slug = ''

This is the main text identifier of the instance. It is alpha-numeric and only contains lowercase letters, underscores and hyphens. The slug is used when building nonces, creating dynamic hooks, and registering post types, taxonomies, and options pages. Note that on instances of WP_Backstage_User, the slug is set to user. The slug is sanitized using WordPress's sanitize_key() function that is used when sanitizing slugs.

the text slug that identifies the instance.

Tags
link

sanitize_key()

since
0.0.1

$textarea_control_fields

Textarea Control Fields

protected array<string|int, mixed> $textarea_control_fields = array('textarea', 'editor', 'code')

Field types that use a textarea input as a control.

Tags
since
0.0.1

$time_pieces

Time Pieces

protected array<string|int, mixed> $time_pieces = array()

This configuration is used in order to create the 3 <select> fields needed to create a time string as 00:00:00. This will register the localized label and set the number of options that are necessary for each time piece (hour, minute, second) respectively.

The configuration for time fields.

Tags
since
0.0.1

$us_states

US States

protected array<string|int, mixed> $us_states = array()

An array of localized US states.

Tags
since
0.0.1

Methods

__construct()

Construct

public __construct([string $slug = '' ][, array<string|int, mixed> $args = array() ][, bool $new = true ]) : void
Parameters
$slug : string = ''

The developer-provided slug for the taxonomy.

$args : array<string|int, mixed> = array()

The developer-provided arguments for this instance.

$new : bool = true

Whether this instance constructs a new taxonomy or modifies an existing one.

Tags
since
0.0.1
since
2.0.0

Adds $new parameter for distinguishing between add and modify behavior.

Return values
void

add_field_columns()

Add Field Columns

public add_field_columns([string $columns = array() ]) : array<string|int, mixed>

This will embed the field columns into the columns array. Looping through the already-set column names, if the column name is comments, date, or posts, The new field columns will be placed before the first instance of one of them. This method is hooked by objects screens that have tables, like WP_Backstage_User, WP_Backstage_Post_Type, and WP_Backstage_Taxonomy. Columns will only be placed for the field if the field's has_column argument is set to true.

Parameters
$columns : string = array()

The columns that are currently set.

Tags
link

hook: manage_{$post_type}_posts_columns

since
0.0.1
Return values
array<string|int, mixed>

The filtered columns with the new columns added.

add_help_tabs()

Add Help Tabs

public add_help_tabs([WP_Screen $screen = null ]) : void

Registers the help tabs.

Parameters
$screen : WP_Screen = null

an instance of WP_Screen.

Tags
link

WP_Screen

link

Current Screen

since
3.4.0
Return values
void

add_list_table_query_actions()

Add List Table Query Action

public add_list_table_query_actions([WP_Term_Query $query = null ]) : void

This method is responsible for adding an action to manage specifically the query that populates the terms list table on the edit taxonomy screens. Currently, there is no way in core to determine if a query is the main query for taxonomy edit screens. This is necessary in order to be able to modify the main query without polluting other term queries that may be on the page. It is safe to assume that the first get_terms() call that is relevant to this taxonomy on the edit screen is the main query that populates the table. This method also takes into account the main "count" query as well, which is a seperate call.

Parameters
$query : WP_Term_Query = null

The currently set WP_Term_Query instance.

Tags
since
3.1.0
Return values
void

Add REST API Field Link

public add_rest_api_field_link([WP_REST_Response $response = null ][, array<string|int, mixed> $field = array() ][, mixed $value = null ]) : WP_REST_Response
Parameters
$response : WP_REST_Response = null

The response object to manipulate.

$field : array<string|int, mixed> = array()

An array of field arguments.

$value : mixed = null

The field's value.

Tags
since
3.4.0
Return values
WP_REST_Response

The augmented response object.

has_errors()

Has Errors

public has_errors() : bool

A utility method to easily check if the instance has errors or not.

Tags
since
0.0.1
Return values
bool

Whether the instance has errors or not.

init()

Init

public init() : void
Tags
since
0.0.1
since
2.0.0

Ensures a new taxonomy is only registered if adding a new one.

since
3.4.0

Adds help tabs, term update messages, and registers meta with the REST API.

since
3.6.0

Removes sprintf templates from hook names.

Return values
void

inline_code_editor_script()

Inline Code Editor Script

public inline_code_editor_script() : void

Inlines the code editor settings objects. This provides necessary context to the code editor scripts when initializing code editor fields.

Tags
link

wp_enqueue_script()

link

wp_enqueue_style()

link

wp_add_inline_script()

link

wp_enqueue_editor()

link

wp_enqueue_media()

link

did_action()

link

hook: admin_enqueue_scripts

link

Including CSS and Javascript in WP

since
0.0.1
Return values
void

manage_admin_column_content()

Manage Admin Column Content

public manage_admin_column_content([string $content = '' ][, string $column = '' ], int $term_id) : string
Parameters
$content : string = ''

The already-set content for this column.

$column : string = ''

The column name.

$term_id : int

The ID of the term for this row.

Tags
since
0.0.1
Return values
string

The populated column content for this column.

manage_default_hidden_columns()

Manage Default Hidden Columns

public manage_default_hidden_columns([array<string|int, mixed> $hidden = array() ][, WP_Screen $screen = null ]) : array<string|int, mixed>

Adds all generated fields to the hidden columns array by default, so as to not choke up the UI. Note that this will only work if this taxonomy's columns UI has never been modified by the user. Hooked to default_hidden_columns.

Parameters
$hidden : array<string|int, mixed> = array()

An array of hidden columns.

$screen : WP_Screen = null

An instance of WP_Screen.

Tags
link

Hook: default_hidden_columns

link

WP_Screen

since
0.0.1
since
3.0.0

Only add the field to hidden columns array if the field is set to have a column.

Return values
array<string|int, mixed>

An array of column names

manage_filtering()

Manage Filtering

public manage_filtering([WP_Term_Query $query = null ]) : void

This method is responsible for filtering the query if a query var set to a field's name is found. The fields are looped over and, if a field is found with the matching query var, builds an array of meta query filters. At the end of the loop, if there is a meta query to be set, the "AND" relation is also added to the meta query, allowing for complex filtering to be accomplished. See WP_Backstage_Taxonomy::manage_list_table_query() to see how the fields are made available as public query vars.

Parameters
$query : WP_Term_Query = null

The currently set WP_Term_Query instance.

Tags
since
3.1.0
Return values
void

manage_list_table_query()

Manage List Table Query Args

public manage_list_table_query([WP_Term_Query $query = null ]) : void

This method is responsible for making the URL query fields available to the main WP_Term_Query. This allows for similar behavior to the query vars filter that is only available for posts. This method loops over the fields, and checks if the field key is a key of the URL query. If it is, it then adds the key and value to the args array to be passed to the WP_Term_Query that runs the main terms list table. This hooks to an action added by WP_Backstage_Taxonomy::add_list_table_query_actions().

Parameters
$query : WP_Term_Query = null

The incoming WP_Term_Query instance.

Tags
since
3.1.0
Return values
void

manage_sortable_columns()

Manage Sortable Columns

public manage_sortable_columns([array<string|int, mixed> $columns = array() ]) : array<string|int, mixed>

This will set which columns are sortable. This method is hooked by object screens that have tables, like WP_Backstage_User, WP_Backstage_Post_Type, and WP_Backstage_Taxonomy. Columns will only be made sortable if the field's has_column and is_sortable arguments are set to true.

Parameters
$columns : array<string|int, mixed> = array()

The sortable columns that are currently set.

Tags
link

hook: manage_{$screen_id}_sortable_columns

since
0.0.1
Return values
array<string|int, mixed>

The sortable columns with the new sortable columns added.

manage_sorting()

Manage Sorting

public manage_sorting([WP_Term_Query $query = null ]) : void

The method is responsible for managing sorting on the query. If a field's name is found in the orderby key, then its key is added as the meta_key for the query, and the orderby is reset to either meta_value or meta_value_num according to if the value is expected to be numeric or not. If no meta query is set, this will add a meta query that filters for terms that either do or do not have the meta value set for the field. By default, setting just meta_key is not sufficient if the desire is to show terms that don't have a value as well.

Parameters
$query : WP_Term_Query = null

The currently set WP_Term_Query instance.

Tags
since
3.1.0
Return values
void

manage_term_updated_messages()

Manage Term Updated Messages

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

An arry of currently set messages.

Tags
since
3.4.0
Return values
array<string|int, mixed>

$messages An array of filtered messages.

prepare_rest_term()

Prepare Rest Term

public prepare_rest_term([WP_REST_Response $response = null ][, WP_Term $term = null ][, WP_REST_Request $request = null ]) : WP_REST_Response

This method is responsible for preparing the REST API response for the term before it is sent out to the consumer. "Links" are added for the fields that reference another content type (posts, attachments, users, etc.), allowing for the content to be embedded if requested.

Parameters
$response : WP_REST_Response = null

The current API response.

$term : WP_Term = null

The requested term.

$request : WP_REST_Request = null

The current API request.

Tags
link

Extending the REST API

link

Modifying Responses

link

WP_REST_Response::add_link()

since
3.4.0
Return values
WP_REST_Response

The filtered API response.

register()

Register

public register() : void

This method does the actual registration of the taxonomy. It will set everything needed to extend WordPress to allow for our new taxonomy such as adding all the labels, setting the rewrite rules and REST API base, and configures the WP admin UI.

Tags
link

register_taxonomy()

link

WP_Taxonomy

since
0.0.1
Return values
void

register_api_meta()

Register API Meta

public register_api_meta() : void

This method is responsible for registering the term meta fields with the REST API, and generating the schema for each.

Tags
since
3.4.0
Return values
void

render_add_fields()

Render Add Fields

public render_add_fields([string $taxonomy = '' ]) : void

This will render all fields on the taxonomy management screen. Note that this passes the taxonomy string, though this is not necessary, as this method is only hooked to {taxonomy}_add_form_fields. This means that this will only run on this instance's taxonomy.

Parameters
$taxonomy : string = ''

The taxonomy slug as registered.

Tags
link

{taxonomy}_add_form_fields

since
0.0.1
Return values
void

render_add_nonce()

Render Add nonce

public render_add_nonce() : string

Renders a nonce with this instance's $nonce_key with the action set to add.

Tags
since
0.0.1
Return values
string

The formatted add nonce.

render_adding_terms_help_tab()

Render Adding Terms Help Tab

public render_adding_terms_help_tab([WP_Screen $screen = null ][, array<string|int, mixed> $args = array() ]) : void
Parameters
$screen : WP_Screen = null

The current WP_Screen instance.

$args : array<string|int, mixed> = array()

An array of help tab arguments.

Tags
since
3.4.0
Return values
void

render_edit_fields()

Render Edit Fields

public render_edit_fields([WP_Term $term = null ][, string $taxonomy = null ]) : void

This will render all fields on the edit singular term screen. An instance of WP_Term is passed as the first argument. Note that this also passes the taxonomy string, though this is not necessary, as this method is only hooked to {taxonomy}_edit_form_fields. This means that this will only run on terms for this instance's taxonomy.

Parameters
$term : WP_Term = null

An instance of WP_Term.

$taxonomy : string = null

The taxonomy slug as registered.

Tags
link

{taxonomy}_edit_form_fields

link

WP_Term

since
0.0.1
Return values
void

render_edit_nonce()

Render Edit nonce

public render_edit_nonce() : string

Renders a nonce with this instance's $nonce_key and the action set to edit.

Tags
since
0.0.1
Return values
string

The formatted edit nonce.

render_overview_help_tab()

Render Overview Help Tab

public render_overview_help_tab([WP_Screen $screen = null ][, array<string|int, mixed> $args = array() ]) : void
Parameters
$screen : WP_Screen = null

The current WP_Screen instance.

$args : array<string|int, mixed> = array()

An array of help tab arguments.

Tags
since
3.4.0
Return values
void

render_rest_api_preview()

Render REST API Preview

public render_rest_api_preview([string $path = '' ]) : void

This method renders a REST API preview for a given path. Code mirror is used to initialize a json editor area that is read only. Filters for context and _embed are provided for through api response checks.

Parameters
$path : string = ''

An API path to fetch.

Tags
since
3.4.0
since
3.4.2

Fixes bug where event listeners were being added instead of removed on destroy.

Return values
void

render_rest_api_preview_help_tab()

Render REST API Preview Help Tab

public render_rest_api_preview_help_tab([WP_Screen $screen = null ][, array<string|int, mixed> $args = array() ]) : void
Parameters
$screen : WP_Screen = null

The current WP_Screen instance.

$args : array<string|int, mixed> = array()

An array of help tab arguments.

Tags
since
3.4.0
Return values
void

render_table_filter_control()

Render Table Filter Control

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

This method is responsible for rendering a single filter control according to the array of arguments passed in. This will always render an HTML <select> element and is constructed in the same way that the existing table filter controls are rendered in core WordPress table fitlers. Note that the options key can either be an array of option arguments, or a string of fully built HTML <options>, to be able to support the drop down walkers for select_users and select_posts.

Parameters
$args : array<string|int, mixed> = array()

The incoming args for this control.

Tags
since
3.1.0
Return values
void

render_table_filter_controls()

Render Table Filter Controls

public render_table_filter_controls() : void

This method is responsible for rendering the filter controls for fields. The fields will get their value from the parsed URL query parameters and set up arguments for the filter select as defined in WP_Backstage_Component::render_table_filter_control().

Tags
since
3.1.0
Return values
void

render_table_filter_form()

Render Table Filter Form

public render_table_filter_form([string $taxonomy = '' ]) : void

This method is responsible for rendering the filter form at the top of the admin taxonomy list table. Because the taxonomy list table does not have filters, it is necessary to add the filter action submit button here. The taxonomy table class provides no hooks to render the filters into the form. The class also renders a form with the method of "post", unlike all the other table forms which use "get". Because of these caveats, it is necessary to both render the fields underneath the table, which is outside the form, and to add some javascript to both move the form into the proper area; as well as add some javascript that will handle submit.

Parameters
$taxonomy : string = ''

The taxonomy of the current screen.

Tags
since
3.1.0
Return values
void

sanitize_address()

Sanitize Address

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

The value to sanitize. Expects an array of address key => value pairs.

Tags
link

esc_attr()

link

Validating, Sanitizing, and Escaping User Data in WP

since
0.0.1
since
2.0.0

Parses against default address values.

since
3.4.0

Maps values with sanitize_text_field() instead of esc_attr().

Return values
array<string|int, mixed>

An array of address key => value pairs.

sanitize_checkbox_set()

Sanitize Checkbox Set

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

The values to sanitize. Expects an array of strings.

Tags
link

Validating, Sanitizing, and Escaping User Data in WP

since
0.0.1
since
2.0.0

Sanitizes more strictly to support strange behavior on menu items.

since
3.4.0

Maps using sanitize_text_field() instead of esc_attr().

Return values
array<string|int, mixed>

An array of values.

sanitize_field()

Sanitize Field

public sanitize_field([array<string|int, mixed> $field = array() ][, mixed $value = null ]) : mixed
Parameters
$field : array<string|int, mixed> = array()

The field args.

$value : mixed = null

The field value.

Tags
link

Validating, Sanitizing, and Escaping User Data in WP

since
0.0.1
since
2.0.0

Removed check for single media vs. multiple media.

since
3.0.0

Added case for select_posts.

since
3.1.0

Added case for select_users.

Return values
mixed

The sanitized value according to the field type.

sanitize_media()

Sanitize Media

public sanitize_media([mixed $value = null ]) : array<string|int, mixed>
Parameters
$value : mixed = null

The value to sanitize. Expects a CSV string or array of attachment IDs.

Tags
link

Validating, Sanitizing, and Escaping User Data in WP

since
0.0.1
since
2.0.0

Removed check for single vs. multiple and treats both as array.

Return values
array<string|int, mixed>

An array of integers.

sanitize_time()

Sanitize Time

public sanitize_time([mixed $value = array() ]) : string
Parameters
$value : mixed = array()

The value to sanitize. Expects an array of 3 2-digit time values keyed as "hour", "minute", "second"; or a time string as hh:mm:ss.

Tags
link

esc_attr()

link

Validating, Sanitizing, and Escaping User Data in WP

since
0.0.1
since
2.0.0

Parses more strictly to support customizer changes.

since
2.4.0

Fixes bug introduced at 2.0.0 that parsed the values incorrectly.

Return values
string

a string as hh:mm:ss.

save()

Save

public save(int $term_id, int $tt_id) : void

Saves the form data as individual keys.

Parameters
$term_id : int

The ID of the term being saved.

$tt_id : int

the tt ID of the term being saved.

Tags
todo

Document $tt_id better.

since
0.0.1
Return values
void

validate_term()

Validate Term

public validate_term([string|WP_Error $term = '' ][, string $taxonomy = '' ][, array<string|int, mixed>|string $args = array() ]) : string|WP_Error
Parameters
$term : string|WP_Error = ''

The term name to add, or a WP_Error object if there's an error.

$taxonomy : string = ''

Taxonomy slug.

$args : array<string|int, mixed>|string = array()

Array or query string of arguments passed to wp_insert_term().

Tags
since
3.5.1
Return values
string|WP_Error

The original term name or a new WP_Error.

format_attrs()

Format Attrs

protected format_attrs([array<string|int, mixed> $attrs = array() ]) : string

A utility method for formatting an array of $key => $value pairs into a string of sanitized HTML element attributes.

Parameters
$attrs : array<string|int, mixed> = array()

An array of attributes as $key => $value pairs.

Tags
since
0.0.1
Return values
string

The imploded, escaped, formatted attributes.

format_field_value()

Format Field Value

protected format_field_value([mixed $value = null ][, array<string|int, mixed> $field = array() ]) : string

This will format a fields value based on a given array of field args. According to the field type, different formatting will be applied to the value.

Parameters
$value : mixed = null

The value to format.

$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
since
2.4.0

Renders the actual value if no label is found on fields like select, radio, and checkbox set.

since
3.0.0

Adds case for select_posts.

since
3.1.0

Adds case for select_users.

since
3.2.0

Abstracts filterable value rendering to the format_filterable_value() method and fixes issue where the color <i> elements were having "display:block" stripped from the inline CSS.

Return values
string

The value of the field as a string

format_filterable_value()

Format Filterable Value

protected format_filterable_value([mixed $value = null ][, string $label = '' ][, string $query_arg = '' ]) : mixed

This method is responsible for formatting filterable values. It accepts a value, a label, and a query arg and will determine what the link should be based on what component is currently being called.

Parameters
$value : mixed = null

The query arg's value.

$label : string = ''

The label that will be printed.

$query_arg : string = ''

The key of the query arg that will be added to the URL.

Tags
since
3.2.0
Return values
mixed

get_field_by()

Get Field By

protected get_field_by([string $key = '' ][, mixed $value = null ]) : array<string|int, mixed>

Get the first field that matches the passed $key and $value.

Parameters
$key : string = ''

the key of the field arg to check.

$value : mixed = null

the value of the passed field arg key to check.

Tags
since
0.0.1
Return values
array<string|int, mixed>

the first field arg array if found, or an empty array.

get_fields()

Get Fields

protected get_fields() : array<string|int, mixed>
Tags
since
0.0.1
Return values
array<string|int, mixed>

An array of field arguments if there are any, or an empty array.

get_fields_by()

Get Fields By

protected get_fields_by([string $key = '' ][, mixed $value = null ], int $number) : array<string|int, mixed>

Get all fields that matches the passed $key and $value.

Parameters
$key : string = ''

the key of the field arg to check.

$value : mixed = null

the value of the passed field arg key to check.

$number : int

the number of fields to return.

Tags
since
0.0.1
Return values
array<string|int, mixed>

an array of field arg arrays if found, or an empty array.

get_fields_by_query()

Get Fields By Query

protected get_fields_by_query([array<string|int, mixed> $query = array() ], int $number) : array<string|int, mixed>

Get all fields that matches the passed query array.

Parameters
$query : array<string|int, mixed> = array()

An array of key values to check against.

$number : int

the number of fields to return.

Tags
since
3.4.0
Return values
array<string|int, mixed>

an array of field arg arrays if found, or an empty array.

get_option_labels()

Get Option Labels

protected get_option_labels([array<string|int, mixed> $field = array() ]) : array<string|int, mixed>

A utility method to get the localized labels for a given field. This will return a $value => $label array that can be used to pluck an option label for a given option value for a field. This is useful when displaying the value of a radio, checkbox, or checkbox_set where the value is not "pretty".

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
array<string|int, mixed>

An array of $value => $label pairs.

get_sanitize_callback()

Get Sanitize Callback

protected get_sanitize_callback([array<string|int, mixed> $field = array() ]) : string

Since the WP_Backstage_Options class is using the WP Settings API, it is necessary to provide a sanitize_callback to the register_setting() function. This method provides a mask of all of this class's sanitize_field methods as strings per field type.

Parameters
$field : array<string|int, mixed> = array()

The field args.

Tags
link

register_setting()

link

Validating, Sanitizing, and Escaping User Data in WP

since
0.0.1
since
2.0.0

Removed check for single media vs. multiple media.

since
3.0.0

Added case for select_posts.

since
3.1.0

Added case for select_users.

Return values
string

The sanitize callback function name as a string.

is_screen()

Is Screen

protected is_screen([string $key = '' ][, string|array<string|int, mixed> $value = '' ]) : bool

A utility method to easily check values returned by get_current_screen().

Parameters
$key : string = ''

The key of the WP_Screen object to check.

$value : string|array<string|int, mixed> = ''

The value or array of values to check.

Tags
link

get_current_screen()

since
0.0.1
since
3.7.1

Returns false if get_current_screen() is not defined.

Return values
bool

If the match was successful or not.

render_address()

Render Address

protected render_address([array<string|int, mixed> $field = array() ]) : void

Render a group of fields that will provide all necessary inputs to create a full address. The value of this field is an array of address pieces as country, address, address_2, city, state, zip. If the US is selected as the country, then a <select> of localized US states will replace the "State/Province/Region" input.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_checkbox()

Render Checkbox

protected render_checkbox([array<string|int, mixed> $field = array() ]) : void

Render a checkbox field. This was separated out from this class's render_input() method because the markup is significantly different.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_checkbox_set()

Render Checkbox Set

protected render_checkbox_set([array<string|int, mixed> $field = array() ]) : void

Render a set of checkboxes that allow for multiple values to be set for a field. The options are set as an array of the field's options key. These can be dynamically created by looping post types, taxonomies, users, options, etc.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_code()

Render Code

protected render_code([array<string|int, mixed> $field = array() ]) : void

Render a code editor using the native CodeMirror integration in WordPress Core. This field supports multiple mime types like text/javascript, text/css, text/html, and application/pdf, etc. WordPress's provided configuration will lint, show errors in code, and provide autocompletes. All WordPress caveats, like bugs when moving code editors around in the DOM in meta boxes, and bugs when displaying a meta box that was hidden on page load, have been handled.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_color()

Render Color

protected render_color([array<string|int, mixed> $field = array() ]) : void

Render a color picker field. This uses the the native Iris JavaScript library as included in WordPress Core to render the same robust color pickers found in WordPress. The field is configurable with arguments for hsl and hsv color modes, as well as custom color palettes.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_date()

Render Date

protected render_date([array<string|int, mixed> $field = array() ]) : void

Render a date field using jQuery UI Datepicker. This was separated out from this class's render_input() method because of the JavaScript integration. This UI method ensures a full-proof way of ensuring date strings are always ISO compliant.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_editor()

Render Editor

protected render_editor([array<string|int, mixed> $field = array() ]) : void

This will render a WordPress editor complete with TinyMCE and quicktags. These provide a WYSIWYG environment where content creation can happen in a familiar WordPress flow. All WordPress caveats, like bugs when moving WP Editors around in the DOM in meta boxes, and bugs when displaying a meta box that was hidden on page load, have been handled.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_field_by_type()

Render Field By Type

protected render_field_by_type([array<string|int, mixed> $field = array() ]) : void

This will render a field by type, given an array of field arguments. Depending on the field type, different render field methods will be called in order to render the appropriate field HTML.

Parameters
$field : array<string|int, mixed> = array()

An array of field args.

Tags
since
0.0.1
since
3.0.0

Added case for select_posts.

since
3.1.0

Added case for select_users.

Return values
void

render_input()

Render Input

protected render_input([array<string|int, mixed> $field = array() ]) : void

Render an input field. This method will handle all HTML <input> types except for radio, checkbox, and those with their own methods like date.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_media_uploader()

Render Media Uploader

protected render_media_uploader([array<string|int, mixed> $field = array() ]) : void

The media uploader field is capable of selecting media files of all mime types, and supports single and multiple image selection. This field is deeply integrated into the WordPress Media Uploader, and there are arguments for mime type selection. Fields that allow multiple attachments to be selected also support selective removal, addition, and drag-and-drop sorting.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
since
2.0.0

Full rewrite of the media uploader markup.

since
3.3.0

Adds error and loader elements and removes the clone methodology in favor of ajax rendering.

Return values
void

render_radio()

Render Radio

protected render_radio([array<string|int, mixed> $field = array() ]) : void

Render a set of radios that allow for a single value to be set for a field. The options are set as an array of the field's options key. These can be dynamically created by looping post types, taxonomies, users, options, etc.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_select()

Render Select

protected render_select([array<string|int, mixed> $field = array() ]) : void

Render a select that allow for a single value to be set for a field. The options are set as an array of the field's options key. These can be dynamically created by looping post types, taxonomies, users, options, etc.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_select_posts()

Render Select Posts

protected render_select_posts([array<string|int, mixed> $field = array() ]) : void

Render a select field prepopulared by WordPress posts.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
3.0.0
since
3.1.0

Allows for full query args to be passed.

Return values
void

render_select_users()

Render Select Users

protected render_select_users([array<string|int, mixed> $field = array() ]) : void

Render a select field prepopulared by WordPress users.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
3.1.0
Return values
void

render_textarea()

Render Textarea

protected render_textarea([array<string|int, mixed> $field = array() ]) : void

Render a textarea field.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_time()

Render Time

protected render_time([array<string|int, mixed> $field = array() ]) : void

Render a time field. This will create the 3 <select> fields needed to create a time string as 00:00:00. This UI method ensures a full-proof way of ensuring time strings are always ISO compliant.

Parameters
$field : array<string|int, mixed> = array()

An array of field arguments.

Tags
since
0.0.1
Return values
void

render_time_options()

Render Time Options

protected render_time_options(int $number[, string $selected = '' ]) : void

This is used in order to create all <option> elements needed to create a time piece <select> as used in this class's render_time() method.

Parameters
$number : int

The number of options to render.

$selected : string = ''

The selected option's value.

Tags
since
0.0.1
Return values
void

set_args()

Set Args

protected set_args([array<string|int, mixed> $args = array() ]) : void
Parameters
$args : array<string|int, mixed> = array()

The developer-provided arguments for this instance.

Tags
since
0.0.1
Return values
void

Search results