Compare commits

..
Author SHA1 Message Date
marcus 31d475beca Fix test workflow issues with WP_Mock, PHP 7.0 compatibility, and code style
Release / Build and Release (push) Canceled after 0s
2025-04-18 16:02:17 +01:00
marcus af48e84614 Fix wiki navigation, update wiki changelog, improve documentation, and fix tests workflow 2025-04-18 15:05:49 +01:00
marcus 5083fcee50 Update wiki Home page with latest version information 2025-04-18 14:47:38 +01:00
marcus 79d1314aed Update version to 0.1.6 with GitHub Actions workflow permissions fix 2025-04-18 14:46:05 +01:00
marcus 2f4d88f8dd Add explicit permissions to GitHub Actions workflows
Release / Build and Release (push) Canceled after 0s
2025-04-18 14:43:19 +01:00
marcus bfac63799b Update to version 0.1.5 with testing setup, multisite compatibility, and npm scripts
Release / Build and Release (push) Canceled after 0s
2025-04-18 14:32:46 +01:00
marcus 9d3e67d16b Fix release workflow to use correct plugin directory name
Release / Build and Release (push) Canceled after 0s
2025-04-18 14:17:19 +01:00
25 changed files with 665 additions and 80 deletions

No files matched your search

+12 -4
View File
@@ -150,7 +150,15 @@ If the plugin is hosted on WordPress.org:
After releasing a new version: After releasing a new version:
1. Update the wiki documentation if needed 1. Update the wiki documentation:
2. Announce the release in relevant channels - Update the Changelog.md file in the .wiki directory to match the main CHANGELOG.md
3. Monitor for any issues or feedback - Add the new version information to the Home.md file in the Latest Updates section
4. Start planning the next release - Ensure all wiki pages are up-to-date with the new features or changes
- Verify that the _Sidebar.md file has the correct navigation structure
2. Verify that GitHub Actions workflows are running correctly:
- Check that the release workflow created the release with the correct assets
- Check that the sync-wiki workflow synced the wiki changes
- Fix any permissions issues in the workflow files if needed
3. Announce the release in relevant channels
4. Monitor for any issues or feedback
5. Start planning the next release
+5 -2
View File
@@ -8,6 +8,7 @@ The wiki documentation is organized into the following sections:
1. **User Documentation**: 1. **User Documentation**:
- Home - Home
- Starter Prompt (must be listed before Installation Guide)
- Installation Guide - Installation Guide
- Usage Instructions - Usage Instructions
- Frequently Asked Questions - Frequently Asked Questions
@@ -88,8 +89,10 @@ Documentation should be updated:
1. Identify the relevant wiki file(s) in the `.wiki/` directory 1. Identify the relevant wiki file(s) in the `.wiki/` directory
2. Make the necessary changes 2. Make the necessary changes
3. Commit and push the changes to the `main` branch 3. **Always ensure the Changelog.md in the wiki is updated to match the main CHANGELOG.md file**
4. The GitHub Actions workflow will automatically sync the changes with the GitHub wiki 4. **Always ensure the _Sidebar.md file has the correct navigation structure with Starter Prompt listed before Installation Guide**
5. Commit and push the changes to the `main` branch
6. The GitHub Actions workflow will automatically sync the changes with the GitHub wiki
### Creating New Pages ### Creating New Pages
+12 -10
View File
@@ -10,6 +10,8 @@ jobs:
build: build:
name: Build and Release name: Build and Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -36,31 +38,31 @@ jobs:
- name: Create build directory - name: Create build directory
run: | run: |
mkdir -p build/wp-plugin-starter-template mkdir -p build/wp-plugin-starter-template-for-ai-coding
cp -R *.php README.md LICENSE CHANGELOG.md readme.txt composer.json build/wp-plugin-starter-template/ cp -R *.php README.md LICENSE CHANGELOG.md readme.txt composer.json build/wp-plugin-starter-template-for-ai-coding/
cp -R admin includes languages vendor build/wp-plugin-starter-template/ cp -R admin includes languages vendor build/wp-plugin-starter-template-for-ai-coding/
mkdir -p build/wp-plugin-starter-template/assets/banner build/wp-plugin-starter-template/assets/icon build/wp-plugin-starter-template/assets/screenshots mkdir -p build/wp-plugin-starter-template-for-ai-coding/assets/banner build/wp-plugin-starter-template-for-ai-coding/assets/icon build/wp-plugin-starter-template-for-ai-coding/assets/screenshots
if [ -d "assets/banner" ]; then cp -R assets/banner/* build/wp-plugin-starter-template/assets/banner/; fi if [ -d "assets/banner" ]; then cp -R assets/banner/* build/wp-plugin-starter-template-for-ai-coding/assets/banner/; fi
if [ -d "assets/icon" ]; then cp -R assets/icon/* build/wp-plugin-starter-template/assets/icon/; fi if [ -d "assets/icon" ]; then cp -R assets/icon/* build/wp-plugin-starter-template-for-ai-coding/assets/icon/; fi
if [ -d "assets/screenshots" ]; then cp -R assets/screenshots/* build/wp-plugin-starter-template/assets/screenshots/; fi if [ -d "assets/screenshots" ]; then cp -R assets/screenshots/* build/wp-plugin-starter-template-for-ai-coding/assets/screenshots/; fi
- name: Create ZIP file - name: Create ZIP file
run: | run: |
cd build cd build
zip -r ../wp-plugin-starter-template-${{ env.VERSION }}.zip wp-plugin-starter-template -x "*.DS_Store" -x "*.git*" zip -r ../wp-plugin-starter-template-for-ai-coding-${{ env.VERSION }}.zip wp-plugin-starter-template-for-ai-coding -x "*.DS_Store" -x "*.git*"
cd .. cd ..
- name: Create Release - name: Create Release
id: create_release id: create_release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
files: wp-plugin-starter-template-${{ env.VERSION }}.zip files: wp-plugin-starter-template-for-ai-coding-${{ env.VERSION }}.zip
name: Version ${{ env.VERSION }} name: Version ${{ env.VERSION }}
draft: false draft: false
prerelease: false prerelease: false
body: | body: |
Release of version ${{ env.VERSION }} Release of version ${{ env.VERSION }}
See [CHANGELOG.md](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/CHANGELOG.md) for details. See [CHANGELOG.md](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/CHANGELOG.md) for details.
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+9 -7
View File
@@ -11,6 +11,8 @@ jobs:
sync-wiki: sync-wiki:
name: Sync Wiki to GitHub name: Sync Wiki to GitHub
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
steps: steps:
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -23,29 +25,29 @@ jobs:
- name: Clone wiki repository - name: Clone wiki repository
run: | run: |
git clone https://github.com/${{ github.repository }}.wiki.git wiki git clone https://github.com/${{ github.repository }}.wiki.git wiki
- name: Sync wiki content - name: Sync wiki content
run: | run: |
# Remove all files from wiki repository except .git # Remove all files from wiki repository except .git
find wiki -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \; find wiki -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \;
# Copy .wiki content to wiki repository # Copy .wiki content to wiki repository
cp -r .wiki/* wiki/ cp -r .wiki/* wiki/
# Go to wiki repository # Go to wiki repository
cd wiki cd wiki
# Add all changes # Add all changes
git add . git add .
# Check if there are changes to commit # Check if there are changes to commit
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No changes to commit" echo "No changes to commit"
exit 0 exit 0
fi fi
# Commit changes # Commit changes
git commit -m "Sync wiki from source repository" git commit -m "Sync wiki from source repository"
# Push changes # Push changes
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git
+13 -4
View File
@@ -13,7 +13,8 @@ jobs:
strategy: strategy:
matrix: matrix:
php-versions: ['7.0', '7.4', '8.0'] php-versions: ['7.0', '7.4', '8.0']
fail-fast: false
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -26,7 +27,15 @@ jobs:
tools: composer:v2 tools: composer:v2
- name: Install dependencies - name: Install dependencies
run: composer install --prefer-dist --no-progress run: |
if [[ "${{ matrix.php-versions }}" == "7.0" ]]; then
composer require --dev phpunit/phpunit:"^6.5" --update-with-dependencies
composer require --dev 10up/wp_mock:"0.3.0" --update-with-dependencies
composer require --dev antecedent/patchwork:"^2.1.21" --update-with-dependencies
else
composer install --prefer-dist --no-progress
composer require --dev 10up/wp_mock:"0.3.0" --update-with-dependencies
fi
- name: Run tests - name: Run tests
run: ./vendor/bin/phpunit run: ./vendor/bin/phpunit
@@ -34,7 +43,7 @@ jobs:
code-style: code-style:
name: Code Style name: Code Style
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -50,4 +59,4 @@ jobs:
run: composer install --prefer-dist --no-progress run: composer install --prefer-dist --no-progress
- name: Run PHPCS - name: Run PHPCS
run: ./vendor/bin/phpcs --standard=WordPress run: ./vendor/bin/phpcs --standard=WordPress --runtime-set installed_paths vendor/wp-coding-standards/wpcs ./includes ./admin ./wp-plugin-starter-template.php
+43 -7
View File
@@ -2,12 +2,48 @@
This page documents all notable changes to the WordPress Plugin Starter Template. This page documents all notable changes to the WordPress Plugin Starter Template.
## Version 0.1.6 (2025-04-19)
### Fixed
- GitHub Actions workflows permissions for releases and wiki sync
## Version 0.1.5 (2025-04-19)
### Fixed
- Release workflow to use correct plugin directory name
### Added
- Testing setup with wp-env and Cypress
- Multisite compatibility
- npm scripts for development and testing
## Version 0.1.3 (2025-04-19)
### Added
- Improved AI IDE context recommendations in documentation
- Enhanced Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/
### Changed
- Updated README.md and readme.txt with AI IDE context recommendations
- Improved documentation for AI-assisted development
- Moved Starter Prompt to the wiki for better organization
## Version 0.1.2 (2025-04-18)
### Added
- STARTER-PROMPT.md with comprehensive guide for customizing the template
- Additional AI workflow files for better development guidance
### Changed
- Updated documentation files with improved instructions
## Version 0.1.1 (2025-04-18)
### Changed
- Updated LICENSE file with correct GPL-2.0 text
## Version 0.1.0 (2025-04-17) ## Version 0.1.0 (2025-04-17)
### Added
- Initial release with basic template structure - Initial release with basic template structure
- Added core plugin architecture with OOP approach - Core plugin architecture with OOP approach
- Added admin interface components and styling - Admin interface components and styling
- Added update mechanism with multiple source options - Update mechanism with multiple source options
- Added documentation templates for users and developers - Documentation templates for users and developers
- Added AI workflow documentation for AI-assisted development - AI workflow documentation for AI-assisted development
- Added GitHub Actions workflows for automated tasks - GitHub Actions workflows for automated tasks
- Added wiki documentation templates - Wiki documentation templates
+5
View File
@@ -4,6 +4,11 @@ Welcome to the documentation wiki for the WordPress Plugin Starter Template.
This template provides a solid foundation for developing WordPress plugins with best practices for AI-assisted development. This template provides a solid foundation for developing WordPress plugins with best practices for AI-assisted development.
## Latest Updates
- Version 0.1.6: Fixed GitHub Actions workflows permissions for releases and wiki sync
- Version 0.1.5: Added testing setup with wp-env and Cypress, multisite compatibility
## Quick Links ## Quick Links
- [Starter Prompt](Starter-Prompt) - [Starter Prompt](Starter-Prompt)
+1
View File
@@ -1,5 +1,6 @@
## User Documentation ## User Documentation
* [Home](Home) * [Home](Home)
* [Starter Prompt](Starter-Prompt)
* [Installation Guide](Installation-Guide) * [Installation Guide](Installation-Guide)
* [Usage Instructions](Usage-Instructions) * [Usage Instructions](Usage-Instructions)
* [Frequently Asked Questions](Frequently-Asked-Questions) * [Frequently Asked Questions](Frequently-Asked-Questions)
+13
View File
@@ -1,5 +1,18 @@
All notable changes to this project should be documented both here and in the main Readme files. All notable changes to this project should be documented both here and in the main Readme files.
#### [0.1.6] - 2025-04-19
#### Fixed
- GitHub Actions workflows permissions for releases and wiki sync
#### [0.1.5] - 2025-04-19
#### Fixed
- Release workflow to use correct plugin directory name
#### Added
- Testing setup with wp-env and Cypress
- Multisite compatibility
- npm scripts for development and testing
#### [0.1.3] - 2025-04-19 #### [0.1.3] - 2025-04-19
#### Added #### Added
- Improved AI IDE context recommendations in documentation - Improved AI IDE context recommendations in documentation
+107 -8
View File
@@ -15,11 +15,12 @@ This template is based on the experience gained from developing the "Fix 'Plugin
* **Object-Oriented Architecture**: Well-structured, maintainable code using OOP principles * **Object-Oriented Architecture**: Well-structured, maintainable code using OOP principles
* **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts * **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts
* **Comprehensive Documentation**: Detailed documentation for both users and developers * **Comprehensive Documentation**: Detailed documentation for both users and developers
* **Testing Framework**: PHPUnit setup for unit testing * **Testing Framework**: PHPUnit setup for unit testing and Cypress for e2e testing
* **Internationalization Ready**: Full support for translation and localization * **Internationalization Ready**: Full support for translation and localization
* **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates * **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates
* **AI Workflow Documentation**: Detailed guides for AI-assisted development * **AI Workflow Documentation**: Detailed guides for AI-assisted development
* **Wiki Documentation**: Ready-to-use wiki structure for comprehensive documentation * **Wiki Documentation**: Ready-to-use wiki structure for comprehensive documentation
* **Multisite Compatible**: Fully tested and compatible with WordPress multisite installations
### How to Use This Template ### How to Use This Template
@@ -70,6 +71,86 @@ To get started with this template, follow these steps:
4. Use an AI assistant like GitHub Copilot, Claude, or ChatGPT to help you customize the template by providing the prompt from the Starter Prompt file. 4. Use an AI assistant like GitHub Copilot, Claude, or ChatGPT to help you customize the template by providing the prompt from the Starter Prompt file.
### Development Environment
This template includes configuration for WordPress Environment (wp-env) to make local development easier:
1. Install Node.js dependencies:
```bash
npm install
```
2. Start the WordPress environment:
```bash
npm run start
```
3. For multisite testing:
```bash
npm run multisite
```
4. Access your local WordPress site at http://localhost:8888 (admin credentials: admin/password)
### Testing
The template includes both PHP unit tests and end-to-end tests:
#### PHP Unit Tests
1. Install Composer dependencies:
```bash
composer install
```
2. Run PHP unit tests:
```bash
npm run test:php
```
3. Check PHP coding standards:
```bash
npm run lint:php
```
4. Fix PHP coding standards issues:
```bash
npm run fix:php
```
#### End-to-End Tests
1. Start the WordPress environment:
```bash
npm run start
```
2. Run Cypress tests in interactive mode:
```bash
npm run test:e2e
```
3. Run Cypress tests in headless mode:
```bash
npm run test:e2e:headless
```
### Building for Production
Use the included build script to create a deployable version of your plugin:
```bash
npm run build
```
Or directly:
```bash
./build.sh {VERSION}
```
This will create a ZIP file that you can install in WordPress.
### Using with Git Updater ### Using with Git Updater
If you've installed this plugin from GitHub or Gitea, you'll need Git Updater to receive updates: If you've installed this plugin from GitHub or Gitea, you'll need Git Updater to receive updates:
@@ -105,13 +186,14 @@ The main files you need to update include:
3. readme.txt 3. readme.txt
4. CHANGELOG.md 4. CHANGELOG.md
5. composer.json 5. composer.json
6. languages/pot file 6. package.json
7. .github/workflows/ 7. languages/pot file
8. .wiki/ 8. .github/workflows/
9. .ai-assistant.md 9. .wiki/
10. includes/plugin.php 10. .ai-assistant.md
11. includes/core.php 11. includes/plugin.php
12. admin/lib/admin.php 12. includes/core.php
13. admin/lib/admin.php
### How do I build and test my plugin? ### How do I build and test my plugin?
@@ -127,6 +209,14 @@ This will create a ZIP file that you can install in WordPress.
Customize the includes/core.php file to implement your core functionality and the admin/lib/admin.php file for admin-specific functionality. Customize the includes/core.php file to implement your core functionality and the admin/lib/admin.php file for admin-specific functionality.
### Is this template compatible with WordPress multisite?
Yes, this template is fully compatible with WordPress multisite installations. You can test multisite compatibility by running:
```bash
npm run multisite
```
## Support & Feedback ## Support & Feedback
If you need help with this template, there are several ways to get support: If you need help with this template, there are several ways to get support:
@@ -188,6 +278,15 @@ For more information on Git Updater integration, see the [Git Updater Required H
## Changelog ## Changelog
### 0.1.6
* Fixed: GitHub Actions workflows permissions for releases and wiki sync
### 0.1.5
* Fixed: Release workflow to use correct plugin directory name
* Added: Testing setup with wp-env and Cypress
* Added: Multisite compatibility
* Added: npm scripts for development and testing
### 0.1.3 ### 0.1.3
* Added: Improved AI IDE context recommendations in documentation * Added: Improved AI IDE context recommendations in documentation
* Enhanced: Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/ * Enhanced: Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/
+74
View File
@@ -1 +1,75 @@
<?php <?php
/**
* Admin functionality
*
* @package WPALLSTARS\PluginStarterTemplate
*/
namespace WPALLSTARS\PluginStarterTemplate\Admin;
use WPALLSTARS\PluginStarterTemplate\Core;
/**
* Admin class
*/
class Admin {
/**
* Core instance
*
* @var Core
*/
private $core;
/**
* Constructor
*
* @param Core $core Core instance.
*/
public function __construct( $core ) {
$this->core = $core;
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] );
}
/**
* Initialize admin
*/
public function init() {
// Initialize admin
}
/**
* Enqueue admin assets
*
* @param string $hook Current admin page.
*/
public function enqueue_admin_assets( $hook ) {
wp_enqueue_style(
'wpst-admin-styles',
WPST_PLUGIN_URL . 'assets/css/admin.css',
[],
WPST_VERSION
);
wp_enqueue_script(
'wpst-admin-scripts',
WPST_PLUGIN_URL . 'assets/js/admin.js',
[ 'jquery' ],
WPST_VERSION,
true
);
wp_localize_script(
'wpst-admin-scripts',
'wpstData',
[
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpst-admin-nonce' ),
'strings' => [
'success' => esc_html__( 'Success!', 'wp-plugin-starter-template' ),
'error' => esc_html__( 'Error!', 'wp-plugin-starter-template' ),
],
]
);
}
}
+5 -2
View File
@@ -14,9 +14,12 @@
"php": ">=7.0" "php": ">=7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^7.5", "phpunit/phpunit": "^6.5 || ^7.5 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",
"wp-coding-standards/wpcs": "^2.3" "wp-coding-standards/wpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"10up/wp_mock": "0.3.0",
"antecedent/patchwork": "^2.1.21"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
+30
View File
@@ -1 +1,31 @@
<?php <?php
/**
* Core functionality for the plugin
*
* @package WPALLSTARS\PluginStarterTemplate
*/
namespace WPALLSTARS\PluginStarterTemplate;
/**
* Core class
*/
class Core {
/**
* Constructor
*/
public function __construct() {
// Initialize hooks
}
/**
* Example method to filter content
*
* @param string $content The content to filter.
* @return string The filtered content.
*/
public function filter_content( $content ) {
return $content;
}
}
+53
View File
@@ -1 +1,54 @@
<?php <?php
/**
* Main plugin class
*
* @package WPALLSTARS\PluginStarterTemplate
*/
namespace WPALLSTARS\PluginStarterTemplate;
/**
* Plugin class
*/
class Plugin {
/**
* Core instance
*
* @var Core
*/
private $core;
/**
* Plugin file
*
* @var string
*/
private $plugin_file;
/**
* Plugin version
*
* @var string
*/
private $version;
/**
* Constructor
*
* @param string $plugin_file Main plugin file path.
* @param string $version Plugin version.
*/
public function __construct($plugin_file, $version) {
$this->plugin_file = $plugin_file;
$this->version = $version;
$this->core = new Core();
}
/**
* Initialize the plugin
*/
public function init() {
// Initialize plugin.
}
}
+57
View File
@@ -1 +1,58 @@
<?php <?php
/**
* Updater functionality for the plugin
*
* @package WPALLSTARS\PluginStarterTemplate
*/
namespace WPALLSTARS\PluginStarterTemplate;
/**
* Updater class
*/
class Updater {
/**
* Plugin file
*
* @var string
*/
private $plugin_file;
/**
* Constructor
*
* @param string $plugin_file Main plugin file path.
*/
public function __construct($plugin_file) {
$this->plugin_file = $plugin_file;
$this->init();
}
/**
* Initialize the updater
*/
public function init() {
add_filter('plugin_action_links_' . plugin_basename($this->plugin_file), array($this, 'add_update_source_link'));
add_action('admin_post_wpst_update_source', array($this, 'handle_update_source'));
}
/**
* Add update source link to plugin actions
*
* @param array $links Plugin action links.
* @return array Modified plugin action links.
*/
public function add_update_source_link($links) {
$update_source_link = '<a href="' . admin_url('admin-post.php?action=wpst_update_source&plugin=' . plugin_basename($this->plugin_file)) . '">' . esc_html__('Update Source', 'wp-plugin-starter-template') . '</a>';
array_unshift($links, $update_source_link);
return $links;
}
/**
* Handle update source selection
*/
public function handle_update_source() {
// Handle update source selection.
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"name": "wp-plugin-starter-template-for-ai-coding",
"version": "0.1.6",
"description": "A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.",
"main": "index.js",
"scripts": {
"start": "wp-env start",
"stop": "wp-env stop",
"wp-env": "wp-env",
"multisite": "wp-env start --config=.wp-env.multisite.json",
"test:e2e": "cypress open --config-file tests/e2e/cypress.json",
"test:e2e:headless": "cypress run --config-file tests/e2e/cypress.json",
"build": "./build.sh",
"lint:php": "composer run-script phpcs",
"fix:php": "composer run-script phpcbf",
"test:php": "composer run-script test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git"
},
"keywords": [
"wordpress",
"plugin",
"template",
"ai",
"coding"
],
"author": "WPALLSTARS",
"license": "GPL-2.0-or-later",
"bugs": {
"url": "https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues"
},
"homepage": "https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding#readme",
"devDependencies": {
"@wordpress/env": "^5.0.0",
"cypress": "^9.7.0"
}
}
+98 -9
View File
@@ -5,7 +5,7 @@ Tags: starter, template, boilerplate, plugin development, ai coding
Requires at least: 5.0 Requires at least: 5.0
Tested up to: 6.4 Tested up to: 6.4
Requires PHP: 7.0 Requires PHP: 7.0
Stable tag: 0.1.3 Stable tag: 0.1.6
License: GPL-2.0+ License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -22,11 +22,12 @@ This template is based on the experience gained from developing the "Fix 'Plugin
* **Object-Oriented Architecture**: Well-structured, maintainable code using OOP principles * **Object-Oriented Architecture**: Well-structured, maintainable code using OOP principles
* **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts * **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts
* **Comprehensive Documentation**: Detailed documentation for both users and developers * **Comprehensive Documentation**: Detailed documentation for both users and developers
* **Testing Framework**: PHPUnit setup for unit testing * **Testing Framework**: PHPUnit setup for unit testing and Cypress for e2e testing
* **Internationalization Ready**: Full support for translation and localization * **Internationalization Ready**: Full support for translation and localization
* **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates * **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates
* **AI Workflow Documentation**: Detailed guides for AI-assisted development * **AI Workflow Documentation**: Detailed guides for AI-assisted development
* **Wiki Documentation**: Ready-to-use wiki structure for comprehensive documentation * **Wiki Documentation**: Ready-to-use wiki structure for comprehensive documentation
* **Multisite Compatible**: Fully tested and compatible with WordPress multisite installations
= How to Use This Template = = How to Use This Template =
@@ -51,6 +52,70 @@ This template includes comprehensive documentation for AI-assisted development:
**Important**: For the best AI assistance, add the .ai-assistant.md file and .ai-workflows/ directory to your AI IDE chat context. In most AI IDEs, you can pin these files to ensure they're considered in each message. **Important**: For the best AI assistance, add the .ai-assistant.md file and .ai-workflows/ directory to your AI IDE chat context. In most AI IDEs, you can pin these files to ensure they're considered in each message.
= Development Environment =
This template includes configuration for WordPress Environment (wp-env) to make local development easier:
1. Install Node.js dependencies:
```bash
npm install
```
2. Start the WordPress environment:
```bash
npm run start
```
3. For multisite testing:
```bash
npm run multisite
```
4. Access your local WordPress site at http://localhost:8888 (admin credentials: admin/password)
= Testing =
The template includes both PHP unit tests and end-to-end tests:
**PHP Unit Tests**
1. Install Composer dependencies:
```bash
composer install
```
2. Run PHP unit tests:
```bash
npm run test:php
```
3. Check PHP coding standards:
```bash
npm run lint:php
```
4. Fix PHP coding standards issues:
```bash
npm run fix:php
```
**End-to-End Tests**
1. Start the WordPress environment:
```bash
npm run start
```
2. Run Cypress tests in interactive mode:
```bash
npm run test:e2e
```
3. Run Cypress tests in headless mode:
```bash
npm run test:e2e:headless
```
= Support & Feedback = = Support & Feedback =
If you need help with this template, there are several ways to get support: If you need help with this template, there are several ways to get support:
@@ -95,13 +160,14 @@ The main files you need to update include:
3. readme.txt 3. readme.txt
4. CHANGELOG.md 4. CHANGELOG.md
5. composer.json 5. composer.json
6. languages/pot file 6. package.json
7. .github/workflows/ 7. languages/pot file
8. .wiki/ 8. .github/workflows/
9. .ai-assistant.md 9. .wiki/
10. includes/plugin.php 10. .ai-assistant.md
11. includes/core.php 11. includes/plugin.php
12. admin/lib/admin.php 12. includes/core.php
13. admin/lib/admin.php
= How do I build and test my plugin? = = How do I build and test my plugin? =
@@ -125,12 +191,29 @@ You'll need to update all namespace references from WPALLSTARS\PluginStarterTemp
You'll need to update all text domain references from 'wp-plugin-starter-template' to your own text domain throughout the codebase. You'll need to update all text domain references from 'wp-plugin-starter-template' to your own text domain throughout the codebase.
= Is this template compatible with WordPress multisite? =
Yes, this template is fully compatible with WordPress multisite installations. You can test multisite compatibility by running:
```bash
npm run multisite
```
== Screenshots == == Screenshots ==
1. This is a placeholder for your plugin's screenshots. Replace with actual screenshots of your plugin in action. 1. This is a placeholder for your plugin's screenshots. Replace with actual screenshots of your plugin in action.
== Changelog == == Changelog ==
= 0.1.6 =
* Fixed: GitHub Actions workflows permissions for releases and wiki sync
= 0.1.5 =
* Fixed: Release workflow to use correct plugin directory name
* Added: Testing setup with wp-env and Cypress
* Added: Multisite compatibility
* Added: npm scripts for development and testing
= 0.1.3 = = 0.1.3 =
* Added: Improved AI IDE context recommendations in documentation * Added: Improved AI IDE context recommendations in documentation
* Enhanced: Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/ * Enhanced: Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/
@@ -158,6 +241,12 @@ You'll need to update all text domain references from 'wp-plugin-starter-templat
== Upgrade Notice == == Upgrade Notice ==
= 0.1.6 =
Fixed GitHub Actions workflows permissions for releases and wiki sync.
= 0.1.5 =
Fixed release workflow and added testing setup with wp-env and Cypress, multisite compatibility, and npm scripts for development and testing.
= 0.1.3 = = 0.1.3 =
Added improved AI IDE context recommendations and moved Starter Prompt to the wiki with guidance on pinning .ai-assistant.md and .ai-workflows/ files. Added improved AI IDE context recommendations and moved Starter Prompt to the wiki with guidance on pinning .ai-assistant.md and .ai-workflows/ files.
+9
View File
@@ -0,0 +1,9 @@
{
"baseUrl": "http://localhost:8889",
"integrationFolder": "tests/e2e/cypress/integration",
"pluginsFile": "tests/e2e/cypress/plugins/index.js",
"supportFile": "tests/e2e/cypress/support/index.js",
"videosFolder": "tests/e2e/cypress/videos",
"screenshotsFolder": "tests/e2e/cypress/screenshots",
"fixturesFolder": "tests/e2e/cypress/fixtures"
}
@@ -0,0 +1,27 @@
/**
* Basic e2e test for the plugin.
*/
describe('Plugin Basic Tests', () => {
before(() => {
cy.login();
});
it('Should activate the plugin', () => {
cy.visit('/wp-admin/plugins.php');
cy.contains('WP Plugin Starter Template').should('exist');
// Check if plugin is not active, then activate it
cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]')
.then(($tr) => {
if ($tr.hasClass('inactive')) {
cy.wrap($tr).find('.activate a').click();
cy.contains('Plugin activated.').should('exist');
}
});
});
it('Should have the plugin settings page', () => {
cy.visit('/wp-admin/options-general.php?page=wp-plugin-starter-template');
cy.contains('WP Plugin Starter Template Settings').should('exist');
});
});
+10
View File
@@ -0,0 +1,10 @@
/**
* Cypress plugins file.
*
* @param {Object} on - Cypress events
* @param {Object} config - Cypress config
* @return {Object} - Modified config
*/
module.exports = (on, config) => {
return config;
};
+12
View File
@@ -0,0 +1,12 @@
/**
* Custom Cypress commands.
*/
// Login command
Cypress.Commands.add('login', (username = 'admin', password = 'password') => {
cy.visit('/wp-login.php');
cy.get('#user_login').type(username);
cy.get('#user_pass').type(password);
cy.get('#wp-submit').click();
cy.get('body.wp-admin').should('exist');
});
+4
View File
@@ -0,0 +1,4 @@
/**
* Import commands.js
*/
import './commands';
+14 -14
View File
@@ -11,7 +11,7 @@ use WPALLSTARS\PluginStarterTemplate\Core;
/** /**
* Admin test case. * Admin test case.
*/ */
class AdminTest extends WP_Mock\Tools\TestCase { class AdminTest extends \WP_Mock\Tools\TestCase {
/** /**
* Test instance * Test instance
@@ -30,21 +30,21 @@ class AdminTest extends WP_Mock\Tools\TestCase {
/** /**
* Set up test environment * Set up test environment
*/ */
public function setUp(): void { public function setUp() {
parent::setUp(); parent::setUp();
// Set up mocks // Set up mocks
WP_Mock::setUp(); WP_Mock::setUp();
// Mock Core class // Mock Core class
$this->core = $this->createMock(Core::class); $this->core = $this->createMock(Core::class);
// Set up WordPress function mocks // Set up WordPress function mocks
WP_Mock::userFunction('add_action', [ WP_Mock::userFunction('add_action', [
'times' => 1, 'times' => 1,
'args' => ['admin_enqueue_scripts', \WP_Mock\Functions::type('array')], 'args' => ['admin_enqueue_scripts', \WP_Mock\Functions::type('array')],
]); ]);
// Create instance of Admin class // Create instance of Admin class
$this->admin = new Admin($this->core); $this->admin = new Admin($this->core);
} }
@@ -52,7 +52,7 @@ class AdminTest extends WP_Mock\Tools\TestCase {
/** /**
* Tear down test environment * Tear down test environment
*/ */
public function tearDown(): void { public function tearDown() {
WP_Mock::tearDown(); WP_Mock::tearDown();
parent::tearDown(); parent::tearDown();
} }
@@ -74,38 +74,38 @@ class AdminTest extends WP_Mock\Tools\TestCase {
'times' => 1, 'times' => 1,
'args' => ['wpst-admin-styles', \WP_Mock\Functions::type('string'), [], \WP_Mock\Functions::type('string')], 'args' => ['wpst-admin-styles', \WP_Mock\Functions::type('string'), [], \WP_Mock\Functions::type('string')],
]); ]);
WP_Mock::userFunction('wp_enqueue_script', [ WP_Mock::userFunction('wp_enqueue_script', [
'times' => 1, 'times' => 1,
'args' => ['wpst-admin-scripts', \WP_Mock\Functions::type('string'), ['jquery'], \WP_Mock\Functions::type('string'), true], 'args' => ['wpst-admin-scripts', \WP_Mock\Functions::type('string'), ['jquery'], \WP_Mock\Functions::type('string'), true],
]); ]);
WP_Mock::userFunction('wp_localize_script', [ WP_Mock::userFunction('wp_localize_script', [
'times' => 1, 'times' => 1,
'args' => ['wpst-admin-scripts', 'wpstData', \WP_Mock\Functions::type('array')], 'args' => ['wpst-admin-scripts', 'wpstData', \WP_Mock\Functions::type('array')],
]); ]);
WP_Mock::userFunction('esc_html__', [ WP_Mock::userFunction('esc_html__', [
'times' => 2, 'times' => 2,
'args' => [\WP_Mock\Functions::type('string'), 'wp-plugin-starter-template'], 'args' => [\WP_Mock\Functions::type('string'), 'wp-plugin-starter-template'],
'return' => 'Translated string', 'return' => 'Translated string',
]); ]);
WP_Mock::userFunction('admin_url', [ WP_Mock::userFunction('admin_url', [
'times' => 1, 'times' => 1,
'args' => ['admin-ajax.php'], 'args' => ['admin-ajax.php'],
'return' => 'http://example.org/wp-admin/admin-ajax.php', 'return' => 'http://example.org/wp-admin/admin-ajax.php',
]); ]);
WP_Mock::userFunction('wp_create_nonce', [ WP_Mock::userFunction('wp_create_nonce', [
'times' => 1, 'times' => 1,
'args' => ['wpst-admin-nonce'], 'args' => ['wpst-admin-nonce'],
'return' => '1234567890', 'return' => '1234567890',
]); ]);
// Call the method // Call the method
$this->admin->enqueue_admin_assets('plugins.php'); $this->admin->enqueue_admin_assets('plugins.php');
// If we get here, the test passed // If we get here, the test passed
$this->assertTrue(true); $this->assertTrue(true);
} }
+6 -6
View File
@@ -10,7 +10,7 @@ use WPALLSTARS\PluginStarterTemplate\Core;
/** /**
* Core test case. * Core test case.
*/ */
class CoreTest extends WP_Mock\Tools\TestCase { class CoreTest extends \WP_Mock\Tools\TestCase {
/** /**
* Test instance * Test instance
@@ -22,12 +22,12 @@ class CoreTest extends WP_Mock\Tools\TestCase {
/** /**
* Set up test environment * Set up test environment
*/ */
public function setUp(): void { public function setUp() {
parent::setUp(); parent::setUp();
// Set up mocks // Set up mocks
WP_Mock::setUp(); WP_Mock::setUp();
// Create instance of Core class // Create instance of Core class
$this->core = new Core(); $this->core = new Core();
} }
@@ -35,7 +35,7 @@ class CoreTest extends WP_Mock\Tools\TestCase {
/** /**
* Tear down test environment * Tear down test environment
*/ */
public function tearDown(): void { public function tearDown() {
WP_Mock::tearDown(); WP_Mock::tearDown();
parent::tearDown(); parent::tearDown();
} }
@@ -53,7 +53,7 @@ class CoreTest extends WP_Mock\Tools\TestCase {
*/ */
public function test_filter_content() { public function test_filter_content() {
$content = 'Test content'; $content = 'Test content';
// Test that filter_content returns the content // Test that filter_content returns the content
$this->assertEquals($content, $this->core->filter_content($content)); $this->assertEquals($content, $this->core->filter_content($content));
} }
+7 -7
View File
@@ -3,7 +3,7 @@
* Plugin Name: WordPress Plugin Starter Template * Plugin Name: WordPress Plugin Starter Template
* Plugin URI: https://www.wpallstars.com * Plugin URI: https://www.wpallstars.com
* Description: A comprehensive starter template for WordPress plugins with best practices for AI-assisted development. * Description: A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.
* Version: 0.1.3 * Version: 0.1.6
* Author: Your Name & The WPALLSTARS Team * Author: Your Name & The WPALLSTARS Team
* Author URI: https://www.wpallstars.com * Author URI: https://www.wpallstars.com
* License: GPL-2.0+ * License: GPL-2.0+
@@ -27,12 +27,12 @@
*/ */
// If this file is called directly, abort. // If this file is called directly, abort.
if (!defined('WPINC')) { if ( ! defined( 'WPINC' ) ) {
die; die;
} }
// Load the main plugin class // Load the main plugin class.
require_once plugin_dir_path(__FILE__) . 'includes/plugin.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/plugin.php';
// Initialize the plugin // Initialize the plugin.
new WPALLSTARS\PluginStarterTemplate\Plugin(__FILE__, '0.1.3'); new WPALLSTARS\PluginStarterTemplate\Plugin( __FILE__, '0.1.7' );