Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31d475beca | ||
|
|
af48e84614 | ||
|
|
5083fcee50 | ||
|
|
79d1314aed | ||
|
|
2f4d88f8dd | ||
|
|
bfac63799b | ||
|
|
9d3e67d16b |
No files matched your search
@@ -150,7 +150,15 @@ If the plugin is hosted on WordPress.org:
|
||||
|
||||
After releasing a new version:
|
||||
|
||||
1. Update the wiki documentation if needed
|
||||
2. Announce the release in relevant channels
|
||||
3. Monitor for any issues or feedback
|
||||
4. Start planning the next release
|
||||
1. Update the wiki documentation:
|
||||
- Update the Changelog.md file in the .wiki directory to match the main CHANGELOG.md
|
||||
- Add the new version information to the Home.md file in the Latest Updates section
|
||||
- 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
|
||||
@@ -8,6 +8,7 @@ The wiki documentation is organized into the following sections:
|
||||
|
||||
1. **User Documentation**:
|
||||
- Home
|
||||
- Starter Prompt (must be listed before Installation Guide)
|
||||
- Installation Guide
|
||||
- Usage Instructions
|
||||
- Frequently Asked Questions
|
||||
@@ -88,8 +89,10 @@ Documentation should be updated:
|
||||
|
||||
1. Identify the relevant wiki file(s) in the `.wiki/` directory
|
||||
2. Make the necessary changes
|
||||
3. Commit and push the changes to the `main` branch
|
||||
4. The GitHub Actions workflow will automatically sync the changes with the GitHub wiki
|
||||
3. **Always ensure the Changelog.md in the wiki is updated to match the main CHANGELOG.md file**
|
||||
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
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ jobs:
|
||||
build:
|
||||
name: Build and Release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
@@ -36,31 +38,31 @@ jobs:
|
||||
|
||||
- name: Create build directory
|
||||
run: |
|
||||
mkdir -p build/wp-plugin-starter-template
|
||||
cp -R *.php README.md LICENSE CHANGELOG.md readme.txt composer.json build/wp-plugin-starter-template/
|
||||
cp -R admin includes languages vendor build/wp-plugin-starter-template/
|
||||
mkdir -p build/wp-plugin-starter-template/assets/banner build/wp-plugin-starter-template/assets/icon build/wp-plugin-starter-template/assets/screenshots
|
||||
if [ -d "assets/banner" ]; then cp -R assets/banner/* build/wp-plugin-starter-template/assets/banner/; fi
|
||||
if [ -d "assets/icon" ]; then cp -R assets/icon/* build/wp-plugin-starter-template/assets/icon/; fi
|
||||
if [ -d "assets/screenshots" ]; then cp -R assets/screenshots/* build/wp-plugin-starter-template/assets/screenshots/; fi
|
||||
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-for-ai-coding/
|
||||
cp -R admin includes languages vendor build/wp-plugin-starter-template-for-ai-coding/
|
||||
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-for-ai-coding/assets/banner/; 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-for-ai-coding/assets/screenshots/; fi
|
||||
|
||||
- name: Create ZIP file
|
||||
run: |
|
||||
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 ..
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: wp-plugin-starter-template-${{ env.VERSION }}.zip
|
||||
files: wp-plugin-starter-template-for-ai-coding-${{ env.VERSION }}.zip
|
||||
name: Version ${{ env.VERSION }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
body: |
|
||||
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.
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -11,6 +11,8 @@ jobs:
|
||||
sync-wiki:
|
||||
name: Sync Wiki to GitHub
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v3
|
||||
@@ -23,29 +25,29 @@ jobs:
|
||||
- name: Clone wiki repository
|
||||
run: |
|
||||
git clone https://github.com/${{ github.repository }}.wiki.git wiki
|
||||
|
||||
|
||||
- name: Sync wiki content
|
||||
run: |
|
||||
# Remove all files from wiki repository except .git
|
||||
find wiki -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \;
|
||||
|
||||
|
||||
# Copy .wiki content to wiki repository
|
||||
cp -r .wiki/* wiki/
|
||||
|
||||
|
||||
# Go to wiki repository
|
||||
cd wiki
|
||||
|
||||
|
||||
# Add all changes
|
||||
git add .
|
||||
|
||||
|
||||
# Check if there are changes to commit
|
||||
if git diff --staged --quiet; then
|
||||
echo "No changes to commit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Commit changes
|
||||
git commit -m "Sync wiki from source repository"
|
||||
|
||||
|
||||
# Push changes
|
||||
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git
|
||||
@@ -13,7 +13,8 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['7.0', '7.4', '8.0']
|
||||
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
@@ -26,7 +27,15 @@ jobs:
|
||||
tools: composer:v2
|
||||
|
||||
- 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
|
||||
run: ./vendor/bin/phpunit
|
||||
@@ -34,7 +43,7 @@ jobs:
|
||||
code-style:
|
||||
name: Code Style
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
@@ -50,4 +59,4 @@ jobs:
|
||||
run: composer install --prefer-dist --no-progress
|
||||
|
||||
- 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
@@ -2,12 +2,48 @@
|
||||
|
||||
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)
|
||||
### Added
|
||||
- Initial release with basic template structure
|
||||
- Added core plugin architecture with OOP approach
|
||||
- Added admin interface components and styling
|
||||
- Added update mechanism with multiple source options
|
||||
- Added documentation templates for users and developers
|
||||
- Added AI workflow documentation for AI-assisted development
|
||||
- Added GitHub Actions workflows for automated tasks
|
||||
- Added wiki documentation templates
|
||||
- Core plugin architecture with OOP approach
|
||||
- Admin interface components and styling
|
||||
- Update mechanism with multiple source options
|
||||
- Documentation templates for users and developers
|
||||
- AI workflow documentation for AI-assisted development
|
||||
- GitHub Actions workflows for automated tasks
|
||||
- Wiki documentation templates
|
||||
@@ -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.
|
||||
|
||||
## 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
|
||||
|
||||
- [Starter Prompt](Starter-Prompt)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
## User Documentation
|
||||
* [Home](Home)
|
||||
* [Starter Prompt](Starter-Prompt)
|
||||
* [Installation Guide](Installation-Guide)
|
||||
* [Usage Instructions](Usage-Instructions)
|
||||
* [Frequently Asked Questions](Frequently-Asked-Questions)
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
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
|
||||
#### Added
|
||||
- Improved AI IDE context recommendations in documentation
|
||||
|
||||
@@ -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
|
||||
* **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts
|
||||
* **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
|
||||
* **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates
|
||||
* **AI Workflow Documentation**: Detailed guides for AI-assisted development
|
||||
* **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
|
||||
|
||||
@@ -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.
|
||||
|
||||
### 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
|
||||
|
||||
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
|
||||
4. CHANGELOG.md
|
||||
5. composer.json
|
||||
6. languages/pot file
|
||||
7. .github/workflows/
|
||||
8. .wiki/
|
||||
9. .ai-assistant.md
|
||||
10. includes/plugin.php
|
||||
11. includes/core.php
|
||||
12. admin/lib/admin.php
|
||||
6. package.json
|
||||
7. languages/pot file
|
||||
8. .github/workflows/
|
||||
9. .wiki/
|
||||
10. .ai-assistant.md
|
||||
11. includes/plugin.php
|
||||
12. includes/core.php
|
||||
13. admin/lib/admin.php
|
||||
|
||||
### 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.
|
||||
|
||||
### 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
|
||||
|
||||
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
|
||||
|
||||
### 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
|
||||
* Added: Improved AI IDE context recommendations in documentation
|
||||
* Enhanced: Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/
|
||||
|
||||
@@ -1 +1,75 @@
|
||||
<?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
@@ -14,9 +14,12 @@
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.0 || ^9.0",
|
||||
"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": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -1 +1,31 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,54 @@
|
||||
<?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.
|
||||
}
|
||||
}
|
||||
@@ -1 +1,58 @@
|
||||
<?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.
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -5,7 +5,7 @@ Tags: starter, template, boilerplate, plugin development, ai coding
|
||||
Requires at least: 5.0
|
||||
Tested up to: 6.4
|
||||
Requires PHP: 7.0
|
||||
Stable tag: 0.1.3
|
||||
Stable tag: 0.1.6
|
||||
License: GPL-2.0+
|
||||
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
|
||||
* **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts
|
||||
* **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
|
||||
* **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates
|
||||
* **AI Workflow Documentation**: Detailed guides for AI-assisted development
|
||||
* **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 =
|
||||
|
||||
@@ -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.
|
||||
|
||||
= 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 =
|
||||
|
||||
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
|
||||
4. CHANGELOG.md
|
||||
5. composer.json
|
||||
6. languages/pot file
|
||||
7. .github/workflows/
|
||||
8. .wiki/
|
||||
9. .ai-assistant.md
|
||||
10. includes/plugin.php
|
||||
11. includes/core.php
|
||||
12. admin/lib/admin.php
|
||||
6. package.json
|
||||
7. languages/pot file
|
||||
8. .github/workflows/
|
||||
9. .wiki/
|
||||
10. .ai-assistant.md
|
||||
11. includes/plugin.php
|
||||
12. includes/core.php
|
||||
13. admin/lib/admin.php
|
||||
|
||||
= 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.
|
||||
|
||||
= 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 ==
|
||||
|
||||
1. This is a placeholder for your plugin's screenshots. Replace with actual screenshots of your plugin in action.
|
||||
|
||||
== 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 =
|
||||
* Added: Improved AI IDE context recommendations in documentation
|
||||
* 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 ==
|
||||
|
||||
= 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 =
|
||||
Added improved AI IDE context recommendations and moved Starter Prompt to the wiki with guidance on pinning .ai-assistant.md and .ai-workflows/ files.
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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');
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Import commands.js
|
||||
*/
|
||||
import './commands';
|
||||
+14
-14
@@ -11,7 +11,7 @@ use WPALLSTARS\PluginStarterTemplate\Core;
|
||||
/**
|
||||
* Admin test case.
|
||||
*/
|
||||
class AdminTest extends WP_Mock\Tools\TestCase {
|
||||
class AdminTest extends \WP_Mock\Tools\TestCase {
|
||||
|
||||
/**
|
||||
* Test instance
|
||||
@@ -30,21 +30,21 @@ class AdminTest extends WP_Mock\Tools\TestCase {
|
||||
/**
|
||||
* Set up test environment
|
||||
*/
|
||||
public function setUp(): void {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
||||
// Set up mocks
|
||||
WP_Mock::setUp();
|
||||
|
||||
|
||||
// Mock Core class
|
||||
$this->core = $this->createMock(Core::class);
|
||||
|
||||
|
||||
// Set up WordPress function mocks
|
||||
WP_Mock::userFunction('add_action', [
|
||||
'times' => 1,
|
||||
'args' => ['admin_enqueue_scripts', \WP_Mock\Functions::type('array')],
|
||||
]);
|
||||
|
||||
|
||||
// Create instance of Admin class
|
||||
$this->admin = new Admin($this->core);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class AdminTest extends WP_Mock\Tools\TestCase {
|
||||
/**
|
||||
* Tear down test environment
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
public function tearDown() {
|
||||
WP_Mock::tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
@@ -74,38 +74,38 @@ class AdminTest extends WP_Mock\Tools\TestCase {
|
||||
'times' => 1,
|
||||
'args' => ['wpst-admin-styles', \WP_Mock\Functions::type('string'), [], \WP_Mock\Functions::type('string')],
|
||||
]);
|
||||
|
||||
|
||||
WP_Mock::userFunction('wp_enqueue_script', [
|
||||
'times' => 1,
|
||||
'args' => ['wpst-admin-scripts', \WP_Mock\Functions::type('string'), ['jquery'], \WP_Mock\Functions::type('string'), true],
|
||||
]);
|
||||
|
||||
|
||||
WP_Mock::userFunction('wp_localize_script', [
|
||||
'times' => 1,
|
||||
'args' => ['wpst-admin-scripts', 'wpstData', \WP_Mock\Functions::type('array')],
|
||||
]);
|
||||
|
||||
|
||||
WP_Mock::userFunction('esc_html__', [
|
||||
'times' => 2,
|
||||
'args' => [\WP_Mock\Functions::type('string'), 'wp-plugin-starter-template'],
|
||||
'return' => 'Translated string',
|
||||
]);
|
||||
|
||||
|
||||
WP_Mock::userFunction('admin_url', [
|
||||
'times' => 1,
|
||||
'args' => ['admin-ajax.php'],
|
||||
'return' => 'http://example.org/wp-admin/admin-ajax.php',
|
||||
]);
|
||||
|
||||
|
||||
WP_Mock::userFunction('wp_create_nonce', [
|
||||
'times' => 1,
|
||||
'args' => ['wpst-admin-nonce'],
|
||||
'return' => '1234567890',
|
||||
]);
|
||||
|
||||
|
||||
// Call the method
|
||||
$this->admin->enqueue_admin_assets('plugins.php');
|
||||
|
||||
|
||||
// If we get here, the test passed
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@ use WPALLSTARS\PluginStarterTemplate\Core;
|
||||
/**
|
||||
* Core test case.
|
||||
*/
|
||||
class CoreTest extends WP_Mock\Tools\TestCase {
|
||||
class CoreTest extends \WP_Mock\Tools\TestCase {
|
||||
|
||||
/**
|
||||
* Test instance
|
||||
@@ -22,12 +22,12 @@ class CoreTest extends WP_Mock\Tools\TestCase {
|
||||
/**
|
||||
* Set up test environment
|
||||
*/
|
||||
public function setUp(): void {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
||||
// Set up mocks
|
||||
WP_Mock::setUp();
|
||||
|
||||
|
||||
// Create instance of Core class
|
||||
$this->core = new Core();
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class CoreTest extends WP_Mock\Tools\TestCase {
|
||||
/**
|
||||
* Tear down test environment
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
public function tearDown() {
|
||||
WP_Mock::tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class CoreTest extends WP_Mock\Tools\TestCase {
|
||||
*/
|
||||
public function test_filter_content() {
|
||||
$content = 'Test content';
|
||||
|
||||
|
||||
// Test that filter_content returns the content
|
||||
$this->assertEquals($content, $this->core->filter_content($content));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: WordPress Plugin Starter Template
|
||||
* Plugin URI: https://www.wpallstars.com
|
||||
* 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 URI: https://www.wpallstars.com
|
||||
* License: GPL-2.0+
|
||||
@@ -27,12 +27,12 @@
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if (!defined('WPINC')) {
|
||||
die;
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
// Load the main plugin class
|
||||
require_once plugin_dir_path(__FILE__) . 'includes/plugin.php';
|
||||
// Load the main plugin class.
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/plugin.php';
|
||||
|
||||
// Initialize the plugin
|
||||
new WPALLSTARS\PluginStarterTemplate\Plugin(__FILE__, '0.1.3');
|
||||
// Initialize the plugin.
|
||||
new WPALLSTARS\PluginStarterTemplate\Plugin( __FILE__, '0.1.7' );
|
||||
Reference in new issue
Block a user