$custom_field ) { acscf_render_single_custom_field_html( $custom_field, $index, $form_id ); } } /** * The required / optional badge. * * @param bool $required Whether the field is required. * @return void */ function acscf_render_required_badge( $required ) { if ( $required ) { echo '' . esc_html__( 'required', 'acs-contact-form' ) . ''; return; } echo '' . esc_html__( 'optional', 'acs-contact-form' ) . ''; } /** * Render one custom field. * * @param array $custom_field Field definition. * @param int $index Field index. * @param int $form_id Form post ID. * @return void */ function acscf_render_single_custom_field_html( $custom_field, $index, $form_id ) { $type = isset( $custom_field['type'] ) ? $custom_field['type'] : 'text'; $label = isset( $custom_field['label'] ) ? $custom_field['label'] : ''; $required = isset( $custom_field['required'] ) && '1' === $custom_field['required']; $placeholder = isset( $custom_field['placeholder'] ) ? $custom_field['placeholder'] : ''; $index = (int) $index; $form_id = (int) $form_id; $field_name = 'acscf_data[' . $index . ']'; $options = array(); if ( in_array( $type, array( 'select', 'radio', 'checkbox' ), true ) && ! empty( $custom_field['options'] ) ) { $options = array_filter( array_map( 'trim', explode( "\n", $custom_field['options'] ) ) ); } ?>