195 lines
6.3 KiB
Markdown
195 lines
6.3 KiB
Markdown
# Go Form Plugin
|
|
|
|
A WordPress plugin for managing Go (Baduk/Weiqi) tournament registrations. Collect player information through frontend forms and export entries to popular tournament management systems.
|
|
|
|
**Version:** 0.05
|
|
|
|
## 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, export entries, and manage forms
|
|
- **Custom Fields** - Add unlimited custom fields (text, email, textarea, select, checkbox) to forms
|
|
- **Entry Editing** - Edit existing registrations from admin panel
|
|
- **EGD Data Sync** - Batch update rank and rating from EGD for all entries with EGD numbers
|
|
- **Responsive Design** - Frontend form with grid layout
|
|
|
|
## Installation
|
|
|
|
1. Upload the `go-form-plugin` folder to your `/wp-content/plugins/` directory
|
|
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 with names
|
|
- **Manage Forms** - View all forms with their shortcodes and IDs
|
|
- **View Entries** - See all submissions for a form in a sortable table
|
|
- **Edit Entries** - Modify existing player registrations
|
|
- **Delete Entries** - Remove individual registrations
|
|
- **Delete Forms** - Remove a form and all its entries (cascading delete)
|
|
- **Export Data** - Download entries in various tournament formats
|
|
- **Manage Custom Fields** - Add, edit, and delete custom fields per form
|
|
- **EGD Data Sync** - Update rank and rating from EGD for all entries with EGD numbers
|
|
|
|
### 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 four tables:
|
|
|
|
- `wp_go_form_forms` - Stores form definitions (id, name, created_at)
|
|
- `wp_go_form_entries` - Stores all player registrations with Go-specific fields
|
|
- `wp_go_form_custom_fields` - Stores custom field definitions per form
|
|
- `wp_go_form_entry_custom_values` - Stores custom field values for each entry
|
|
|
|
All tables use foreign keys with CASCADE delete and are automatically removed when the plugin is uninstalled.
|
|
|
|
### Rank System
|
|
|
|
Ranks are stored as integers (0-47) mapping to:
|
|
- 0-29: 30k to 1k
|
|
- 30-38: 1d to 9d
|
|
- 39-47: 1p to 9p
|
|
|
|
Rating auto-calculation: `rating = (rank * 100) - 900`
|
|
|
|
## 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) |
|
|
| EGD Number | No | European Go Database PIN |
|
|
|
|
## Hooks
|
|
|
|
### Actions
|
|
|
|
**Form Handling:**
|
|
- `admin_post_go_form_handle_submission` - Frontend form submission handler
|
|
- `admin_post_go_form_update_entry` - Update entry from admin panel
|
|
|
|
**Form Management:**
|
|
- `admin_post_go_form_create_form` - Create new form
|
|
- `admin_post_go_form_delete_form` - Delete form and all its entries
|
|
|
|
**Entry Management:**
|
|
- `admin_post_go_form_delete_entry` - Delete single entry
|
|
|
|
**Custom Fields:**
|
|
- `admin_post_go_form_create_custom_field` - Create custom field
|
|
- `admin_post_go_form_update_custom_field` - Update custom field
|
|
- `admin_post_go_form_delete_custom_field` - Delete custom field
|
|
|
|
**EGD Integration:**
|
|
- `admin_post_go_form_update_egd_data` - Batch update entries from EGD database
|
|
|
|
**Export:**
|
|
- `admin_post_go_form_export_csv` - CSV export handler
|
|
- `admin_post_go_form_export_pairgoth` - Pairgoth JSON export handler
|
|
- `admin_post_go_form_export_opengotha` - OpenGotha XML export handler
|
|
- `admin_post_go_form_export_mcmahon` - McMahon XML export handler
|
|
|
|
### Filters
|
|
|
|
None currently available.
|
|
|
|
## Custom Fields
|
|
|
|
Each form can have unlimited custom fields with the following types:
|
|
|
|
| Type | Description | Options |
|
|
|------|-------------|---------|
|
|
| `text` | Single line text input | - |
|
|
| `email` | Email address input with validation | - |
|
|
| `textarea` | Multi-line text input | - |
|
|
| `select` | Dropdown selection | Comma-separated options |
|
|
| `checkbox` | Checkbox (yes/no) | - |
|
|
|
|
### Custom Field Settings
|
|
|
|
- **Public** - Display on frontend form
|
|
- **Required** - Mandatory field
|
|
- **Full Width** - Display outside the grid layout
|
|
|
|
## Security
|
|
|
|
- All forms use WordPress nonces for CSRF protection
|
|
- Admin actions require `manage_options` capability
|
|
- All input is sanitized using WordPress sanitization functions (`sanitize_text_field`, `sanitize_textarea_field`, `intval`)
|
|
- Direct file access is blocked with `ABSPATH` check
|
|
- Database operations use `$wpdb->prepare()` for SQL injection prevention
|
|
|
|
## API Integration
|
|
|
|
### European Go Database (EGD)
|
|
|
|
The plugin integrates with the European Go Database for player data:
|
|
|
|
- **Search API**: `https://europeangodatabase.eu/EGD/GetPlayerDataByData.php?lastname=X&name=Y`
|
|
- **Player Data API**: `https://europeangodatabase.eu/EGD/GetPlayerDataByPIN.php?pin=XXXX`
|
|
|
|
Fields retrieved from EGD:
|
|
- Name, Last Name
|
|
- Country Code
|
|
- Club
|
|
- Grade (rank text)
|
|
- Grade_n (rank numeric)
|
|
- Gor (rating)
|
|
- Pin_Player (EGD PIN)
|
|
|
|
## Author
|
|
|
|
Nikola Petrov - nikola@petrovv.com
|
|
|
|
## License
|
|
|
|
MIT License - See LICENSE file for details.
|