PHP Class MC4WP_Form

Afficher le fichier Open project: dannyvankooten/mailchimp-for-wordpress Class Usage Examples

Méthodes publiques

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

Свойство Type Description
$post_meta Raw array or post_meta values.

Méthodes publiques

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

Méthodes protégées

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

Method Details

__construct() public méthode

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

__get() public méthode

public __get ( string $name ) : mixed
$name string
Résultat mixed

__toString() public méthode

Output this form
public __toString ( ) : string
Résultat string

add_error() public méthode

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

add_message() public méthode

public add_message ( $key )
$key

get_action() public méthode

Valid return values are "subscribe" and "unsubscribe"
public get_action ( ) : string
Résultat string

get_data() public méthode

public get_data ( ) : array
Résultat array

get_element() public méthode

public get_element ( string $element_id = 'mc4wp-form', array $config = [] ) : MC4WP_Form_element
$element_id string
$config array
Résultat MC4WP_Form_element

get_email_type() public méthode

Get "email_type" setting for new MailChimp subscribers added by this form.
public get_email_type ( ) : string
Résultat string

get_field_types() public méthode

Get an array of field types which are present in this form.
public get_field_types ( ) : array
Résultat array

get_html() public méthode

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

get_instance() public static méthode

Get a shared form instance.
public static get_instance ( integer | WP_Post $form_id ) : MC4WP_Form
$form_id integer | WP_Post
Résultat MC4WP_Form

get_lists() public méthode

Get MailChimp lists this form subscribes to
public get_lists ( ) : array
Résultat array

get_message() public méthode

Get message object
public get_message ( string $key ) : MC4WP_Form_Message
$key string
Résultat MC4WP_Form_Message

get_message_html() public méthode

Get HTML string for a message, including wrapper element.
Deprecation: 3.1
public get_message_html ( string $key ) : string
$key string
Résultat string

get_redirect_url() public méthode

Get "redirect to url after success" setting for this form
public get_redirect_url ( ) : string
Résultat string

get_required_fields() public méthode

Get array of name attributes for the required fields in this form.
public get_required_fields ( ) : array
Résultat array

get_response_html() public méthode

This does not take the submitted form element into account.
See also: MC4WP_Form_Element::get_response_html()
public get_response_html ( ) : string
Résultat string

get_stylesheet() public méthode

Gets the filename of the stylesheet to load for this form.
public get_stylesheet ( ) : string
Résultat string

handle_request() public méthode

Handle an incoming request. Should be called before calling validate() method.
See also: MC4WP_Form::validate
public handle_request ( MC4WP_Request $request ) : void
$request MC4WP_Request
Résultat void

has_errors() public méthode

Should always evaluate to false when form has not been submitted.
public has_errors ( ) : boolean
Résultat boolean

has_field_type() public méthode

Does this form has a field of the given type?
public has_field_type ( $type ) : boolean
$type
Résultat boolean

load_messages() protected méthode

protected load_messages ( ) : array
Résultat array

load_settings() protected méthode

protected load_settings ( ) : array
Résultat array

parse_request_data() protected méthode

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

set_config() public méthode

Update configuration for this form
public set_config ( array $config ) : array
$config array
Résultat array

validate() public méthode

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

Property Details

$ID public_oe property

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

$config public_oe property

public array $config
Résultat array

$content public_oe property

The form HTML content
public $content

$errors public_oe property

Array of error codes
public $errors

$instances public_oe static_oe property

Array of instantiated form objects.
public static $instances

$is_submitted public_oe property

Was this form submitted?
public $is_submitted

$messages public_oe property

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

$name public_oe property

The form name
public $name

$post public_oe property

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

$post_meta protected_oe property

Raw array or post_meta values.
protected $post_meta

$raw_data public_oe property

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

$settings public_oe property

Array of settings
public $settings