PHP Класс MC4WP_Form

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

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

Свойство Тип Описание
$ID The form ID, matches the underlying post its ID
$config array
$content The form HTML content
$errors Array of error codes
$instances Array of instantiated form objects.
$is_submitted Was this form submitted?
$messages Array of message codes that will show when this form renders
$name The form name
$post The internal post object that represents this form.
$raw_data Array of the raw form data that was submitted.
$settings Array of settings

Защищенные свойства (Protected)

Свойство Тип Описание
$post_meta Raw array or post_meta values.

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

Метод Описание
__construct ( integer $id )
__get ( string $name ) : mixed
__toString ( ) : string Output this form
add_error ( string $error_code ) Add an error to this form
add_message ( $key )
get_action ( ) : string Get the form action
get_data ( ) : array
get_element ( string $element_id = 'mc4wp-form', array $config = [] ) : MC4WP_Form_element
get_email_type ( ) : string Get "email_type" setting for new MailChimp subscribers added by this form.
get_field_types ( ) : array Get an array of field types which are present in this form.
get_html ( string $element_id = 'mc4wp-form', array $config = [] ) : string Get HTML string for this form.
get_instance ( integer | WP_Post $form_id ) : MC4WP_Form Get a shared form instance.
get_lists ( ) : array Get MailChimp lists this form subscribes to
get_message ( string $key ) : MC4WP_Form_Message Get message object
get_message_html ( string $key ) : string Get HTML string for a message, including wrapper element.
get_redirect_url ( ) : string Get "redirect to url after success" setting for this form
get_required_fields ( ) : array Get array of name attributes for the required fields in this form.
get_response_html ( ) : string Gets the form response string
get_stylesheet ( ) : string Gets the filename of the stylesheet to load for this form.
handle_request ( MC4WP_Request $request ) : void Handle an incoming request. Should be called before calling validate() method.
has_errors ( ) : boolean Does this form have errors?
has_field_type ( $type ) : boolean Does this form has a field of the given type?
set_config ( array $config ) : array Update configuration for this form
validate ( ) : boolean Is this form valid?

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

Метод Описание
load_messages ( ) : array
load_settings ( ) : array
parse_request_data ( MC4WP_Request $request ) : array Parse a request for data which should be binded to $data property.

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

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

public __construct ( integer $id )
$id integer The post ID

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

public __get ( string $name ) : mixed
$name string
Результат mixed

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

Output this form
public __toString ( ) : string
Результат string

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

Add an error to this form
public add_error ( string $error_code )
$error_code string

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

public add_message ( $key )
$key

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

Valid return values are "subscribe" and "unsubscribe"
public get_action ( ) : string
Результат string

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

public get_data ( ) : array
Результат array

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

public get_element ( string $element_id = 'mc4wp-form', array $config = [] ) : MC4WP_Form_element
$element_id string
$config array
Результат MC4WP_Form_element

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

Get "email_type" setting for new MailChimp subscribers added by this form.
public get_email_type ( ) : string
Результат string

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

Get an array of field types which are present in this form.
public get_field_types ( ) : array
Результат array

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

If you want to output a form, use mc4wp_show_form instead as it.
public get_html ( string $element_id = 'mc4wp-form', array $config = [] ) : string
$element_id string
$config array
Результат string

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

Get a shared form instance.
public static get_instance ( integer | WP_Post $form_id ) : MC4WP_Form
$form_id integer | WP_Post
Результат MC4WP_Form

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

Get MailChimp lists this form subscribes to
public get_lists ( ) : array
Результат array

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

Get message object
public get_message ( string $key ) : MC4WP_Form_Message
$key string
Результат MC4WP_Form_Message

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

Get HTML string for a message, including wrapper element.
Устаревший: 3.1
public get_message_html ( string $key ) : string
$key string
Результат string

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

Get "redirect to url after success" setting for this form
public get_redirect_url ( ) : string
Результат string

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

Get array of name attributes for the required fields in this form.
public get_required_fields ( ) : array
Результат array

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

This does not take the submitted form element into account.
См. также: MC4WP_Form_Element::get_response_html()
public get_response_html ( ) : string
Результат string

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

Gets the filename of the stylesheet to load for this form.
public get_stylesheet ( ) : string
Результат string

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

Handle an incoming request. Should be called before calling validate() method.
См. также: MC4WP_Form::validate
public handle_request ( MC4WP_Request $request ) : void
$request MC4WP_Request
Результат void

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

Should always evaluate to false when form has not been submitted.
public has_errors ( ) : boolean
Результат boolean

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

Does this form has a field of the given type?
public has_field_type ( $type ) : boolean
$type
Результат boolean

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

protected load_messages ( ) : array
Результат array

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

protected load_settings ( ) : array
Результат array

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

This does the following on all post data. - Removes fields starting with an underscore. - Remove fields which are set to be ignored. - Uppercase all field names
protected parse_request_data ( MC4WP_Request $request ) : array
$request MC4WP_Request
Результат array

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

Update configuration for this form
public set_config ( array $config ) : array
$config array
Результат array

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

Will always return true if the form is not yet submitted. Otherwise, it will run validation and store any errors. This method should be called before get_errors()
public validate ( ) : boolean
Результат boolean

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

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

The form ID, matches the underlying post its ID
public $ID

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

public array $config
Результат array

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

The form HTML content
public $content

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

Array of error codes
public $errors

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

Array of instantiated form objects.
public static $instances

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

Was this form submitted?
public $is_submitted

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

Array of message codes that will show when this form renders
public $messages

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

The form name
public $name

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

The internal post object that represents this form.
public $post

$post_meta защищенное свойство

Raw array or post_meta values.
protected $post_meta

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

Array of the raw form data that was submitted.
public $raw_data

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

Array of settings
public $settings