Properties

$current_widget_id

$current_widget_id : string

Type

string — The Widget ID of the widget currently being processed. Used to build the unique contact-form ID for forms embedded in widgets.

Methods

init()

init()

strip_tags()

strip_tags(string $string) : string

Strips HTML tags from input. Output is NOT HTML safe.

Parameters

string $string

Returns

string

__construct()

__construct()

process_form_submission()

process_form_submission()

Handles all contact-form POST submissions

Conditionally attached to template_redirect

ajax_request()

ajax_request()

insert_feedback_filter()

insert_feedback_filter(array $data, array $postarr) : array

Ensure the post author is always zero for contact-form feedbacks Attached to `wp_insert_post_data`

Parameters

array $data

the data to insert

array $postarr

the data sent to wp_insert_post()

Returns

array —

The filtered $data to insert

add_shortcode()

add_shortcode()

track_current_widget()

track_current_widget(array $widget)

Tracks the widget currently being processed.

Attached to dynamic_sidebar

Parameters

array $widget

The widget data

widget_atts()

widget_atts(string $text) : string

Adds a "widget" attribute to every contact-form embedded in a text widget.

Used to tell the difference between post-embedded contact-forms and widget-embedded contact-forms Attached to widget_text

Parameters

string $text

The widget text

Returns

string —

The filtered widget text

widget_shortcode_hack()

widget_shortcode_hack(string $text) : string

For sites where text widgets are not processed for shortcodes, we add this hack to process just our shortcode Attached to `widget_text`

Parameters

string $text

The widget text

Returns

string —

The contact-form filtered widget text

prepare_for_akismet()

prepare_for_akismet(array $form) : array

Populate an array with all values necessary to submit a NEW contact-form feedback to Akismet.

Note that this includes the current user_ip etc, so this should only be called when accepting a new item via $_POST

Parameters

array $form

Contact form feedback array

Returns

array —

feedback array with additional data ready for submission to Akismet

is_spam_akismet()

is_spam_akismet(array $form) : bool|\WP_Error

Submit contact-form data to Akismet to check for spam.

If you're accepting a new item via $_POST, run it Grunion_Contact_Form_Plugin::prepare_for_akismet() first Attached to contact_form_is_spam

Parameters

array $form

Returns

bool|\WP_Error —

TRUE => spam, FALSE => not spam, WP_Error => stop processing entirely

akismet_submit()

akismet_submit(string $as, array $form)

Submit a feedback as either spam or ham

Parameters

string $as

Either 'spam' or 'ham'.

array $form

the contact-form data

export_form()

export_form()

Prints the menu

download_feedback_as_csv()

download_feedback_as_csv()

download as a csv a contact form or all of them in a csv file

get_feedbacks_as_options()

get_feedbacks_as_options() : string

Returns a string of HTML <option> items from an array of posts

Returns

string —

a string of HTML

get_field_names()

get_field_names(array|int $posts) : array

Get the names of all the form's fields

Parameters

array|int $posts

the post we want the fields of

Returns

array —

the array of fields

make_csv_row_from_feedback()

make_csv_row_from_feedback(int $post_id, array $fields) : String

Creates a valid csv row from a post id

Parameters

int $post_id

The id of the post

array $fields

An array containing the names of all the fields of the csv

Returns

String —

The csv row