Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
libzip-dev \
libxml2-dev \
libonig-dev \
default-mysql-client \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
Expand Down
5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
]
}
},
"forwardPorts": [
24511
],
"postCreateCommand": "bash .devcontainer/post-create.sh"
}
}
23 changes: 15 additions & 8 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
app:
build:
Expand All @@ -16,12 +14,18 @@ services:
- type: volume
source: vendor
target: /workspace/vendor
- type: volume
source: wordpress_data
target: /var/www/html
- type: volume
source: wordpress_logs
target: /var/log/apache2
command: sleep infinity
environment:
- MYSQL_HOST=db
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_NAME=wordpress
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress

wordpress:
image: wordpress:php8.3-apache
Expand All @@ -30,13 +34,15 @@ services:
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: 1
ports:
- "24511:80"
- "8000:80"
depends_on:
- db
volumes:
- wordpress_data:/var/www/html
- ../:/var/www/html/wp-content/plugins/template_wp_plugin:ro
- wordpress_logs:/var/log/apache2
- ../:/var/www/html/wp-content/plugins/template-wp-plugin:ro

db:
image: mariadb:10.11
Expand All @@ -53,6 +59,7 @@ services:

volumes:
wordpress_data:
wordpress_logs:
db_data:
node_modules:
vendor:
72 changes: 69 additions & 3 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash

echo "Running post-create setup for WordPress Write AI Plugin..."
echo "Running post-create setup for WordPress Plugin..."

# Change to workspace directory
cd /workspace || exit 1

# Ensure proper ownership of volume directories
echo "Setting up directory permissions..."
sudo chown -R vscode:www-data /workspace/node_modules /workspace/vendor 2>/dev/null || true
sudo chown -R vscode:www-data /var/www/html 2>/dev/null || true

# Install PHP dependencies via Composer
echo "Installing PHP dependencies..."
Expand All @@ -31,11 +32,76 @@ fi
echo "Configuring git for dev container..."
git config core.filemode false

# ========================================
# Automated WordPress Installation
# ========================================
echo ""
echo "Setting up WordPress..."

# WordPress configuration
WP_URL="http://localhost:8000"
WP_TITLE="WordPress Dev"
WP_ADMIN_USER="admin"
WP_ADMIN_PASSWORD="admin"
WP_ADMIN_EMAIL="admin@example.com"

# Wait for WordPress files to be available
echo "Waiting for WordPress files..."
attempt=0
while [ ! -f "/var/www/html/wp-load.php" ]; do
attempt=$((attempt + 1))
if [ $attempt -ge $max_attempts ]; then
echo "WordPress files not found after $max_attempts attempts, skipping WordPress setup."
exit 0
fi
echo " Attempt $attempt/$max_attempts - waiting for WordPress files..."
sleep 2
done
echo "WordPress files are ready!"

# Check if WordPress is already installed
if wp core is-installed --path=/var/www/html --allow-root 2>/dev/null; then
echo "WordPress is already installed!"
else
# Install WordPress
echo "Installing WordPress..."
wp core install \
--path=/var/www/html \
--url="$WP_URL" \
--title="$WP_TITLE" \
--admin_user="$WP_ADMIN_USER" \
--admin_password="$WP_ADMIN_PASSWORD" \
--admin_email="$WP_ADMIN_EMAIL" \
--skip-email \
--allow-root

if [ $? -eq 0 ]; then
echo "WordPress installed successfully!"
else
echo "WordPress installation failed. You may need to install manually."
fi
fi

# Remove default plugins (Akismet and Hello Dolly)
echo "Removing default plugins..."
wp plugin deactivate akismet hello --path=/var/www/html --allow-root 2>/dev/null || true
wp plugin delete akismet hello --path=/var/www/html --allow-root 2>/dev/null || true

# Activate the plugin if it exists
PLUGIN_DIR="/var/www/html/wp-content/plugins/template-wp-plugin"
if [ -d "$PLUGIN_DIR" ]; then
echo "Activating plugin..."
wp plugin activate template-wp-plugin --path=/var/www/html --allow-root 2>/dev/null || true
fi

echo ""
echo "=========================================="
echo "WordPress Write AI Plugin Development Environment Ready!"
echo "WordPress Plugin Development Environment Ready!"
echo "=========================================="
echo "WordPress Site: http://localhost:24511"
echo "WordPress Site: $WP_URL"
echo "Admin URL: $WP_URL/wp-admin"
echo "Admin User: $WP_ADMIN_USER"
echo "Admin Password: $WP_ADMIN_PASSWORD"
echo ""
echo "Available tools:"
echo "- PHP $(php --version | head -n1)"
Expand Down
2 changes: 1 addition & 1 deletion .github/prompts/ws-release.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Version Update Process:
- Add new version entry with current date
- Include all changes since last release
- Categorize changes (Added, Changed, Deprecated, Removed, Fixed, Security)
2. Check current version in `wp-plugin.php` header
2. Check current version in `template-wp-plugin.php` header
3. If version in file doesn't match the new tag, update the Plugin Version header
4. Commit any version and changelog updates before creating the tag
5. Create the annotated git tag
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ jobs:
- name: Upload plugin artifact
uses: actions/upload-artifact@v5
with:
name: wp-plugin
name: template-wp-plugin
path: release/
retention-days: 30
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
./scripts/validate-versions.sh

