PHP Класс Grunion_Contact_Form_Plugin, jetpack

Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$current_widget_id The Widget ID of the widget currently being processed. Used to build the unique contact-form ID for forms embedded in widgets.
$using_contact_form_field

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

Метод Описание
__construct ( )
add_shortcode ( ) * Adds our contact-form shortcode The "child" contact-field shortcode is enabled as needed by the contact-form shortcode handler
ajax_request ( )
akismet_submit ( string $as, array $form ) Submit a feedback as either spam or ham
allow_feedback_rest_api_type ( $post_types ) Add to REST API post type whitelist
daily_akismet_meta_cleanup ( ) Runs daily to clean up spam detection metadata after 15 days. Keeps your DB squeaky clean.
download_feedback_as_csv ( ) download as a csv a contact form or all of them in a csv file
esc_csv ( string $field ) : string Escape a string to be used in a CSV context
export_form ( ) Prints the menu
get_export_data_for_posts ( array $post_ids ) : array Prepares feedback post data for CSV export.
get_ip_address ( )
get_parsed_field_contents_of_post ( integer $post_id ) : array Get parsed feedback post fields.
get_post_content_for_csv_export ( integer $post_id ) : string Fetch post content for a post and extract just the comment.
get_post_meta_for_csv_export ( integer $post_id ) : mixed Get _feedback_extra_fields field from post meta data.
init ( )
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
is_spam_akismet ( boolean $is_spam, array $form = [] ) : boolean | WP_Error Submit contact-form data to Akismet to check for spam.
map_parsed_field_contents_of_post_to_field_names ( array $parsed_post_content ) : array Properly maps fields that are missing from the post meta data to names, that are similar to those of the post meta.
parse_fields_from_content ( $post_id )
prepare_for_akismet ( array $form ) : array Populate an array with all values necessary to submit a NEW contact-form feedback to Akismet.
process_form_submission ( ) Handles all contact-form POST submissions
replace_tokens_with_input ( string $subject, array $field_values ) : string Replaces tokens like {city} or {City} (case insensitive) with the value of an input field of that name
sanitize_value ( $value )
strip_tags ( mixed $data_with_tags ) : mixed Strips HTML tags from input. Output is NOT HTML safe.
tokenize_label ( $label )
track_current_widget ( array $widget ) Tracks the widget currently being processed.
unread_count ( object $screen ) Display the count of new feedback entries received. It's reset when user visits the Feedback screen.
widget_atts ( string $text ) : string Adds a "widget" attribute to every contact-form embedded in a text widget.
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

Защищенные методы

Метод Описание
get_feedbacks_as_options ( ) : string Returns a string of HTML
get_field_names ( array | integer $posts ) : array Get the names of all the form's fields
make_csv_row_from_feedback ( integer $post_id, array $fields ) : String Creates a valid csv row from a post id

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

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

public __construct ( )

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

* Adds our contact-form shortcode The "child" contact-field shortcode is enabled as needed by the contact-form shortcode handler
public add_shortcode ( )

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

public ajax_request ( )

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

Submit a feedback as either spam or ham
public akismet_submit ( string $as, array $form )
$as string Either 'spam' or 'ham'.
$form array the contact-form data

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

Add to REST API post type whitelist
public allow_feedback_rest_api_type ( $post_types )

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

Runs daily to clean up spam detection metadata after 15 days. Keeps your DB squeaky clean.

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

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

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

Malicious input can inject formulas into CSV files, opening up the possibility for phishing attacks and disclosure of sensitive information. Additionally, Excel exposes the ability to launch arbitrary commands through the DDE protocol.
См. также: http://www.contextis.com/resources/blog/comma-separated-vulnerabilities/
public esc_csv ( string $field ) : string
$field string
Результат string

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

Prints the menu
public export_form ( )

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

Prepares feedback post data for CSV export.
public get_export_data_for_posts ( array $post_ids ) : array
$post_ids array Post IDs to fetch the data for. These need to be Feedback posts.
Результат array

