You appear to be a bot. Output may be restricted
Description
Usage
Grunion_Contact_Form_Field::__construct( $attributes, $content, $form );
Parameters
- $attributes
- ( array ) required – An associative array of shortcode attributes. @see shortcode_atts()
- $content
- ( null|string ) optional – Null for selfclosing shortcodes. The inner content otherwise.
- $form
- ( Grunion_Contact_Form ) optional – The parent form
Returns
void
Source
File name: jetpack/modules/contact-form/grunion-contact-form.php
Lines:
1 to 72 of 72
function __construct( $attributes, $content = null, $form = null ) { $attributes = shortcode_atts( array( 'label' => null, 'type' => 'text', 'required' => false, 'options' => array(), 'id' => null, 'default' => null, 'values' => null, 'placeholder' => null, 'class' => null, 'width' => null, 'consenttype' => null, 'implicitconsentmessage' => null, 'explicitconsentmessage' => null, ), $attributes, 'contact-field' ); // special default for subject field if ( 'subject' == $attributes['type'] && is_null( $attributes['default'] ) && ! is_null( $form ) ) { $attributes['default'] = $form->get_attribute( 'subject' ); } // allow required=1 or required=true if ( '1' == $attributes['required'] || 'true' == strtolower( $attributes['required'] ) ) { $attributes['required'] = true; } else { $attributes['required'] = false; } // parse out comma-separated options list (for selects, radios, and checkbox-multiples) if ( ! empty( $attributes['options'] ) && is_string( $attributes['options'] ) ) { $attributes['options'] = array_map( 'trim', explode( ',', $attributes['options'] ) ); if ( ! empty( $attributes['values'] ) && is_string( $attributes['values'] ) ) { $attributes['values'] = array_map( 'trim', explode( ',', $attributes['values'] ) ); } } if ( $form ) { // make a unique field ID based on the label, with an incrementing number if needed to avoid clashes $form_id = $form->get_attribute( 'id' ); $id = isset( $attributes['id'] ) ? $attributes['id'] : false; $unescaped_label = $this->unesc_attr( $attributes['label'] ); $unescaped_label = str_replace( '%', '-', $unescaped_label ); // jQuery doesn't like % in IDs? $unescaped_label = preg_replace( '/[^a-zA-Z0-9.-_:]/', '', $unescaped_label ); if ( empty( $id ) ) { $id = sanitize_title_with_dashes( 'g' . $form_id . '-' . $unescaped_label ); $i = 0; $max_tries = 99; while ( isset( $form->fields[ $id ] ) ) { $i++; $id = sanitize_title_with_dashes( 'g' . $form_id . '-' . $unescaped_label . '-' . $i ); if ( $i > $max_tries ) { break; } } } $attributes['id'] = $id; } parent::__construct( $attributes, $content ); // Store parent form $this->form = $form; }