diff --git a/go-form-plugin/go-form-plugin.php b/go-form-plugin/go-form-plugin.php index fe967dc..098ee5b 100644 --- a/go-form-plugin/go-form-plugin.php +++ b/go-form-plugin/go-form-plugin.php @@ -37,6 +37,12 @@ function go_form_activate() { PRIMARY KEY (id), KEY form_id (form_id) ) $charset;"); + + // Add default form if none exist + $existing_forms = $wpdb->get_var("SELECT COUNT(*) FROM $forms"); + if ($existing_forms == 0) { + $wpdb->insert($forms, ['name' => 'Default Form']); + } } register_activation_hook(__FILE__, 'go_form_activate'); @@ -48,8 +54,7 @@ function go_form_uninstall() { register_uninstall_hook(__FILE__, 'go_form_uninstall'); // ========== Helpers ========== -function go_form_get_rank_dropdown($selected = 0) { - $ranks = [ +$ranks = [ 0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k', 5 => '25k', 6 => '24k', 7 => '23k', 8 => '22k', 9 => '21k', 10 => '20k', 11 => '19k', 12 => '18k', 13 => '17k', 14 => '16k', @@ -57,18 +62,10 @@ function go_form_get_rank_dropdown($selected = 0) { 20 => '10k', 21 => '9k', 22 => '8k', 23 => '7k', 24 => '6k', 25 => '5k', 26 => '4k', 27 => '3k', 28 => '2k', 29 => '1k', 30 => '1d', 31 => '2d', 32 => '3d', 33 => '4d', 34 => '5d', - 35 => '6d', 36 => '7d', 37 => '8d', 38 => '9d', 39 => '1p', 40=> '2p', - 41 => '3p', 42=> '4p', 43 => '5p', 44=> '6p', 45 => '7p', 46 => '8p', 47 => '9p' + 35 => '6d', 36 => '7d', 37 => '8d', 38 => '9d', 39 => '1p', + 40 => '2p', 41 => '3p', 42 => '4p', 43 => '5p', 44 => '6p', + 45 => '7p', 46 => '8p', 47 => '9p' ]; - - $html = '"; - echo $html; -} function go_form_get_forms() { global $wpdb; @@ -78,26 +75,28 @@ function go_form_get_forms() { function go_form_get_entries($form_id) { global $wpdb; return $wpdb->get_results($wpdb->prepare( - "SELECT * FROM {$wpdb->prefix}go_form_entries WHERE form_id = %d ORDER BY created_at DESC", + "SELECT * FROM {$wpdb->prefix}go_form_entries WHERE form_id = %d ORDER BY rank DESC", $form_id )); } function go_form_render_entries_table($entries, $show_delete = false) { + global $ranks; + if (empty($entries)) { echo '

No entries yet.

'; return; } - $headers = ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Date Added']; + $headers = ['First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Date Added']; if ($show_delete) $headers[] = 'Action'; echo ''; - + foreach ($entries as $e) { - echo ' - + echo ' + '; if ($show_delete) { @@ -155,7 +154,7 @@ function go_form_shortcode($atts) { if (isset($_GET['form_success']) && $_GET['form_success'] == 1) $msg = '
Entry added successfully!
'; elseif (isset($_GET['form_error'])) { - $errors = ['1' => 'Please fill in all required fields.', 'rank' => 'Rank must be 0-40.', 'email' => 'Please enter a valid email.']; + $errors = ['1' => 'Please fill in all required fields.', 'rank' => 'Rank must be 0-47.', 'email' => 'Please enter a valid email.']; $msg = '
'.esc_html($errors[$_GET['form_error']] ?? $errors['1']).'
'; } diff --git a/go-form-plugin/templates/form-shortcode.php b/go-form-plugin/templates/form-shortcode.php index 5691a9b..62ef7e4 100644 --- a/go-form-plugin/templates/form-shortcode.php +++ b/go-form-plugin/templates/form-shortcode.php @@ -53,7 +53,17 @@ - + + +
@@ -77,9 +87,7 @@ document.addEventListener('DOMContentLoaded', function() { const resultsDiv = document.getElementById('egd-results'); const searchButton = document.getElementById('egd-search'); const closeButton = document.getElementById('egd-popup-close'); - console.log("WE ARE SET UP"); function fetchPlayers() { - console.log("HI"); const firstName = firstNameInput.value.trim(); const lastName = lastNameInput.value.trim();
'.implode('', $headers).'
'.esc_html($e->id).''.esc_html($e->first_name).''.esc_html($e->last_name).''.esc_html($e->country).''.esc_html($e->club).''.esc_html($e->rank).'
'.esc_html($e->first_name).''.esc_html($e->last_name).''.esc_html($e->country).''.esc_html($e->club).''.esc_html($ranks[$e->rank]).' '.esc_html($e->email).''.esc_html($e->egd_number).''.esc_html($e->created_at).'