*/
$form = new WAI_FORM();
$current_csv = get_option( 'wai_current_csv' );
$step = 'step-1';
if ( is_array( $current_csv ) && file_exists( $current_csv['file'] ) ) {
$step = 'step-2';
}
if ( $step == 'step-1' ) {
$form->set_header( esc_html__( 'Step 1 - Upload CSV', 'text-prompter' ), $response );
$form->add_element(
'group',
'csv_upload_step_1',
array(
'value' => esc_html__( 'Step 1 - Upload CSV', 'text-prompter' ),
'before' => '
| CSV Field | Assign |
';
foreach ( $csv_columns as $key => $value ) {
if ( isset( $_POST['csv_columns'][ $key ] ) ) {
$selected = sanitize_text_field( $_POST['csv_columns'][ $key ] );
} elseif ( array_key_exists( $value, $core_fields ) ) {
$selected = $value;
} else {
$selected = '';
}
$html .= '| ' . $value . ' | ' . $form->field_select(
'csv_columns[' . $key . ']',
array(
'options' => $csv_options,
'current' => $selected,
)
) . ' |
';
}
$html .= '
';
$form->add_element(
'html',
'instruction_html',
array(
'html' => $html,
'before' => '
',
'after' => '
',
)
);
$form->add_element(
'hidden',
'operation',
array(
'value' => 'import_prompt',
)
);
$form->add_element(
'hidden',
'import',
array(
'value' => 'prompt_import',
)
);
$submit_button = $form->field_submit(
'import_loc',
array(
'value' => esc_html__( 'Import Prompts', 'text-prompter' ),
'no-sticky' => true,
'class' => 'form-control fc-btn fc-btn-submit fc-btn-big',
)
);
$cancel_button = $form->field_button(
'cancel_import',
array(
'value' => esc_html__( 'Cancel', 'text-prompter' ),
'no-sticky' => true,
'class' => 'fc-btn fc-danger fc-btn-big cancel_import',
)
);
$html = "
" . $submit_button . '
' . $cancel_button . '
';
$form->add_element(
'html',
'button_html',
array(
'html' => $html,
'before' => '
',
'after' => '
',
)
);
$form->render();
}