PHP Class 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")
Inheritance: extends Crunion_Contact_Form_Shortcode
Afficher le fichier Open project: automattic/jetpack Class Usage Examples

Méthodes publiques

Свойство Type Description
$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

Méthodes publiques

Méthode Description
__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.

Method Details

__construct() public méthode

public __construct ( $attributes, $content = null )

_style_on() static public méthode

Turn on printing of grunion.css stylesheet
See also: ::style()
static public _style_on ( )

addslashes_deep() public méthode

public addslashes_deep ( $value )

get_compiled_form() static public méthode

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
Résultat array $lines

get_field_ids() public méthode

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
Résultat array

parse() static public méthode

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]
Résultat string HTML for the concat form.

parse_contact_field() static public méthode

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]
Résultat HTML for the contact form field

process_submission() public méthode

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

store_shortcode() static public méthode

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() static public méthode

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

success_message() static public méthode

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
Résultat string $message

Property Details

$current_form static_oe public_oe property

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

$errors public_oe property

stores form submission errors
public $errors

$last static_oe public_oe property

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

$shortcode_name public_oe property

public $shortcode_name

$style static_oe public_oe property

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