Cp_Plgn_Drctry_Fx

Trait to provide helper Functions for arbitrary operations.

Description

Adds functions for: Nonce validation

Tags
author

Beda Schmid beda@tukutoi.com

Table of Contents

encode_to_json()  : mixed
Encode data to JSON or return empty string.
get_content_between()  : string
Get string value between delimiters.
get_file_contents()  : mixed
CP Way of getting File Contents.
get_posted_data()  : mixed
Validates any POSTed nonce by key and nonce.
get_remote_decoded_body()  : mixed
Get Remote body json decoded.
get_remote_header()  : mixed
Get Remote header.
get_remote_raw_body()  : mixed
Get Remote body json decoded.
list_pagination()  : mixed
Create a paginated list out of an array of items
maybe_populate_cache()  : mixed
Maybe populate cache file.
maybe_send_json_failure()  : mixed
Validates any POSTed nonce by key and nonce.
put_file_contents()  : mixed
CP Way of putting File Contentes.
search_form()  : mixed
Create a safe HTML search form input
validate_get_nonce()  : mixed
Validates any GET nonce by key and nonce.
validate_post_nonce()  : mixed
Validates any POSTed nonce by key and nonce.
vetted_orgs()  : array<string|int, mixed>
Get a list of vetted orgs

Methods

encode_to_json()

Encode data to JSON or return empty string.

private encode_to_json(mixed $data) : mixed
Parameters
$data
(mixed) The Data to encode.
Return
(mixed)

get_content_between()

Get string value between delimiters.

private get_content_between(string $str, string $start_delimiter, string $end_delimiter) : string
Parameters
$str
(string) The string to scan.
$start_delimiter
(string) The start delimiter to look for.
$end_delimiter
(string) The end delimiter to look for.
Return
(string) The string between.

get_file_contents()

CP Way of getting File Contents.

private get_file_contents(string $file) : mixed
Parameters
$file
(string) The file path to get contents from.
Return
(mixed)

get_posted_data()

Validates any POSTed nonce by key and nonce.

private get_posted_data(string $key, string $sanitization) : mixed
Parameters
$key
(string) The POST key where nonce is passed.
$sanitization
(string) The Sanitization function to use.
Return
(mixed)

get_remote_decoded_body()

Get Remote body json decoded.

private get_remote_decoded_body(string $url[, array<string|int, mixed> $header = array() ]) : mixed
Parameters
$url
(string) Remote URL.
$header
(array<string|int, mixed>) Array of headers to send to remote. Empty by default. Defaults to: array()
Return
(mixed)

get_remote_header()

Get Remote header.

private get_remote_header(string $url[, array<string|int, mixed> $header = array() ], string $return) : mixed
Parameters
$url
(string) Remote URL.
$header
(array<string|int, mixed>) Array of headers to send to remote. Empty by default. Defaults to: array()
$return
(string) The header to return.
Return
(mixed)

get_remote_raw_body()

Get Remote body json decoded.

private get_remote_raw_body(string $url[, array<string|int, mixed> $header = array() ]) : mixed
Parameters
$url
(string) Remote URL.
$header
(array<string|int, mixed>) Array of headers to send to remote. Empty by default. Defaults to: array()
Return
(mixed)

list_pagination()

Create a paginated list out of an array of items

private list_pagination(array<string|int, mixed> $data, string $return) : mixed
Parameters
$data
(array<string|int, mixed>) The data to paginate.
$return
(string) What part of the pagination assets to return.
Return
(mixed)

maybe_populate_cache()

Maybe populate cache file.

private maybe_populate_cache(string $file) : mixed
Parameters
$file
(string) The Cache file path.
Return
(mixed)

maybe_send_json_failure()

Validates any POSTed nonce by key and nonce.

private maybe_send_json_failure(string $key[, string $message = 'Something went wrong' ]) : mixed
Parameters
$key
(string) The POST key where nonce is passed.
$message
(string) The message to return on failure. Defaults to: 'Something went wrong'
Return
(mixed)

put_file_contents()

CP Way of putting File Contentes.

private put_file_contents(mixed $contents, string $file) : mixed
Parameters
$contents
(mixed) The content to put.
$file
(string) The file path to get contents from.
Return
(mixed)

validate_get_nonce()

Validates any GET nonce by key and nonce.

private validate_get_nonce(string $key, string $nonce) : mixed
Parameters
$key
(string) The GET key where nonce is passed.
$nonce
(string) The Nonce to validate (name).
Return
(mixed)

validate_post_nonce()

Validates any POSTed nonce by key and nonce.

private validate_post_nonce(string $key, string $nonce[, string $message = 'Invalid or missing Nonce!' ]) : mixed
Parameters
$key
(string) The POST key where nonce is passed.
$nonce
(string) The Nonce to validate (name).
$message
(string) The message to return on failure. Defaults to: 'Invalid or missing Nonce!'
Return
(mixed)

vetted_orgs()

Get a list of vetted orgs

private vetted_orgs() : array<string|int, mixed>
Return
(array<string|int, mixed>) $_orgs An array of vetted orgs.

Search results