PHP Класс Grunion_Contact_Form, jetpack

Parses shortcode to output the contact form as HTML Sends email and stores the contact form response (a.k.a. "feedback")
Наследование: extends Crunion_Contact_Form_Shortcode
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$current_form form we are currently looking at. If processed, will become $last
$errors stores form submission errors
$last The most recent (inclusive) contact-form shortcode processed
$shortcode_name
$style Whether to print the grunion.css style when processing the contact-form shortcode

Открытые методы

Метод Описание
__construct ( $attributes, $content = null )
_style_on ( ) Turn on printing of grunion.css stylesheet
addslashes_deep ( $value )
get_compiled_form ( integer $feedback_id, $form ) : array Returns a compiled form with labels and values in a form of an array of lines.
get_field_ids ( ) : array Loops through $this->fields to generate a (structured) list of field IDs.
parse ( array $attributes, string | null $content ) : string The contact-form shortcode processor
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.
process_submission ( ) Process the contact form's POST submission Stores feedback. Sends email.
store_shortcode ( string $content = null, $attributes = null ) Store shortcode content for recall later - used to receate shortcode when user uses do_shortcode
style ( boolean $style ) Toggle for printing the grunion.css stylesheet
success_message ( integer $feedback_id, $form ) : string Returns a success message to be returned if the form is sent via AJAX.

Описание методов

__construct() публичный Метод

public __construct ( $attributes, $content = null )

_style_on() статический публичный Метод

Turn on printing of grunion.css stylesheet
См. также: ::style()
static public _style_on ( )

addslashes_deep() публичный Метод

public addslashes_deep ( $value )

get_compiled_form() статический публичный Метод

Returns a compiled form with labels and values in a form of an array of lines.
static public get_compiled_form ( integer $feedback_id, $form ) : array
$feedback_id integer
Результат array $lines

get_field_ids() публичный Метод

Important: Currently the whitelisted fields are defined as follows: name, email, url, subject, textarea If you need to add new fields to the Contact Form, please don't add them to the whitelisted fields and leave them as extra fields. The reasoning behind this is that both the admin Feedback view and the CSV export will not include any fields that are added to the list of whitelisted fields without taking proper care to add them to all the other places where they accessed/used/saved. The safest way to add new fields is to add them to the dropdown and the HTML list ( @see Grunion_Contact_Form_Field::render ) and don't add them to the list of whitelisted fields. This way they will become a part of the extra fields which are saved in the post meta and will be properly handled by the admin Feedback view and the CSV Export without any extra work. If there is need to add a field to the whitelisted fields, then please take proper care to add logic to handle the field in the following places: - Below in the switch statement - so the field is recognized as whitelisted. - Grunion_Contact_Form::process_submission - validation and logic. - Grunion_Contact_Form::process_submission - add the field as an additional field in the post_content when saving the feedback content. - Grunion_Contact_Form_Plugin::parse_fields_from_content - add mapping for the field, defined in the above method. - Grunion_Contact_Form_Plugin::map_parsed_field_contents_of_post_to_field_names - add mapping of the field for the CSV Export. Otherwise it will be missing from the exported data. - admin.php / grunion_manage_post_columns - add the field to the render logic. Otherwise it will be missing from the admin Feedback view.
public get_field_ids ( ) : array
Результат array

parse() статический публичный Метод

The contact-form shortcode processor
static public parse ( array $attributes, string | null $content ) : string
$attributes array Key => Value pairs as parsed by shortcode_parse_atts()
$content string | null The shortcode's inner content: [contact-form]$content[/contact-form]
Результат string HTML for the concat form.

parse_contact_field() статический публичный Метод

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.
static public parse_contact_field ( array $attributes, string | null $content ) : HTML
$attributes array Key => Value pairs as parsed by shortcode_parse_atts()
$content string | null The shortcode's inner content: [contact-field]$content[/contact-field]
Результат HTML for the contact form field

process_submission() публичный Метод

Process the contact form's POST submission Stores feedback. Sends email.
public process_submission ( )

store_shortcode() статический публичный Метод

Store shortcode content for recall later - used to receate shortcode when user uses do_shortcode
static public store_shortcode ( string $content = null, $attributes = null )
$content string

style() статический публичный Метод

Toggle for printing the grunion.css stylesheet
static public style ( boolean $style )
$style boolean

success_message() статический публичный Метод

Returns a success message to be returned if the form is sent via AJAX.
static public success_message ( integer $feedback_id, $form ) : string
$feedback_id integer
Результат string $message

Описание свойств

$current_form статическое публичное свойство

form we are currently looking at. If processed, will become $last
static public $current_form

$errors публичное свойство

stores form submission errors
public $errors

$last статическое публичное свойство

The most recent (inclusive) contact-form shortcode processed
static public $last

$shortcode_name публичное свойство

public $shortcode_name

$style статическое публичное свойство

Whether to print the grunion.css style when processing the contact-form shortcode
static public $style