\Grunion_Contact_Form

Class for the contact-form shortcode.

Parses shortcode to output the contact form as HTML Sends email and stores the contact form response (a.k.a. "feedback")

Summary

Methods
Properties
Constants
__construct()
store_shortcode()
style()
parse()
success_message()
parse_contact_field()
get_field_ids()
process_submission()
addslashes_deep()
parse_content()
get_attribute()
esc_attr()
unesc_attr()
__toString()
$shortcode_name
$errors
$last
$style
$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 /]

$errors

$errors : \WP_Error

Type

\WP_Error — stores form submission errors

$last

$last : \Grunion_Contact_Form

Type

\Grunion_Contact_Form — The most recent (inclusive) contact-form shortcode processed

$style

$style : bool

Type

bool — Whether to print the grunion.css style when processing the contact-form shortcode

$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.

store_shortcode()

store_shortcode(string $content,  $attributes)

Store shortcode content for recall later - used to receate shortcode when user uses do_shortcode

Parameters

string $content
$attributes

style()

style(bool $style)

Toggle for printing the grunion.css stylesheet

Parameters

bool $style

parse()

parse(array $attributes, string|null $content) : string

The contact-form shortcode processor

Parameters

array $attributes

Key => Value pairs as parsed by shortcode_parse_atts()

string|null $content

The shortcode's inner content: [contact-form]$content[/contact-form]

Returns

string —

HTML for the concat form.

success_message()

success_message( $feedback_id,  $form)

Parameters

$feedback_id
$form

parse_contact_field()

parse_contact_field(array $attributes, string|null $content) : \HTML

The contact-field shortcode processor We use an object method here instead of a static Grunion_Contact_Form_Field class method to parse contact-field shortcodes so that we can tie them to the contact-form object.

Parameters

array $attributes

Key => Value pairs as parsed by shortcode_parse_atts()

string|null $content

The shortcode's inner content: [contact-field]$content[/contact-field]

Returns

\HTML —

for the contact form field

get_field_ids()

get_field_ids() : array

Loops through $this->fields to generate a (structured) list of field IDs

Returns

array

process_submission()

process_submission()

Process the contact form's POST submission Stores feedback. Sends email.

addslashes_deep()

addslashes_deep( $value)

Parameters

$value

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