Documentation

WP_Backstage_Nav_Menu_Item extends WP_Backstage_Component
in package

WP Backstage Nav Menu Item

Tags
since
2.0.0

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
$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
$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_field_columns()  : array<string|int, mixed>
Add Field Columns
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
inline_customizer_style()  : void
Inline Customizer Style
manage_customizer_meta_preview()  : void
Manage Customizer Meta Preview
manage_default_hidden_columns()  : array<string|int, mixed>
Manage Default Hidden Columns
manage_sortable_columns()  : array<string|int, mixed>
Manage Sortable Columns
modify()  : WP_Backstage_Nav_Menu_Item
Add
print_errors()  : void
Print Errors
render_add_nonce()  : string
Render Add nonce
render_customizer_fields()  : void
Render Customizer Fields
render_edit_nonce()  : string
Render Edit nonce
render_fields()  : void
Render Fields
render_rest_api_preview()  : void
Render REST API Preview
render_table_filter_control()  : void
Render Table Filter Control
render_table_filter_controls()  : void
Render Table Filter Controls
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
save_customizer()  : void
Save Customizer
setup_nav_menu_item()  : object
Setup Nav Menu Item
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('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

$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()

The required arguments for this instance. Arguments in this array will throw an error if empty.

Tags
since
0.0.1

$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([array<string|int, mixed> $args = array() ]) : void
Parameters
$args : array<string|int, mixed> = array()

An array of arguments.

Tags
since
2.0.0
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 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
2.0.0
since
3.5.0

Hooks the manage_customizer_meta_preview method at a much later priority.

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

inline_customizer_style()

Inline Customizer Style

public inline_customizer_style() : void

This method is responsible for inlint field specific customizer styles.

Tags
since
2.0.0
Return values
void

manage_customizer_meta_preview()

Manage Customizer Meta Preview

public manage_customizer_meta_preview([WP_Customize_Manager $wp_customize = null ]) : void

Preview changes to the nav menu item roles. Note the unimplemented to-do in the doc block for the setting's preview method. This will only work for existing menu items. New menu items have a dynamically generated ID and do not exist in the database yet. Note that this is a "short-circuit" filter, which means if a non-null value is returned, it will be used instead of the DB or cache value. This filter always receives null as the $value. The return value must always be an array, even if it is a single value.

Parameters
$wp_customize : WP_Customize_Manager = null

The WP Customize instance.

Tags
link

Filter: get_{$meta_type}_metadata

link

Stack Overflow Discussion on Nav Menu Items in the Customizer

link

Customizer Roles Plugin Example by Weston Ruter

since
2.0.0
since
3.5.0

Always cast value to array, more strict checks of value existence, upped the priority so this always runs last.

Return values
void

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 post type'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
2.0.0
Return values
array<string|int, mixed>

An array of hidden column keys.

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.

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_customizer_fields()

Render Customizer Fields

public render_customizer_fields() : void

Render the customizer template for new menu items. Note that the templating is different in the customizer for menu items, therefore the before and after field actions are different in this case and are passed different values.

Tags
since
2.0.0
since
3.5.0

Uses the menu item ID as the dynamic portion of the name/id instead of the instance number.

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_fields()

Render Fields

public render_fields(int $item_id[, WP_Post $item = null ], int $depth[, object $args = null ], int $id) : void
Parameters
$item_id : int

The nav menu item ID.

$item : WP_Post = null

The nav menu item post object.

$depth : int

The depth of menu item.

$args : object = null

An object of menu item arguments.

$id : int

The ID of the nav menu that this item is related to.

Tags
since
2.0.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_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

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 $menu_id, int $item_id[, array<string|int, mixed> $menu_item_data = array() ]) : void
Parameters
$menu_id : int

The ID of the menu that the item is in.

$item_id : int

The ID of the menu item.

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

The menu item data.

Tags
since
2.0.0
Return values
void

save_customizer()

Save Customizer

public save_customizer([WP_Customize_Manager $wp_customize = null ]) : void

Save the Nav Menu Item settings after the customizer has finished saving.

Parameters
$wp_customize : WP_Customize_Manager = null

The current WP Customize instance.

Tags
todo

Though it's probably not needed, try to check nonce here.

since
2.0.0
Return values
void

setup_nav_menu_item()

Setup Nav Menu Item

public setup_nav_menu_item([object $item = null ]) : object

Adds all values to the Nav Menu Item object.

Parameters
$item : object = null

The incoming nav menu item object.

Tags
since
2.0.0
Return values
object

The nav menu item object with axtra meta hydrated.

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
2.0.0
Return values
array<string|int, mixed>

An array of field argument arrays.

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()

An array of arguments.

Tags
since
2.0.0
Return values
void

Search results