diff --git a/go-form-plugin/database-schema.sql b/go-form-plugin/database-schema.sql index 8cb0cdc..8abd915 100644 --- a/go-form-plugin/database-schema.sql +++ b/go-form-plugin/database-schema.sql @@ -20,7 +20,8 @@ CREATE TABLE wp_go_form_entries ( created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id), FOREIGN KEY (form_id) REFERENCES wp_go_form_forms(id) ON DELETE CASCADE, - INDEX (form_id) + INDEX (form_id), + INDEX (egd_number) ); -- ========== Custom Fields Tables ========== @@ -29,10 +30,11 @@ CREATE TABLE wp_go_form_custom_fields ( id int NOT NULL AUTO_INCREMENT, form_id int NOT NULL, field_name varchar(100) NOT NULL, - field_type enum('select','text','checkbox', 'email') NOT NULL DEFAULT 'text', + field_type enum('select','text','checkbox', 'email', 'textarea') NOT NULL DEFAULT 'text', field_options text, is_public tinyint(1) NOT NULL DEFAULT 0, is_required tinyint(1) NOT NULL DEFAULT 0, + is_full_width tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id), FOREIGN KEY (form_id) REFERENCES wp_go_form_forms(id) ON DELETE CASCADE, INDEX (form_id) diff --git a/go-form-plugin/go-form-plugin.php b/go-form-plugin/go-form-plugin.php index 5a9d9b7..6d5d556 100644 --- a/go-form-plugin/go-form-plugin.php +++ b/go-form-plugin/go-form-plugin.php @@ -34,17 +34,19 @@ function go_form_activate() created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id), FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE, - INDEX (form_id) + INDEX (form_id), + INDEX (egd_number) ) $charset;"); dbDelta("CREATE TABLE $custom_fields ( id int NOT NULL AUTO_INCREMENT, form_id int NOT NULL, field_name varchar(100) NOT NULL, - field_type enum('select','text','checkbox', 'email') NOT NULL DEFAULT 'text', + field_type enum('select','text','checkbox', 'email', 'textarea') NOT NULL DEFAULT 'text', field_options text, is_public tinyint(1) NOT NULL DEFAULT 0, is_required tinyint(1) NOT NULL DEFAULT 0, + is_full_width tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id), FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE, INDEX (form_id) @@ -352,6 +354,7 @@ function go_form_create_custom_field() $field_options = isset($_POST['field_options']) ? sanitize_textarea_field($_POST['field_options']) : ''; $is_public = isset($_POST['is_public']) ? 1 : 0; $is_required = isset($_POST['is_required']) ? 1 : 0; + $is_full_width = isset($_POST['is_full_width']) ? 1 : 0; $wpdb->insert("{$wpdb->prefix}go_form_custom_fields", [ 'form_id' => $form_id, @@ -359,7 +362,8 @@ function go_form_create_custom_field() 'field_type' => $field_type, 'field_options' => $field_options, 'is_public' => $is_public, - 'is_required' => $is_required + 'is_required' => $is_required, + 'is_full_width' => $is_full_width ]); } $redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $_POST['form_id'], 'created_field' => 1), admin_url('admin.php')); @@ -379,13 +383,15 @@ function go_form_update_custom_field() $field_options = isset($_POST['field_options']) ? sanitize_textarea_field($_POST['field_options']) : ''; $is_public = isset($_POST['is_public']) ? 1 : 0; $is_required = isset($_POST['is_required']) ? 1 : 0; + $is_full_width = isset($_POST['is_full_width']) ? 1 : 0; $wpdb->update("{$wpdb->prefix}go_form_custom_fields", [ 'field_name' => $field_name, 'field_type' => $field_type, 'field_options' => $field_options, 'is_public' => $is_public, - 'is_required' => $is_required + 'is_required' => $is_required, + 'is_full_width' => $is_full_width ], ['id' => $field_id]); } $redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $_POST['form_id'], 'updated_field' => 1), admin_url('admin.php')); @@ -397,9 +403,9 @@ add_action('admin_post_go_form_update_custom_field', 'go_form_update_custom_fiel function go_form_delete_custom_field() { go_form_admin_action('delete_custom_field'); - if (isset($_POST['field_id'])) { + if (isset($_POST['value_one'])) { global $wpdb; - $field_id = intval($_POST['field_id']); + $field_id = intval($_POST['value_one']); $field = go_form_get_custom_field_by_id($field_id); $form_id = $field ? $field->form_id : 0; $wpdb->delete("{$wpdb->prefix}go_form_custom_fields", ['id' => $field_id]); diff --git a/go-form-plugin/templates/form-shortcode.php b/go-form-plugin/templates/form-shortcode.php index 199ac4e..ecb0322 100644 --- a/go-form-plugin/templates/form-shortcode.php +++ b/go-form-plugin/templates/form-shortcode.php @@ -102,7 +102,19 @@ is_full_width) { + $full_width_fields[] = $field; + } else { + $grid_fields[] = $field; + } + } + + // Render grid fields + foreach ($grid_fields as $field): $field_id = 'custom_field_' . $field->id; echo 'field_type === 'checkbox' ? ' style="grid-column: span 2;"' : '') . '>'; echo ''; @@ -114,6 +126,9 @@ case 'email': echo 'is_required ? ' required' : '') . '>'; break; + case 'textarea': + echo ''; + break; case 'select': $options = $field->field_options ? explode(',', $field->field_options) : []; echo 'is_required ? ' required' : '') . '>'; + break; + case 'email': + echo 'is_required ? ' required' : '') . '>'; + break; + case 'textarea': + echo ''; + break; + case 'select': + $options = $field->field_options ? explode(',', $field->field_options) : []; + echo ''; + break; + case 'checkbox': + echo 'is_required ? ' required' : '') . '>'; + break; + } + echo ''; + endforeach; + ?> +