get_feedbacks_as_options() защищенный Метод

Returns a string of HTML
protected get_feedbacks_as_options ( ) : string
Результат string a string of HTML

get_field_names() защищенный Метод

Get the names of all the form's fields
Устаревший: As this is no longer necessary as of the CSV export rewrite. - 2015-12-29
protected get_field_names ( array | integer $posts ) : array
$posts array | integer the post we want the fields of
Результат array the array of fields

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

public static get_ip_address ( )

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

Get parsed feedback post fields.
public get_parsed_field_contents_of_post ( integer $post_id ) : array
$post_id integer Id of the post to fetch parsed contents for.
Результат array

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

Fetch post content for a post and extract just the comment.
public get_post_content_for_csv_export ( integer $post_id ) : string
$post_id integer The post id to fetch the content for.
Результат string Trimmed post comment.

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

Get _feedback_extra_fields field from post meta data.
public get_post_meta_for_csv_export ( integer $post_id ) : mixed
$post_id integer Id of the post to fetch meta data for.
Результат mixed

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

static public init ( )

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

Ensure the post author is always zero for contact-form feedbacks Attached to wp_insert_post_data
См. также: Grunion_Contact_Form::process_submission()
public insert_feedback_filter ( array $data, array $postarr ) : array
$data array the data to insert
$postarr array the data sent to wp_insert_post()
Результат array The filtered $data to insert

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

If you're accepting a new item via $_POST, run it Grunion_Contact_Form_Plugin::prepare_for_akismet() first Attached to jetpack_contact_form_is_spam
public is_spam_akismet ( boolean $is_spam, array $form = [] ) : boolean | WP_Error
$is_spam boolean
$form array
Результат boolean | WP_Error TRUE => spam, FALSE => not spam, WP_Error => stop processing entirely

make_csv_row_from_feedback() защищенный статический Метод

Creates a valid csv row from a post id
Устаревший: This is no longer needed, as of the CSV export rewrite.
protected static make_csv_row_from_feedback ( integer $post_id, array $fields ) : String
$post_id integer The id of the post
$fields array An array containing the names of all the fields of the csv
Результат String The csv row

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

Properly maps fields that are missing from the post meta data to names, that are similar to those of the post meta.
См. также: parse_fields_from_content for how the input data is generated.
public map_parsed_field_contents_of_post_to_field_names ( array $parsed_post_content ) : array
$parsed_post_content array Parsed post content
Результат array Mapped fields.

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

public static parse_fields_from_content ( $post_id )

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

Note that this includes the current user_ip etc, so this should only be called when accepting a new item via $_POST
public prepare_for_akismet ( array $form ) : array
$form array Contact form feedback array
Результат array feedback array with additional data ready for submission to Akismet

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

Conditionally attached to template_redirect

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

Replaces tokens like {city} or {City} (case insensitive) with the value of an input field of that name
public replace_tokens_with_input ( string $subject, array $field_values ) : string
$subject string
$field_values array Array with field label => field value associations
Результат string The filtered $subject with the tokens replaced

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

static public sanitize_value ( $value )

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

Strips HTML tags from input. Output is NOT HTML safe.
public static strip_tags ( mixed $data_with_tags ) : mixed
$data_with_tags mixed
Результат mixed

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

static public tokenize_label ( $label )

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

Attached to dynamic_sidebar
public track_current_widget ( array $widget )
$widget array The widget data

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

Display the count of new feedback entries received. It's reset when user visits the Feedback screen.
С версии: 4.1.0
public unread_count ( object $screen )
$screen object Information about the current screen.

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

Used to tell the difference between post-embedded contact-forms and widget-embedded contact-forms Attached to widget_text
public widget_atts ( string $text ) : string
$text string The widget text
Результат string The filtered widget text

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

For sites where text widgets are not processed for shortcodes, we add this hack to process just our shortcode Attached to widget_text
public widget_shortcode_hack ( string $text ) : string
$text string The widget text
Результат string The contact-form filtered widget text

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

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

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

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

static public $using_contact_form_field