Frontend_Form implements Registerable, Premium_Service, JsonSerializable
Responsible for displaying the frontend submission form.
Tags
Interfaces, Classes and Traits
- Registerable
- Premium_Service
- JsonSerializable
Table of Contents
- $errors : array<string|int, mixed>
- Form errors.
- $fields : array<string|int, mixed>
- Form fields.
- $template_loader : Template_Loader
- Template loader instance.
- __construct() : mixed
- Constructor.
- add_error() : mixed
- Adds an error.
- display_form() : string
- Displays the form via the shortcode.
- get_fields() : array<string|int, mixed>
- Gets fields for the form.
- init_fields() : void
- Define the list of fields for the form.
- jsonSerialize() : array<string|int, mixed>
- Script configuration for the frontend.
- load_posted_form() : void
- Detect submission of the form and handle it.
- process_form() : void
- Process submission of the form.
- register() : void
- Hook into WP.
- register_scripts() : void
- Register assets.
- setup_upload_dir() : array<string|int, mixed>
- Filters the upload dir when dlp is making an upload.
- get_posted_editor_field() : string
- Gets the value of a posted textarea field.
- get_posted_field() : string|array<string|int, mixed>
- Gets the value of a posted field.
- get_posted_fields() : array<string|int, mixed>
- Gets post data for fields.
- get_posted_file_field() : string|array<string|int, mixed>
- Gets the value of a posted file field.
- get_posted_taxonomy_field() : array<string|int, mixed>
- Gets posted terms for the taxonomy.
- get_posted_textarea_field() : string
- Gets the value of a posted textarea field.
- is_empty() : bool
- Checks whether a value is empty.
- sanitize_posted_field() : mixed
- Sanitize the value of a field.
- sort_by_priority() : int
- Sorts array by priority value.
- upload_file() : string|array<string|int, mixed>
- Handles the uploading of files.
- validate_fields() : bool|WP_Error
- Validates the posted fields.
- asset_url() : string
- Get the assets url.
- delete_document_file() : void
- Delete the temporary document file.
- get_theme_slug() : string
- Get the slug of the currently active theme.
Properties
$errors
Form errors.
protected
array<string|int, mixed>
$errors
= []
$fields
Form fields.
protected
array<string|int, mixed>
$fields
= []
$template_loader
Template loader instance.
private
Template_Loader
$template_loader
The template loader.
Methods
__construct()
Constructor.
public
__construct() : mixed
Return values
mixed —add_error()
Adds an error.
public
add_error(string $error) : mixed
Parameters
- $error : string
-
The error message.
Return values
mixed —display_form()
Displays the form via the shortcode.
public
display_form() : string
Return values
string —get_fields()
Gets fields for the form.
public
get_fields() : array<string|int, mixed>
Return values
array<string|int, mixed> —init_fields()
Define the list of fields for the form.
public
init_fields() : void
Return values
void —jsonSerialize()
Script configuration for the frontend.
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —load_posted_form()
Detect submission of the form and handle it.
public
load_posted_form() : void
Return values
void —process_form()
Process submission of the form.
public
process_form() : void
Tags
Return values
void —register()
Hook into WP.
public
register() : void
Return values
void —register_scripts()
Register assets.
public
register_scripts() : void
Return values
void —setup_upload_dir()
Filters the upload dir when dlp is making an upload.
public
setup_upload_dir(array<string|int, mixed> $pathdata) : array<string|int, mixed>
Parameters
- $pathdata : array<string|int, mixed>
Return values
array<string|int, mixed> —get_posted_editor_field()
Gets the value of a posted textarea field.
protected
get_posted_editor_field(string $key, array<string|int, mixed> $field) : string
Parameters
- $key : string
- $field : array<string|int, mixed>
Return values
string —get_posted_field()
Gets the value of a posted field.
protected
get_posted_field(string $key, array<string|int, mixed> $field) : string|array<string|int, mixed>
Parameters
- $key : string
- $field : array<string|int, mixed>
Return values
string|array<string|int, mixed> —get_posted_fields()
Gets post data for fields.
protected
get_posted_fields() : array<string|int, mixed>
Return values
array<string|int, mixed> —of data.
get_posted_file_field()
Gets the value of a posted file field.
protected
get_posted_file_field(string $key, array<string|int, mixed> $field) : string|array<string|int, mixed>
Parameters
- $key : string
- $field : array<string|int, mixed>
Tags
Return values
string|array<string|int, mixed> —get_posted_taxonomy_field()
Gets posted terms for the taxonomy.
protected
get_posted_taxonomy_field(string $key, array<string|int, mixed> $field) : array<string|int, mixed>
Parameters
- $key : string
- $field : array<string|int, mixed>
Return values
array<string|int, mixed> —get_posted_textarea_field()
Gets the value of a posted textarea field.
protected
get_posted_textarea_field(string $key, array<string|int, mixed> $field) : string
Parameters
- $key : string
- $field : array<string|int, mixed>
Return values
string —is_empty()
Checks whether a value is empty.
protected
is_empty(string|numeric-string|int|float|array<string|int, mixed>|bool $value[, string $key = '' ]) : bool
Parameters
- $value : string|numeric-string|int|float|array<string|int, mixed>|bool
-
The value that is being checked.
- $key : string = ''
-
The key of the field that is being checked.
Return values
bool —True if value is empty, false otherwise.
sanitize_posted_field()
Sanitize the value of a field.
protected
sanitize_posted_field(mixed $value[, mixed $sanitizer = null ]) : mixed
Parameters
- $value : mixed
- $sanitizer : mixed = null
Return values
mixed —sort_by_priority()
Sorts array by priority value.
protected
sort_by_priority(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>
Return values
int —upload_file()
Handles the uploading of files.
protected
upload_file(string $field_key, array<string|int, mixed> $field) : string|array<string|int, mixed>
Parameters
- $field_key : string
- $field : array<string|int, mixed>
Tags
Return values
string|array<string|int, mixed> —validate_fields()
Validates the posted fields.
protected
validate_fields(array<string|int, mixed> $values) : bool|WP_Error
Parameters
- $values : array<string|int, mixed>
Tags
Return values
bool|WP_Error —True on success, WP_Error on failure.
asset_url()
Get the assets url.
private
asset_url(string $path) : string
Parameters
- $path : string
Return values
string —delete_document_file()
Delete the temporary document file.
private
delete_document_file(array<string|int, mixed> $values) : void
Usually used when validation error occurs or after successful submission.
Parameters
- $values : array<string|int, mixed>
Return values
void —get_theme_slug()
Get the slug of the currently active theme.
private
get_theme_slug() : string
We'll use this as class name to add theme specific styling.