Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6a210f281 | ||
|
|
ad1ed7e45a | ||
|
|
6aeee287f8 | ||
|
|
4925b345bc | ||
|
|
c36f409484 | ||
|
|
2139a31e7c | ||
|
|
17998dc7b2 | ||
|
|
d5e0feb4f2 | ||
|
|
f9555e4547 | ||
|
|
1b0d00f380 | ||
|
|
2f06a8a4f1 | ||
|
|
08ae633d01 | ||
|
|
6cebf05e32 | ||
|
|
f5b5af5372 | ||
|
|
1d5fed6e1f | ||
|
|
d75997fbb5 | ||
|
|
ffaa624f65 | ||
|
|
6e1bc4ac1b | ||
|
|
ad1a535795 | ||
|
|
7c6eaa895d | ||
|
|
f5a48a62db | ||
|
|
529dd442b5 | ||
|
|
13a4ee0ae7 | ||
|
|
9ef421eeb5 | ||
|
|
38a3a2153b | ||
|
|
851c9d3674 | ||
|
|
ed67849629 | ||
|
|
cdda18f6de | ||
|
|
5c287eceba | ||
|
|
2d537f07dd | ||
|
|
bd7b9e1731 | ||
|
|
8b54aff9ac |
@@ -2,114 +2,11 @@
|
|||||||
|
|
||||||
A WordPress plugin for managing Go (Baduk/Weiqi) tournament registrations. Collect player information through frontend forms and export entries to popular tournament management systems.
|
A WordPress plugin for managing Go (Baduk/Weiqi) tournament registrations. Collect player information through frontend forms and export entries to popular tournament management systems.
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- **Frontend Registration Form** with shortcode support
|
|
||||||
- **EGD Database Integration** - Search and auto-fill player data from the European Go Database
|
|
||||||
- **Rank Selection** - Dropdown with ranks from 30k to 9p
|
|
||||||
- **Automatic Rating Calculation** - Auto-computes rating from rank when needed
|
|
||||||
- **Multiple Export Formats** - CSV, Pairgoth (JSON), OpenGotha (XML), McMahon (XML)
|
|
||||||
- **Multi-Form Support** - Create and manage multiple registration forms
|
|
||||||
- **Admin Dashboard** - View, delete, and export entries
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Upload the `go-form-plugin` folder to your `/wp-content/plugins/` directory
|
1. Upload the `go-form-plugin` folder to your `/wp-content/plugins/` directory
|
||||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||||
3. A default form is automatically created on activation
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Displaying a Form
|
|
||||||
|
|
||||||
Use the shortcode to display a registration form on any page or post:
|
|
||||||
|
|
||||||
```
|
|
||||||
[go_form id=1]
|
|
||||||
```
|
|
||||||
|
|
||||||
Replace `1` with your form ID. Find form IDs in the admin settings page.
|
|
||||||
|
|
||||||
### Admin Settings
|
|
||||||
|
|
||||||
Navigate to **Go Form** in the WordPress admin menu to:
|
|
||||||
|
|
||||||
- **Create Forms** - Add new registration forms
|
|
||||||
- **Manage Forms** - View all forms with their shortcodes
|
|
||||||
- **View Entries** - See all submissions for a form
|
|
||||||
- **Delete Entries** - Remove individual registrations
|
|
||||||
- **Delete Forms** - Remove a form and all its entries (cannot delete default form)
|
|
||||||
- **Export Data** - Download entries in various tournament formats
|
|
||||||
|
|
||||||
### EGD Search
|
|
||||||
|
|
||||||
Players can click the "Search EGD" button on the frontend form to look up their information in the European Go Database. This auto-fills:
|
|
||||||
- First Name
|
|
||||||
- Last Name
|
|
||||||
- Country
|
|
||||||
- Club
|
|
||||||
- Rank
|
|
||||||
- EGD Number
|
|
||||||
- Rating
|
|
||||||
|
|
||||||
## Export Formats
|
|
||||||
|
|
||||||
| Format | File Extension | Description |
|
|
||||||
|--------|---------------|-------------|
|
|
||||||
| CSV | `.csv` | Standard spreadsheet format |
|
|
||||||
| Pairgoth | `.tour` | JSON format for Pairgoth pairing system |
|
|
||||||
| OpenGotha | `.xml` | XML format for OpenGotha tournament manager |
|
|
||||||
| McMahon | `.xml` | XML format for McMahon tournament system |
|
|
||||||
|
|
||||||
## Database
|
|
||||||
|
|
||||||
The plugin creates two tables:
|
|
||||||
|
|
||||||
- `wp_go_form_forms` - Stores form definitions
|
|
||||||
- `wp_go_form_entries` - Stores all player registrations
|
|
||||||
|
|
||||||
Both tables are automatically removed when the plugin is uninstalled.
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- WordPress 5.0 or higher
|
|
||||||
- PHP 7.4 or higher
|
|
||||||
- MySQL 5.6 or higher
|
|
||||||
|
|
||||||
## Fields Collected
|
|
||||||
|
|
||||||
| Field | Required | Description |
|
|
||||||
|-------|----------|-------------|
|
|
||||||
| First Name | Yes | Player's first name |
|
|
||||||
| Last Name | Yes | Player's last name |
|
|
||||||
| Country | Yes | Country code (2-3 letters) |
|
|
||||||
| Club | Yes | Club name |
|
|
||||||
| Rank | Yes | Go rank (30k to 9p) |
|
|
||||||
| Rating | No | EGD rating (auto-calculated from rank if missing) |
|
|
||||||
| Email | No | Email address |
|
|
||||||
| EGD Number | No | European Go Database PIN |
|
|
||||||
| Comment | No | Additional notes |
|
|
||||||
|
|
||||||
## Hooks
|
|
||||||
|
|
||||||
### Actions
|
|
||||||
|
|
||||||
- `admin_post_go_form_handle_submission` - Form submission handler
|
|
||||||
- `admin_post_go_form_delete_entry` - Delete entry handler
|
|
||||||
- `admin_post_go_form_create_form` - Create form handler
|
|
||||||
- `admin_post_go_form_delete_form` - Delete form handler
|
|
||||||
- `admin_post_go_form_export_csv` - CSV export handler
|
|
||||||
- `admin_post_go_form_export_pairgoth` - Pairgoth export handler
|
|
||||||
- `admin_post_go_form_export_opengotha` - OpenGotha export handler
|
|
||||||
- `admin_post_go_form_export_mcmahon` - McMahon export handler
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
- All forms use WordPress nonces for CSRF protection
|
|
||||||
- Admin actions require `manage_options` capability
|
|
||||||
- All input is sanitized using WordPress sanitization functions
|
|
||||||
- Direct file access is blocked
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
Nikola Petrov nikola@petrovv.com
|
Nikola Petrov - nikola@petrovv.com
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
Remove update egd data
|
||||||
|
|
||||||
|
https://stackoverflow.com/questions/18796221/creating-a-select-box-with-a-search-option
|
||||||
|
|
||||||
|
|
||||||
|
<input list="brow">
|
||||||
|
<datalist id="brow">
|
||||||
|
<option value="Internet Explorer">
|
||||||
|
<option value="Firefox">
|
||||||
|
<option value="Chrome">
|
||||||
|
<option value="Opera">
|
||||||
|
<option value="Safari">
|
||||||
|
</datalist>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"retcode":"Ok","Pin_Player":"12098053","AGAID":"0","Last_Name":"Podavini","Name":"Aldo","Country_Code":"IT","Club":"Mila","Grade":"5k","Grade_n":"25","EGF_Placement":"0","Gor":"1576","DGor":"0","Proposed_Grade":"","Tot_Tournaments":"36","Last_Appearance":"T101212A","Elab_Date":"2009-04-03","Hidden_History":"0","Real_Last_Name":"Podavini","Real_Name":"Aldo"}
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,257 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Country codes and names extracted from go-form.xml
|
||||||
|
* Generated automatically - do not edit manually
|
||||||
|
*/
|
||||||
|
|
||||||
|
$countries = array(
|
||||||
|
'AC' => 'Ascension Island',
|
||||||
|
'AD' => 'Andorra',
|
||||||
|
'AE' => 'United Arab Emirates',
|
||||||
|
'AF' => 'Afghanistan',
|
||||||
|
'AG' => 'Antigua and Barbuda',
|
||||||
|
'AI' => 'Anguilla',
|
||||||
|
'AL' => 'Albania',
|
||||||
|
'AM' => 'Armenia',
|
||||||
|
'AN' => 'Netherlands Antilles',
|
||||||
|
'AO' => 'Angola',
|
||||||
|
'AQ' => 'Antarctica',
|
||||||
|
'AR' => 'Argentina',
|
||||||
|
'AS' => 'American Samoa',
|
||||||
|
'AT' => 'Austria',
|
||||||
|
'AU' => 'Australia',
|
||||||
|
'AW' => 'Aruba',
|
||||||
|
'AX' => 'Åland',
|
||||||
|
'AZ' => 'Azerbaijan',
|
||||||
|
'BA' => 'Bosnia and Herzegovina',
|
||||||
|
'BB' => 'Barbados',
|
||||||
|
'BD' => 'Bangladesh',
|
||||||
|
'BE' => 'Belgium',
|
||||||
|
'BF' => 'Burkina Faso',
|
||||||
|
'BG' => 'Bulgaria',
|
||||||
|
'BH' => 'Bahrain',
|
||||||
|
'BI' => 'Burundi',
|
||||||
|
'BJ' => 'Benin',
|
||||||
|
'BM' => 'Bermuda',
|
||||||
|
'BN' => 'Brunei Darussalam',
|
||||||
|
'BO' => 'Bolivia',
|
||||||
|
'BR' => 'Brazil',
|
||||||
|
'BS' => 'Bahamas',
|
||||||
|
'BT' => 'Bhutan',
|
||||||
|
'BV' => 'Bouvet Island',
|
||||||
|
'BW' => 'Botswana',
|
||||||
|
'BY' => 'Belarus',
|
||||||
|
'BZ' => 'Belize',
|
||||||
|
'CA' => 'Canada',
|
||||||
|
'CC' => 'Cocos (Keeling) Islands',
|
||||||
|
'CD' => 'Democratic Republic of the Congo',
|
||||||
|
'CF' => 'Central African Republic',
|
||||||
|
'CG' => 'Republic of the Congo',
|
||||||
|
'CH' => 'Switzerland',
|
||||||
|
'CI' => 'Côte d\'Ivoire',
|
||||||
|
'CK' => 'Cook Islands',
|
||||||
|
'CL' => 'Chile',
|
||||||
|
'CM' => 'Cameroon',
|
||||||
|
'CN' => 'People\'s Republic of China',
|
||||||
|
'CO' => 'Colombia',
|
||||||
|
'CR' => 'Costa Rica',
|
||||||
|
'CS' => 'Czechoslovakia',
|
||||||
|
'CU' => 'Cuba',
|
||||||
|
'CV' => 'Cape Verde',
|
||||||
|
'CX' => 'Christmas Island',
|
||||||
|
'CY' => 'Cyprus',
|
||||||
|
'CZ' => 'Czech Republic',
|
||||||
|
'DE' => 'Germany',
|
||||||
|
'DJ' => 'Djibouti',
|
||||||
|
'DK' => 'Denmark',
|
||||||
|
'DM' => 'Dominica',
|
||||||
|
'DO' => 'Dominican Republic',
|
||||||
|
'DZ' => 'Algeria',
|
||||||
|
'EC' => 'Ecuador',
|
||||||
|
'EE' => 'Estonia',
|
||||||
|
'EG' => 'Egypt',
|
||||||
|
'ER' => 'Eritrea',
|
||||||
|
'ES' => 'Spain',
|
||||||
|
'ET' => 'Ethiopia',
|
||||||
|
'EU' => 'European Union',
|
||||||
|
'FI' => 'Finland',
|
||||||
|
'FJ' => 'Fiji',
|
||||||
|
'FK' => 'Falkland Islands',
|
||||||
|
'FM' => 'Federated States of Micronesia',
|
||||||
|
'FO' => 'Faroe Islands',
|
||||||
|
'FR' => 'France',
|
||||||
|
'GA' => 'Gabon',
|
||||||
|
'GB' => 'United Kingdom',
|
||||||
|
'GD' => 'Grenada',
|
||||||
|
'GE' => 'Georgia',
|
||||||
|
'GF' => 'French Guiana',
|
||||||
|
'GG' => 'Guernsey',
|
||||||
|
'GH' => 'Ghana',
|
||||||
|
'GI' => 'Gibraltar',
|
||||||
|
'GL' => 'Greenland',
|
||||||
|
'GM' => 'The Gambia',
|
||||||
|
'GN' => 'Guinea',
|
||||||
|
'GP' => 'Guadeloupe',
|
||||||
|
'GQ' => 'Equatorial Guinea',
|
||||||
|
'GR' => 'Greece',
|
||||||
|
'GS' => 'South Georgia and the South Sandwich Islands',
|
||||||
|
'GT' => 'Guatemala',
|
||||||
|
'GU' => 'Guam',
|
||||||
|
'GW' => 'Guinea-Bissau',
|
||||||
|
'GY' => 'Guyana',
|
||||||
|
'HK' => 'Hong Kong',
|
||||||
|
'HM' => 'Heard Island and McDonald Islands',
|
||||||
|
'HN' => 'Honduras',
|
||||||
|
'HR' => 'Croatia',
|
||||||
|
'HT' => 'Haiti',
|
||||||
|
'HU' => 'Hungary',
|
||||||
|
'ID' => 'Indonesia',
|
||||||
|
'IE' => 'Ireland',
|
||||||
|
'IL' => 'Israel',
|
||||||
|
'IM' => 'Isle of Man',
|
||||||
|
'IN' => 'India',
|
||||||
|
'IO' => 'British Indian Ocean Territory',
|
||||||
|
'IQ' => 'Iraq',
|
||||||
|
'IR' => 'Iran',
|
||||||
|
'IS' => 'Iceland',
|
||||||
|
'IT' => 'Italy',
|
||||||
|
'JE' => 'Jersey',
|
||||||
|
'JM' => 'Jamaica',
|
||||||
|
'JO' => 'Jordan',
|
||||||
|
'JP' => 'Japan',
|
||||||
|
'KE' => 'Kenya',
|
||||||
|
'KG' => 'Kyrgyzstan',
|
||||||
|
'KH' => 'Cambodia',
|
||||||
|
'KI' => 'Kiribati',
|
||||||
|
'KM' => 'Comoros',
|
||||||
|
'KN' => 'Saint Kitts and Nevis',
|
||||||
|
'KP' => 'Democratic People\'s Republic of Korea',
|
||||||
|
'KR' => 'Republic of Korea',
|
||||||
|
'KW' => 'Kuwait',
|
||||||
|
'KY' => 'Cayman Islands',
|
||||||
|
'KZ' => 'Kazakhstan',
|
||||||
|
'LA' => 'Laos',
|
||||||
|
'LB' => 'Lebanon',
|
||||||
|
'LC' => 'Saint Lucia',
|
||||||
|
'LI' => 'Liechtenstein',
|
||||||
|
'LK' => 'Sri Lanka',
|
||||||
|
'LR' => 'Liberia',
|
||||||
|
'LS' => 'Lesotho',
|
||||||
|
'LT' => 'Lithuania',
|
||||||
|
'LU' => 'Luxembourg',
|
||||||
|
'LV' => 'Latvia',
|
||||||
|
'LY' => 'Libya',
|
||||||
|
'MA' => 'Morocco',
|
||||||
|
'MC' => 'Monaco',
|
||||||
|
'MD' => 'Moldova',
|
||||||
|
'ME' => 'Montenegro',
|
||||||
|
'MG' => 'Madagascar',
|
||||||
|
'MH' => 'Marshall Islands',
|
||||||
|
'MK' => 'Republic of Macedonia',
|
||||||
|
'ML' => 'Mali',
|
||||||
|
'MM' => 'Myanmar',
|
||||||
|
'MN' => 'Mongolia',
|
||||||
|
'MO' => 'Macau',
|
||||||
|
'MP' => 'Northern Mariana Islands',
|
||||||
|
'MQ' => 'Martinique',
|
||||||
|
'MR' => 'Mauritania',
|
||||||
|
'MS' => 'Montserrat',
|
||||||
|
'MT' => 'Malta',
|
||||||
|
'MU' => 'Mauritius',
|
||||||
|
'MV' => 'Maldives',
|
||||||
|
'MW' => 'Malawi',
|
||||||
|
'MX' => 'Mexico',
|
||||||
|
'MY' => 'Malaysia',
|
||||||
|
'MZ' => 'Mozambique',
|
||||||
|
'NA' => 'Namibia',
|
||||||
|
'NC' => 'New Caledonia',
|
||||||
|
'NE' => 'Niger',
|
||||||
|
'NF' => 'Norfolk Island',
|
||||||
|
'NG' => 'Nigeria',
|
||||||
|
'NI' => 'Nicaragua',
|
||||||
|
'NL' => 'Netherlands',
|
||||||
|
'NO' => 'Norway',
|
||||||
|
'NP' => 'Nepal',
|
||||||
|
'NR' => 'Nauru',
|
||||||
|
'NU' => 'Niue',
|
||||||
|
'NZ' => 'New Zealand',
|
||||||
|
'OM' => 'Oman',
|
||||||
|
'PA' => 'Panama',
|
||||||
|
'PE' => 'Peru',
|
||||||
|
'PF' => 'French Polynesia',
|
||||||
|
'PG' => 'Papua New Guinea',
|
||||||
|
'PH' => 'Philippines',
|
||||||
|
'PK' => 'Pakistan',
|
||||||
|
'PL' => 'Poland',
|
||||||
|
'PM' => 'Saint-Pierre and Miquelon',
|
||||||
|
'PN' => 'Pitcairn Islands',
|
||||||
|
'PR' => 'Puerto Rico',
|
||||||
|
'PS' => 'Palestinian territories',
|
||||||
|
'PT' => 'Portugal',
|
||||||
|
'PW' => 'Palau',
|
||||||
|
'PY' => 'Paraguay',
|
||||||
|
'QA' => 'Qatar',
|
||||||
|
'RE' => 'Réunion',
|
||||||
|
'RO' => 'Romania',
|
||||||
|
'RS' => 'Serbia',
|
||||||
|
'RU' => 'Russia',
|
||||||
|
'RW' => 'Rwanda',
|
||||||
|
'SA' => 'Saudi Arabia',
|
||||||
|
'SB' => 'Solomon Islands',
|
||||||
|
'SC' => 'Seychelles',
|
||||||
|
'SD' => 'Sudan',
|
||||||
|
'SE' => 'Sweden',
|
||||||
|
'SG' => 'Singapore',
|
||||||
|
'SH' => 'Saint Helena',
|
||||||
|
'SI' => 'Slovenia',
|
||||||
|
'SJ' => 'Svalbard and Jan Mayen Islands',
|
||||||
|
'SK' => 'Slovakia',
|
||||||
|
'SL' => 'Sierra Leone',
|
||||||
|
'SM' => 'San Marino',
|
||||||
|
'SN' => 'Senegal',
|
||||||
|
'SO' => 'Somalia',
|
||||||
|
'SR' => 'Suriname',
|
||||||
|
'ST' => 'São Tomé and Príncipe',
|
||||||
|
'SU' => 'Soviet Union',
|
||||||
|
'SV' => 'El Salvador',
|
||||||
|
'SY' => 'Syria',
|
||||||
|
'SZ' => 'Swaziland',
|
||||||
|
'TC' => 'Turks and Caicos Islands',
|
||||||
|
'TD' => 'Chad',
|
||||||
|
'TF' => 'French Southern and Antarctic Lands',
|
||||||
|
'TG' => 'Togo',
|
||||||
|
'TH' => 'Thailand',
|
||||||
|
'TJ' => 'Tajikistan',
|
||||||
|
'TK' => 'Tokelau',
|
||||||
|
'TL' => 'East Timor',
|
||||||
|
'TM' => 'Turkmenistan',
|
||||||
|
'TN' => 'Tunisia',
|
||||||
|
'TO' => 'Tonga',
|
||||||
|
'TP' => 'East Timor',
|
||||||
|
'TR' => 'Turkey',
|
||||||
|
'TT' => 'Trinidad and Tobago',
|
||||||
|
'TV' => 'Tuvalu',
|
||||||
|
'TW' => 'Republic of China (Taiwan)',
|
||||||
|
'TZ' => 'Tanzania',
|
||||||
|
'UA' => 'Ukraine',
|
||||||
|
'UG' => 'Uganda',
|
||||||
|
'UK' => 'United Kingdom',
|
||||||
|
'US' => 'United States of America',
|
||||||
|
'UY' => 'Uruguay',
|
||||||
|
'UZ' => 'Uzbekistan',
|
||||||
|
'VA' => 'Vatican City',
|
||||||
|
'VC' => 'Saint Vincent and the Grenadines',
|
||||||
|
'VE' => 'Venezuela',
|
||||||
|
'VG' => 'British Virgin Islands',
|
||||||
|
'VI' => 'US Virgin Islands',
|
||||||
|
'VN' => 'Vietnam',
|
||||||
|
'VU' => 'Vanuatu',
|
||||||
|
'WF' => 'Wallis and Futuna',
|
||||||
|
'WS' => 'Samoa',
|
||||||
|
'YE' => 'Yemen',
|
||||||
|
'YT' => 'Mayotte',
|
||||||
|
'ZA' => 'South Africa',
|
||||||
|
'ZM' => 'Zambia',
|
||||||
|
'ZW' => 'Zimbabwe',
|
||||||
|
);
|
||||||
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
-- ========== Original Plugin Tables ==========
|
||||||
|
|
||||||
|
CREATE TABLE wp_go_form_forms (
|
||||||
|
id int NOT NULL AUTO_INCREMENT,
|
||||||
|
name varchar(255) NOT NULL,
|
||||||
|
email varchar(255) DEFAULT 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,
|
||||||
|
display_country varchar(150) DEFAULT NULL,
|
||||||
|
display_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),
|
||||||
|
INDEX (egd_number)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ========== 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', '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)
|
||||||
|
);
|
||||||
|
|
||||||
|
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)
|
||||||
|
);
|
||||||
@@ -10,28 +10,41 @@ $form_id = intval($_POST['value_one']);
|
|||||||
$form = go_form_get_form_by_id($form_id);
|
$form = go_form_get_form_by_id($form_id);
|
||||||
$form_name = $form ? $form->name : 'Unknown Form';
|
$form_name = $form ? $form->name : 'Unknown Form';
|
||||||
$entries = go_form_get_entries($form_id);
|
$entries = go_form_get_entries($form_id);
|
||||||
|
$custom_fields = go_form_get_custom_fields($form_id);
|
||||||
|
|
||||||
header('Content-Type: text/csv; charset=utf-8');
|
header('Content-Type: text/csv; charset=utf-8');
|
||||||
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
||||||
|
|
||||||
$output = fopen('php://output', 'w');
|
$output = fopen('php://output', 'w');
|
||||||
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Rating', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
|
||||||
|
|
||||||
foreach ($entries as $e) {
|
// Build header row
|
||||||
|
$header = ['N', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Rating', 'EGD Number', 'Date Added'];
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
$header[] = $field->field_name;
|
||||||
|
}
|
||||||
|
fputcsv($output, $header);
|
||||||
|
|
||||||
|
foreach ($entries as $i => $e) {
|
||||||
global $ranks;
|
global $ranks;
|
||||||
fputcsv($output, [
|
$row = [
|
||||||
$e->id,
|
$i,
|
||||||
$e->first_name,
|
$e->first_name,
|
||||||
$e->last_name,
|
$e->last_name,
|
||||||
$e->country,
|
$e->country,
|
||||||
$e->club,
|
$e->club,
|
||||||
$ranks[$e->rank] ?? '',
|
$ranks[$e->rank] ?? '',
|
||||||
$e->rating,
|
$e->rating,
|
||||||
$e->email,
|
|
||||||
$e->egd_number,
|
$e->egd_number,
|
||||||
$e->comment,
|
|
||||||
$e->created_at
|
$e->created_at
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
// Add custom field values
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
$value = go_form_get_custom_value($e->id, $field->id);
|
||||||
|
$row[] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
fputcsv($output, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($output);
|
fclose($output);
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
$macmahonfirst = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<Tournament typeversion="9">
|
||||||
|
<NumberOfRounds>5</NumberOfRounds>
|
||||||
|
<CurrentRoundNumber>1</CurrentRoundNumber>
|
||||||
|
<TakeCurrentRoundInAccount>true</TakeCurrentRoundInAccount>
|
||||||
|
<DefaultAsianName>false</DefaultAsianName>
|
||||||
|
<RatingAllowed>false</RatingAllowed>
|
||||||
|
<RatingLowestOneDanRating>2050</RatingLowestOneDanRating>
|
||||||
|
<RatingDeterminesRank>false</RatingDeterminesRank>
|
||||||
|
<RatingDeterminesStartScore>false</RatingDeterminesStartScore>
|
||||||
|
<LowerMacMahonBar>true</LowerMacMahonBar>
|
||||||
|
<LowerMacMahonBarLevel>10k</LowerMacMahonBarLevel>
|
||||||
|
<UpperMacMahonBar>true</UpperMacMahonBar>
|
||||||
|
<UpperMacMahonBarLevel>2k</UpperMacMahonBarLevel>
|
||||||
|
<UpperMacMahonBarRating>0</UpperMacMahonBarRating>
|
||||||
|
<ByeShouldResultInZeroSOSetc>false</ByeShouldResultInZeroSOSetc>
|
||||||
|
<HalfScoreGroupsRoundDown>false</HalfScoreGroupsRoundDown>
|
||||||
|
<HalfScoreGroupsRoundDownNotJigo>true</HalfScoreGroupsRoundDownNotJigo>
|
||||||
|
<PreliminaryDefaultRegistration>false</PreliminaryDefaultRegistration>
|
||||||
|
<OnlineEgdSupport>true</OnlineEgdSupport>
|
||||||
|
<OnlineEgdSupportByPin>false</OnlineEgdSupportByPin>
|
||||||
|
<HandicapUsed>true</HandicapUsed>
|
||||||
|
<HandicapBelow>false</HandicapBelow>
|
||||||
|
<HandicapBelowLevel>1d</HandicapBelowLevel>
|
||||||
|
<HandicapByLevel>true</HandicapByLevel>
|
||||||
|
<HandicapAdjustment>true</HandicapAdjustment>
|
||||||
|
<HandicapAdjustmentValue>-2</HandicapAdjustmentValue>
|
||||||
|
<HandicapLimit>true</HandicapLimit>
|
||||||
|
<HandicapLimitValue>9</HandicapLimitValue>
|
||||||
|
<HandicapIncludeInTieBreakers>true</HandicapIncludeInTieBreakers>
|
||||||
|
<AllowJigo>false</AllowJigo>
|
||||||
|
<Boardsize>19</Boardsize>
|
||||||
|
<PairingsMarkFixedBoardnumbers>true</PairingsMarkFixedBoardnumbers>
|
||||||
|
<PairingsMarkMissingResults>true</PairingsMarkMissingResults>
|
||||||
|
<PairingsMarkWinner>true</PairingsMarkWinner>
|
||||||
|
<PairingsMarkUnwantedPairings>true</PairingsMarkUnwantedPairings>
|
||||||
|
<PairingsShowLevels>true</PairingsShowLevels>
|
||||||
|
<PairingsShortNotationForLevel>false</PairingsShortNotationForLevel>
|
||||||
|
<PairingsShowScores>false</PairingsShowScores>
|
||||||
|
<PairingsShowHandicaps>true</PairingsShowHandicaps>
|
||||||
|
<PairingsFontsize>18</PairingsFontsize>
|
||||||
|
<PairingsBlackColumnWidth>283</PairingsBlackColumnWidth>
|
||||||
|
<PairingsWhiteColumnWidth>301</PairingsWhiteColumnWidth>
|
||||||
|
<ImportEncoding>UTF-8</ImportEncoding>
|
||||||
|
<ExportColumnDelimiter><![CDATA[f]]></ExportColumnDelimiter>
|
||||||
|
<ExportWalllistShowTournamentTitle>true</ExportWalllistShowTournamentTitle>
|
||||||
|
<ExportEncoding>UTF-8</ExportEncoding>
|
||||||
|
<VersionCreated>MacMahon 3.10</VersionCreated>
|
||||||
|
<VersionSaved>MacMahon 3.10</VersionSaved>
|
||||||
|
<MakePairingTopGroup>true</MakePairingTopGroup>
|
||||||
|
<MakePairingTopGroupEverywhere>false</MakePairingTopGroupEverywhere>
|
||||||
|
<MakePairingTopGroupStrictlyByTopBar>false</MakePairingTopGroupStrictlyByTopBar>
|
||||||
|
<MakePairingTopGroupByNumberOfPlayersAuto>true</MakePairingTopGroupByNumberOfPlayersAuto>
|
||||||
|
<MakePairingTopGroupByNumberOfPlayers>0</MakePairingTopGroupByNumberOfPlayers>
|
||||||
|
<MakePairingTopGroupSeeding>true</MakePairingTopGroupSeeding>
|
||||||
|
<MakePairingSeedingPlacementCriterion typeversion="2">
|
||||||
|
<ShortName>SOS</ShortName>
|
||||||
|
</MakePairingSeedingPlacementCriterion>
|
||||||
|
<MakePairingTopGroupSeedingByRating>false</MakePairingTopGroupSeedingByRating>
|
||||||
|
<MakePairingTopGroupSeedingByRatingRound>2</MakePairingTopGroupSeedingByRatingRound>
|
||||||
|
<MakePairingOutsideTopGroupSameCountry>true</MakePairingOutsideTopGroupSameCountry>
|
||||||
|
<MakePairingOutsideTopGroupSameClub>true</MakePairingOutsideTopGroupSameClub>
|
||||||
|
<MakePairingOutsideTopGroupSameNationality>false</MakePairingOutsideTopGroupSameNationality>
|
||||||
|
<MakePairingOutsideTopGroupStrengthDifference>true</MakePairingOutsideTopGroupStrengthDifference>
|
||||||
|
<MakePairingOutsideTopGroupStrengthDifferenceValue>3</MakePairingOutsideTopGroupStrengthDifferenceValue>
|
||||||
|
<MakePairingOutsideTopGroupColorBalance>true</MakePairingOutsideTopGroupColorBalance>
|
||||||
|
<MakePairingOutsideTopGroupWeakOddMan>true</MakePairingOutsideTopGroupWeakOddMan>
|
||||||
|
<MakePairingOutsideTopGroupSeeding>false</MakePairingOutsideTopGroupSeeding>
|
||||||
|
<PrintWalllistFont>SansSerif</PrintWalllistFont>
|
||||||
|
<PrintWalllistFontsize>9</PrintWalllistFontsize>
|
||||||
|
<PrintWalllistIndentationTop>0</PrintWalllistIndentationTop>
|
||||||
|
<PrintWalllistIndentationLeft>0</PrintWalllistIndentationLeft>
|
||||||
|
<PrintWalllistColumnDistance>2</PrintWalllistColumnDistance>
|
||||||
|
<PrintWalllistAbbreviateName>true</PrintWalllistAbbreviateName>
|
||||||
|
<PrintWalllistAbbreviateNameLength>28</PrintWalllistAbbreviateNameLength>
|
||||||
|
<PrintPairingsFont>SansSerif</PrintPairingsFont>
|
||||||
|
<PrintPairingsFontsize>10</PrintPairingsFontsize>
|
||||||
|
<PrintPairingsIndentationTop>0</PrintPairingsIndentationTop>
|
||||||
|
<PrintPairingsIndentationLeft>0</PrintPairingsIndentationLeft>
|
||||||
|
<PrintPairingsColumnDistance>3</PrintPairingsColumnDistance>
|
||||||
|
<PrintPairingsAbbreviateName>true</PrintPairingsAbbreviateName>
|
||||||
|
<PrintPairingsAbbreviateNameLength>35</PrintPairingsAbbreviateNameLength>
|
||||||
|
<Walllist typeversion="3">
|
||||||
|
<ShowCountry>true</ShowCountry>
|
||||||
|
<ShowClub>true</ShowClub>
|
||||||
|
<ShowClubEgdName>false</ShowClubEgdName>
|
||||||
|
<ShowClubAbbreviateName>true</ShowClubAbbreviateName>
|
||||||
|
<ShowLevels>true</ShowLevels>
|
||||||
|
<ShortNotationForLevel>false</ShortNotationForLevel>
|
||||||
|
<ShowBarMembership>true</ShowBarMembership>
|
||||||
|
<ShowRatings>true</ShowRatings>
|
||||||
|
<MarkPreliminaryRegisteredParticipants>true</MarkPreliminaryRegisteredParticipants>
|
||||||
|
<MarkResultsByReferree>true</MarkResultsByReferree>
|
||||||
|
<ShowColors>false</ShowColors>
|
||||||
|
<ShowHandicap>true</ShowHandicap>
|
||||||
|
<ShowWarningMissingPairing>true</ShowWarningMissingPairing>
|
||||||
|
<Fontsize>18</Fontsize>
|
||||||
|
<NameColumnWidth>221</NameColumnWidth>
|
||||||
|
<ClubColumnWidth>0</ClubColumnWidth>
|
||||||
|
<ClubColumnAlignmentCenter>true</ClubColumnAlignmentCenter>
|
||||||
|
<WeakSortCriteria>1</WeakSortCriteria>
|
||||||
|
<SortCriterionDescriptor typeversion="2">
|
||||||
|
<ShortName>Score</ShortName>
|
||||||
|
</SortCriterionDescriptor>
|
||||||
|
<SortCriterionDescriptor typeversion="2">
|
||||||
|
<ShortName>SOS</ShortName>
|
||||||
|
</SortCriterionDescriptor>
|
||||||
|
<SortCriterionDescriptor typeversion="2">
|
||||||
|
<ShortName>SOSOS</ShortName>
|
||||||
|
</SortCriterionDescriptor>
|
||||||
|
<SortCriterionDescriptor typeversion="2">
|
||||||
|
<ShortName>ScoreX</ShortName>
|
||||||
|
</SortCriterionDescriptor>
|
||||||
|
</Walllist>';
|
||||||
|
|
||||||
|
$macmahonlast = '<TournamentRound typeversion="2">
|
||||||
|
<RoundNumber>1</RoundNumber>
|
||||||
|
<LastUpdated>2026-05-13 21:30:31</LastUpdated>
|
||||||
|
</TournamentRound>
|
||||||
|
<TournamentRound typeversion="2">
|
||||||
|
<RoundNumber>2</RoundNumber>
|
||||||
|
<LastUpdated>2026-05-13 21:30:21</LastUpdated>
|
||||||
|
</TournamentRound>
|
||||||
|
<TournamentRound typeversion="2">
|
||||||
|
<RoundNumber>3</RoundNumber>
|
||||||
|
<LastUpdated>2026-05-13 21:30:10</LastUpdated>
|
||||||
|
</TournamentRound>
|
||||||
|
<TournamentRound typeversion="2">
|
||||||
|
<RoundNumber>4</RoundNumber>
|
||||||
|
<LastUpdated>2026-05-13 21:29:20</LastUpdated>
|
||||||
|
</TournamentRound>
|
||||||
|
<TournamentRound typeversion="2">
|
||||||
|
<RoundNumber>5</RoundNumber>
|
||||||
|
<LastUpdated>2026-05-13 21:29:04</LastUpdated>
|
||||||
|
</TournamentRound>
|
||||||
|
</Tournament>';
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
go_form_admin_action('export_mcmahon');
|
go_form_admin_action('export_macmahon');
|
||||||
if (!isset($_POST['value_one'])) {
|
if (!isset($_POST['value_one'])) {
|
||||||
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
exit;
|
exit;
|
||||||
@@ -15,9 +15,43 @@ header('Content-Type: text/xml; charset=utf-8');
|
|||||||
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export-macmahon.xml"');
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export-macmahon.xml"');
|
||||||
|
|
||||||
$output = fopen('php://output', 'w');
|
$output = fopen('php://output', 'w');
|
||||||
include_once 'mcmahon-help.php';
|
include_once 'macmahon-help.php';
|
||||||
|
|
||||||
fwrite($output, $mcmahonfirst);
|
fwrite($output, $macmahonfirst);
|
||||||
|
|
||||||
|
// Gather the distinct clubs used per country among the actual participants
|
||||||
|
$clubs_by_country = [];
|
||||||
|
foreach ($entries as $e) {
|
||||||
|
$country_code = strtoupper(trim($e->country));
|
||||||
|
$club = trim($e->club);
|
||||||
|
if ($country_code === '' || $club === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isset($clubs_by_country[$country_code])) {
|
||||||
|
$clubs_by_country[$country_code] = [];
|
||||||
|
}
|
||||||
|
if (!in_array($club, $clubs_by_country[$country_code], true)) {
|
||||||
|
$clubs_by_country[$country_code][] = $club;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($countries as $code => $name) {
|
||||||
|
$out = ' <Country typeversion="1">
|
||||||
|
<InternetCode>' . esc_html(strtolower($code)) . '</InternetCode>
|
||||||
|
<Name>' . esc_html($name) . '</Name>';
|
||||||
|
if (!empty($clubs_by_country[$code])) {
|
||||||
|
foreach ($clubs_by_country[$code] as $club) {
|
||||||
|
$out .= '
|
||||||
|
<Club typeversion="1">
|
||||||
|
<Name>' . esc_html($club) . '</Name>
|
||||||
|
<EGDName>' . esc_html($club) . '</EGDName>
|
||||||
|
</Club>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$out .= '
|
||||||
|
</Country>';
|
||||||
|
fwrite($output, $out);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($entries as $i => $e) {
|
foreach ($entries as $i => $e) {
|
||||||
$rank = $ranks[$e->rank];
|
$rank = $ranks[$e->rank];
|
||||||
@@ -44,6 +78,6 @@ foreach ($entries as $i => $e) {
|
|||||||
fwrite($output, $out);
|
fwrite($output, $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite($output, $mcmahonlast);
|
fwrite($output, $macmahonlast);
|
||||||
|
|
||||||
fclose($output);
|
fclose($output);
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -16,20 +16,20 @@ header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($f
|
|||||||
|
|
||||||
$output = fopen('php://output', 'w');
|
$output = fopen('php://output', 'w');
|
||||||
|
|
||||||
fwrite($output,'{"id":1,"type":"INDIVIDUAL","name":"Template","shortName":"20251111-Template","startDate":"2025-11-11","endDate":"2025-11-11","director":"","country":"si","location":"Template","online":false,"komi":6.5,"rules":"JAPANESE","gobanSize":19,"timeSystem":{"type":"CANADIAN","mainTime":2400,"byoyomi":300,"stones":15},"rounds":5,"pairing":{"type":"MAC_MAHON","base":{"nx1":0.5,"dupWeight":5.0E14,"random":0.0,"deterministic":true,"colorBalanceWeight":1000000.0},"main":{"catWeight":2.0E13,"scoreWeight":1.0E11,"upDownWeight":1.0E8,"upDownCompensate":true,"upDownLowerMode":"MIDDLE","upDownUpperMode":"MIDDLE","maximizeSeeding":5000000.0,"firstSeedLastRound":2,"firstSeed":"SPLIT_AND_RANDOM","secondSeed":"SPLIT_AND_FOLD","firstSeedAddCrit":"RATING","secondSeedAddCrit":"NONE","mmsValueAbsent":0.5,"roundDownScore":true,"sosValueAbsentUseBase":true},"secondary":{"barThreshold":true,"rankThreshold":0,"winsThreshold":true,"secWeight":1.0E11},"geo":{"weight":1.0E11,"mmsDiffCountry":1,"mmsDiffClubGroup":3,"mmsDiffClub":3},"handicap":{"weight":0.0,"useMMS":false,"threshold":8,"correction":2,"ceiling":9},"placement":["MMS","SOSM","SOSOSM"],"mmFloor":-20,"mmBar":0},"players":[');
|
fwrite($output, '{"id":1,"type":"INDIVIDUAL","name":"Template","shortName":"20251111-Template","startDate":"2025-11-11","endDate":"2025-11-11","director":"","country":"si","location":"Template","online":false,"komi":6.5,"rules":"JAPANESE","gobanSize":19,"timeSystem":{"type":"CANADIAN","mainTime":2400,"byoyomi":300,"stones":15},"rounds":5,"pairing":{"type":"MAC_MAHON","base":{"nx1":0.5,"dupWeight":5.0E14,"random":0.0,"deterministic":true,"colorBalanceWeight":1000000.0},"main":{"catWeight":2.0E13,"scoreWeight":1.0E11,"upDownWeight":1.0E8,"upDownCompensate":true,"upDownLowerMode":"MIDDLE","upDownUpperMode":"MIDDLE","maximizeSeeding":5000000.0,"firstSeedLastRound":2,"firstSeed":"SPLIT_AND_RANDOM","secondSeed":"SPLIT_AND_FOLD","firstSeedAddCrit":"RATING","secondSeedAddCrit":"NONE","mmsValueAbsent":0.5,"roundDownScore":true,"sosValueAbsentUseBase":true},"secondary":{"barThreshold":true,"rankThreshold":0,"winsThreshold":true,"secWeight":1.0E11},"geo":{"weight":1.0E11,"mmsDiffCountry":1,"mmsDiffClubGroup":3,"mmsDiffClub":3},"handicap":{"weight":0.0,"useMMS":false,"threshold":8,"correction":2,"ceiling":9},"placement":["MMS","SOSM","SOSOSM"],"mmFloor":-20,"mmBar":0},"players":[');
|
||||||
|
|
||||||
$count = count($entries);
|
$count = count($entries);
|
||||||
foreach ($entries as $i => $e) {
|
foreach ($entries as $i => $e) {
|
||||||
$rank = $e->rank - 30;
|
$rank = $e->rank - 30;
|
||||||
$id = ($i + 1) * 2;
|
$id = ($i + 1) * 2;
|
||||||
$out = "{\"id\":$id,\"name\":\"$e->first_name\",\"firstname\":\"$e->last_name\",\"rating\":$e->rating,\"rank\":$rank,\"country\":\"$e->country\",\"club\":\"$e->club\",\"final\":false,\"egf\":\"$e->egd_number\"}";
|
$out = "{\"id\":$id,\"name\":\"$e->last_name\",\"firstname\":\"$e->first_name\",\"rating\":$e->rating,\"rank\":$rank,\"country\":\"$e->country\",\"club\":\"$e->club\",\"final\":false,\"egf\":\"$e->egd_number\"}";
|
||||||
if ($i + 1 < $count) {
|
if ($i + 1 < $count) {
|
||||||
$out .= ",";
|
$out .= ",";
|
||||||
}
|
}
|
||||||
fwrite($output, $out);
|
fwrite($output, $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite($output,'],"games":[[]]}');
|
fwrite($output, '],"games":[[]]}');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
if (!defined('ABSPATH'))
|
if (!defined('ABSPATH'))
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
// ========== Database ==========
|
// Load helpers
|
||||||
|
require_once plugin_dir_path(__FILE__) . 'helpers.php';
|
||||||
|
require_once plugin_dir_path(__FILE__) . 'countries.php';
|
||||||
|
|
||||||
|
// ========== Database ===========
|
||||||
function go_form_activate()
|
function go_form_activate()
|
||||||
{
|
{
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
@@ -11,52 +15,72 @@ function go_form_activate()
|
|||||||
$charset = $wpdb->get_charset_collate();
|
$charset = $wpdb->get_charset_collate();
|
||||||
$forms = $wpdb->prefix . 'go_form_forms';
|
$forms = $wpdb->prefix . 'go_form_forms';
|
||||||
$entries = $wpdb->prefix . 'go_form_entries';
|
$entries = $wpdb->prefix . 'go_form_entries';
|
||||||
|
$custom_fields = $wpdb->prefix . 'go_form_custom_fields';
|
||||||
|
$custom_values = $wpdb->prefix . 'go_form_entry_custom_values';
|
||||||
|
|
||||||
dbDelta("CREATE TABLE $forms (
|
dbDelta("CREATE TABLE $forms (
|
||||||
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
id int NOT NULL AUTO_INCREMENT,
|
||||||
name varchar(255) NOT NULL,
|
name varchar(255) NOT NULL,
|
||||||
|
email varchar(255) DEFAULT NULL,
|
||||||
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) $charset;");
|
) $charset;");
|
||||||
|
|
||||||
dbDelta("CREATE TABLE $entries (
|
dbDelta("CREATE TABLE $entries (
|
||||||
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
id int NOT NULL AUTO_INCREMENT,
|
||||||
form_id mediumint(9) DEFAULT 1,
|
form_id int DEFAULT 1,
|
||||||
first_name varchar(100) NOT NULL,
|
first_name varchar(100) NOT NULL,
|
||||||
last_name varchar(100) NOT NULL,
|
last_name varchar(100) NOT NULL,
|
||||||
country varchar(100) DEFAULT NULL,
|
country varchar(100) DEFAULT NULL,
|
||||||
club varchar(100) DEFAULT NULL,
|
club varchar(100) DEFAULT NULL,
|
||||||
|
display_country varchar(150) DEFAULT NULL,
|
||||||
|
display_club varchar(100) DEFAULT NULL,
|
||||||
rank tinyint(2) DEFAULT 0,
|
rank tinyint(2) DEFAULT 0,
|
||||||
rating smallint(5) DEFAULT 0,
|
rating smallint(5) DEFAULT 0,
|
||||||
email varchar(255) DEFAULT NULL,
|
|
||||||
egd_number varchar(20) DEFAULT NULL,
|
egd_number varchar(20) DEFAULT NULL,
|
||||||
comment text DEFAULT NULL,
|
|
||||||
created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE
|
FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE,
|
||||||
|
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', '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)
|
||||||
|
) $charset;");
|
||||||
|
|
||||||
|
dbDelta("CREATE TABLE $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 $entries(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (field_id) REFERENCES $custom_fields(id) ON DELETE CASCADE,
|
||||||
|
INDEX (entry_id),
|
||||||
|
INDEX (field_id)
|
||||||
) $charset;");
|
) $charset;");
|
||||||
}
|
}
|
||||||
|
|
||||||
function go_form_uninstall()
|
function go_form_uninstall()
|
||||||
{
|
{
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entry_custom_values");
|
||||||
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_custom_fields");
|
||||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
||||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
||||||
}
|
}
|
||||||
// ========== Helpers ==========
|
// ========== Helpers ==========
|
||||||
$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',
|
|
||||||
15 => '15k', 16 => '14k', 17 => '13k', 18 => '12k', 19 => '11k',
|
|
||||||
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'
|
|
||||||
];
|
|
||||||
|
|
||||||
function go_form_get_forms()
|
function go_form_get_forms()
|
||||||
{
|
{
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
@@ -78,13 +102,63 @@ function go_form_get_entries($form_id)
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function go_form_render_entries_table($entries, $show_admin = false)
|
function go_form_render_entries_table($entries, $show_admin = false, $custom_fields = [], $form_id = 0)
|
||||||
{
|
{
|
||||||
global $ranks;
|
global $ranks;
|
||||||
|
|
||||||
include "templates/table.php";
|
include "templates/table.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========== Custom Fields Helpers ==========
|
||||||
|
function go_form_get_custom_fields($form_id)
|
||||||
|
{
|
||||||
|
global $wpdb;
|
||||||
|
return $wpdb->get_results($wpdb->prepare(
|
||||||
|
"SELECT * FROM {$wpdb->prefix}go_form_custom_fields WHERE form_id = %d ORDER BY id ASC",
|
||||||
|
$form_id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function go_form_get_custom_field_by_id($field_id)
|
||||||
|
{
|
||||||
|
global $wpdb;
|
||||||
|
return $wpdb->get_row($wpdb->prepare(
|
||||||
|
"SELECT * FROM {$wpdb->prefix}go_form_custom_fields WHERE id = %d",
|
||||||
|
$field_id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function go_form_get_custom_values($entry_id)
|
||||||
|
{
|
||||||
|
global $wpdb;
|
||||||
|
return $wpdb->get_results($wpdb->prepare(
|
||||||
|
"SELECT cf.*, cv.value FROM {$wpdb->prefix}go_form_custom_fields cf
|
||||||
|
JOIN {$wpdb->prefix}go_form_entry_custom_values cv ON cf.id = cv.field_id
|
||||||
|
WHERE cv.entry_id = %d",
|
||||||
|
$entry_id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function go_form_get_custom_value($entry_id, $field_id)
|
||||||
|
{
|
||||||
|
global $wpdb;
|
||||||
|
return $wpdb->get_var($wpdb->prepare(
|
||||||
|
"SELECT value FROM {$wpdb->prefix}go_form_entry_custom_values
|
||||||
|
WHERE entry_id = %d AND field_id = %d",
|
||||||
|
$entry_id,
|
||||||
|
$field_id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function go_form_get_entry_by_id($entry_id)
|
||||||
|
{
|
||||||
|
global $wpdb;
|
||||||
|
return $wpdb->get_row($wpdb->prepare(
|
||||||
|
"SELECT * FROM {$wpdb->prefix}go_form_entries WHERE id = %d",
|
||||||
|
$entry_id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// ========== Form Handling ==========
|
// ========== Form Handling ==========
|
||||||
function go_form_handle_submission()
|
function go_form_handle_submission()
|
||||||
{
|
{
|
||||||
@@ -92,6 +166,7 @@ function go_form_handle_submission()
|
|||||||
wp_die('Security check failed');
|
wp_die('Security check failed');
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
global $ranks;
|
||||||
if (isset($_POST['form_id'])) {
|
if (isset($_POST['form_id'])) {
|
||||||
$form_id = intval($_POST['form_id']);
|
$form_id = intval($_POST['form_id']);
|
||||||
} else {
|
} else {
|
||||||
@@ -111,11 +186,11 @@ function go_form_handle_submission()
|
|||||||
'last_name' => sanitize_text_field($_POST['last_name']),
|
'last_name' => sanitize_text_field($_POST['last_name']),
|
||||||
'country' => sanitize_text_field($_POST['country'] ?? ''),
|
'country' => sanitize_text_field($_POST['country'] ?? ''),
|
||||||
'club' => sanitize_text_field($_POST['club'] ?? ''),
|
'club' => sanitize_text_field($_POST['club'] ?? ''),
|
||||||
|
'display_country' => sanitize_text_field($_POST['display_country'] ?? ''),
|
||||||
|
'display_club' => sanitize_text_field($_POST['display_club'] ?? ''),
|
||||||
'rank' => $rank,
|
'rank' => $rank,
|
||||||
'rating' => $rating,
|
'rating' => $rating,
|
||||||
'email' => sanitize_email($_POST['email'] ?? ''),
|
|
||||||
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
|
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
|
||||||
'comment' => sanitize_textarea_field($_POST['comment'] ?? '')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (empty($data['first_name']) || empty($data['last_name'])) {
|
if (empty($data['first_name']) || empty($data['last_name'])) {
|
||||||
@@ -124,15 +199,64 @@ function go_form_handle_submission()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$wpdb->insert("{$wpdb->prefix}go_form_entries", $data);
|
$wpdb->insert("{$wpdb->prefix}go_form_entries", $data);
|
||||||
|
$entry_id = $wpdb->insert_id;
|
||||||
|
|
||||||
|
// Save custom field values
|
||||||
|
$custom_fields = go_form_get_custom_fields($form_id);
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
$field_name = 'custom_field_' . $field->id;
|
||||||
|
if (isset($_POST[$field_name])) {
|
||||||
|
$value = $_POST[$field_name];
|
||||||
|
if ($field->field_type === 'checkbox') {
|
||||||
|
$value = isset($_POST[$field_name]) ? '1' : '0';
|
||||||
|
} elseif (is_array($value)) {
|
||||||
|
$value = implode(',', array_map('sanitize_text_field', $value));
|
||||||
|
} else {
|
||||||
|
$value = sanitize_text_field($value);
|
||||||
|
}
|
||||||
|
$wpdb->insert("{$wpdb->prefix}go_form_entry_custom_values", [
|
||||||
|
'entry_id' => $entry_id,
|
||||||
|
'field_id' => $field->id,
|
||||||
|
'value' => $value
|
||||||
|
]);
|
||||||
|
} elseif ($field->is_required) {
|
||||||
|
// If required field is missing, delete the entry and redirect back
|
||||||
|
$wpdb->delete("{$wpdb->prefix}go_form_entries", ['id' => $entry_id]);
|
||||||
|
wp_redirect($_SERVER['HTTP_REFERER']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send notification email if form has an email configured
|
||||||
|
$form = go_form_get_form_by_id($form_id);
|
||||||
|
if (!empty($form->email)) {
|
||||||
|
$to = $form->email;
|
||||||
|
$subject = 'New Go Tournament Registration';
|
||||||
|
|
||||||
|
$message = "A new player has signed up:\n\n";
|
||||||
|
$message .= "Form: {$form->name}\n";
|
||||||
|
$message .= "Form ID: {$form_id}\n";
|
||||||
|
$message .= "Name: {$data['first_name']} {$data['last_name']}\n";
|
||||||
|
$message .= "Country: {$data['country']}\n";
|
||||||
|
$message .= "Club: {$data['club']}\n";
|
||||||
|
$message .= "Rank: {$ranks[$data['rank']]}\n";
|
||||||
|
$message .= "Rating: {$data['rating']}\n";
|
||||||
|
$message .= "EGD Number: {$data['egd_number']}\n";
|
||||||
|
$message .= "Date: " . date('Y-m-d H:i:s') . "\n";
|
||||||
|
|
||||||
|
wp_mail($to, $subject, $message);
|
||||||
|
}
|
||||||
|
|
||||||
wp_redirect($_SERVER['HTTP_REFERER']);
|
wp_redirect($_SERVER['HTTP_REFERER']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
add_action('admin_post_go_form_handle_submission', 'go_form_handle_submission');
|
add_action('admin_post_go_form_handle_submission', 'go_form_handle_submission');
|
||||||
|
add_action('admin_post_nopriv_go_form_handle_submission', 'go_form_handle_submission');
|
||||||
|
|
||||||
// ========== Shortcode ==========
|
// ========== Shortcode ==========
|
||||||
function go_form_shortcode($atts)
|
function go_form_shortcode($atts)
|
||||||
{
|
{
|
||||||
global $ranks;
|
global $ranks, $countries;
|
||||||
$form_id = intval($atts['id']);
|
$form_id = intval($atts['id']);
|
||||||
|
|
||||||
$form = go_form_get_form_by_id($form_id);
|
$form = go_form_get_form_by_id($form_id);
|
||||||
@@ -181,7 +305,11 @@ function go_form_create_form()
|
|||||||
go_form_admin_action('create_form');
|
go_form_admin_action('create_form');
|
||||||
if (isset($_POST['form_name']) && !empty($_POST['form_name'])) {
|
if (isset($_POST['form_name']) && !empty($_POST['form_name'])) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$wpdb->insert("{$wpdb->prefix}go_form_forms", ['name' => sanitize_text_field($_POST['form_name'])]);
|
$form_data = [
|
||||||
|
'name' => sanitize_text_field($_POST['form_name']),
|
||||||
|
'email' => isset($_POST['form_email']) ? sanitize_text_field($_POST['form_email']) : ''
|
||||||
|
];
|
||||||
|
$wpdb->insert("{$wpdb->prefix}go_form_forms", $form_data);
|
||||||
$new_form_id = $wpdb->insert_id;
|
$new_form_id = $wpdb->insert_id;
|
||||||
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $new_form_id, 'created' => 1), admin_url('admin.php'));
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $new_form_id, 'created' => 1), admin_url('admin.php'));
|
||||||
wp_redirect($redirect_url);
|
wp_redirect($redirect_url);
|
||||||
@@ -193,6 +321,27 @@ function go_form_create_form()
|
|||||||
}
|
}
|
||||||
add_action('admin_post_go_form_create_form', 'go_form_create_form');
|
add_action('admin_post_go_form_create_form', 'go_form_create_form');
|
||||||
|
|
||||||
|
function go_form_update_form()
|
||||||
|
{
|
||||||
|
go_form_admin_action('update_form');
|
||||||
|
if (isset($_POST['form_id']) && isset($_POST['form_name']) && !empty($_POST['form_name'])) {
|
||||||
|
global $wpdb;
|
||||||
|
$form_id = intval($_POST['form_id']);
|
||||||
|
$form_data = [
|
||||||
|
'name' => sanitize_text_field($_POST['form_name']),
|
||||||
|
'email' => isset($_POST['form_email']) ? sanitize_text_field($_POST['form_email']) : ''
|
||||||
|
];
|
||||||
|
$wpdb->update("{$wpdb->prefix}go_form_forms", $form_data, ['id' => $form_id]);
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id, 'updated_form' => 1), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings'), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_update_form', 'go_form_update_form');
|
||||||
|
|
||||||
function go_form_delete_form()
|
function go_form_delete_form()
|
||||||
{
|
{
|
||||||
go_form_admin_action('delete_form');
|
go_form_admin_action('delete_form');
|
||||||
@@ -229,13 +378,247 @@ function go_form_export_opengotha()
|
|||||||
}
|
}
|
||||||
add_action('admin_post_go_form_export_opengotha', 'go_form_export_opengotha');
|
add_action('admin_post_go_form_export_opengotha', 'go_form_export_opengotha');
|
||||||
|
|
||||||
function go_form_export_mcmahon()
|
function go_form_export_macmahon()
|
||||||
{
|
{
|
||||||
global $ranks;
|
global $ranks, $countries;
|
||||||
include_once 'export/mcmahon.php';
|
include_once 'export/macmahon.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
add_action('admin_post_go_form_export_mcmahon', 'go_form_export_mcmahon');
|
add_action('admin_post_go_form_export_macmahon', 'go_form_export_macmahon');
|
||||||
|
|
||||||
|
// ========== Custom Field Admin Actions ==========
|
||||||
|
function go_form_create_custom_field()
|
||||||
|
{
|
||||||
|
go_form_admin_action('create_custom_field');
|
||||||
|
if (isset($_POST['form_id']) && isset($_POST['field_name']) && isset($_POST['field_type'])) {
|
||||||
|
global $wpdb;
|
||||||
|
$form_id = intval($_POST['form_id']);
|
||||||
|
$field_name = sanitize_text_field($_POST['field_name']);
|
||||||
|
$field_type = sanitize_text_field($_POST['field_type']);
|
||||||
|
$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,
|
||||||
|
'field_name' => $field_name,
|
||||||
|
'field_type' => $field_type,
|
||||||
|
'field_options' => $field_options,
|
||||||
|
'is_public' => $is_public,
|
||||||
|
'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'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_create_custom_field', 'go_form_create_custom_field');
|
||||||
|
|
||||||
|
function go_form_update_custom_field()
|
||||||
|
{
|
||||||
|
go_form_admin_action('update_custom_field');
|
||||||
|
if (isset($_POST['field_id']) && isset($_POST['field_name']) && isset($_POST['field_type'])) {
|
||||||
|
global $wpdb;
|
||||||
|
$field_id = intval($_POST['field_id']);
|
||||||
|
$field_name = sanitize_text_field($_POST['field_name']);
|
||||||
|
$field_type = sanitize_text_field($_POST['field_type']);
|
||||||
|
$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_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'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_update_custom_field', 'go_form_update_custom_field');
|
||||||
|
|
||||||
|
function go_form_delete_custom_field()
|
||||||
|
{
|
||||||
|
go_form_admin_action('delete_custom_field');
|
||||||
|
if (isset($_POST['value_one'])) {
|
||||||
|
global $wpdb;
|
||||||
|
$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]);
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id, 'deleted_field' => 1), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings'), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_delete_custom_field', 'go_form_delete_custom_field');
|
||||||
|
|
||||||
|
// ========== Entry Edit Admin Action ==========
|
||||||
|
function go_form_fetch_egd_data($pin)
|
||||||
|
{
|
||||||
|
$pin = trim($pin);
|
||||||
|
if (empty($pin)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = 'https://europeangodatabase.eu/EGD/GetPlayerDataByPIN.php?pin=' . urlencode($pin);
|
||||||
|
$response = wp_remote_get($url, ['timeout' => 10]);
|
||||||
|
|
||||||
|
if (is_wp_error($response)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
|
if ($data && isset($data['retcode']) && $data['retcode'] === 'Ok') {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function go_form_update_egd_data()
|
||||||
|
{
|
||||||
|
go_form_admin_action('update_egd_data');
|
||||||
|
|
||||||
|
if (!isset($_POST['value_one'])) {
|
||||||
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$form_id = intval($_POST['value_one']);
|
||||||
|
$entries = go_form_get_entries($form_id);
|
||||||
|
$updated_count = 0;
|
||||||
|
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
if (empty($entry->egd_number)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = go_form_fetch_egd_data($entry->egd_number);
|
||||||
|
if (!$data) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map EGD Grade_n to our rank system
|
||||||
|
// EGD Grade_n: 0=30k, 1=29k, ... 25=5k, 30=1d, ... 39=9d, 40=1p, ... 47=9p
|
||||||
|
// Our ranks array: 0=30k, 1=29k, ... 25=5k, 30=1d, ... 39=9d, 40=1p, ... 47=9p
|
||||||
|
// So we can use Grade_n directly as our rank value
|
||||||
|
$new_rank = isset($data['Grade_n']) ? intval($data['Grade_n']) : $entry->rank;
|
||||||
|
$new_rating = isset($data['Gor']) ? intval($data['Gor']) : $entry->rating;
|
||||||
|
|
||||||
|
// Only update if values changed
|
||||||
|
if ($new_rank !== $entry->rank || $new_rating !== $entry->rating) {
|
||||||
|
$wpdb->update(
|
||||||
|
"{$wpdb->prefix}go_form_entries",
|
||||||
|
['rank' => $new_rank, 'rating' => $new_rating],
|
||||||
|
['id' => $entry->id]
|
||||||
|
);
|
||||||
|
$updated_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$redirect_url = add_query_arg(
|
||||||
|
array('page' => 'go-form-settings', 'form_id' => $form_id, 'egd_updated' => $updated_count),
|
||||||
|
admin_url('admin.php')
|
||||||
|
);
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_update_egd_data', 'go_form_update_egd_data');
|
||||||
|
|
||||||
|
function go_form_update_entry()
|
||||||
|
{
|
||||||
|
go_form_admin_action('update_entry');
|
||||||
|
if (!isset($_POST['entry_id']) || !isset($_POST['form_id'])) {
|
||||||
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$entry_id = intval($_POST['entry_id']);
|
||||||
|
$form_id = intval($_POST['form_id']);
|
||||||
|
|
||||||
|
$rating = intval($_POST['rating']);
|
||||||
|
$rank = intval($_POST['rank']);
|
||||||
|
if ($rating < -900) {
|
||||||
|
$rating = ($rank * 100) - 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'first_name' => sanitize_text_field($_POST['first_name']),
|
||||||
|
'last_name' => sanitize_text_field($_POST['last_name']),
|
||||||
|
'country' => sanitize_text_field($_POST['country'] ?? ''),
|
||||||
|
'club' => sanitize_text_field($_POST['club'] ?? ''),
|
||||||
|
'display_country' => sanitize_text_field($_POST['display_country'] ?? ''),
|
||||||
|
'display_club' => sanitize_text_field($_POST['display_club'] ?? ''),
|
||||||
|
'rank' => $rank,
|
||||||
|
'rating' => $rating,
|
||||||
|
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (empty($data['first_name']) || empty($data['last_name'])) {
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id, 'edit_entry' => $entry_id, 'error' => 'missing_required'), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wpdb->update("{$wpdb->prefix}go_form_entries", $data, ['id' => $entry_id]);
|
||||||
|
|
||||||
|
// Update custom field values
|
||||||
|
$custom_fields = go_form_get_custom_fields($form_id);
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
$field_name = 'custom_field_' . $field->id;
|
||||||
|
if (isset($_POST[$field_name])) {
|
||||||
|
$value = $_POST[$field_name];
|
||||||
|
if ($field->field_type === 'checkbox') {
|
||||||
|
$value = isset($_POST[$field_name]) ? '1' : '0';
|
||||||
|
} elseif (is_array($value)) {
|
||||||
|
$value = implode(',', array_map('sanitize_text_field', $value));
|
||||||
|
} else {
|
||||||
|
$value = sanitize_text_field($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if custom value exists
|
||||||
|
$existing = go_form_get_custom_value($entry_id, $field->id);
|
||||||
|
if ($existing !== null) {
|
||||||
|
$wpdb->update(
|
||||||
|
"{$wpdb->prefix}go_form_entry_custom_values",
|
||||||
|
['value' => $value],
|
||||||
|
['entry_id' => $entry_id, 'field_id' => $field->id]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$wpdb->insert("{$wpdb->prefix}go_form_entry_custom_values", [
|
||||||
|
'entry_id' => $entry_id,
|
||||||
|
'field_id' => $field->id,
|
||||||
|
'value' => $value
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} elseif ($field->is_required) {
|
||||||
|
// If required field is missing, redirect back with error
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id, 'edit_entry' => $entry_id, 'error' => 'missing_required_field'), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id, 'updated_entry' => 1), admin_url('admin.php'));
|
||||||
|
wp_redirect($redirect_url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_update_entry', 'go_form_update_entry');
|
||||||
|
|
||||||
// ========== Admin Page ====================
|
// ========== Admin Page ====================
|
||||||
function go_form_admin_menu()
|
function go_form_admin_menu()
|
||||||
@@ -248,7 +631,7 @@ function action_button($action, $name, $confirm_massage, $value_one)
|
|||||||
{
|
{
|
||||||
echo '
|
echo '
|
||||||
<form method="post" action="' . admin_url('admin-post.php') . '">
|
<form method="post" action="' . admin_url('admin-post.php') . '">
|
||||||
' . wp_nonce_field($action . '_action', $action . '_nonce', true, false) . '
|
' . wp_nonce_field("{$action}_action", "{$action}_nonce", true, false) . '
|
||||||
<input type="hidden" name="action" value="' . $action . '">
|
<input type="hidden" name="action" value="' . $action . '">
|
||||||
<input type="hidden" name="value_one" value="' . $value_one . '">
|
<input type="hidden" name="value_one" value="' . $value_one . '">
|
||||||
<input type="submit" value="' . $name . '" class="button" onclick="return confirm(\'' . $confirm_massage . '\')">
|
<input type="submit" value="' . $name . '" class="button" onclick="return confirm(\'' . $confirm_massage . '\')">
|
||||||
@@ -259,3 +642,11 @@ function go_form_settings_page()
|
|||||||
{
|
{
|
||||||
include_once 'templates/settings-page.php';
|
include_once 'templates/settings-page.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function go_form_egd_hint($value)
|
||||||
|
{
|
||||||
|
if ($value === null || $value === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return ' <span style="color:#2271b1; font-style:italic;">(EGD: ' . esc_html($value) . ')</span>';
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('ABSPATH'))
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// Go ranks array - maps numeric rank values to rank labels
|
||||||
|
// 0-29: 30k to 1k
|
||||||
|
// 30-39: 1d to 9d
|
||||||
|
// 40-47: 1p to 9p
|
||||||
|
$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',
|
||||||
|
15 => '15k',
|
||||||
|
16 => '14k',
|
||||||
|
17 => '13k',
|
||||||
|
18 => '12k',
|
||||||
|
19 => '11k',
|
||||||
|
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'
|
||||||
|
];
|
||||||
@@ -54,6 +54,15 @@
|
|||||||
grid-template-columns: auto auto;
|
grid-template-columns: auto auto;
|
||||||
column-gap: 16px;
|
column-gap: 16px;
|
||||||
}
|
}
|
||||||
|
.go-form-user-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto min-content;
|
||||||
|
column-gap: 16px;
|
||||||
|
}
|
||||||
|
.egd-search {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="form">
|
<div id="form">
|
||||||
@@ -62,7 +71,10 @@
|
|||||||
<input type="hidden" name="action" value="go_form_handle_submission">
|
<input type="hidden" name="action" value="go_form_handle_submission">
|
||||||
<input type="hidden" name="form_id" value="<?php echo esc_attr($form_id); ?>">
|
<input type="hidden" name="form_id" value="<?php echo esc_attr($form_id); ?>">
|
||||||
<input type="hidden" name="rating" id="rating" value="-1000">
|
<input type="hidden" name="rating" id="rating" value="-1000">
|
||||||
<div class="go-form-grid">
|
<input type="hidden" name="country" id="country">
|
||||||
|
<input type="hidden" name="club" id="club">
|
||||||
|
|
||||||
|
<div class="go-form-user-grid">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="first_name">First Name*:</label><input type="text" name="first_name" id="first_name" required>
|
<label for="first_name">First Name*:</label><input type="text" name="first_name" id="first_name" required>
|
||||||
@@ -72,10 +84,13 @@
|
|||||||
<label for="last_name">Last Name*:</label><input type="text" name="last_name" id="last_name" required>
|
<label for="last_name">Last Name*:</label><input type="text" name="last_name" id="last_name" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="egd-search">
|
||||||
<button type="button" id="egd-search" class="button">Search EGD</button>
|
<button type="button" id="egd-search" class="button">Search EGD</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="go-form-grid">
|
||||||
<div>
|
<div>
|
||||||
<label for="rank">Rank*:</label>
|
<label for="rank">Rank*:</label>
|
||||||
<select name="rank" id="rank">
|
<select name="rank" id="rank">
|
||||||
@@ -87,28 +102,103 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="country">Country*:</label><input type="text" name="country" id="country" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="club">Club*:</label><input type="text" name="club" id="club" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="egd_number">EGD Number:</label><input type="text" name="egd_number" id="egd_number">
|
<label for="egd_number">EGD Number:</label><input type="text" name="egd_number" id="egd_number">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="email">Email:</label><input type="email" name="email" id="email">
|
<label for="display_country">Country*:</label><input type="text" name="display_country" id="display_country" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="display_club">Club:</label><input type="text" name="display_club" id="display_club">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Display custom fields
|
||||||
|
$custom_fields = go_form_get_custom_fields($form_id);
|
||||||
|
$full_width_fields = [];
|
||||||
|
$grid_fields = [];
|
||||||
|
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
if ($field->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 '<div' . ($field->field_type === 'checkbox' ? ' style="grid-column: span 2;"' : '') . '>';
|
||||||
|
echo '<label for="' . esc_attr($field_id) . '">' . esc_html($field->field_name) . ($field->is_required ? '*' : '') . ':</label>';
|
||||||
|
|
||||||
|
switch ($field->field_type) {
|
||||||
|
case 'text':
|
||||||
|
echo '<input type="text" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
case 'email':
|
||||||
|
echo '<input type="email" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
case 'textarea':
|
||||||
|
echo '<textarea name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" rows="4" style="width:100%;"' . ($field->is_required ? ' required' : '') . '></textarea>';
|
||||||
|
break;
|
||||||
|
case 'select':
|
||||||
|
$options = $field->field_options ? explode(',', $field->field_options) : [];
|
||||||
|
echo '<select name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
echo '<option value="">-- Select --</option>';
|
||||||
|
foreach ($options as $option) {
|
||||||
|
$option = trim($option);
|
||||||
|
echo '<option value="' . esc_attr($option) . '">' . esc_html($option) . '</option>';
|
||||||
|
}
|
||||||
|
echo '</select>';
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
echo '<input type="checkbox" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" value="1"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Render full-width fields outside the grid
|
||||||
|
foreach ($full_width_fields as $field):
|
||||||
|
$field_id = 'custom_field_' . $field->id;
|
||||||
|
echo '<div style="grid-column: 1 / -1; margin-top: 10px;">';
|
||||||
|
echo '<label for="' . esc_attr($field_id) . '">' . esc_html($field->field_name) . ($field->is_required ? '*' : '') . ':</label>';
|
||||||
|
|
||||||
|
switch ($field->field_type) {
|
||||||
|
case 'text':
|
||||||
|
echo '<input type="text" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" style="width:100%;"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
case 'email':
|
||||||
|
echo '<input type="email" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" style="width:100%;"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
case 'textarea':
|
||||||
|
echo '<textarea name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" rows="4" style="width:100%;"' . ($field->is_required ? ' required' : '') . '></textarea>';
|
||||||
|
break;
|
||||||
|
case 'select':
|
||||||
|
$options = $field->field_options ? explode(',', $field->field_options) : [];
|
||||||
|
echo '<select name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" style="width:100%;"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
echo '<option value="">-- Select --</option>';
|
||||||
|
foreach ($options as $option) {
|
||||||
|
$option = trim($option);
|
||||||
|
echo '<option value="' . esc_attr($option) . '">' . esc_html($option) . '</option>';
|
||||||
|
}
|
||||||
|
echo '</select>';
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
echo '<input type="checkbox" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" value="1"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
|
|
||||||
<label for="comment">Comment</label>
|
|
||||||
<textarea name="comment" id="comment" rows="3"></textarea>
|
|
||||||
|
|
||||||
<p>* Required fields</p>
|
|
||||||
<input type="submit" name="go_form_submit" value="Submit">
|
<input type="submit" name="go_form_submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@@ -121,27 +211,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$entries = go_form_get_entries($form_id);
|
$entries = go_form_get_entries($form_id);
|
||||||
$entries_count = count($entries);
|
$custom_fields = go_form_get_custom_fields($form_id);
|
||||||
?>
|
?>
|
||||||
<h2>Sign-up players: <?= esc_html($entries_count); ?></h2>
|
<?php go_form_render_entries_table($entries, false, $custom_fields, $form_id); ?>
|
||||||
<?php go_form_render_entries_table($entries); ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const contentDiv = document.getElementById('egd-results-content');
|
const contentDiv = document.getElementById('egd-results-content');
|
||||||
const egdOverlay = document.getElementById('egd-popup-overlay');
|
const egdOverlay = document.getElementById('egd-popup-overlay');
|
||||||
|
const countryMap = <?php echo wp_json_encode($countries); ?>;
|
||||||
|
|
||||||
function fetchPlayers() {
|
function fetchPlayers() {
|
||||||
const firstName = document.getElementById('first_name').value.trim();
|
const firstName = document.getElementById('first_name').value.trim();
|
||||||
const lastName = document.getElementById('last_name').value.trim();
|
const lastName = document.getElementById('last_name').value.trim();
|
||||||
|
|
||||||
if (firstName.length < 2) {
|
if (firstName.length < 2) {
|
||||||
alert('Please enter at least 2 characters in first or last name');
|
alert('Please enter at least 2 characters in first and last name');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lastName.length < 2) {
|
if (lastName.length < 2) {
|
||||||
alert('Please enter at least 2 characters in first or last name');
|
alert('Please enter at least 2 characters in first and last name');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +272,8 @@
|
|||||||
document.getElementById('last_name').value = player.Last_Name || player.Real_Last_Name || '';
|
document.getElementById('last_name').value = player.Last_Name || player.Real_Last_Name || '';
|
||||||
document.getElementById('country').value = player.Country_Code || '';
|
document.getElementById('country').value = player.Country_Code || '';
|
||||||
document.getElementById('club').value = player.Club || '';
|
document.getElementById('club').value = player.Club || '';
|
||||||
|
document.getElementById('display_country').value = countryMap[player.Country_Code] || player.Country_Code || '';
|
||||||
|
document.getElementById('display_club').value = player.Club || '';
|
||||||
document.getElementById('rank').value = player.Grade_n || 0;
|
document.getElementById('rank').value = player.Grade_n || 0;
|
||||||
document.getElementById('egd_number').value = player.Pin_Player || '';
|
document.getElementById('egd_number').value = player.Pin_Player || '';
|
||||||
document.getElementById('rating').value = player.Gor || 0;
|
document.getElementById('rating').value = player.Gor || 0;
|
||||||
|
|||||||
@@ -7,28 +7,29 @@ if (isset($_GET['deleted']))
|
|||||||
echo '<div class="notice notice-success"><p>Deleted!</p></div>';
|
echo '<div class="notice notice-success"><p>Deleted!</p></div>';
|
||||||
if (isset($_GET['created']))
|
if (isset($_GET['created']))
|
||||||
echo '<div class="notice notice-success"><p>Form created!</p></div>';
|
echo '<div class="notice notice-success"><p>Form created!</p></div>';
|
||||||
|
if (isset($_GET['updated_form']))
|
||||||
|
echo '<div class="notice notice-success"><p>Form updated!</p></div>';
|
||||||
|
if (isset($_GET['created_field']))
|
||||||
|
echo '<div class="notice notice-success"><p>Custom field created!</p></div>';
|
||||||
|
if (isset($_GET['updated_field']))
|
||||||
|
echo '<div class="notice notice-success"><p>Custom field updated!</p></div>';
|
||||||
|
if (isset($_GET['deleted_field']))
|
||||||
|
echo '<div class="notice notice-success"><p>Custom field deleted!</p></div>';
|
||||||
|
if (isset($_GET['updated_entry']))
|
||||||
|
echo '<div class="notice notice-success"><p>Entry updated!</p></div>';
|
||||||
|
if (isset($_GET['egd_updated']))
|
||||||
|
echo '<div class="notice notice-success"><p>' . esc_html($_GET['egd_updated']) . ' entries updated with EGD data!</p></div>';
|
||||||
|
if (isset($_GET['error']) && $_GET['error'] == 'missing_required')
|
||||||
|
echo '<div class="notice notice-error"><p>First Name and Last Name are required!</p></div>';
|
||||||
|
if (isset($_GET['error']) && $_GET['error'] == 'missing_required_field')
|
||||||
|
echo '<div class="notice notice-error"><p>A required custom field is missing!</p></div>';
|
||||||
|
if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed')
|
||||||
|
echo '<div class="notice notice-error"><p>Failed to update EGD data. Check error logs.</p></div>';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1>Go Form Settings</h1>
|
<h1>Go Form Settings</h1>
|
||||||
|
|
||||||
<h2>Create New Form</h2>
|
|
||||||
<form method="post" action=" <?= admin_url('admin-post.php') ?> ">
|
|
||||||
<?= wp_nonce_field('go_form_create_form_action', 'go_form_create_form_nonce', true, false) ?>
|
|
||||||
<input type="hidden" name="action" value="go_form_create_form">
|
|
||||||
<table class="form-table">
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<label for="form_name">Form Name:</label>
|
|
||||||
</th>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="form_name" id="form_name" required>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit"><input type="submit" class="button button-primary" value="Create Form"></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<h2>Manage Forms & Entries</h2>
|
<h2>Manage Forms & Entries</h2>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@@ -38,29 +39,232 @@ if (isset($_GET['created']))
|
|||||||
|
|
||||||
$form = go_form_get_form_by_id($selected_form_id);
|
$form = go_form_get_form_by_id($selected_form_id);
|
||||||
$form_name = $form ? $form->name : 'Unknown Form';
|
$form_name = $form ? $form->name : 'Unknown Form';
|
||||||
echo "<h3> $form_name</h3>";
|
|
||||||
echo '<div style="margin-bottom:15px">';
|
// Form info and edit UI
|
||||||
|
if ($form) {
|
||||||
|
echo '<div style="margin-bottom:20px; padding:15px; background:#fff; border:1px solid #ddd; border-radius:4px;">';
|
||||||
|
echo '<form method="post" action="' . admin_url('admin-post.php') . '">';
|
||||||
|
echo wp_nonce_field('go_form_update_form_action', 'go_form_update_form_nonce', true, false);
|
||||||
|
echo '<input type="hidden" name="action" value="go_form_update_form">';
|
||||||
|
echo '<input type="hidden" name="form_id" value="' . esc_attr($selected_form_id) . '">';
|
||||||
|
echo '<table class="form-table">';
|
||||||
|
echo '<tr><th><label for="form_name">Form Name:</label></th><td><input type="text" name="form_name" id="form_name" value="' . esc_attr($form->name) . '" required></td></tr>';
|
||||||
|
echo '<tr><th><label for="form_email">Notification Email:</label></th><td><input type="email" name="form_email" id="form_email" value="' . esc_attr($form->email ?? '') . '" placeholder="Optional email for signup notifications"></td></tr>';
|
||||||
|
echo '</table>';
|
||||||
|
echo '<p class="submit"><input type="submit" class="button button-primary" value="Update Form"></p>';
|
||||||
|
echo '</form>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div style="margin-bottom:15px; display: flex; flex-wrap: wrap; gap: 10px;">';
|
||||||
action_button('go_form_delete_form', 'Delete Form', 'Delete this form and ALL entries?', $selected_form_id);
|
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_csv', 'Export to CSV', 'Confirm Export', $selected_form_id);
|
||||||
action_button('go_form_export_pairgoth', 'Export to Pairgoth', 'Confrm 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', 'Confrm 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', 'Confrm Export', $selected_form_id);
|
action_button('go_form_export_macmahon', 'Export to MacMahon', '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 '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
|
// ========== Custom Fields Management ==========
|
||||||
|
$custom_fields = go_form_get_custom_fields($selected_form_id);
|
||||||
|
|
||||||
|
echo '<div style="margin-bottom:20px; padding:15px; background:#f9f9f9; border:1px solid #ddd; border-radius:4px;">';
|
||||||
|
echo '<h3>Custom Fields</h3>';
|
||||||
|
|
||||||
|
// Add new custom field form
|
||||||
|
echo '<details style="margin-bottom:15px;"><summary style="cursor:pointer; font-weight:bold;">Add New Custom Field</summary>';
|
||||||
|
echo '<form method="post" action="' . admin_url('admin-post.php') . '" style="margin-top:10px; padding-left:15px;">';
|
||||||
|
echo wp_nonce_field('go_form_create_custom_field_action', 'go_form_create_custom_field_nonce', true, false);
|
||||||
|
echo '<input type="hidden" name="action" value="go_form_create_custom_field">';
|
||||||
|
echo '<input type="hidden" name="form_id" value="' . esc_attr($selected_form_id) . '">';
|
||||||
|
echo '<table class="form-table">';
|
||||||
|
echo '<tr><th><label for="field_name">Field Name:</label></th><td><input type="text" name="field_name" id="field_name" required></td></tr>';
|
||||||
|
echo '<tr><th><label for="field_type">Field Type:</label></th><td>';
|
||||||
|
echo '<select name="field_type" id="field_type">';
|
||||||
|
echo '<option value="text">Text</option>';
|
||||||
|
echo '<option value="select">Dropdown (Select)</option>';
|
||||||
|
echo '<option value="checkbox">Checkbox</option>';
|
||||||
|
echo '<option value="email">Email</option>';
|
||||||
|
echo '<option value="textarea">Textarea</option>';
|
||||||
|
echo '</select>';
|
||||||
|
echo '</td></tr>';
|
||||||
|
echo '<tr><th><label for="field_options">Options (for select, comma-separated):</label></th><td><textarea name="field_options" id="field_options" rows="2" style="width:100%;"></textarea><small>e.g., Option 1,Option 2,Option 3</small></td></tr>';
|
||||||
|
echo '<tr><th><label for="is_public">Public:</label></th><td><input type="checkbox" name="is_public" id="is_public" value="1" checked> <small>Show on public form</small></td></tr>';
|
||||||
|
echo '<tr><th><label for="is_required">Required:</label></th><td><input type="checkbox" name="is_required" id="is_required" value="1"> <small>Required field</small></td></tr>';
|
||||||
|
echo '<tr><th><label for="is_full_width">Full Width:</label></th><td><input type="checkbox" name="is_full_width" id="is_full_width" value="1"> <small>Display on full width (outside grid)</small></td></tr>';
|
||||||
|
echo '</table>';
|
||||||
|
echo '<p class="submit"><input type="submit" class="button button-primary" value="Add Custom Field"></p>';
|
||||||
|
echo '</form>';
|
||||||
|
echo '</details>';
|
||||||
|
|
||||||
|
// List existing custom fields
|
||||||
|
if (!empty($custom_fields)) {
|
||||||
|
echo '<table class="wp-list-table widefat striped" style="margin-top:15px;">';
|
||||||
|
echo '<thead><tr><th>Field Name</th><th>Type</th><th>Public</th><th>Required</th><th>Full Width</th><th>Actions</th></tr></thead><tbody>';
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
echo '<tr>';
|
||||||
|
echo '<td>' . esc_html($field->field_name) . '</td>';
|
||||||
|
echo '<td>' . esc_html($field->field_type) . '</td>';
|
||||||
|
echo '<td>' . ($field->is_public ? 'Yes' : 'No') . '</td>';
|
||||||
|
echo '<td>' . ($field->is_required ? 'Yes' : 'No') . '</td>';
|
||||||
|
echo '<td>' . ($field->is_full_width ? 'Yes' : 'No') . '</td>';
|
||||||
|
echo '<td style="white-space: nowrap;">';
|
||||||
|
// Edit button (toggle to show edit form)
|
||||||
|
echo '<a href="' . add_query_arg(array('page' => 'go-form-settings', 'form_id' => $selected_form_id, 'edit_field' => $field->id), admin_url('admin.php')) . '" class="button" style="margin-right: 4px;">Edit</a> ';
|
||||||
|
echo '<span style="display: inline-block;">';
|
||||||
|
action_button('go_form_delete_custom_field', 'Delete', 'Delete this custom field?', $field->id);
|
||||||
|
echo '</span>';
|
||||||
|
echo '</td>';
|
||||||
|
echo '</tr>';
|
||||||
|
}
|
||||||
|
echo '</tbody></table>';
|
||||||
|
} else {
|
||||||
|
echo '<p><em>No custom fields yet.</em></p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit custom field form
|
||||||
|
if (isset($_GET['edit_field']) && $edit_field_id = intval($_GET['edit_field'])) {
|
||||||
|
$edit_field = go_form_get_custom_field_by_id($edit_field_id);
|
||||||
|
if ($edit_field && $edit_field->form_id == $selected_form_id) {
|
||||||
|
echo '<details open style="margin-top:20px;"><summary style="cursor:pointer; font-weight:bold;">Edit Custom Field</summary>';
|
||||||
|
echo '<form method="post" action="' . admin_url('admin-post.php') . '" style="margin-top:10px; padding-left:15px;">';
|
||||||
|
echo wp_nonce_field('go_form_update_custom_field_action', 'go_form_update_custom_field_nonce', true, false);
|
||||||
|
echo '<input type="hidden" name="action" value="go_form_update_custom_field">';
|
||||||
|
echo '<input type="hidden" name="form_id" value="' . esc_attr($selected_form_id) . '">';
|
||||||
|
echo '<input type="hidden" name="field_id" value="' . esc_attr($edit_field->id) . '">';
|
||||||
|
echo '<table class="form-table">';
|
||||||
|
echo '<tr><th><label for="field_name">Field Name:</label></th><td><input type="text" name="field_name" id="field_name" value="' . esc_attr($edit_field->field_name) . '" required></td></tr>';
|
||||||
|
echo '<tr><th><label for="field_type">Field Type:</label></th><td>';
|
||||||
|
echo '<select name="field_type" id="field_type">';
|
||||||
|
echo '<option value="text"' . selected($edit_field->field_type, 'text', false) . '>Text</option>';
|
||||||
|
echo '<option value="select"' . selected($edit_field->field_type, 'select', false) . '>Dropdown (Select)</option>';
|
||||||
|
echo '<option value="checkbox"' . selected($edit_field->field_type, 'checkbox', false) . '>Checkbox</option>';
|
||||||
|
echo '<option value="email"' . selected($edit_field->field_type, 'email', false) . '>Email</option>';
|
||||||
|
echo '<option value="textarea"' . selected($edit_field->field_type, 'textarea', false) . '>Textarea</option>';
|
||||||
|
echo '</select>';
|
||||||
|
echo '</td></tr>';
|
||||||
|
echo '<tr><th><label for="field_options">Options (for select, comma-separated):</label></th><td><textarea name="field_options" id="field_options" rows="2" style="width:100%;">' . esc_textarea($edit_field->field_options) . '</textarea><small>e.g., Option 1,Option 2,Option 3</small></td></tr>';
|
||||||
|
echo '<tr><th><label for="is_public">Public:</label></th><td><input type="checkbox" name="is_public" id="is_public" value="1" ' . checked($edit_field->is_public, 1, false) . '> <small>Show on public form</small></td></tr>';
|
||||||
|
echo '<tr><th><label for="is_required">Required:</label></th><td><input type="checkbox" name="is_required" id="is_required" value="1" ' . checked($edit_field->is_required, 1, false) . '> <small>Required field</small></td></tr>';
|
||||||
|
echo '<tr><th><label for="is_full_width">Full Width:</label></th><td><input type="checkbox" name="is_full_width" id="is_full_width" value="1" ' . checked($edit_field->is_full_width, 1, false) . '> <small>Display on full width (outside grid)</small></td></tr>';
|
||||||
|
echo '</table>';
|
||||||
|
echo '<p class="submit"><input type="submit" class="button button-primary" value="Update Custom Field"> <a href="' . add_query_arg(array('page' => 'go-form-settings', 'form_id' => $selected_form_id), admin_url('admin.php')) . '" class="button">Cancel</a></p>';
|
||||||
|
echo '</form>';
|
||||||
|
echo '</details>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
// ========== Edit Entry Form ==========
|
||||||
|
if (isset($_GET['edit_entry']) && $edit_entry_id = intval($_GET['edit_entry'])) {
|
||||||
|
$entry = go_form_get_entry_by_id($edit_entry_id);
|
||||||
|
if ($entry && $entry->form_id == $selected_form_id) {
|
||||||
|
$custom_fields = go_form_get_custom_fields($selected_form_id);
|
||||||
|
global $ranks;
|
||||||
|
$egd_data = !empty($entry->egd_number) ? go_form_fetch_egd_data($entry->egd_number) : null;
|
||||||
|
|
||||||
|
echo '<div style="margin-bottom:20px; padding:15px; background:#fff; border:1px solid #ddd; border-radius:4px;">';
|
||||||
|
echo '<h3>Edit Entry</h3>';
|
||||||
|
if (!empty($entry->egd_number) && !$egd_data) {
|
||||||
|
echo '<div class="notice notice-warning inline"><p>Could not fetch EGD data for PIN ' . esc_html($entry->egd_number) . '.</p></div>';
|
||||||
|
}
|
||||||
|
echo '<form method="post" action="' . admin_url('admin-post.php') . '">';
|
||||||
|
echo wp_nonce_field('go_form_update_entry_action', 'go_form_update_entry_nonce', true, false);
|
||||||
|
echo '<input type="hidden" name="action" value="go_form_update_entry">';
|
||||||
|
echo '<input type="hidden" name="entry_id" value="' . esc_attr($entry->id) . '">';
|
||||||
|
echo '<input type="hidden" name="form_id" value="' . esc_attr($selected_form_id) . '">';
|
||||||
|
echo '<table class="form-table">';
|
||||||
|
echo '<tr><th><label for="first_name">First Name*:</label></th><td><input type="text" name="first_name" id="first_name" value="' . esc_attr($entry->first_name) . '" required>' . go_form_egd_hint($egd_data['Name'] ?? $egd_data['Real_Name'] ?? null) . '</td></tr>';
|
||||||
|
echo '<tr><th><label for="last_name">Last Name*:</label></th><td><input type="text" name="last_name" id="last_name" value="' . esc_attr($entry->last_name) . '" required>' . go_form_egd_hint($egd_data['Last_Name'] ?? $egd_data['Real_Last_Name'] ?? null) . '</td></tr>';
|
||||||
|
echo '<tr><th><label for="country">Country:</label></th><td><input type="text" name="country" id="country" value="' . esc_attr($entry->country) . '">' . go_form_egd_hint($egd_data['Country_Code'] ?? null) . '</td></tr>';
|
||||||
|
echo '<tr><th><label for="club">Club:</label></th><td><input type="text" name="club" id="club" value="' . esc_attr($entry->club) . '">' . go_form_egd_hint($egd_data['Club'] ?? null) . '</td></tr>';
|
||||||
|
echo '<tr><th><label for="display_country">Display Country:</label></th><td><input type="text" name="display_country" id="display_country" value="' . esc_attr($entry->display_country) . '"></td></tr>';
|
||||||
|
echo '<tr><th><label for="display_club">Display Club:</label></th><td><input type="text" name="display_club" id="display_club" value="' . esc_attr($entry->display_club) . '"></td></tr>';
|
||||||
|
echo '<tr><th><label for="rank">Rank:</label></th><td>';
|
||||||
|
echo '<select name="rank" id="rank">';
|
||||||
|
foreach ($ranks as $value => $label) {
|
||||||
|
echo '<option value="' . esc_attr($value) . '" ' . selected($entry->rank, $value, false) . '>' . esc_html($label) . '</option>';
|
||||||
|
}
|
||||||
|
echo '</select>';
|
||||||
|
echo go_form_egd_hint(isset($egd_data['Grade_n']) ? ($ranks[intval($egd_data['Grade_n'])] ?? null) : null);
|
||||||
|
echo '</td></tr>';
|
||||||
|
echo '<tr><th><label for="rating">Rating:</label></th><td><input type="number" name="rating" id="rating" value="' . esc_attr($entry->rating) . '">' . go_form_egd_hint($egd_data['Gor'] ?? null) . '</td></tr>';
|
||||||
|
echo '<tr><th><label for="egd_number">EGD Number:</label></th><td><input type="text" name="egd_number" id="egd_number" value="' . esc_attr($entry->egd_number) . '"></td></tr>';
|
||||||
|
|
||||||
|
// Custom fields
|
||||||
|
if (!empty($custom_fields)) {
|
||||||
|
foreach ($custom_fields as $field) {
|
||||||
|
$field_id = 'custom_field_' . $field->id;
|
||||||
|
$value = go_form_get_custom_value($entry->id, $field->id);
|
||||||
|
echo '<tr><th><label for="' . esc_attr($field_id) . '">' . esc_html($field->field_name) . ($field->is_required ? '*' : '') . ':</label></th><td>';
|
||||||
|
|
||||||
|
switch ($field->field_type) {
|
||||||
|
case 'text':
|
||||||
|
echo '<input type="text" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" value="' . esc_attr($value) . '"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
case 'email':
|
||||||
|
echo '<input type="email" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" value="' . esc_attr($value) . '"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
break;
|
||||||
|
case 'textarea':
|
||||||
|
echo '<textarea name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" rows="4" style="width:100%;"' . ($field->is_required ? ' required' : '') . '>' . esc_textarea($value) . '</textarea>';
|
||||||
|
break;
|
||||||
|
case 'select':
|
||||||
|
$options = $field->field_options ? explode(',', $field->field_options) : [];
|
||||||
|
echo '<select name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '"' . ($field->is_required ? ' required' : '') . '>';
|
||||||
|
echo '<option value="">-- Select --</option>';
|
||||||
|
foreach ($options as $option) {
|
||||||
|
$option = trim($option);
|
||||||
|
echo '<option value="' . esc_attr($option) . '" ' . selected($value, $option, false) . '>' . esc_html($option) . '</option>';
|
||||||
|
}
|
||||||
|
echo '</select>';
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
echo '<input type="checkbox" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" value="1" ' . checked($value, '1', false) . '>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
echo '</td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</table>';
|
||||||
|
echo '<p class="submit">';
|
||||||
|
echo '<input type="submit" class="button button-primary" value="Update Entry">';
|
||||||
|
echo ' <a href="' . add_query_arg(array('page' => 'go-form-settings', 'form_id' => $selected_form_id), admin_url('admin.php')) . '" class="button">Cancel</a>';
|
||||||
|
echo '</p>';
|
||||||
|
echo '</form>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$entries = go_form_get_entries($selected_form_id);
|
$entries = go_form_get_entries($selected_form_id);
|
||||||
go_form_render_entries_table($entries, true);
|
$custom_fields = go_form_get_custom_fields($selected_form_id);
|
||||||
|
go_form_render_entries_table($entries, true, $custom_fields, $selected_form_id);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
echo '<h2>Create New Form</h2>';
|
||||||
|
echo '<form method="post" action="' . admin_url('admin-post.php') . '">';
|
||||||
|
echo wp_nonce_field('go_form_create_form_action', 'go_form_create_form_nonce', true, false);
|
||||||
|
echo '<input type="hidden" name="action" value="go_form_create_form">';
|
||||||
|
echo '<table class="form-table">';
|
||||||
|
echo '<tr><th><label for="form_name">Form Name:</label></th><td><input type="text" name="form_name" id="form_name" required></td></tr>';
|
||||||
|
echo '<tr><th><label for="form_email">Notification Email:</label></th><td><input type="email" name="form_email" id="form_email" placeholder="Optional email for signup notifications"></td></tr>';
|
||||||
|
echo '</table>';
|
||||||
|
echo '<p class="submit"><input type="submit" class="button button-primary" value="Create Form"></p>';
|
||||||
|
echo '</form>';
|
||||||
|
|
||||||
$forms = go_form_get_forms();
|
$forms = go_form_get_forms();
|
||||||
echo '<h3>Forms</h3><ul>';
|
echo '<h3>Forms</h3><ul>';
|
||||||
foreach ($forms as $f) {
|
foreach ($forms as $f) {
|
||||||
|
|
||||||
$url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $f->id), admin_url('admin.php'));
|
$url = add_query_arg(array('page' => 'go-form-settings', 'form_id' => $f->id), admin_url('admin.php'));
|
||||||
echo '<li><a href="' . esc_url($url) . '">' . esc_html($f->name) . '</a> <span style="color:#888">(ID: ' . esc_html($f->id) . ')</span> - <small>Shortcode: <code>[go_form id=' . esc_html($f->id) . ']</code></small></li>';
|
echo '<li><a href="' . esc_url($url) . '">' . esc_html($f->name) . '</a> <span style="color:#888">(ID: ' . esc_html($f->id) . ')</span> - <small>Shortcode: <code>[go_form id=' . esc_html($f->id) . ']</code></small>';
|
||||||
|
if (!empty($f->email)) {
|
||||||
|
echo ' - <span style="color:#2271b1;">Email: ' . esc_html($f->email) . '</span>';
|
||||||
|
}
|
||||||
|
echo '</li>';
|
||||||
}
|
}
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +1,85 @@
|
|||||||
<table class="wp-list-table widefat striped">
|
<div class="go-form-table-container" style="overflow-x: auto; -webkit-overflow-scrolling: touch;">
|
||||||
<thead>
|
<table class="wp-list-table widefat striped">
|
||||||
<tr>
|
<thead>
|
||||||
<th>First Name</th>
|
|
||||||
<th>Last Name</th>
|
|
||||||
<th>Country</th>
|
|
||||||
<th>Club</th>
|
|
||||||
<th>Rank</th>
|
|
||||||
<th>EGD Number</th>
|
|
||||||
<th>Date Added</th>
|
|
||||||
<?php if ($show_admin): ?>
|
|
||||||
<th>Rating</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Action</th>
|
|
||||||
<th>Comment</th>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
<?php foreach ($entries as $e): ?>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td> <?= esc_html($e->first_name) ?> </td>
|
<th></th>
|
||||||
<td> <?= esc_html($e->last_name) ?> </td>
|
<th>First Name</th>
|
||||||
<td> <?= esc_html($e->country) ?> </td>
|
<th>Last Name</th>
|
||||||
<td> <?= esc_html($e->club) ?> </td>
|
<th>Rank</th>
|
||||||
<td> <?= esc_html($ranks[$e->rank]) ?> </td>
|
|
||||||
<td> <?= esc_html($e->egd_number) ?> </td>
|
|
||||||
<td> <?= esc_html($e->created_at) ?> </td>
|
|
||||||
|
|
||||||
<?php if ($show_admin): ?>
|
<?php if ($show_admin): ?>
|
||||||
|
<th>Rating</th>
|
||||||
<td> <?= esc_html($e->rating) ?> </td>
|
|
||||||
<td> <?= esc_html($e->email) ?> </td>
|
|
||||||
<td>
|
|
||||||
<?php action_button('go_form_delete_entry', 'Delete', 'Delete this entry?', $e->id); ?>
|
|
||||||
</td>
|
|
||||||
<td> <?= esc_html($e->comment) ?> </td>
|
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<th>Country</th>
|
||||||
|
<th>Club</th>
|
||||||
|
<?php if ($show_admin): ?>
|
||||||
|
<th>Country (raw)</th>
|
||||||
|
<th>Club (raw)</th>
|
||||||
|
<?php endif; ?>
|
||||||
|
<th>EGD Number</th>
|
||||||
|
<th>Date Added</th>
|
||||||
|
<?php
|
||||||
|
// Add custom field columns
|
||||||
|
foreach ($custom_fields as $field):
|
||||||
|
if ($field->is_public || $show_admin):
|
||||||
|
echo '<th>' . esc_html($field->field_name) . '</th>';
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
|
||||||
|
if ($show_admin):
|
||||||
|
echo '<th>Action</th>';
|
||||||
|
endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
</tbody>
|
<?php foreach ($entries as $i => $e): ?>
|
||||||
</table>
|
|
||||||
|
<tr>
|
||||||
|
<td> <?= $i + 1 ?> </td>
|
||||||
|
<td> <?= esc_html($e->first_name) ?> </td>
|
||||||
|
<td> <?= esc_html($e->last_name) ?> </td>
|
||||||
|
<td> <?= esc_html($ranks[$e->rank]) ?> </td>
|
||||||
|
<?php if ($show_admin): ?>
|
||||||
|
<td> <?= esc_html($e->rating) ?> </td>
|
||||||
|
<?php endif; ?>
|
||||||
|
<td> <?= esc_html($e->display_country) ?> </td>
|
||||||
|
<td> <?= esc_html($e->display_club) ?> </td>
|
||||||
|
<?php if ($show_admin): ?>
|
||||||
|
<td> <?= esc_html($e->country) ?> </td>
|
||||||
|
<td> <?= esc_html($e->club) ?> </td>
|
||||||
|
<?php endif; ?>
|
||||||
|
<td><a
|
||||||
|
href="<?= esc_url('https://europeangodatabase.eu/EGD/Player_Card.php?&key=' . $e->egd_number) ?>"><?= esc_html($e->egd_number) ?>
|
||||||
|
</a> </td>
|
||||||
|
<td> <?= esc_html($e->created_at) ?> </td>
|
||||||
|
<?php
|
||||||
|
// Display custom field values
|
||||||
|
foreach ($custom_fields as $field):
|
||||||
|
if ($field->is_public || $show_admin):
|
||||||
|
echo '<td>';
|
||||||
|
$value = go_form_get_custom_value($e->id, $field->id);
|
||||||
|
if ($field->field_type === 'checkbox') {
|
||||||
|
echo $value ? 'Yes' : 'No';
|
||||||
|
} else {
|
||||||
|
echo esc_html($value);
|
||||||
|
}
|
||||||
|
echo '</td>';
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if ($show_admin): ?>
|
||||||
|
|
||||||
|
<td style="white-space: nowrap;">
|
||||||
|
<a href="<?= add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id ?? 0, 'edit_entry' => $e->id), admin_url('admin.php')) ?>"
|
||||||
|
class="button" style="margin-right: 4px;">Edit</a>
|
||||||
|
<span style="display: inline-block;"><?php action_button('go_form_delete_entry', 'Delete', 'Delete this entry?', $e->id); ?></span>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Plugin Name: Go Form Plugin
|
* Plugin Name: Go Form Plugin
|
||||||
* Description: Form plugin for Go players
|
* Description: Form plugin for Go players
|
||||||
* Version: 0.04
|
* Version: 0.07
|
||||||
* Author: Nikola Petrov
|
* Author: Nikola Petrov
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: docker.io/mariadb:latest
|
||||||
|
container_name: wordpress_db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: mysupersecurepass
|
||||||
|
MYSQL_PASSWORD: mysupersecurepass
|
||||||
|
MYSQL_DATABASE: wordpress_db
|
||||||
|
MYSQL_USER: justbeauniqueuser
|
||||||
|
volumes:
|
||||||
|
- ./database:/var/lib/mysql
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
|
||||||
|
wordpress:
|
||||||
|
image: docker.io/wordpress:latest
|
||||||
|
container_name: wordpress
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
environment:
|
||||||
|
WORDPRESS_DB_HOST: db:3306
|
||||||
|
WORDPRESS_DB_NAME: wordpress_db
|
||||||
|
WORDPRESS_DB_USER: justbeauniqueuser
|
||||||
|
WORDPRESS_DB_PASSWORD: mysupersecurepass
|
||||||
|
volumes:
|
||||||
|
- ./html:/var/www/html
|
||||||
|
ports:
|
||||||
|
- "8090:80"
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
sudo rm -rf html/wp-content/plugins/go-form-plugin
|
cd ..
|
||||||
sudo cp -r go-form-plugin html/wp-content/plugins/
|
sudo rm -rf scripts/html/wp-content/plugins/go-form-plugin
|
||||||
|
sudo mkdir scripts/html/wp-content/plugins/go-form-plugin
|
||||||
|
sudo cp main.php scripts/html/wp-content/plugins/go-form-plugin/
|
||||||
|
sudo cp -r go-form-plugin scripts/html/wp-content/plugins/go-form-plugin/go-form-plugin/
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
DB_NAME='wordpress_db'
|
|
||||||
DB_PASS='mysupersecurepass'
|
|
||||||
DB_USER='justbeauniqueuser'
|
|
||||||
POD_NAME='wordpress_with_mariadb'
|
|
||||||
CONTAINER_NAME_DB='wordpress_db'
|
|
||||||
CONTAINER_NAME_WP='wordpress'
|
|
||||||
|
|
||||||
# Stop and remove containers
|
|
||||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
|
||||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
|
||||||
|
|
||||||
# Remove pod
|
|
||||||
podman pod rm -f $POD_NAME || true
|
|
||||||
|
|
||||||
echo "removed pods"
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# restart_wp.sh - Fully restart WordPress pod and containers
|
|
||||||
|
|
||||||
DB_NAME='wordpress_db'
|
|
||||||
DB_PASS='mysupersecurepass'
|
|
||||||
DB_USER='justbeauniqueuser'
|
|
||||||
POD_NAME='wordpress_with_mariadb'
|
|
||||||
CONTAINER_NAME_DB='wordpress_db'
|
|
||||||
CONTAINER_NAME_WP='wordpress'
|
|
||||||
|
|
||||||
# Stop and remove containers
|
|
||||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
|
||||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
|
||||||
|
|
||||||
# Remove pod
|
|
||||||
podman pod rm -f $POD_NAME || true
|
|
||||||
|
|
||||||
echo "removed pods"
|
|
||||||
#exit 0
|
|
||||||
|
|
||||||
# Recreate pod
|
|
||||||
podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306
|
|
||||||
|
|
||||||
|
|
||||||
# Start MariaDB
|
|
||||||
podman run --detach --pod $POD_NAME \
|
|
||||||
-e MYSQL_ROOT_PASSWORD=$DB_PASS \
|
|
||||||
-e MYSQL_PASSWORD=$DB_PASS \
|
|
||||||
-e MYSQL_DATABASE=$DB_NAME \
|
|
||||||
-e MYSQL_USER=$DB_USER \
|
|
||||||
--name $CONTAINER_NAME_DB -v "$PWD/database":/var/lib/mysql \
|
|
||||||
docker.io/mariadb:latest
|
|
||||||
|
|
||||||
# Start WordPress
|
|
||||||
podman run --detach --pod $POD_NAME \
|
|
||||||
-e WORDPRESS_DB_HOST=127.0.0.1:3306 \
|
|
||||||
-e WORDPRESS_DB_NAME=$DB_NAME \
|
|
||||||
-e WORDPRESS_DB_USER=$DB_USER \
|
|
||||||
-e WORDPRESS_DB_PASSWORD=$DB_PASS \
|
|
||||||
--name $CONTAINER_NAME_WP -v "$PWD/html":/var/www/html \
|
|
||||||
docker.io/wordpress
|
|
||||||
|
|
||||||
echo "WordPress restarted on http://localhost:8090"
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# Source - https://stackoverflow.com/a/74956385
|
|
||||||
# Posted by tiemco
|
|
||||||
# Retrieved 2026-05-04, License - CC BY-SA 4.0
|
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
# https://stackoverflow.com/questions/74054932/how-to-install-and-setup-wordpress-using-podman
|
|
||||||
|
|
||||||
# Set environment variables:
|
|
||||||
DB_NAME='wordpress_db'
|
|
||||||
DB_PASS='mysupersecurepass'
|
|
||||||
DB_USER='justbeauniqueuser'
|
|
||||||
POD_NAME='wordpress_with_mariadb'
|
|
||||||
CONTAINER_NAME_DB='wordpress_db'
|
|
||||||
CONTAINER_NAME_WP='wordpress'
|
|
||||||
|
|
||||||
mkdir -p html
|
|
||||||
mkdir -p database
|
|
||||||
|
|
||||||
# Remove previous attempts
|
|
||||||
podman pod rm -f $POD_NAME
|
|
||||||
|
|
||||||
# Pull before run, bc: invalid reference format error
|
|
||||||
podman pull docker.io/mariadb:latest
|
|
||||||
podman pull docker.io/wordpress
|
|
||||||
|
|
||||||
# Create a pod instead of --link.
|
|
||||||
# So both containers are able to reach each others.
|
|
||||||
podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306
|
|
||||||
|
|
||||||
podman run --detach --pod $POD_NAME \
|
|
||||||
-e MYSQL_ROOT_PASSWORD=$DB_PASS \
|
|
||||||
-e MYSQL_PASSWORD=$DB_PASS \
|
|
||||||
-e MYSQL_DATABASE=$DB_NAME \
|
|
||||||
-e MYSQL_USER=$DB_USER \
|
|
||||||
--name $CONTAINER_NAME_DB -v "$PWD/database":/var/lib/mysql \
|
|
||||||
docker.io/mariadb:latest
|
|
||||||
|
|
||||||
podman run --detach --pod $POD_NAME \
|
|
||||||
-e WORDPRESS_DB_HOST=127.0.0.1:3306 \
|
|
||||||
-e WORDPRESS_DB_NAME=$DB_NAME \
|
|
||||||
-e WORDPRESS_DB_USER=$DB_USER \
|
|
||||||
-e WORDPRESS_DB_PASSWORD=$DB_PASS \
|
|
||||||
--name $CONTAINER_NAME_WP -v "$PWD/html":/var/www/html \
|
|
||||||
docker.io/wordpress
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
POD_NAME='wordpress_with_mariadb'
|
|
||||||
|
|
||||||
podman pod start $POD_NAME
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
POD_NAME='wordpress_with_mariadb'
|
|
||||||
|
|
||||||
podman pod stop $POD_NAME
|
|
||||||
Reference in New Issue
Block a user