# GorillaDash Plugin Reorganization

This document outlines the reorganization of the GorillaDash WordPress plugin according to modern WordPress development standards.

## New Directory Structure

```
gorilladash/
│
├─ gorilla-dash-integration.php         // Main plugin file (Plugin Header)
├─ uninstall.php                       // Plugin cleanup on uninstall
├─ readme.txt                          // WordPress.org plugin description
├─ REORGANIZATION.md                   // This documentation
│
├─ /includes                           // PHP core logic & classes
│   ├─ class-loader.php                // Autoloader and initialization
│   ├─ class-admin.php                 // Admin/backend functionality
│   ├─ class-frontend.php              // Frontend functionality
│   ├─ class-map.php                   // Map functionality (separated)
│   ├─ class-tribe-info.php            // GetTribeInfoFromSlug functionality (separated)
│   └─ functions.php                   // Shared API functions
│
├─ /assets                             // Frontend static resources
│   ├─ gorilladash-api.css            // Plugin styles
│   ├─ gorilladash-api.js             // Form handling JavaScript
│   ├─ gorilladash-map.js             // Map functionality JavaScript
│   └─ gorilladash-map-block.js       // Gutenberg block JavaScript
│
├─ /templates                          // Custom frontend templates
│   └─ test-page-template.php         // Testing template
│
└─ /languages                          // Translation files (.po/.mo)
```

## Key Improvements

### 1. Modular Architecture
- **Map functionality** separated into `class-map.php`
- **Tribe info functionality** separated into `class-tribe-info.php`
- **Admin functionality** separated into `class-admin.php`
- **Frontend functionality** separated into `class-frontend.php`

### 2. Shared API Functions
All API calls now use centralized functions in `functions.php`:
- `gorilladash_api_request()` - Base API request function
- `gorilladash_submit_enquiry()` - Form submission
- `gorilladash_search_tribes()` - Tribe search by coordinates
- `gorilladash_get_tribe_by_slug()` - Get tribe data by slug
- `gorilladash_debug_log()` - Debug logging
- `gorilladash_get_array_value()` - Array navigation helper
- `gorilladash_get_url_last_segment()` - URL parsing
- `gorilladash_sanitize_form_data()` - Form data sanitization

### 3. Improved Code Organization
- **Separation of concerns** - Each class handles specific functionality
- **DRY principle** - Common API functions prevent code duplication
- **WordPress standards** - Follows WordPress coding and architecture standards
- **Better maintainability** - Easier to locate and modify specific features

### 4. Enhanced Error Handling
- Centralized API error handling
- Consistent error messages and logging
- Better debugging capabilities

## Class Responsibilities

### GorillaDash_Loader
- Autoloads all plugin dependencies
- Initializes all components
- Manages plugin hooks and WordPress integration

### GorillaDash_Admin
- WordPress admin interface
- Settings page management
- Gutenberg block editor assets

### GorillaDash_Map
- Google Maps integration
- Store locator functionality
- Tribe search by coordinates
- Map shortcode and Gutenberg block

### GorillaDash_Tribe_Info
- URL-based tribe data retrieval
- Tribe information shortcodes
- Location template handling
- API testing functionality

## Migration Notes

- Original plugin file backed up as `gorilladash-api.php.backup`
- All existing functionality preserved
- Shortcodes remain unchanged
- Settings and options maintained
- Asset files unchanged

## Benefits

1. **Easier Maintenance** - Features are logically separated
2. **Better Code Reuse** - Shared API functions eliminate duplication
3. **Improved Testing** - Individual components can be tested separately
4. **Enhanced Scalability** - Easy to add new features without affecting existing code
5. **WordPress Compliance** - Follows WordPress plugin development best practices
