\Grunion_Contact_Form_Field

Class for the contact-field shortcode.

Parses shortcode to output the contact form field as HTML. Validates input.

Summary

Methods
Properties
Constants
__construct()
add_error()
is_error()
validate()
render()
parse_content()
get_attribute()
esc_attr()
unesc_attr()
__toString()
$shortcode_name
$form
$value
$error
$attributes
$defaults
$content
$fields
$body
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$shortcode_name

$shortcode_name : string

Type

string — the name of the shortcode: [$shortcode_name /]

$value

$value : string

Type

string — default or POSTed value

$error

$error : bool

Type

bool — Is the input invalid?

$attributes

$attributes : array

Type

array — key => value pairs for the shortcode's attributes: [$shortcode_name key="value" ... /]

$defaults

$defaults : array

Type

array — key => value pair for attribute defaults

$content

$content : null|string

Type

null|string — Null for selfclosing shortcodes. Hhe inner content of otherwise: [$shortcode_name]$content[/$shortcode_name]

$fields

$fields : array

Type

array — Associative array of inner "child" shortcodes equivalent to the $content: [$shortcode_name][child 1/][child 2/][/$shortcode_name]

$body

$body : null|string

Type

null|string — The HTML of the parsed inner "child" shortcodes". Null for selfclosing shortcodes.

Methods

__construct()

__construct(array $attributes, null|string $content)

Parameters

array $attributes

An associative array of shortcode attributes. @see shortcode_atts()

null|string $content

Null for selfclosing shortcodes. The inner content otherwise.

add_error()

add_error(string $message)

This field's input is invalid. Flag as invalid and add an error to the parent form

Parameters

string $message

The error message to display on the form.

is_error()

is_error() : bool

Is the field input invalid?

Returns

bool

validate()

validate()

Validates the form input

render()

render() : string

Outputs the HTML for this form field

Returns

string —

HTML

parse_content()

parse_content(string $content)

Processes the shortcode's inner content for "child" shortcodes

Parameters

string $content

The shortcode's inner content: [shortcode]$content[/shortcode]

get_attribute()

get_attribute(string $key) : mixed

Returns the value of the requested attribute.

Parameters

string $key

The attribute to retrieve

Returns

mixed

esc_attr()

esc_attr( $value)

Parameters

$value

unesc_attr()

unesc_attr( $value)

Parameters

$value

__toString()

__toString()

Generates the shortcode