WP_Backstage_User
extends WP_Backstage_Component
in package
WP Backstage User
Tags
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_field_group_args : array<string|int, mixed>
- Default Field Group 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_help_tabs() : void
- Add Help Tabs
- 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_args() : array<string|int, mixed>
- Manage List Table Query Args
- manage_sortable_columns() : array<string|int, mixed>
- Manage Sortable Columns
- manage_sorting() : void
- Manage Sorting
- modify() : WP_Backstage_User
- Add
- prepare_rest_user() : WP_REST_Response
- Prepare Rest User
- print_errors() : void
- Print Errors
- register_api_meta() : void
- Register API Meta
- render_add_nonce() : string
- Render Add nonce
- render_edit_nonce() : string
- Render Edit nonce
- render_field_groups() : void
- Render Edit Fields
- render_rest_api_preview() : void
- Render REST API Preview
- render_rest_api_preview_help_tab() : void
- Render 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
- 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_groups() : array<string|int, mixed>
- Get Field Groups
- 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_fields() : void
- Render Fields
- 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
$args
Args
protected
array<string|int, mixed>
$args
= array()
The array of args on the instance.
Tags
$countries
Countries
protected
array<string|int, mixed>
$countries
= array()
An array of localized countries.
Tags
$date_format
Date Format
protected
string
$date_format
= ''
The php date format.
Tags
$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
$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
$default_args
Default Args
protected
array<string|int, mixed>
$default_args
= array('field_groups' => array())
The default arguments for this instance.
Tags
$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
$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
$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
$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
$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
$default_field_group_args
Default Field Group Args
protected
array<string|int, mixed>
$default_field_group_args
= array('id' => '', 'title' => '', 'description' => '', 'fields' => array())
The default field group arguments for this instance.
Tags
$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
$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
$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
$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
$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
$errors
Errors
protected
array<string|int, mixed>
$errors
= array()
The array of all errors on the instance.
Tags
$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
$global_code_settings
Global Code Settings
protected
array<string|int, mixed>
$global_code_settings
= array('codemirror' => array('lineWrapping' => \false))
Global settings for CodeMirror.
Tags
$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
$nonce_key
Nonce Key
protected
string
$nonce_key
= '_wp_backstage_nonce'
The key for nonce fields.
Tags
$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
$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
$screen_id
Screen ID
protected
string|array<string|int, mixed>
$screen_id
= ''
The screen ID or IDs that apply to this instance.
Tags
$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
$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
$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
$us_states
US States
protected
array<string|int, mixed>
$us_states
= array()
An array of localized US states.
Tags
Methods
__construct()
Construct
public
__construct([array<string|int, mixed> $args = array() ]) : void
Parameters
- $args : array<string|int, mixed> = array()
-
An array of arguments.
Tags
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
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 user help tabs.
Parameters
- $screen : WP_Screen = null
-
an instance of
WP_Screen
.
Tags
Return values
void —add_rest_api_field_link()
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
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
Return values
bool —Whether the instance has errors or not.
init()
Init
public
init() : void
Tags
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
Return values
void —manage_admin_column_content()
Manage Admin Column Content
public
manage_admin_column_content([string $content = '' ][, string $column = '' ][, int $user_id = null ]) : string
Parameters
- $content : string = ''
-
The original column content.
- $column : string = ''
-
The column name.
- $user_id : int = null
-
The ID of the user to populate the column for.
Tags
Return values
string —The new formatted column content.
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 user'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
Return values
array<string|int, mixed> —An array of hidden column keys.
manage_filtering()
Manage Filtering
public
manage_filtering([WP_User_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_Post_Type::manage_list_table_query_args()
to see how the fields
are made available as public query vars.
Parameters
- $query : WP_User_Query = null
-
An instance of
WP_User_Query
.
Tags
Return values
void —manage_list_table_query_args()
Manage List Table Query Args
public
manage_list_table_query_args([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
This method is responsible for making the URL query fields available to the main WP User 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_User_Query
that runs the main
users table.
Parameters
- $args : array<string|int, mixed> = array()
-
The incoming array of arguments.
Tags
Return values
array<string|int, mixed> —The filtered array of arguments.
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
Return values
array<string|int, mixed> —The sortable columns with the new sortable columns added.
manage_sorting()
Manage Sorting
public
manage_sorting([WP_User_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 users 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 users that don't have a value as well.
Parameters
- $query : WP_User_Query = null
-
An instance of
WP_User_Query
.
Tags
Return values
void —modify()
Add
public
static modify([array<string|int, mixed> $args = array() ]) : WP_Backstage_User
Parameters
- $args : array<string|int, mixed> = array()
-
An array of arguments for this instance.
Tags
Return values
WP_Backstage_User —A fully constructed instance of WP_Backstage_User
.
prepare_rest_user()
Prepare Rest User
public
prepare_rest_user([WP_REST_Response $response = null ][, WP_User $user = null ][, WP_REST_Request $request = null ]) : WP_REST_Response
This method is responsible for preparing the REST API response for the user 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.
- $user : WP_User = null
-
The user being requested.
- $request : WP_REST_Request = null
-
The current API request.
Tags
Return values
WP_REST_Response —The filtered API response.
print_errors()
Print Errors
public
print_errors() : void
Tags
Return values
void —register_api_meta()
Register API Meta
public
register_api_meta() : void
This method is responsible for registering the user meta fields with the REST API, and generating the schema for each.
Tags
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
Return values
string —The formatted add
nonce.
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
Return values
string —The formatted edit
nonce.
render_field_groups()
Render Edit Fields
public
render_field_groups([WP_User|string $user = null ]) : void
Parameters
- $user : WP_User|string = null
-
An instance of
WP_User
or the stringadd-new-user
if on the add new user form.
Tags
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
Return values
void —render_rest_api_preview_help_tab()
Render 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
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
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
Return values
void —render_table_filter_form()
Render Table Filter Form
public
render_table_filter_form([string $which = 'top' ]) : void
This method is responsible for rendering the filter form at the top of the admin user list table. Because the user list table does not have filters, it is necessary to add the filter action submit button here.
Parameters
- $which : string = 'top'
-
whether the form is displayed at the top or bottom, or both. Possible values are
top
,bottom
, or an empty string.
Tags
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
Return values
array<string|int, mixed> —An array of address key => value pairs.
sanitize_checkbox()
Sanitize Checkbox
public
sanitize_checkbox([bool $value = false ]) : bool
Parameters
- $value : bool = false
-
The value to sanitize. Expects a value that can be cast to a boolean.
Tags
Return values
bool —A boolean.
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
Return values
array<string|int, mixed> —An array of values.
sanitize_code()
Sanitize Code
public
sanitize_code([string $value = '' ]) : string
Parameters
- $value : string = ''
-
The value to sanitize. Expects a string.
Tags
Return values
string —An unsanitized string.
sanitize_editor()
Sanitize Editor
public
sanitize_editor([string $value = '' ]) : string
Parameters
- $value : string = ''
-
The value to sanitize. Expects a string.
Tags
Return values
string —the string sanitized as post content.
sanitize_email()
Sanitize Email
public
sanitize_email([string $value = '' ]) : string
Parameters
- $value : string = ''
-
The value to sanitize. Expects an email address.
Tags
Return values
string —An email address.
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
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
Return values
array<string|int, mixed> —An array of integers.
sanitize_number()
Sanitize Number
public
sanitize_number([int|float $value = null ]) : float
Parameters
- $value : int|float = null
-
The value to sanitize. Expects a numeric value.
Tags
Return values
float —a float, or null if empty.
sanitize_select_posts()
Sanitize Select Posts
public
sanitize_select_posts(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
-
The value to sanitize. Expects a post ID.
Tags
Return values
array<string|int, mixed> —A non-negative integer.
sanitize_select_users()
Sanitize Select Users
public
sanitize_select_users(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
-
The value to sanitize. Expects a user ID.
Tags
Return values
array<string|int, mixed> —A non-negative integer.
sanitize_text()
Sanitize Text
public
sanitize_text([string $value = '' ]) : string
Parameters
- $value : string = ''
-
The value to sanitize. Expects a string.
Tags
Return values
string —a text field sanitized string.
sanitize_textarea()
Sanitize Textarea
public
sanitize_textarea([string $value = '' ]) : string
Parameters
- $value : string = ''
-
The value to sanitize. Expects a string.
Tags
Return values
string —a textarea sanitized string.
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
Return values
string —a string as hh:mm:ss
.
sanitize_url()
Sanitize URL
public
sanitize_url([string $value = '' ]) : string
Parameters
- $value : string = ''
-
The value to sanitize. Expects a URL.
Tags
Return values
string —A URL.
save()
Save
public
save([int $user_id = null ]) : void
Parameters
- $user_id : int = null
-
The ID of the user to update.
Tags
Return values
void —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
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
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
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
Return values
array<string|int, mixed> —the first field arg array if found, or an empty array.
get_field_groups()
Get Field Groups
protected
get_field_groups() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of field group argument arrays.
get_field_schema()
Get Field Schema
protected
get_field_schema([array<string|int, mixed> $field = array() ]) : array<string|int, mixed>
Parameters
- $field : array<string|int, mixed> = array()
-
An array of field arguments.
Tags
Return values
array<string|int, mixed> —An array of schema arguments.
get_fields()
Get Fields
protected
get_fields() : array<string|int, mixed>
Tags
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
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
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
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
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
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
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
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
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
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
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
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
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
Return values
void —render_fields()
Render Fields
protected
render_fields([array<string|int, mixed> $field_group = array() ][, WP_User|null $user = null ]) : void
Parameters
- $field_group : array<string|int, mixed> = array()
-
An array of field group arguments.
- $user : WP_User|null = null
-
An instance of
WP_User
or null if on the add user form.
Tags
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
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
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
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
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
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
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
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
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
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
Return values
void —set_errors()
Set Errors
protected
set_errors() : void