connection_config['wordpress'] ); $fields = array( 'name' => array( 'display' => 1, 'type' => 'text', 'name' => 'name', 'label' => __( 'Name', TVE_DASH_TRANSLATE_DOMAIN ), 'required' => false, ), 'email' => array( 'display' => 1, 'type' => 'email', 'name' => 'email', 'label' => __( 'Email', TVE_DASH_TRANSLATE_DOMAIN ), 'validation' => 'email', 'required' => true, ), 'phone' => array( 'display' => 1, 'type' => 'text', 'name' => 'phone', 'label' => __( 'Phone Number', TVE_DASH_TRANSLATE_DOMAIN ), 'validation' => 'phone', ), ); if ( $account ) { $fields['password'] = array( 'display' => 0, 'type' => 'password', 'name' => 'password', 'label' => __( 'Password', TVE_DASH_TRANSLATE_DOMAIN ), 'validation' => 'password', 'required' => false, ); $fields['confirm_password'] = array( 'display' => 0, 'type' => 'password', 'name' => 'confirm_password', 'label' => __( 'Confirm Password', TVE_DASH_TRANSLATE_DOMAIN ), 'validation' => 'password', 'required' => false, ); } /** * allow adding / removing fields from the form */ $fields = apply_filters( 'tcb_lead_generation_api_fields', $fields ); return $fields; } /** * generate the setup table for the fields included in API-connected forms * * @param array $params provide a way to filter the output * @param array $order elements order - numeric array containing field names as values * * @return string the generated table containing all input data */ public function apiFieldsTable( $params = array(), $order = array(), $connection_config ) { $this->connection_config = $connection_config; $this->show_display_options = empty( $params['show_display_options'] ) ? false : true; $this->show_order = empty( $params['show_order'] ) ? false : true; $fields = $this->getOrderedFields( $order ); return $this->fieldsTable( $fields ); } /** * get the ordered list of fields * * @param array $order elements order - numeric array containing field names as values * * @return array */ public function getOrderedFields( $order ) { $fields = $this->getApiFields(); if ( ! empty( $order ) ) { $ordered = array(); foreach ( $order as $field ) { if ( ! isset( $fields[ $field ] ) ) { continue; } $ordered[ $field ] = $fields[ $field ]; unset( $fields[ $field ] ); } /** * take on any other fields */ foreach ( $fields as $k => $f ) { $ordered[ $k ] = $f; } $fields = $ordered; } return $fields; } /** * render the table containing all fields (inside the editor view / panel) * * @param array $elements * * @return string the table containing the setup fields */ public function fieldsTable( $elements = array() ) { $html = ''; $html .= $this->_tableHead() . ''; $input_index = 1; foreach ( $elements as $element ) { switch ( $element['type'] ) { case 'text': case 'password': case 'email': $html .= $this->_textRow( $element, $input_index, 'text' ); break; case 'radio': $html .= $this->_radioRow( $element, $input_index ); break; case 'checkbox': $html .= $this->_checkboxRow( $element, $input_index ); break; case 'select': $html .= $this->_selectRow( $element, $input_index ); break; case 'textarea': $html .= $this->_textareaRow( $element, $input_index ); break; } $input_index ++; } $html .= '
'; return $html; } /** * render the table head * * @return string */ protected function _tableHead() { ob_start(); ?> show_order ) : ?>   show_display_options ? esc_html__( 'Display', TVE_DASH_TRANSLATE_DOMAIN ) : esc_html__( 'Field Number', TVE_DASH_TRANSLATE_DOMAIN ); ?> encodeAttrName( $field ); ob_start(); ?> show_order ) : ?> show_display_options ) : ?> -
_validationOptions( $field, $element ) ?>
id="required_"/>
encodeAttrName( $field ); ob_start(); ?> show_order ) : ?>  
id="required_:"/>
- encodeAttrName( $field ); ob_start(); ?> show_order ) : ?> $radio_label ) : ?>  
id="required_:"/>
  encodeAttrName( $field ); ob_start(); ?> show_order ) : ?>  
id="required_:"/>
  _textRow( $element, $input_index ); } /** * output validation options * * @param string $field * @param array $element element data */ protected function _validationOptions( $field, $element ) { $selected = ! empty( $element['validation'] ) ? $element['validation'] : ''; $account = isset( $this->connection_config['wordpress'] ); ?>