Tkt_Template_Builder_Sanitizer
in package
The Sanitization, Validation and error handling Class.
Description
Registers all methods for sanitization, validation and error handling.
Tags
Table of Contents
- $debug : bool
- Debug mode.
- $debug_log : string
- Debug log mode.
- $declarations : string
- The Configuration object.
- $plugin_prefix : string
- The unique prefix of this plugin.
- $version : string
- The version of this plugin.
- __construct() : mixed
- Initialize the class and set its properties.
- get_errors() : array<string|int, mixed>
- Return Errors to debug log if active.
- invalid_or_error() : bool
- Check for WP Errors, null or false.
- sanitize() : mixed
- Public facing Sanitization Callaback.
- validate() : mixed
- Public facing Validation Callback.
- handle_array_validation() : array<string|int, mixed>
- Validate Array.
- handle_object_prop_validation() : mixed
- Validate Object, then validate requested property.
- handle_object_validation() : object
- Validate Object.
- handle_operator_validation() : string
- Validate Operators.
- handle_sanitizer() : mixed
- Route the value through the correct sanitization callback.
Properties
$debug
Debug mode.
private
bool
$debug
Description
Wether Debug is enabled or not.
Tags
$debug_log
Debug log mode.
private
string
$debug_log
Description
Debug logging mode.
Tags
$declarations
The Configuration object.
private
string
$declarations
Description
All configurations and declarations of this plugin.
Tags
$plugin_prefix
The unique prefix of this plugin.
private
string
$plugin_prefix
Description
The string used to uniquely prefix technical functions of this plugin.
Tags
$version
The version of this plugin.
private
string
$version
Description
The current version of this plugin.
Tags
Methods
__construct()
Initialize the class and set its properties.
public
__construct(string $plugin_prefix, string $version, array<string|int, mixed> $declarations) : mixed
Parameters
- $plugin_prefix
- (string) The unique prefix of this plugin.
- $version
- (string) The version of this plugin.
- $declarations
- (array<string|int, mixed>) The Configuration object.
Tags
Return
(mixed)get_errors()
Return Errors to debug log if active.
public
get_errors(mixed $result, string $location, string $backtrace) : array<string|int, mixed>
Parameters
- $result
- (mixed) The value to get error of.
- $location
- (string) The method where the error happened.
- $backtrace
- (string) The Debug backtrace to the error.
Tags
Return
(array<string|int, mixed>) $errors Array of (NOT Sanitized).invalid_or_error()
Check for WP Errors, null or false.
public
invalid_or_error(mixed $result) : bool
Parameters
- $result
- (mixed) The value to check.
Tags
Return
(bool) true if has errors, false if not.sanitize()
Public facing Sanitization Callaback.
public
sanitize(string $type, mixed $value[, string $item = '' ][, string $object_type = '' ][, string $object_subtype = '' ]) : mixed
Parameters
- $type
- (string) The type of sanitization to apply.
- $value
- (mixed) The value to sanitize.
- $item
-
(string) The meta key of the field to sanitize. Defaults to:
''
- $object_type
-
(string) The object type of the meta to sanitize. Defaults to:
''
- $object_subtype
-
(string) The object subtype of the meta to sanitize. Defaults to:
''
Tags
Return
(mixed) $value sanitized value.validate()
Public facing Validation Callback.
public
validate(string $type, mixed $value[, string $prop = null ]) : mixed
Parameters
- $type
- (string) The type of validation to apply.
- $value
- (mixed) The value to validate.
- $prop
-
(string) The property or array key to validate. Defaults to:
null
Tags
Return
(mixed) $value validated value.handle_array_validation()
Validate Array.
private
handle_array_validation(mixed $value) : array<string|int, mixed>
Parameters
- $value
- (mixed) The value to validate.
Tags
Return
(array<string|int, mixed>) $value | wp_error validated array (NOT Sanitized) or wp_error on failure.handle_object_prop_validation()
Validate Object, then validate requested property.
private
handle_object_prop_validation(mixed $value, string $prop) : mixed
Parameters
- $value
- (mixed) The value to validate.
- $prop
- (string) The property to validate and return.
Tags
Return
(mixed) $value->$prop | wp_error validated property value (NOT Sanitized) or wp_error on failure.handle_object_validation()
Validate Object.
private
handle_object_validation(mixed $value) : object
Parameters
- $value
- (mixed) The value to validate.
Tags
Return
(object) $value | wp_error validated object (NOT Sanitized) or wp_error on failure.handle_operator_validation()
Validate Operators.
private
handle_operator_validation(mixed $value) : string
Parameters
- $value
- (mixed) The value to validate.
Tags
Return
(string) $value | wp_error validated opereator value (NOT Sanitized) or wp_error on failure.handle_sanitizer()
Route the value through the correct sanitization callback.
private
handle_sanitizer([string $type = '' ][, array<string|int, mixed> $args = array() ]) : mixed
Description
Return the sanitized value or empty if all fails.
Parameters
- $type
-
(string) The type of sanitization to apply. Defaults to:
''
- $args
-
(array<string|int, mixed>) The arguments to pass to the user function. Defaults to:
array()