* Required fields

diff --git a/go-form-plugin/templates/settings-page.php b/go-form-plugin/templates/settings-page.php index ded7c2b..f5330c4 100644 --- a/go-form-plugin/templates/settings-page.php +++ b/go-form-plugin/templates/settings-page.php @@ -41,10 +41,10 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') echo '
'; action_button('go_form_delete_form', 'Delete Form', 'Delete this form and ALL entries?', $selected_form_id); - action_button('go_form_export_csv', 'Export to CSV', 'Confrm Export', $selected_form_id); - action_button('go_form_export_pairgoth', 'Export to Pairgoth', 'Confrm Export', $selected_form_id); - action_button('go_form_export_opengotha', 'Export to Opengoth', 'Confrm Export', $selected_form_id); - action_button('go_form_export_mcmahon', 'Export to McMahon', 'Confrm Export', $selected_form_id); + action_button('go_form_export_csv', 'Export to CSV', 'Confirm Export', $selected_form_id); + action_button('go_form_export_pairgoth', 'Export to Pairgoth', 'Confirm Export', $selected_form_id); + action_button('go_form_export_opengotha', 'Export to Opengoth', 'Confirm Export', $selected_form_id); + action_button('go_form_export_mcmahon', 'Export to McMahon', 'Confirm Export', $selected_form_id); action_button('go_form_update_egd_data', 'Update EGD Data', 'Update rank and rating from EGD for all entries with EGD numbers?', $selected_form_id); echo '
'; @@ -69,11 +69,13 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') echo ''; echo ''; echo ''; + echo ''; echo ''; echo ''; echo 'e.g., Option 1,Option 2,Option 3'; echo ' Show on public form'; echo ' Required field'; + echo ' Display on full width (outside grid)'; echo ''; echo '

'; echo ''; @@ -82,13 +84,14 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') // List existing custom fields if (!empty($custom_fields)) { echo ''; - echo ''; + echo ''; foreach ($custom_fields as $field) { echo ''; echo ''; echo ''; echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; + echo ''; echo '
Field NameTypePublicRequiredActions
Field NameTypePublicRequiredFull WidthActions
' . esc_html($field->field_name) . '' . esc_html($field->field_type) . '' . ($field->is_public ? 'Yes' : 'No') . '' . ($field->is_required ? 'Yes' : 'No') . '' . ($field->is_full_width ? 'Yes' : 'No') . ''; // Edit button (toggle to show edit form) echo 'Edit '; @@ -119,11 +122,13 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') echo ''; echo ''; echo ''; + echo ''; echo ''; echo '
e.g., Option 1,Option 2,Option 3
is_public, 1, false) . '> Show on public form
is_required, 1, false) . '> Required field
is_full_width, 1, false) . '> Display on full width (outside grid)
'; echo '

Cancel

'; echo ''; @@ -175,6 +180,9 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed') case 'email': echo 'is_required ? ' required' : '') . '>'; break; + case 'textarea': + echo ''; + break; case 'select': $options = $field->field_options ? explode(',', $field->field_options) : []; echo '