From 8b54aff9acd6a1c35ef5cf315d456f31eeeab9ab Mon Sep 17 00:00:00 2001 From: Nikola Petrov Date: Sat, 9 May 2026 00:43:23 +0200 Subject: [PATCH] Start work on custom fields --- go-form-plugin/database-schema.sql | 51 ++++++++++++++++++++++++++++++ go-form-plugin/go-form-plugin.php | 2 +- main.php | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 go-form-plugin/database-schema.sql diff --git a/go-form-plugin/database-schema.sql b/go-form-plugin/database-schema.sql new file mode 100644 index 0000000..8cb0cdc --- /dev/null +++ b/go-form-plugin/database-schema.sql @@ -0,0 +1,51 @@ +-- ========== Original Plugin Tables ========== + +CREATE TABLE wp_go_form_forms ( + id int NOT NULL AUTO_INCREMENT, + name varchar(255) NOT NULL, + created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE wp_go_form_entries ( + id int NOT NULL AUTO_INCREMENT, + form_id int DEFAULT 1, + first_name varchar(100) NOT NULL, + last_name varchar(100) NOT NULL, + country varchar(100) DEFAULT NULL, + club varchar(100) DEFAULT NULL, + rank tinyint(2) DEFAULT 0, + rating smallint(5) DEFAULT 0, + egd_number varchar(20) DEFAULT NULL, + 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) +); + +-- ========== Custom Fields Tables ========== + +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_options text, + is_public tinyint(1) NOT NULL DEFAULT 0, + is_required 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) +); + +CREATE TABLE wp_go_form_entry_custom_values ( + id int NOT NULL AUTO_INCREMENT, + entry_id int NOT NULL, + field_id int NOT NULL, + value text, + PRIMARY KEY (id), + FOREIGN KEY (entry_id) REFERENCES wp_go_form_entries(id) ON DELETE CASCADE, + FOREIGN KEY (field_id) REFERENCES wp_go_form_custom_fields(id) ON DELETE CASCADE, + INDEX (entry_id), + INDEX (field_id) +); diff --git a/go-form-plugin/go-form-plugin.php b/go-form-plugin/go-form-plugin.php index 5d5b101..c9d100a 100644 --- a/go-form-plugin/go-form-plugin.php +++ b/go-form-plugin/go-form-plugin.php @@ -248,7 +248,7 @@ function action_button($action, $name, $confirm_massage, $value_one) { echo '
- ' . wp_nonce_field($action . '_action', $action . '_nonce', true, false) . ' + ' . wp_nonce_field("{$action}_action", "{$action}_nonce", true, false) . ' diff --git a/main.php b/main.php index 203eb21..fdce359 100644 --- a/main.php +++ b/main.php @@ -2,7 +2,7 @@ /** * Plugin Name: Go Form Plugin * Description: Form plugin for Go players - * Version: 0.04 + * Version: 0.05-WIP * Author: Nikola Petrov */