- name: Create release archive
run: ./scripts/build-plugin.sh release wp-plugin.zip
run: ./scripts/build-plugin.sh release template-wp-plugin.zip

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: wp-plugin.zip
files: template-wp-plugin.zip
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 20 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

This template follows absolute minimalism - start simple, add complexity only when needed.

## Template Initialization

For new plugins based on this template, use the automated initialization:

1. Edit `template.json` with your plugin details
2. Run `python3 scripts/init-repo.py --dry-run` to preview changes
3. Run `python3 scripts/init-repo.py` to apply changes (resets changelog by default)
4. Add `--keep-changelog` flag to preserve existing changelog

The `template.json` file contains all configurable values:
- Plugin name, slug, description, version, URI
- Author name and URI
- PHP namespace, function prefix, constant prefix
- Composer package name
- GitHub owner and repository

## Code Standards

### PHP Code Quality
Expand All @@ -20,16 +36,16 @@ This template follows absolute minimalism - start simple, add complexity only wh
## Minimal Plugin Structure

Keep it simple:
- Single main plugin file: `wp-plugin.php`
- Single main plugin file: `template-wp-plugin.php`
- Basic activation/deactivation hooks only
- No complex class architecture unless required
- No admin pages, assets, or translations unless needed

## Development Workflow

1. Copy this template for new plugins
2. Rename main plugin file: `wp-plugin.php` → `your-plugin.php`
3. Update plugin headers (name, description, author)
1. Clone/fork this template for new plugins
2. Edit `template.json` with your plugin details
3. Run `python3 scripts/init-repo.py` to rebrand
4. Install dev dependencies: `composer install`
5. Add functionality incrementally as needed
6. Run `composer run lint` before commits
Expand Down
79 changes: 72 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,78 @@ Click "Use this template" on GitHub or clone this repository:
```bash
git clone https://github.com/liasoft/template-wp-plugin.git my-new-plugin
cd my-new-plugin
rm -rf .git && git init # Start fresh git history
```

### 2. Customize Your Plugin
### 2. Customize Your Plugin (Automated)

The easiest way to customize this template is using the initialization script:

1. **Edit `template.json`** with your plugin details:

```json
{
"plugin": {
"name": "My Awesome Plugin",
"slug": "my-awesome-plugin",
"description": "Does awesome things for WordPress.",
"version": "1.0.0",
"uri": "https://github.com/yourname/my-awesome-plugin"
},
"author": {
"name": "Your Name",
"uri": "https://yourwebsite.com"
},
"php": {
"namespace": "MyAwesomePlugin",
"function_prefix": "my_awesome_plugin",
"constant_prefix": "MY_AWESOME_PLUGIN"
},
"composer": {
"name": "yourname/my-awesome-plugin"
},
"github": {
"owner": "yourname",
"repo": "my-awesome-plugin"
}
}
```

2. **Run the initialization script**:

```bash
# Preview changes (dry run)
python scripts/init-repo.py --dry-run

# Apply changes (resets changelog by default)
python scripts/init-repo.py

1. **Rename the main plugin file**: `wp-plugin.php` → `your-plugin-name.php`
# Apply changes but keep existing changelog
python scripts/init-repo.py --keep-changelog
```

The script will:
- Replace all template placeholders across all files
- Rename `template-wp-plugin.php` to `your-plugin-slug.php`
- Update version validation scripts
- Reset the changelog for a fresh start (use `--keep-changelog` to preserve it)

### 2b. Customize Your Plugin (Manual)

Alternatively, you can manually customize:

1. **Rename the main plugin file**: `template-wp-plugin.php` → `your-plugin-name.php`

2. **Update plugin headers** in your renamed file:
- `Template WordPress Plugin` → `Your Plugin Name`
- `A minimal boilerplate for WordPress plugins` → `Your plugin description`
- `Your Name` → Your actual name
- `https://yourwebsite.com` → Your website URL
- `Liasoft GmbH` → Your name
- Update all URLs to your repository

3. **Update function names** to match your plugin (replace `template_wp_plugin` prefix)

4. **Update these files**: `composer.json`, `README.md`, `CHANGELOG.md`, `phpcs.xml`


### 3. Install Development Dependencies

Expand Down Expand Up @@ -69,14 +127,21 @@ composer run lint:fix
your-plugin-name/
├── .editorconfig # Editor configuration
├── .github/ # GitHub configuration
│ └── prompts/ # Copilot workspace prompt files
│ ├── prompts/ # Copilot workspace prompt files
│ └── workflows/ # CI/CD workflows
├── .gitignore # Git ignore rules
├── assets/ # Plugin assets (banner, icons)
├── scripts/ # Development scripts
│ ├── build-plugin.sh # Build and package plugin
│ ├── init-repo.py # Template initialization script
│ └── validate-versions.sh # Version consistency checker
├── phpcs.xml # WordPress Coding Standards config
├── composer.json # PHP dependencies and scripts
├── composer.lock # Dependency lock file
├── LICENSE # AGPL-3.0-or-later license
├── template.json # Template configuration (edit this first!)
├── LICENSE # GPL-3.0-or-later license
├── README.md # This file
├── wp-plugin.php # Main plugin file (rename this)
├── template-wp-plugin.php # Main plugin file (rename this)
└── vendor/ # Composer dependencies (after install)
```

Expand Down
Loading