|
| 1 | +# GameStore WordPress Theme & Blocks |
| 2 | + |
| 3 | +> 📖 **Documentation Language**: [Русский](./docs/ru/README.md) | **English** (current) |
| 4 | +
|
| 5 | +A modern WordPress block theme for gaming stores, built with full-site editing support and custom React-based blocks. |
| 6 | + |
| 7 | +## 🎮 Project Overview |
| 8 | + |
| 9 | +- **Block Theme**: Modern FSE (Full Site Editing) theme optimized for gaming stores |
| 10 | +- **Custom Blocks**: React-based Gutenberg blocks for enhanced functionality |
| 11 | +- **Core Plugin**: Essential functionality and customizations |
| 12 | +- **MU Plugin**: Must-use plugin for site-wide features |
| 13 | +- **Automated Deployment**: GitHub Actions CI/CD pipeline |
| 14 | + |
| 15 | +## 🏗️ Project Structure |
| 16 | + |
| 17 | +``` |
| 18 | +game-store/ |
| 19 | +├── .github/workflows/ |
| 20 | +│ └── CICD.yml # Automated deployment pipeline |
| 21 | +├── docs/ |
| 22 | +│ └── ru/ # Russian documentation |
| 23 | +├── mu-plugins/ |
| 24 | +│ └── gamestore-general.php # Must-use plugin |
| 25 | +├── plugins/ |
| 26 | +│ ├── blocks-gamestore/ # Custom React blocks |
| 27 | +│ └── core-gamestore/ # Core functionality plugin |
| 28 | +├── themes/ |
| 29 | +│ └── game-store/ # Main block theme |
| 30 | +├── docker-compose.yml # Local development environment |
| 31 | +├── wp-version-control.cfg # WordPress version management |
| 32 | +└── README.md # This file |
| 33 | +``` |
| 34 | + |
| 35 | +## 🔧 Project Architecture and Components |
| 36 | + |
| 37 | +### 🎨 Main Theme: `themes/game-store/` |
| 38 | +**Purpose**: WordPress block theme with Full Site Editing (FSE) support |
| 39 | + |
| 40 | +**Key files and directories:** |
| 41 | +- `themes/game-store/style.css` - main theme styles and meta information |
| 42 | +- `themes/game-store/theme.json` - theme configuration, color palette, typography |
| 43 | +- `themes/game-store/templates/` - HTML templates for different page types |
| 44 | +- `themes/game-store/patterns/` - ready-made block patterns for quick insertion |
| 45 | +- `themes/game-store/parts/` - theme parts (header, footer) |
| 46 | + |
| 47 | +**Why needed**: Provides the visual foundation of the site, defines the design system, colors, fonts, and overall appearance. FSE allows editing layouts through WordPress interface without code. |
| 48 | + |
| 49 | +### 🧩 Custom Blocks: `plugins/blocks-gamestore/` |
| 50 | +**Purpose**: React components for creating specialized Gutenberg blocks |
| 51 | + |
| 52 | +**Structure:** |
| 53 | +- `plugins/blocks-gamestore/src/` - source code of React-based blocks |
| 54 | +- `plugins/blocks-gamestore/build/` - compiled blocks for production |
| 55 | +- `plugins/blocks-gamestore/package.json` - dependencies and build scripts |
| 56 | + |
| 57 | +**Why needed**: Extends standard WordPress blocks with gaming store-specific elements (game cards, galleries, ratings, etc.). React provides interactivity and modern UX. |
| 58 | + |
| 59 | +### ⚙️ Core Plugin: `plugins/core-gamestore/` |
| 60 | +**Purpose**: Centralized logic and site functionality |
| 61 | + |
| 62 | +**Contains:** |
| 63 | +- Custom post types (for games, reviews) |
| 64 | +- API integrations (payment systems, game catalogs) |
| 65 | +- Administrative settings |
| 66 | +- WordPress hooks and filters |
| 67 | + |
| 68 | +**Why needed**: Separates business logic from presentation, ensures function portability between themes, manages gaming store-specific data. |
| 69 | + |
| 70 | +### 🔧 Must-Use Plugin: `mu-plugins/gamestore-general.php` |
| 71 | +**Purpose**: Critical functionality that must always be active |
| 72 | + |
| 73 | +**Location**: `mu-plugins/` (Must Use plugins) - automatically activated |
| 74 | + |
| 75 | +**What it does:** |
| 76 | +- Basic security settings |
| 77 | +- Essential redirects and rewrites |
| 78 | +- System hooks that cannot be disabled |
| 79 | +- Project constants initialization |
| 80 | + |
| 81 | +**Why separate folder**: MU-plugins cannot be deactivated through WordPress admin, which is critical for site stability. They load before regular plugins and are always active. |
| 82 | + |
| 83 | +## 🚀 Development Setup |
| 84 | + |
| 85 | +### Prerequisites |
| 86 | +- Node.js 18+ |
| 87 | +- Docker & Docker Compose |
| 88 | +- Git |
| 89 | + |
| 90 | +### Local Development |
| 91 | + |
| 92 | +1. **Clone the repository** |
| 93 | + ```bash |
| 94 | + git clone https://github.com/GKVSO/GameStore.git> |
| 95 | + cd game-store |
| 96 | + ``` |
| 97 | + |
| 98 | +2. **Start development environment** |
| 99 | + ```bash |
| 100 | + docker-compose up -d |
| 101 | + ``` |
| 102 | + |
| 103 | +3. **Build custom blocks** |
| 104 | + ```bash |
| 105 | + cd plugins/blocks-gamestore |
| 106 | + npm install |
| 107 | + npm run start |
| 108 | + ``` |
| 109 | + |
| 110 | +### Block Development Commands |
| 111 | + |
| 112 | +```bash |
| 113 | +# Development mode with hot reload |
| 114 | +npm run start |
| 115 | + |
| 116 | +# Production build |
| 117 | +npm run build |
| 118 | + |
| 119 | +# Code formatting |
| 120 | +npm run format |
| 121 | + |
| 122 | +# Linting |
| 123 | +npm run lint:js |
| 124 | +npm run lint:css |
| 125 | + |
| 126 | +# Create plugin zip |
| 127 | +npm run plugin-zip |
| 128 | +``` |
| 129 | + |
| 130 | +## 🔐 CI/CD Configuration |
| 131 | + |
| 132 | +### Required GitHub Secrets |
| 133 | + |
| 134 | +The automated deployment requires the following secrets to be configured in your GitHub repository: |
| 135 | + |
| 136 | +| Secret Name | Description | Example | |
| 137 | +|-------------|-------------|---------| |
| 138 | +| `SERVER_HOST` | Server IP address or domain | `192.168.1.100` or `example.com` | |
| 139 | +| `SERVER_USER` | SSH username | `ubuntu` | |
| 140 | +| `SERVER_SSH_PASSWORD` | SSH password | `your-secure-password` | |
| 141 | +| `SERVER_PORT` | SSH port (usually 22) | `22` | |
| 142 | +| `SERVER_DEV_TARGET_PATH` | Development deployment path | `/var/www/dev.example.com` | |
| 143 | +| `SERVER_PROD_TARGET_PATH` | Production deployment path | `/var/www/example.com` | |
| 144 | + |
| 145 | +### Setting Up Secrets |
| 146 | + |
| 147 | +1. Go to your GitHub repository |
| 148 | +2. Navigate to **Settings** → **Secrets and variables** → **Actions** |
| 149 | +3. Click **New repository secret** |
| 150 | +4. Add each secret with its corresponding value |
| 151 | + |
| 152 | +### WordPress Version Control |
| 153 | + |
| 154 | +The `wp-version-control.cfg` file contains the WordPress download URL: |
| 155 | +``` |
| 156 | +https://wordpress.org/latest.zip |
| 157 | +``` |
| 158 | + |
| 159 | +This ensures consistent WordPress versions across deployments. |
| 160 | + |
| 161 | +## 🚀 Deployment Process |
| 162 | + |
| 163 | +### Trigger Events |
| 164 | + |
| 165 | +- **Development Deployment**: Push to `dev` branch |
| 166 | +- **Production Deployment**: Create a release |
| 167 | + |
| 168 | +### Deployment Stages |
| 169 | + |
| 170 | +1. **Preparation** |
| 171 | + - Download WordPress from `wp-version-control.cfg` |
| 172 | + - Package plugins, themes, and mu-plugins |
| 173 | + |
| 174 | +2. **File Transfer** |
| 175 | + - Upload WordPress and content packages to server |
| 176 | + - Enable maintenance mode |
| 177 | + |
| 178 | +3. **WordPress Core Update** |
| 179 | + - Backup existing configuration |
| 180 | + - Replace WordPress core files (preserving `wp-config.php`) |
| 181 | + - Update admin and includes directories |
| 182 | + |
| 183 | +4. **Content Update** |
| 184 | + - Update plugins, themes, and mu-plugins |
| 185 | + - Preserve existing uploads and configurations |
| 186 | + |
| 187 | +5. **Cleanup** |
| 188 | + - Disable maintenance mode |
| 189 | + - Remove temporary files |
| 190 | + - Verify deployment |
| 191 | + |
| 192 | +### Deployment Features |
| 193 | + |
| 194 | +- **Zero-downtime deployment**: Maintenance mode prevents broken states |
| 195 | +- **Complete WordPress Core update**: Unlike standard deployments that only update themes and plugins, this approach downloads and replaces the entire WordPress Core. This is critical for large-scale projects where strict version control is essential |
| 196 | +- **WordPress version control**: The `wp-version-control.cfg` file allows locking to a specific WordPress version across all environments, eliminating compatibility issues and ensuring stability |
| 197 | +- **Selective updates**: Preserves `wp-config.php` and uploads directory with media files |
| 198 | +- **Automatic cleanup**: Removes temporary files post-deployment |
| 199 | +- **Environment-specific paths**: Different paths for dev/prod |
| 200 | + |
| 201 | +## 🛠️ Development Workflow |
| 202 | + |
| 203 | +### Working with Blocks |
| 204 | + |
| 205 | +1. **Create new block** |
| 206 | + ```bash |
| 207 | + cd plugins/blocks-gamestore |
| 208 | + npx @wordpress/create-block new-block-name |
| 209 | + ``` |
| 210 | + |
| 211 | +2. **Development workflow** |
| 212 | + ```bash |
| 213 | + npm run start # Start development server |
| 214 | + # Edit files in src/ |
| 215 | + # Browser auto-refreshes |
| 216 | + ``` |
| 217 | + |
| 218 | +3. **Production build** |
| 219 | + ```bash |
| 220 | + npm run build |
| 221 | + ``` |
| 222 | + |
| 223 | +### Theme Development |
| 224 | + |
| 225 | +- Edit template files in `themes/game-store/templates/` |
| 226 | +- Modify patterns in `themes/game-store/patterns/` |
| 227 | +- Update styles in `themes/game-store/style.css` |
| 228 | +- Configure theme in `themes/game-store/theme.json` |
| 229 | + |
| 230 | +## 📝 Contributing |
| 231 | + |
| 232 | +1. Fork the repository |
| 233 | +2. Create a feature branch |
| 234 | +3. Make changes following WordPress coding standards |
| 235 | +4. Test locally with Docker |
| 236 | +5. Submit a pull request |
| 237 | + |
| 238 | +## 📄 License |
| 239 | + |
| 240 | +This project is licensed under the GPL v2 or later - see the [LICENSE](LICENSE) file for details. |
| 241 | + |
| 242 | +## 👨💻 Author |
| 243 | + |
| 244 | +**GKVSO** |
| 245 | +- Telegram: [@GKVSO](https://t.me/GKVSO) |
| 246 | + |
| 247 | +--- |
| 248 | + |
| 249 | +📖 **Documentation**: [Русская версия](./docs/ru/README.md) | **English** (current) |
0 commit comments