# Gapify Live Chat - Packaging Guide

This plugin has a modular packaging system with shared functions and centralized configuration.

## 📦 Packaging System Architecture

### Core Files:
- **`config.sh`** - Centralized configuration (versions, file lists, etc.)
- **`packaging-functions.sh`** - Shared functions for both packaging scripts
- **`create-package.sh`** - WordPress.org submission package (NO ASSETS)
- **`create-final-package.sh`** - Final distribution package (WITH ASSETS)

## 🚀 Packaging Scripts

### 1. `create-package.sh` - WordPress.org Submission Package
**Use this for:** Submitting to WordPress.org plugin directory review

**What it includes:**
- ✅ Plugin code and functionality
- ✅ Language files
- ❌ **NO WordPress.org assets** (banners, icons, screenshots)

**File size:** ~60KB
**Output:** `gapify-livechat-1.0.3.zip`

**Why no assets?** WordPress.org requires assets to be uploaded separately via SVN after plugin approval.

### 2. `create-final-package.sh` - Final Distribution Package
**Use this for:** Public distribution, GitHub releases, direct installation

**What it includes:**
- ✅ Plugin code and functionality
- ✅ Language files
- ✅ **WordPress.org assets** (banners, icons, screenshots)

**File size:** ~4.4MB
**Output:** `gapify-livechat-final-1.0.3.zip`

## 🔧 Configuration Management

### `config.sh` - Centralized Configuration
All configuration is managed in one place:
```bash
# Plugin Information
PLUGIN_NAME="gapify-livechat"
VERSION="1.0.3"

# File Lists
REQUIRED_FILES=(
    "includes/"
    "languages/"
    "gapify-livechat.php"
    "readme.txt"
    "uninstall.php"
)

ASSET_FILES=(
    "assets/icon-*.png"
    "assets/banner-*.png"
    "assets/screenshot-*.png"
)
```

**Benefits:**
- ✅ Single source of truth for version numbers
- ✅ Easy to add/remove files from packages
- ✅ Consistent configuration across scripts
- ✅ Easy version updates

## 🔄 Shared Functions

### `packaging-functions.sh` - Reusable Functions
Common functionality shared between scripts:
- `create_temp_directory()` - Creates temp dir and copies files
- `copy_assets()` - Handles asset copying logic
- `create_zip_file()` - Creates the final zip package
- `validate_required_files()` - Ensures all required files exist
- `get_package_size()` - Returns human-readable package size

**Benefits:**
- ✅ No code duplication
- ✅ Consistent behavior across scripts
- ✅ Easy to maintain and update
- ✅ Better error handling

## 📋 Usage

### For WordPress.org Submission:
```bash
./create-package.sh
```

### For Final Distribution:
```bash
./create-final-package.sh
```

## 🔄 Version Updates

When updating the plugin version, only update `config.sh`:
```bash
# In config.sh
VERSION="1.0.4"
```

The packaging scripts will automatically use the new version.

## 📁 Assets Directory

The `assets/` directory contains:
- `icon-128x128.png` - Plugin icon (required)
- `icon-256x256.png` - Plugin icon (recommended)
- `banner-772x250.png` - Plugin banner (required)
- `banner-1544x500.png` - Plugin banner (recommended)
- `screenshot-1.png`, `screenshot-2.png`, etc. - Screenshots

## 🏗️ SOLID Principles Compliance

### ✅ Single Responsibility Principle (SRP)
- Each script has one clear purpose
- Shared functions have single responsibilities
- Configuration is separated from logic

### ✅ Open/Closed Principle (OCP)
- Easy to extend with new file types
- Easy to add new packaging requirements
- Configuration-driven approach

### ✅ Interface Segregation Principle (ISP)
- Focused interfaces for each script
- No unnecessary dependencies
- Clean separation of concerns

### ✅ Dependency Inversion Principle (DIP)
- Scripts depend on abstractions (functions)
- Configuration is injected, not hardcoded
- Easy to test and modify

## 📚 Resources

- [WordPress.org Plugin Assets Guide](https://developer.wordpress.org/plugins/wordpress-org/how-your-plugin-assets-work/)
- [WordPress.org Plugin Submission](https://developer.wordpress.org/plugins/wordpress-org/)
