commit c7b590870c144281a93ec4fcead376b47f67cead Author: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Fri Apr 18 03:09:39 2025 +0100 Initial commit of WordPress Plugin Starter Template for AI Coding diff --git a/.ai-assistant.md b/.ai-assistant.md new file mode 100644 index 0000000..cadbf22 --- /dev/null +++ b/.ai-assistant.md @@ -0,0 +1,121 @@ +# AI Assistant Guide for WordPress Plugin Development + +This guide helps AI assistants understand the project structure, workflows, and best practices for this repository. + +## IMPORTANT: Repository Context + +This workspace may contain multiple repository folders. Always focus ONLY on the current repository you're working in and avoid hallucinating functionality from other repositories in the workspace. + +- **Current Repository**: wp-plugin-starter-template-for-ai-coding +- **Repository Purpose**: A comprehensive starter template for WordPress plugins with best practices for AI-assisted development +- **Repository Scope**: All code changes, documentation, and functionality discussions should be limited to THIS repository only + +## Project Overview + +- **Plugin Name**: WordPress Plugin Starter Template +- **Plugin Slug**: wp-plugin-starter-template +- **Text Domain**: wp-plugin-starter-template +- **Namespace**: WPALLSTARS\PluginStarterTemplate +- **Version**: 0.1.0 +- **Requires WordPress**: 5.0+ +- **Requires PHP**: 7.0+ +- **License**: GPL-2.0+ + +## Repository Structure + +- **wp-plugin-starter-template.php**: Main plugin file with plugin headers +- **includes/**: Core plugin functionality + - **plugin.php**: Main plugin class that initializes everything + - **core.php**: Core functionality class + - **updater.php**: Update mechanism for multiple sources +- **admin/**: Admin-specific functionality + - **lib/**: Admin classes + - **css/**: Admin stylesheets + - **js/**: Admin JavaScript files +- **languages/**: Translation files +- **.github/workflows/**: GitHub Actions workflows +- **.ai-workflows/**: Documentation for AI assistants +- **.wiki/**: Wiki documentation templates + +## Coding Standards + +This project follows the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/): + +- Use tabs for indentation, not spaces +- Follow WordPress naming conventions: + - Class names: `Class_Name` + - Function names: `function_name` + - Variable names: `$variable_name` +- Use proper DocBlocks for all classes, methods, and functions +- Ensure all user-facing strings are translatable +- Validate and sanitize all inputs +- Escape all outputs + +## Common Tasks + +For detailed instructions on common tasks like creating releases, adding features, fixing bugs, and testing previous versions, see **@.ai-workflows/release-process.md**. + +## Avoiding Cross-Repository Confusion + +When working in a multi-repository workspace, follow these guidelines to avoid confusion: + +1. **Verify Repository Context**: Always check which repository you're currently working in before making any changes or recommendations. + +2. **Limit Code Search Scope**: When searching for code or functionality, explicitly limit your search to the current repository. + +3. **Don't Assume Features**: Never assume that features present in one repository should be implemented in another. Each repository has its own specific purpose and feature set. + +4. **Repository-Specific Documentation**: Documentation should only reflect the actual features and functionality of the current repository. + +5. **Cross-Repository Inspiration**: If you want to implement a feature inspired by another repository, explicitly mention that it's a new feature being added, not an existing one. + +6. **Verify Before Implementation**: Before implementing or documenting a feature, verify that it actually exists in the current repository by checking the codebase. + +## Internationalization (i18n) + +All user-facing strings should be translatable: + +- Use `__()` for simple strings +- Use `_e()` for echoed strings +- Use `esc_html__()` for escaped strings +- Use `esc_html_e()` for escaped and echoed strings +- Always use the plugin's text domain: `wp-plugin-starter-template` + +Example: +```php +echo esc_html__('This is a translatable string', 'wp-plugin-starter-template'); +``` + +## Security Best Practices + +- Validate and sanitize all inputs +- Escape all outputs +- Use nonces for form submissions +- Use capability checks for user actions +- Follow the principle of least privilege + +## Documentation + +- Keep code comments up-to-date +- Update README.md and readme.txt when adding new features +- Update wiki documentation in the `.wiki/` directory +- Update changelog in both CHANGELOG.md and readme.txt + +## Git Workflow + +- Create feature branches from `main` +- Use descriptive branch names (e.g., `feature/add-settings-page`) +- Make atomic commits with clear messages +- Create pull requests for review +- Tag releases with version numbers (e.g., `v1.0.0`) + +## Developer Preferences + +When working with this repository, remember these preferences: + +1. Follow WordPress coding standards +2. Use OOP approach with namespaced classes +3. Keep code modular and maintainable +3. Reference these preferences in future interactions + +This ensures consistency across coding sessions and reduces the need for developers to repeatedly explain their preferences. diff --git a/.ai-workflows/multi-repo-workspace.md b/.ai-workflows/multi-repo-workspace.md new file mode 100644 index 0000000..dfd3f1b --- /dev/null +++ b/.ai-workflows/multi-repo-workspace.md @@ -0,0 +1,122 @@ +# Working in Multi-Repository Workspaces + +This document provides guidelines for AI assistants working in VSCode/VSCodium workspaces that contain multiple repository folders. + +## Understanding Multi-Repository Workspaces + +In VSCode/VSCodium, developers often create workspaces that include multiple repository folders. This allows them to work on related projects simultaneously or reference code from one project while working on another. + +### Common Workspace Configurations + +1. **Multiple WordPress Plugins**: A workspace containing several WordPress plugin repositories +2. **Plugin and Theme Combinations**: Repositories for both plugins and themes that work together +3. **Reference Repositories**: Including repositories purely for reference or inspiration +4. **Shared Libraries**: Repositories containing shared code used across multiple projects + +## Potential Issues in Multi-Repository Workspaces + +### 1. Feature Hallucination + +The most common issue is "feature hallucination" - assuming that features present in one repository should be implemented in another, or documenting non-existent features based on code seen in other repositories. + +### 2. Cross-Repository Code References + +Referencing or suggesting code patterns from one repository when working on another can lead to inconsistent coding styles and approaches. + +### 3. Documentation Confusion + +Creating documentation that includes features or functionality from other repositories in the workspace. + +### 4. Scope Creep + +Suggesting changes or improvements based on other repositories, leading to scope creep and feature bloat. + +## Best Practices for AI Assistants + +### 1. Repository Verification + +**ALWAYS** verify which repository you're currently working in before: +- Making code suggestions +- Creating or updating documentation +- Discussing features or functionality +- Implementing new features + +### 2. Explicit Code Search Scoping + +When searching for code or functionality: +- Explicitly limit searches to the current repository +- Use repository-specific paths in search queries +- Verify search results are from the current repository before using them + +### 3. Feature Verification Process + +Before documenting or implementing a feature: + +1. **Check the codebase**: Use the codebase-retrieval tool to search for relevant code in the current repository +2. **Verify functionality**: Look for actual implementation, not just references or comments +3. **Check documentation**: Review existing documentation to understand intended functionality +4. **Ask for clarification**: If uncertain, ask the developer to confirm the feature's existence or scope + +### 4. Documentation Guidelines + +When creating or updating documentation: + +1. **Repository-specific content**: Only document features and functionality that exist in the current repository +2. **Verify before documenting**: Check the codebase to confirm features actually exist +3. **Clear boundaries**: Make it clear which repository the documentation applies to +4. **Accurate feature descriptions**: Describe features as they are implemented, not as they might be in other repositories + +### 5. Cross-Repository Inspiration + +When implementing features inspired by other repositories: + +1. **Explicit attribution**: Clearly state that the feature is inspired by another repository +2. **New implementation**: Treat it as a new feature being added, not an existing one +3. **Repository-appropriate adaptation**: Adapt the feature to fit the current repository's architecture and style +4. **Developer confirmation**: Confirm with the developer that adding the feature is appropriate + +## Repository Context Verification Checklist + +Before making significant changes or recommendations, run through this checklist: + +- [ ] Verified current working directory/repository +- [ ] Confirmed repository name and purpose +- [ ] Checked that code searches are limited to current repository +- [ ] Verified features exist in current repository before documenting them +- [ ] Ensured documentation reflects only the current repository's functionality +- [ ] Confirmed that any cross-repository inspiration is clearly marked as new functionality + +## Example Verification Workflow + +1. **Check current repository**: + ``` + pwd + git remote -v + ``` + +2. **Verify feature existence**: + ``` + # Use codebase-retrieval to search for the feature + # Look for actual implementation, not just references + ``` + +3. **Document with clear repository context**: + ``` + # Always include repository name in documentation + # Be specific about which features are included + ``` + +4. **When suggesting new features**: + ``` + # Clearly state if inspired by another repository + # Explain why it's appropriate for the current repository + ``` + +## Handling Repository Switching + +When the developer switches between repositories in the workspace: + +1. **Acknowledge the switch**: Confirm the new repository context +2. **Reset context**: Don't carry over assumptions from the previous repository +3. **Verify new environment**: Check the structure and features of the new repository +4. **Update documentation references**: Ensure you're referencing documentation specific to the new repository diff --git a/.ai-workflows/readme.md b/.ai-workflows/readme.md new file mode 100644 index 0000000..6c05206 --- /dev/null +++ b/.ai-workflows/readme.md @@ -0,0 +1,19 @@ +# AI Workflows + +This directory contains workflow documentation for AI assistants working with this repository. + +## Contents + +- **bug-fixing.md**: Guidelines for identifying and fixing bugs in the codebase +- **code-review.md**: Standards and procedures for reviewing code changes +- **dev-prefs-memory.md**: Persistent memory of developer preferences +- **feature-development.md**: Process for developing new features +- **folder-structure.md**: Documentation of the plugin's folder structure and naming conventions +- **git-workflow.md**: Detailed git workflow and branch management guidelines +- **incremental-development.md**: Time-efficient approach for incremental development and testing +- **local-env-vars.md**: Local development environment paths and URLs +- **multi-repo-workspace.md**: Guidelines for working in workspaces with multiple repositories +- **release-process.md**: Steps for preparing and publishing new releases +- **wiki-documentation.md**: Guidelines for maintaining wiki documentation + +These documents help ensure consistent quality and approach when using AI tools to assist with development tasks. diff --git a/.ai-workflows/release-process.md b/.ai-workflows/release-process.md new file mode 100644 index 0000000..8a8cc6c --- /dev/null +++ b/.ai-workflows/release-process.md @@ -0,0 +1,156 @@ +# Release Process Guide for AI Assistants + +This document outlines the process for preparing and publishing new releases of the WordPress Plugin Starter Template. + +## Release Workflow Overview + +1. Create a version branch +2. Update version numbers in all required files +3. Build and test the plugin +4. Commit version changes +5. Create version tags +6. Push to remote repositories +7. Merge into main branch + +## Detailed Steps + +### 1. Create a Version Branch + +Always start by creating a version branch from the latest main branch: + +```bash +git checkout main +git pull origin main # Critical step - never skip this +git checkout -b v{MAJOR}.{MINOR}.{PATCH} +``` + +Example: `git checkout -b v1.0.0` + +### 2. Update Version Numbers + +Update version numbers in all required files: + +1. **Main plugin file** (wp-plugin-starter-template.php): + - Update the `Version:` header + - Update the version parameter in the Plugin class instantiation + +2. **readme.txt**: + - Update the `Stable tag:` value + - Add a new section to the changelog + +3. **README.md**: + - Update version references + - Add new section to the changelog + +4. **CHANGELOG.md**: + - Add a new version section at the top + +5. **languages/wp-plugin-starter-template.pot**: + - Update the `Project-Id-Version` header + +### 3. Build and Test the Plugin + +Build the plugin with the new version: + +```bash +./build.sh {MAJOR}.{MINOR}.{PATCH} +``` + +This will: +- Create a clean build in the `build/` directory +- Generate a ZIP file for distribution +- Deploy to a local WordPress installation if configured + +Test the plugin thoroughly: +- Test with the latest WordPress version +- Test with the minimum supported WordPress version (5.0) +- Test with PHP 7.0+ (minimum supported version) +- Test all features and functionality + +### 4. Commit Version Changes + +Commit all version changes: + +```bash +git add wp-plugin-starter-template.php readme.txt README.md CHANGELOG.md languages/wp-plugin-starter-template.pot +git commit -m "Version {MAJOR}.{MINOR}.{PATCH} - [brief description]" +``` + +### 5. Create Version Tags + +Create version tags: + +```bash +git tag -a v{MAJOR}.{MINOR}.{PATCH} -m "Version {MAJOR}.{MINOR}.{PATCH}" +git tag -a v{MAJOR}.{MINOR}.{PATCH}-stable -m "Stable version {MAJOR}.{MINOR}.{PATCH}" +``` + +The `-stable` tag is used by Git Updater to identify the stable version. + +### 6. Push to Remote Repositories + +Push the version branch and tags to remote repositories: + +```bash +# Push to GitHub +git push github refs/heads/v{MAJOR}.{MINOR}.{PATCH}:refs/heads/v{MAJOR}.{MINOR}.{PATCH} +git push github refs/tags/v{MAJOR}.{MINOR}.{PATCH}:refs/tags/v{MAJOR}.{MINOR}.{PATCH} +git push github refs/tags/v{MAJOR}.{MINOR}.{PATCH}-stable:refs/tags/v{MAJOR}.{MINOR}.{PATCH}-stable + +# Push to Gitea +git push gitea refs/heads/v{MAJOR}.{MINOR}.{PATCH}:refs/heads/v{MAJOR}.{MINOR}.{PATCH} +git push gitea refs/tags/v{MAJOR}.{MINOR}.{PATCH}:refs/tags/v{MAJOR}.{MINOR}.{PATCH} +git push gitea refs/tags/v{MAJOR}.{MINOR}.{PATCH}-stable:refs/tags/v{MAJOR}.{MINOR}.{PATCH}-stable +``` + +### 7. Merge into Main Branch + +Merge the version branch into the main branch: + +```bash +git checkout main +git merge v{MAJOR}.{MINOR}.{PATCH} --no-ff -m "Merge v{MAJOR}.{MINOR}.{PATCH} into main" +git push github main +git push gitea main +``` + +## Version Numbering Guidelines + +Follow semantic versioning (MAJOR.MINOR.PATCH): + +- **MAJOR**: Incompatible API changes +- **MINOR**: Add functionality in a backward-compatible manner +- **PATCH**: Backward-compatible bug fixes + +Examples: +- Bug fix: 1.0.0 → 1.0.1 +- New feature: 1.0.0 → 1.1.0 +- Breaking change: 1.0.0 → 2.0.0 + +## GitHub Actions Workflow + +When you push a tag, the GitHub Actions workflow will: + +1. Build the plugin +2. Create a ZIP file +3. Create a GitHub release +4. Attach the ZIP file to the release + +You can monitor the workflow in the "Actions" tab of the GitHub repository. + +## WordPress.org Deployment (If Applicable) + +If the plugin is hosted on WordPress.org: + +1. Ensure the `readme.txt` file is properly formatted +2. Ensure the stable tag matches the new version +3. Use the WordPress.org SVN repository to deploy the new version + +## Post-Release Tasks + +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 diff --git a/.ai-workflows/wiki-documentation.md b/.ai-workflows/wiki-documentation.md new file mode 100644 index 0000000..3d95550 --- /dev/null +++ b/.ai-workflows/wiki-documentation.md @@ -0,0 +1,181 @@ +# Wiki Documentation Guide for AI Assistants + +This document provides guidelines for maintaining and updating the wiki documentation for the WordPress Plugin Starter Template. + +## Wiki Structure + +The wiki documentation is organized into the following sections: + +1. **User Documentation**: + - Home + - Installation Guide + - Usage Instructions + - Frequently Asked Questions + - Troubleshooting + +2. **Developer Documentation**: + - Architecture Overview + - Customization Guide + - Extending the Plugin + - Coding Standards + - Release Process + +3. **AI Documentation**: + - AI Workflow Documentation + +4. **Additional Resources**: + - Changelog + - Contributing + +## Wiki Files Location + +The wiki documentation is stored in the `.wiki/` directory in the repository. This allows: + +1. Version control of wiki content alongside the code +2. Automated synchronization with the GitHub wiki using GitHub Actions +3. Easy contribution to documentation through pull requests + +## Synchronization Process + +When changes are pushed to the `.wiki/` directory in the `main` branch, the GitHub Actions workflow `.github/workflows/sync-wiki.yml` automatically synchronizes these changes with the GitHub wiki. + +## Documentation Standards + +### General Guidelines + +- Use clear, concise language +- Follow Markdown formatting conventions +- Include code examples where appropriate +- Use screenshots or diagrams for complex concepts +- Keep documentation up-to-date with code changes + +### Markdown Formatting + +- Use `#` for main headings +- Use `##` for section headings +- Use `###` for subsection headings +- Use backticks for inline code: `code` +- Use triple backticks for code blocks: + ```php + // Code example + function example() { + return true; + } + ``` +- Use bullet points for lists +- Use numbered lists for sequential steps +- Use blockquotes for important notes: > Note + +### Code Examples + +- Include complete, working code examples +- Use proper syntax highlighting +- Include comments to explain complex parts +- Follow WordPress coding standards in examples + +## Updating Documentation + +### When to Update + +Documentation should be updated: + +1. When adding new features +2. When changing existing functionality +3. When fixing bugs that affect user experience +4. When improving or clarifying existing documentation + +### How to Update + +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 + +### Creating New Pages + +To create a new wiki page: + +1. Create a new Markdown file in the `.wiki/` directory +2. Name the file according to the page title (e.g., `New-Feature.md`) +3. Add a link to the new page in the appropriate section of `Home.md` +4. Add a link to the new page in `_Sidebar.md` + +## Repository-Specific Documentation + +When working in a multi-repository workspace, it's critical to ensure that wiki documentation accurately reflects the features and functionality of the **current repository only**. + +### Avoiding Cross-Repository Confusion + +1. **Verify Features Before Documenting**: + - Always verify that a feature exists in the current repository before documenting it + - Use `codebase-retrieval` to search for feature implementations + - Check the actual code, not just comments or references + +2. **Repository-Specific Content**: + - Document only features that exist in the current repository + - Don't assume features from other repositories are present in this one + - Be explicit about which repository the documentation applies to + +3. **Feature Inspiration vs. Existing Features**: + - If documenting a feature inspired by another repository but not yet implemented, clearly mark it as a proposed feature + - Don't document features as if they exist when they're only planned or inspired by other repositories + +4. **Cross-Repository References**: + - If referencing functionality from another repository, clearly indicate that it's external + - Use phrases like "unlike Repository X, this plugin does not include..." + +For detailed guidelines on working in multi-repository workspaces, see **@.ai-workflows/multi-repo-workspace.md**. + +## Best Practices + +### Content Guidelines + +- Use clear, concise language +- Include step-by-step instructions for complex tasks +- Use screenshots or diagrams to illustrate concepts +- Provide code examples for developers +- Keep the documentation organized and easy to navigate + +### Formatting Guidelines + +- Use consistent Markdown formatting +- Use headings to create a clear hierarchy +- Use lists for steps or related items +- Use tables for structured data +- Use code blocks for code examples + +### Maintenance Guidelines + +- Review documentation regularly for accuracy +- Update documentation when code changes +- Remove outdated information +- Add new documentation for new features +- Respond to user feedback about documentation + +## User-Focused Documentation + +When writing documentation for users: + +1. Assume minimal technical knowledge +2. Provide clear, step-by-step instructions +3. Include screenshots for visual guidance +4. Explain technical terms when necessary +5. Focus on what users want to accomplish + +## Developer-Focused Documentation + +When writing documentation for developers: + +1. Assume familiarity with WordPress development +2. Provide technical details and explanations +3. Include code examples and API references +4. Explain architectural decisions +5. Focus on how to extend or customize the plugin + +## Responding to User Feedback + +Improve documentation based on user feedback: + +1. Monitor GitHub issues and WordPress.org support forums for common questions +2. Update the FAQ and troubleshooting sections based on user feedback +3. Add new examples or clarifications based on user questions diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..010e8c7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +on: + push: + tags: + - 'v*' + - 'v*-stable' + +jobs: + build: + name: Build and Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: mbstring, intl, zip + tools: composer:v2 + + - name: Get tag name + id: get_tag + run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Extract version from tag + id: get_version + run: | + VERSION=$(echo ${{ env.TAG }} | sed 's/^v//' | sed 's/-stable$//') + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Install dependencies + run: composer install --no-dev --optimize-autoloader + + - 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 + + - 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*" + cd .. + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + files: wp-plugin-starter-template-${{ 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 }} diff --git a/.github/workflows/sync-wiki.yml b/.github/workflows/sync-wiki.yml new file mode 100644 index 0000000..e56b4a3 --- /dev/null +++ b/.github/workflows/sync-wiki.yml @@ -0,0 +1,51 @@ +name: Sync Wiki + +on: + push: + branches: + - main + paths: + - '.wiki/**' + +jobs: + sync-wiki: + name: Sync Wiki to GitHub + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Configure Git + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + - 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..e9a223a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,53 @@ +name: Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: PHP ${{ matrix.php-versions }} + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['7.0', '7.4', '8.0'] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl, zip + tools: composer:v2 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run tests + run: ./vendor/bin/phpunit + + code-style: + name: Code Style + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: mbstring, intl, zip + tools: composer:v2, phpcs + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run PHPCS + run: ./vendor/bin/phpcs --standard=WordPress diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fda86fb --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# Operating System Files +.DS_Store +Thumbs.db +ehthumbs.db +Desktop.ini +$RECYCLE.BIN/ + +# IDE Files +.idea/ +.vscode/ +*.sublime-project +*.sublime-workspace +*.komodoproject +.komodotools/ +*.code-workspace + +# Dependency Directories +node_modules/ +vendor/ +bower_components/ + +# Build Files +build/ +dist/ +*.zip +*.tar.gz +*.tgz + +# Composer +composer.phar + +# WordPress +wp-config.php +wp-content/advanced-cache.php +wp-content/backup-db/ +wp-content/backups/ +wp-content/blogs.dir/ +wp-content/cache/ +wp-content/upgrade/ +wp-content/uploads/ +wp-content/wp-cache-config.php +wp-content/plugins/hello.php + +# Log Files +*.log +logs/ +error_log + +# Environment Files +.env +.env.* +!.env.example + +# Temporary Files +tmp/ +temp/ +*.tmp +*.bak +*.swp +*~ + +# Test Coverage +coverage/ +.phpunit.result.cache diff --git a/.wiki/Changelog.md b/.wiki/Changelog.md new file mode 100644 index 0000000..62e8cbf --- /dev/null +++ b/.wiki/Changelog.md @@ -0,0 +1,13 @@ +# Changelog + +This page documents all notable changes to the WordPress Plugin Starter Template. + +## Version 0.1.0 (2025-04-17) +- 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 diff --git a/.wiki/Frequently-Asked-Questions.md b/.wiki/Frequently-Asked-Questions.md new file mode 100644 index 0000000..8cce44b --- /dev/null +++ b/.wiki/Frequently-Asked-Questions.md @@ -0,0 +1,118 @@ +# Frequently Asked Questions + +This page answers common questions about the WordPress Plugin Starter Template. + +## General Questions + +### What is the WordPress Plugin Starter Template? + +The WordPress Plugin Starter Template is a comprehensive starting point for developing WordPress plugins. It provides a well-structured codebase, documentation templates, and best practices to help you create high-quality WordPress plugins efficiently. + +### Who is this template for? + +This template is designed for: +- WordPress plugin developers looking for a solid foundation +- Developers who want to leverage AI assistance in their development workflow +- Anyone who wants to create a WordPress plugin following best practices + +### Is this template suitable for all types of plugins? + +Yes, this template provides a solid foundation for most WordPress plugins. It's designed to be flexible and can be adapted for various types of plugins, from simple utilities to complex applications. + +## Usage Questions + +### How do I use this template? + +This template is meant to be a starting point for your own plugin development. You should: + +1. Copy the template files to your new plugin directory +2. Rename files and update namespaces to match your plugin name +3. Update plugin headers in the main PHP file +4. Customize the functionality to meet your specific needs +5. Update documentation to reflect your plugin's features + +For detailed instructions, see the [Usage Instructions](Usage-Instructions) page. + +### Do I need to keep the original credits? + +While not strictly required, we appreciate if you keep a reference to the original template in your plugin's documentation. This helps others discover the template and contributes to the open-source community. + +### Can I use this template for commercial plugins? + +Yes, you can use this template for both free and commercial plugins. The template is licensed under GPL-2.0+, which allows for commercial use. + +## Technical Questions + +### What PHP version is required? + +The template requires PHP 7.0 or higher, which is the minimum recommended version for WordPress plugins today. + +### Does this template support Gutenberg blocks? + +The template doesn't include Gutenberg blocks by default, but it provides a structure that makes it easy to add them. You can extend the template to include block registration and block-specific assets. + +### How do I add custom post types or taxonomies? + +To add custom post types or taxonomies: + +1. Create a new class in `includes/` for your post type or taxonomy +2. Register the post type or taxonomy in the class constructor +3. Initialize the class in `includes/plugin.php` + +### How do I handle plugin updates? + +The template includes an update mechanism that supports multiple sources: + +- WordPress.org +- GitHub +- Gitea + +To configure the update mechanism: + +1. Update the plugin headers in the main PHP file +2. Customize the `updater.php` file if needed +3. Ensure your repository follows the required structure for updates + +## AI-Assisted Development Questions + +### How does this template support AI-assisted development? + +The template includes: + +1. Detailed documentation in the `.ai-assistant.md` file +2. Workflow guidelines in the `.ai-workflows/` directory +3. Clear code structure and comments that help AI understand the codebase +4. Best practices for AI-friendly code organization + +### What AI tools work best with this template? + +This template is designed to work well with various AI coding assistants, including: + +- GitHub Copilot +- Claude +- ChatGPT +- Other AI coding assistants + +### How do I use the AI workflow documentation? + +The AI workflow documentation in the `.ai-workflows/` directory provides guidelines for AI assistants working with this template. These files help ensure consistent, high-quality code and documentation when using AI tools for development. + +## Contributing Questions + +### How can I contribute to this template? + +Contributions are welcome! Please feel free to: + +1. Report bugs or issues +2. Suggest new features or improvements +3. Submit pull requests with bug fixes or enhancements + +For more information, see the [Contributing](Contributing) page. + +### Where can I report issues? + +You can report issues on the [GitHub repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues). + +### Is there a roadmap for future development? + +Yes, we maintain a roadmap of planned features and improvements. You can find it in the [GitHub repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/projects). diff --git a/.wiki/Home.md b/.wiki/Home.md new file mode 100644 index 0000000..94ae115 --- /dev/null +++ b/.wiki/Home.md @@ -0,0 +1,35 @@ +# WordPress Plugin Starter Template + +Welcome to the WordPress Plugin Starter Template wiki! This documentation provides comprehensive information about using, customizing, and extending the template for your WordPress plugin development. + +## Overview + +The WordPress Plugin Starter Template provides a solid foundation for developing WordPress plugins with AI assistance. It includes a well-structured codebase, documentation templates, and best practices to help you create high-quality WordPress plugins efficiently. + +## For Users + +- [Installation Guide](Installation-Guide): How to install and set up the plugin +- [Usage Instructions](Usage-Instructions): How to use the plugin's features +- [Frequently Asked Questions](Frequently-Asked-Questions): Common questions and answers +- [Troubleshooting](Troubleshooting): Solutions to common issues + +## For Developers + +- [Architecture Overview](Architecture-Overview): Understanding the plugin's structure +- [Customization Guide](Customization-Guide): How to customize the template for your needs +- [Extending the Plugin](Extending-the-Plugin): Adding new features and functionality +- [Coding Standards](Coding-Standards): Coding standards and best practices +- [Release Process](Release-Process): How to create and publish releases + +## For AI Assistants + +- [AI Workflow Documentation](AI-Workflow-Documentation): Guidelines for AI-assisted development + +## Additional Resources + +- [Changelog](Changelog): History of changes and updates +- [Contributing](Contributing): How to contribute to the project + +## Credits + +This template is maintained by [WPALLSTARS](https://www.wpallstars.com) and is based on the experience and best practices developed while creating the [Fix 'Plugin file does not exist' Notices](https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices) plugin. diff --git a/.wiki/Installation-Guide.md b/.wiki/Installation-Guide.md new file mode 100644 index 0000000..b93e0ad --- /dev/null +++ b/.wiki/Installation-Guide.md @@ -0,0 +1,81 @@ +# Installation Guide + +This guide provides instructions for installing and setting up the WordPress Plugin Starter Template. + +## Prerequisites + +Before installing the plugin, ensure you have: + +- WordPress 5.0 or higher +- PHP 7.0 or higher +- A WordPress site with administrator access + +## Installation Methods + +### Method 1: From WordPress.org (For Released Plugins) + +1. Log in to your WordPress admin dashboard. +2. Navigate to **Plugins > Add New**. +3. Search for "WordPress Plugin Starter Template". +4. Click **Install Now** next to the plugin. +5. After installation, click **Activate**. + +### Method 2: Manual Installation + +1. Download the latest release from the [GitHub repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/releases). +2. Log in to your WordPress admin dashboard. +3. Navigate to **Plugins > Add New**. +4. Click the **Upload Plugin** button at the top of the page. +5. Click **Choose File** and select the downloaded ZIP file. +6. Click **Install Now**. +7. After installation, click **Activate**. + +### Method 3: Using as a Template for Your Plugin + +1. Clone or download the repository: + ```bash + git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git your-plugin-name + ``` + +2. Navigate to your plugin directory: + ```bash + cd your-plugin-name + ``` + +3. Rename files and update namespaces: + - Rename `wp-plugin-starter-template.php` to your plugin name (e.g., `your-plugin-name.php`) + - Update the namespace from `WPALLSTARS\PluginStarterTemplate` to your own + - Update text domain from `wp-plugin-starter-template` to your own + +4. Update plugin headers in the main PHP file. + +5. Install dependencies: + ```bash + composer install + ``` + +6. Upload the plugin to your WordPress site or use the local development script: + ```bash + ./scripts/deploy-local.sh + ``` + +## Post-Installation + +After installing and activating the plugin, you should: + +1. Review the plugin settings (if applicable). +2. Customize the plugin for your specific needs. +3. Update documentation to reflect your plugin's features. + +## Troubleshooting Installation Issues + +If you encounter any issues during installation, please check the following: + +1. **Plugin Conflicts**: Deactivate other plugins to check for conflicts. +2. **Server Requirements**: Ensure your server meets the minimum requirements. +3. **File Permissions**: Check that your WordPress installation has the correct file permissions. +4. **Memory Limit**: Increase PHP memory limit if you encounter memory-related errors. + +## Next Steps + +After installation, refer to the [Usage Instructions](Usage-Instructions) to learn how to use and customize the plugin. diff --git a/.wiki/Usage-Instructions.md b/.wiki/Usage-Instructions.md new file mode 100644 index 0000000..9ef8781 --- /dev/null +++ b/.wiki/Usage-Instructions.md @@ -0,0 +1,121 @@ +# Usage Instructions + +This guide provides instructions for using and customizing the WordPress Plugin Starter Template for your own plugin development. + +## Basic Usage + +The WordPress Plugin Starter Template is designed to be a starting point for your WordPress plugin development. It provides a well-structured codebase that you can customize to create your own plugin. + +### Template Structure + +The template follows a modular structure: + +- `wp-plugin-starter-template.php`: Main plugin file with plugin headers +- `includes/`: Core plugin functionality + - `plugin.php`: Main plugin class that initializes everything + - `core.php`: Core functionality class + - `updater.php`: Update mechanism for multiple sources +- `admin/`: Admin-specific functionality + - `lib/`: Admin classes + - `css/`: Admin stylesheets + - `js/`: Admin JavaScript files +- `languages/`: Translation files +- `.github/workflows/`: GitHub Actions workflows +- `.ai-workflows/`: Documentation for AI assistants +- `.wiki/`: Wiki documentation templates + +### Customizing for Your Plugin + +1. **Rename Files and Update Namespaces**: + - Rename `wp-plugin-starter-template.php` to your plugin name + - Update the namespace from `WPALLSTARS\PluginStarterTemplate` to your own + - Update text domain from `wp-plugin-starter-template` to your own + +2. **Update Plugin Headers**: + - Edit the plugin headers in the main PHP file + - Update GitHub/Gitea repository URLs + +3. **Customize Functionality**: + - Modify the core functionality in `includes/core.php` + - Add your own classes as needed + - Customize admin interfaces in the `admin/` directory + +4. **Update Documentation**: + - Update README.md and readme.txt with your plugin information + - Customize wiki documentation in the `.wiki/` directory + +## Advanced Usage + +### Adding Admin Pages + +The template includes a structure for adding admin pages to the WordPress dashboard. To add an admin page: + +1. Uncomment the `add_admin_menu` method in `admin/lib/admin.php` +2. Customize the menu parameters to match your plugin +3. Create the corresponding render method for your admin page +4. Create template files in an `admin/templates/` directory + +### Adding Settings + +To add settings to your plugin: + +1. Create a settings class in `includes/settings.php` +2. Register settings using the WordPress Settings API +3. Create form fields for your settings +4. Handle settings validation and sanitization + +### Adding Custom Post Types or Taxonomies + +To add custom post types or taxonomies: + +1. Create a new class in `includes/` for your post type or taxonomy +2. Register the post type or taxonomy in the class constructor +3. Initialize the class in `includes/plugin.php` + +### Internationalization + +The template is ready for internationalization. To make your plugin translatable: + +1. Use translation functions for all user-facing strings: + - `__()` for simple strings + - `_e()` for echoed strings + - `esc_html__()` for escaped strings +2. Update the text domain in all translation functions +3. Generate a POT file for translations + +### Update Mechanism + +The template includes an update mechanism that supports multiple sources: + +- WordPress.org +- GitHub +- Gitea + +To configure the update mechanism: + +1. Update the plugin headers in the main PHP file +2. Customize the `updater.php` file if needed +3. Ensure your repository follows the required structure for updates + +## Building and Releasing + +The template includes scripts for building and releasing your plugin: + +1. **Building the Plugin**: + ```bash + ./build.sh + ``` + +2. **Deploying to a Local WordPress Installation**: + ```bash + ./scripts/deploy-local.sh + ``` + +3. **Creating a Release**: + - Tag a new version in Git + - Push the tag to GitHub + - The GitHub Actions workflow will create a release + +## Next Steps + +After customizing the template for your needs, refer to the [Architecture Overview](Architecture-Overview) to understand the plugin's structure in more detail. diff --git a/.wiki/_Sidebar.md b/.wiki/_Sidebar.md new file mode 100644 index 0000000..b62025a --- /dev/null +++ b/.wiki/_Sidebar.md @@ -0,0 +1,20 @@ +## User Documentation +* [Home](Home) +* [Installation Guide](Installation-Guide) +* [Usage Instructions](Usage-Instructions) +* [Frequently Asked Questions](Frequently-Asked-Questions) +* [Troubleshooting](Troubleshooting) + +## Developer Documentation +* [Architecture Overview](Architecture-Overview) +* [Customization Guide](Customization-Guide) +* [Extending the Plugin](Extending-the-Plugin) +* [Coding Standards](Coding-Standards) +* [Release Process](Release-Process) + +## AI Documentation +* [AI Workflow Documentation](AI-Workflow-Documentation) + +## Additional Resources +* [Changelog](Changelog) +* [Contributing](Contributing) diff --git a/.wordpress-org/README.md b/.wordpress-org/README.md new file mode 100644 index 0000000..89bb2cd --- /dev/null +++ b/.wordpress-org/README.md @@ -0,0 +1,65 @@ +# WordPress.org Plugin Assets + +This directory contains assets for the WordPress.org plugin repository. These assets are not included in the plugin itself but are used for the plugin's WordPress.org page. + +## Directory Structure + +- `assets/`: Contains images and other assets for the WordPress.org plugin page + - `banner-772x250.png`: Banner image for the plugin page (772x250 pixels) + - `banner-1544x500.png`: Retina banner image (1544x500 pixels) + - `icon-128x128.png`: Icon for the plugin (128x128 pixels) + - `icon-256x256.png`: Retina icon (256x256 pixels) + - `screenshot-1.png`: First screenshot + - `screenshot-2.png`: Second screenshot (if applicable) + - etc. + +## Asset Requirements + +### Banner + +- Regular: 772x250 pixels +- Retina: 1544x500 pixels +- PNG or JPG format +- The banner should be visually appealing and represent the plugin's purpose + +### Icon + +- Regular: 128x128 pixels +- Retina: 256x256 pixels +- PNG format with transparency +- The icon should be simple and recognizable + +### Screenshots + +- Should be at least 1200 pixels wide +- PNG or JPG format +- Should demonstrate the plugin's functionality +- Should be clear and easy to understand + +## WordPress.org Plugin Submission + +When submitting a plugin to WordPress.org, you need to: + +1. Create a plugin ZIP file without the `.wordpress-org` directory +2. Upload the ZIP file to WordPress.org +3. Upload the assets separately through the WordPress.org plugin repository interface + +For more information, see [WORDPRESS_ORG_SUBMISSION.md](WORDPRESS_ORG_SUBMISSION.md). + +## Asset Design Guidelines + +- Use consistent branding (colors, fonts, etc.) +- Keep the design simple and focused +- Ensure text is readable +- Use high-quality images +- Test how assets look on different devices and screen sizes + +## Updating Assets + +When updating assets: + +1. Replace the files in this directory +2. Upload the new assets to WordPress.org through the plugin repository interface +3. It may take some time for the changes to appear on WordPress.org + +For more information about WordPress.org plugin assets, see [WORDPRESS_ORG_ASSETS.md](WORDPRESS_ORG_ASSETS.md). diff --git a/.wordpress-org/WORDPRESS_ORG_ASSETS.md b/.wordpress-org/WORDPRESS_ORG_ASSETS.md new file mode 100644 index 0000000..e49fa5c --- /dev/null +++ b/.wordpress-org/WORDPRESS_ORG_ASSETS.md @@ -0,0 +1,83 @@ +# WordPress.org Plugin Assets Guide + +This document provides detailed information about the assets required for the WordPress.org plugin repository. + +## Required Assets + +### Banner + +The banner is displayed at the top of your plugin's page on WordPress.org. + +- **Regular Banner**: 772x250 pixels +- **Retina Banner**: 1544x500 pixels +- **Format**: PNG or JPG +- **File Names**: `banner-772x250.{png|jpg}` and `banner-1544x500.{png|jpg}` + +### Icon + +The icon is displayed next to your plugin's name in search results and on your plugin's page. + +- **Regular Icon**: 128x128 pixels +- **Retina Icon**: 256x256 pixels +- **Format**: PNG with transparency +- **File Names**: `icon-128x128.png` and `icon-256x256.png` + +### Screenshots + +Screenshots are displayed in the "Screenshots" tab on your plugin's page. + +- **Size**: At least 1200 pixels wide +- **Format**: PNG or JPG +- **File Names**: `screenshot-1.{png|jpg}`, `screenshot-2.{png|jpg}`, etc. +- **Description**: Screenshot descriptions are added in the `readme.txt` file under the "Screenshots" section + +## Asset Design Best Practices + +### Banner Design + +- **Keep it Simple**: Don't overcrowd the banner with too much information +- **Consistent Branding**: Use colors and fonts that match your plugin's branding +- **Readable Text**: Ensure any text is large enough to read +- **Purpose**: Clearly communicate what your plugin does +- **Avoid Small Details**: Small details may not be visible at the displayed size + +### Icon Design + +- **Simple and Recognizable**: The icon should be simple and easily recognizable +- **Consistent with Banner**: Use similar colors and style as your banner +- **Works at Small Sizes**: Ensure the icon is recognizable even at small sizes +- **Transparent Background**: Use a transparent background for the PNG + +### Screenshot Best Practices + +- **Show Key Features**: Showcase the most important features of your plugin +- **Logical Order**: Arrange screenshots in a logical order that tells a story +- **Clear and Focused**: Each screenshot should focus on a specific feature +- **Annotations**: Consider adding annotations to highlight important elements +- **Real-World Examples**: Show the plugin in action with real-world examples + +## Uploading Assets + +Assets are uploaded separately from your plugin code: + +1. Log in to your WordPress.org account +2. Navigate to your plugin's page +3. Click on the "Assets" tab +4. Upload your assets using the provided interface + +## Asset Updates + +When updating assets: + +1. Prepare the new assets following the guidelines above +2. Log in to your WordPress.org account +3. Navigate to your plugin's page +4. Click on the "Assets" tab +5. Upload the new assets +6. It may take some time for the changes to appear on WordPress.org + +## Additional Resources + +- [WordPress Plugin Developer Handbook](https://developer.wordpress.org/plugins/) +- [WordPress Plugin Directory Guidelines](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/) +- [WordPress Plugin Assets](https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/) diff --git a/.wordpress-org/WORDPRESS_ORG_SUBMISSION.md b/.wordpress-org/WORDPRESS_ORG_SUBMISSION.md new file mode 100644 index 0000000..87282c9 --- /dev/null +++ b/.wordpress-org/WORDPRESS_ORG_SUBMISSION.md @@ -0,0 +1,120 @@ +# WordPress.org Plugin Submission Guide + +This document provides a step-by-step guide for submitting your plugin to the WordPress.org plugin repository. + +## Before Submission + +### 1. Prepare Your Plugin + +- Ensure your plugin follows the [WordPress Plugin Guidelines](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/) +- Check that your plugin meets the [Plugin Directory Requirements](https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/) +- Verify that your plugin follows WordPress coding standards +- Test your plugin thoroughly on different WordPress versions + +### 2. Prepare Required Files + +- **readme.txt**: Create a readme.txt file following the [WordPress readme.txt standard](https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/) +- **Plugin Header**: Ensure your main plugin file includes the required plugin header +- **License**: Include the GPL v2 or later license +- **Assets**: Prepare banner, icon, and screenshots (see [WORDPRESS_ORG_ASSETS.md](WORDPRESS_ORG_ASSETS.md)) + +### 3. Create a Clean Build + +- Remove any development files (e.g., .git, node_modules, etc.) +- Remove any unnecessary files (e.g., .DS_Store, Thumbs.db, etc.) +- Create a ZIP file of your plugin + +## Submission Process + +### 1. Create a WordPress.org Account + +If you don't already have one, create an account on [WordPress.org](https://wordpress.org/). + +### 2. Submit Your Plugin + +1. Go to the [Add Your Plugin](https://wordpress.org/plugins/developers/add/) page +2. Fill out the submission form: + - Plugin Name + - Plugin URL (optional) + - Description + - Upload your plugin ZIP file +3. Agree to the terms and submit your plugin + +### 3. Wait for Review + +- The WordPress.org team will review your plugin +- This process can take several weeks +- You'll receive an email when your plugin is approved or if there are issues to address + +### 4. Address Review Feedback + +If the WordPress.org team provides feedback: + +1. Make the requested changes +2. Create a new ZIP file +3. Reply to the review email with the changes you've made +4. Attach the updated ZIP file or provide a link to download it + +### 5. Upload Assets + +Once your plugin is approved: + +1. Log in to your WordPress.org account +2. Navigate to your plugin's page +3. Click on the "Assets" tab +4. Upload your banner, icon, and screenshots + +## After Approval + +### 1. Set Up SVN Access + +WordPress.org uses Subversion (SVN) for plugin management: + +1. You'll receive SVN access details via email +2. Set up SVN on your local machine +3. Check out your plugin repository + +### 2. Manage Your Plugin with SVN + +Basic SVN commands for managing your plugin: + +```bash +# Check out your plugin repository +svn checkout https://plugins.svn.wordpress.org/your-plugin-name/ + +# Add new files +svn add new-file.php + +# Commit changes +svn commit -m "Description of changes" + +# Update your local copy +svn update +``` + +### 3. Release Updates + +To release a new version: + +1. Update the version number in your plugin file and readme.txt +2. Update the changelog in readme.txt +3. Test the new version thoroughly +4. Commit the changes to the `trunk` directory +5. Tag the new version: + ```bash + svn copy https://plugins.svn.wordpress.org/your-plugin-name/trunk https://plugins.svn.wordpress.org/your-plugin-name/tags/1.0.1 -m "Tagging version 1.0.1" + ``` + +## Best Practices + +- **Respond Promptly**: Respond to review feedback promptly +- **Be Patient**: The review process can take time +- **Be Thorough**: Test your plugin thoroughly before submission +- **Follow Guidelines**: Adhere to all WordPress.org guidelines +- **Maintain Your Plugin**: Regularly update your plugin to fix bugs and add features + +## Additional Resources + +- [WordPress Plugin Developer Handbook](https://developer.wordpress.org/plugins/) +- [WordPress Plugin Directory Guidelines](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/) +- [WordPress Plugin Developer FAQ](https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d72d884 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +All notable changes to this project should be documented both here and in the main Readme files. + +#### [0.1.0] - 2025-04-17 +#### Added +- Initial release with basic template structure +- 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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aa57bd6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ + + +302 Found + +

Found

+

The document has moved here.

+ diff --git a/README.md b/README.md new file mode 100644 index 0000000..500270f --- /dev/null +++ b/README.md @@ -0,0 +1,142 @@ +# WordPress Plugin Starter Template for AI Coding + +A comprehensive starter template for WordPress plugins with best practices for AI-assisted development. + +[![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/wp-plugin-starter-template-for-ai-coding)](https://wordpress.org/plugins/wp-plugin-starter-template-for-ai-coding/) +[![WordPress Plugin Rating](https://img.shields.io/wordpress/plugin/rating/wp-plugin-starter-template-for-ai-coding)](https://wordpress.org/plugins/wp-plugin-starter-template-for-ai-coding/) +[![WordPress Plugin Downloads](https://img.shields.io/wordpress/plugin/dt/wp-plugin-starter-template-for-ai-coding)](https://wordpress.org/plugins/wp-plugin-starter-template-for-ai-coding/) +[![License](https://img.shields.io/github/license/wpallstars/wp-plugin-starter-template-for-ai-coding)](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/LICENSE) + +## Description + +The WordPress Plugin Starter Template provides a solid foundation for developing WordPress plugins with AI assistance. It includes a well-structured codebase, documentation templates, and best practices to help you create high-quality WordPress plugins efficiently. + +### Key Features + +- **Well-structured codebase** following WordPress coding standards +- **Modular architecture** for easy maintenance and extension +- **Comprehensive documentation** templates for both users and developers +- **AI-friendly workflows** with detailed guidance for AI assistants +- **Git integration** with GitHub and Gitea support +- **Update mechanism** with multiple source options (WordPress.org, GitHub, Gitea) +- **Internationalization** ready with proper text domain setup +- **Admin interface** components for building settings pages + +### For Developers + +This template is designed to be a starting point for your WordPress plugin development. It provides: + +- A clean, well-organized file structure +- OOP approach with namespaced classes +- Separation of concerns (admin, core functionality) +- Documentation templates for wiki and readme files +- GitHub Actions workflows for automated tasks +- AI workflow documentation for AI-assisted development + +## Installation + +### From GitHub + +1. Download the latest release from the [GitHub repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/releases) +2. Upload the plugin files to the `/wp-content/plugins/wp-plugin-starter-template` directory, or install the plugin through the WordPress plugins screen directly +3. Activate the plugin through the 'Plugins' screen in WordPress + +### Using as a Template for Your Plugin + +1. Clone or download this repository +2. Rename the plugin directory and files to match your plugin name +3. Update namespaces, function prefixes, and text domains +4. Update plugin headers in the main PHP file +5. Customize the functionality to meet your specific needs +6. Update documentation to reflect your plugin's features + +## Usage + +### Basic Structure + +The template follows a modular structure: + +- `wp-plugin-starter-template.php`: Main plugin file with plugin headers +- `includes/`: Core plugin functionality + - `plugin.php`: Main plugin class that initializes everything + - `core.php`: Core functionality class + - `updater.php`: Update mechanism for multiple sources +- `admin/`: Admin-specific functionality + - `lib/`: Admin classes + - `css/`: Admin stylesheets + - `js/`: Admin JavaScript files +- `languages/`: Translation files +- `.github/workflows/`: GitHub Actions workflows +- `.ai-workflows/`: Documentation for AI assistants +- `.wiki/`: Wiki documentation templates + +### Customizing for Your Plugin + +1. **Rename Files and Update Namespaces**: + - Rename `wp-plugin-starter-template.php` to your plugin name + - Update the namespace from `WPALLSTARS\PluginStarterTemplate` to your own + - Update text domain from `wp-plugin-starter-template` to your own + +2. **Update Plugin Headers**: + - Edit the plugin headers in the main PHP file + - Update GitHub/Gitea repository URLs + +3. **Customize Functionality**: + - Modify the core functionality in `includes/core.php` + - Add your own classes as needed + - Customize admin interfaces in the `admin/` directory + +4. **Update Documentation**: + - Update README.md and readme.txt with your plugin information + - Customize wiki documentation in the `.wiki/` directory + +## Documentation + +Comprehensive documentation is available in the [Wiki](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki). + +### For Users + +- [Installation Guide](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Installation-Guide) +- [Usage Instructions](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Usage-Instructions) +- [Frequently Asked Questions](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Frequently-Asked-Questions) +- [Troubleshooting](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Troubleshooting) + +### For Developers + +- [Architecture Overview](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Architecture-Overview) +- [Extending the Plugin](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Extending-the-Plugin) +- [Coding Standards](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Coding-Standards) +- [Release Process](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki/Release-Process) + +### For AI Assistants + +The `.ai-assistant.md` file and `.ai-workflows/` directory contain detailed guidance for AI assistants working with this template. These resources help ensure consistent, high-quality code and documentation when using AI tools for development. + +## Contributing + +Contributions are welcome! Please feel free to submit a pull request or open an issue on the [GitHub repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding). + +### Development Process + +1. Fork the repository +2. Create a feature branch: `git checkout -b feature/your-feature-name` +3. Make your changes and commit them: `git commit -m 'Add some feature'` +4. Push to the branch: `git push origin feature/your-feature-name` +5. Submit a pull request + +## Credits + +This template is maintained by [WPALLSTARS](https://www.wpallstars.com) and is based on the experience and best practices developed while creating the [Fix 'Plugin file does not exist' Notices](https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices) plugin. + +## License + +This project is licensed under the GPL-2.0+ License - see the [LICENSE](LICENSE) file for details. + +## Changelog + +### 0.1.0 +- Initial release with basic template structure +- Added core plugin architecture +- Added admin interface components +- Added documentation templates +- Added AI workflow documentation diff --git a/admin/css/admin-styles.css b/admin/css/admin-styles.css new file mode 100644 index 0000000..cdd92d2 --- /dev/null +++ b/admin/css/admin-styles.css @@ -0,0 +1,145 @@ +/** + * Admin Styles + * + * @package WPALLSTARS\PluginStarterTemplate + */ + +/* General Admin Styles */ +.wpst-admin-page { + max-width: 1200px; + margin: 20px auto; + padding: 20px; + background: #fff; + border-radius: 5px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.wpst-admin-header { + margin-bottom: 20px; + padding-bottom: 20px; + border-bottom: 1px solid #eee; +} + +.wpst-admin-header h1 { + margin-top: 0; + color: #23282d; +} + +/* Admin Form Styles */ +.wpst-form-table { + width: 100%; + border-collapse: collapse; +} + +.wpst-form-table th { + text-align: left; + padding: 15px 10px 15px 0; + width: 200px; + vertical-align: top; +} + +.wpst-form-table td { + padding: 15px 0; + vertical-align: middle; +} + +.wpst-form-table input[type="text"], +.wpst-form-table input[type="number"], +.wpst-form-table select, +.wpst-form-table textarea { + width: 400px; + max-width: 100%; +} + +.wpst-form-table textarea { + min-height: 100px; +} + +.wpst-form-description { + color: #666; + font-style: italic; + margin-top: 5px; +} + +/* Admin Notices */ +.wpst-notice { + padding: 10px 15px; + margin: 15px 0; + border-radius: 3px; + border-left: 4px solid #00a0d2; + background: #f7fcff; +} + +.wpst-notice.success { + border-left-color: #46b450; + background: #ecf7ed; +} + +.wpst-notice.error { + border-left-color: #dc3232; + background: #fbeaea; +} + +.wpst-notice.warning { + border-left-color: #ffb900; + background: #fff8e5; +} + +/* Admin Cards */ +.wpst-card-container { + display: flex; + flex-wrap: wrap; + margin: 0 -10px; +} + +.wpst-card { + flex: 1 0 300px; + margin: 10px; + padding: 20px; + background: #fff; + border-radius: 3px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.wpst-card-header { + margin-bottom: 15px; + padding-bottom: 15px; + border-bottom: 1px solid #eee; +} + +.wpst-card-title { + margin: 0; + font-size: 16px; + font-weight: 600; +} + +.wpst-card-content { + margin-bottom: 15px; +} + +.wpst-card-footer { + padding-top: 15px; + border-top: 1px solid #eee; + text-align: right; +} + +/* Responsive Styles */ +@media screen and (max-width: 782px) { + .wpst-form-table th { + width: 100%; + display: block; + padding-bottom: 0; + } + + .wpst-form-table td { + width: 100%; + display: block; + } + + .wpst-form-table input[type="text"], + .wpst-form-table input[type="number"], + .wpst-form-table select, + .wpst-form-table textarea { + width: 100%; + } +} diff --git a/admin/css/update-source-selector.css b/admin/css/update-source-selector.css new file mode 100644 index 0000000..c545a75 --- /dev/null +++ b/admin/css/update-source-selector.css @@ -0,0 +1,143 @@ +/** + * Update Source Selector Styles + * + * @package WPALLSTARS\PluginStarterTemplate + */ + +/* Modal Styles */ +.wpst-modal { + display: none; + position: fixed; + z-index: 100000; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.4); +} + +.wpst-modal-content { + position: relative; + background-color: #fefefe; + margin: 10% auto; + padding: 20px; + border-radius: 5px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + width: 500px; + max-width: 90%; +} + +.wpst-modal-header { + padding-bottom: 15px; + border-bottom: 1px solid #eee; + margin-bottom: 15px; +} + +.wpst-modal-title { + margin: 0; + font-size: 18px; + font-weight: 600; +} + +.wpst-modal-close { + position: absolute; + top: 10px; + right: 15px; + font-size: 20px; + font-weight: bold; + color: #666; + cursor: pointer; +} + +.wpst-modal-close:hover, +.wpst-modal-close:focus { + color: #000; + text-decoration: none; +} + +.wpst-modal-body { + margin-bottom: 20px; +} + +.wpst-modal-footer { + padding-top: 15px; + border-top: 1px solid #eee; + text-align: right; +} + +/* Source Selection Styles */ +.wpst-source-options { + margin: 15px 0; +} + +.wpst-source-option { + display: block; + margin-bottom: 10px; + padding: 10px; + border: 1px solid #ddd; + border-radius: 3px; + cursor: pointer; +} + +.wpst-source-option:hover { + background-color: #f9f9f9; +} + +.wpst-source-option.selected { + border-color: #0073aa; + background-color: #f0f6fc; +} + +.wpst-source-option input[type="radio"] { + margin-right: 10px; +} + +.wpst-source-option-label { + font-weight: 600; +} + +.wpst-source-option-description { + margin-top: 5px; + color: #666; + font-size: 13px; +} + +/* Loading Indicator */ +.wpst-loading { + display: inline-block; + width: 20px; + height: 20px; + border: 2px solid rgba(0, 0, 0, 0.1); + border-radius: 50%; + border-top-color: #0073aa; + animation: wpst-spin 1s ease-in-out infinite; + margin-right: 10px; + vertical-align: middle; +} + +@keyframes wpst-spin { + to { + transform: rotate(360deg); + } +} + +/* Message Styles */ +.wpst-modal-message { + padding: 10px; + margin: 10px 0; + border-radius: 3px; + display: none; +} + +.wpst-modal-message.success { + background-color: #ecf7ed; + border: 1px solid #46b450; + color: #2a6f31; +} + +.wpst-modal-message.error { + background-color: #fbeaea; + border: 1px solid #dc3232; + color: #8a1f1f; +} diff --git a/admin/js/admin-scripts.js b/admin/js/admin-scripts.js new file mode 100644 index 0000000..76ec836 --- /dev/null +++ b/admin/js/admin-scripts.js @@ -0,0 +1,125 @@ +/** + * Admin Scripts + * + * @package WPALLSTARS\PluginStarterTemplate + */ + +(function($) { + 'use strict'; + + /** + * Admin functionality + */ + const WPSTAdmin = { + /** + * Initialize + */ + init: function() { + // Initialize components + this.initComponents(); + + // Bind events + this.bindEvents(); + }, + + /** + * Initialize components + */ + initComponents: function() { + // Initialize any components here + }, + + /** + * Bind events + */ + bindEvents: function() { + // Example: Toggle sections + $('.wpst-toggle-section').on('click', this.toggleSection); + + // Example: Form submission + $('#wpst-settings-form').on('submit', this.handleFormSubmit); + }, + + /** + * Toggle section visibility + * + * @param {Event} e Click event + */ + toggleSection: function(e) { + e.preventDefault(); + + const $this = $(this); + const target = $this.data('target'); + + $(target).slideToggle(200); + $this.toggleClass('open'); + }, + + /** + * Handle form submission + * + * @param {Event} e Submit event + */ + handleFormSubmit: function(e) { + e.preventDefault(); + + const $form = $(this); + const $submitButton = $form.find('input[type="submit"]'); + const formData = $form.serialize(); + + // Disable submit button and show loading state + $submitButton.prop('disabled', true).addClass('loading'); + + // Send AJAX request + $.ajax({ + url: wpstData.ajaxUrl, + type: 'POST', + data: { + action: 'wpst_save_settings', + nonce: wpstData.nonce, + formData: formData + }, + success: function(response) { + if (response.success) { + WPSTAdmin.showNotice('success', response.data.message); + } else { + WPSTAdmin.showNotice('error', response.data.message); + } + }, + error: function() { + WPSTAdmin.showNotice('error', 'An error occurred. Please try again.'); + }, + complete: function() { + // Re-enable submit button and remove loading state + $submitButton.prop('disabled', false).removeClass('loading'); + } + }); + }, + + /** + * Show admin notice + * + * @param {string} type Notice type (success, error, warning) + * @param {string} message Notice message + */ + showNotice: function(type, message) { + const $notice = $('

' + message + '

'); + + // Add notice to the page + $('.wpst-notices').html($notice); + + // Automatically remove notice after 5 seconds + setTimeout(function() { + $notice.fadeOut(300, function() { + $(this).remove(); + }); + }, 5000); + } + }; + + // Initialize when document is ready + $(document).ready(function() { + WPSTAdmin.init(); + }); + +})(jQuery); diff --git a/admin/js/update-source-selector.js b/admin/js/update-source-selector.js new file mode 100644 index 0000000..96696ea --- /dev/null +++ b/admin/js/update-source-selector.js @@ -0,0 +1,164 @@ +/** + * Update Source Selector Scripts + * + * @package WPALLSTARS\PluginStarterTemplate + */ + +(function($) { + 'use strict'; + + /** + * Update Source Selector functionality + */ + const WPSTUpdateSourceSelector = { + /** + * Modal element + */ + $modal: null, + + /** + * Selected source + */ + selectedSource: '', + + /** + * Initialize + */ + init: function() { + // Cache DOM elements + this.$modal = $('#wpst-update-source-modal'); + + // Bind events + this.bindEvents(); + }, + + /** + * Bind events + */ + bindEvents: function() { + // Open modal when clicking on the update source link + $(document).on('click', '.wpst-update-source-selector', this.openModal.bind(this)); + + // Close modal when clicking on the close button or outside the modal + this.$modal.on('click', '.wpst-modal-close', this.closeModal.bind(this)); + $(document).on('click', '.wpst-modal', function(e) { + if ($(e.target).hasClass('wpst-modal')) { + WPSTUpdateSourceSelector.closeModal(); + } + }); + + // Select source option + this.$modal.on('click', '.wpst-source-option', this.selectSource.bind(this)); + + // Save source selection + this.$modal.on('click', '#wpst-save-source', this.saveSource.bind(this)); + }, + + /** + * Open the modal + * + * @param {Event} e Click event + */ + openModal: function(e) { + e.preventDefault(); + this.$modal.show(); + }, + + /** + * Close the modal + */ + closeModal: function() { + this.$modal.hide(); + }, + + /** + * Select a source option + * + * @param {Event} e Click event + */ + selectSource: function(e) { + const $option = $(e.currentTarget); + + // Update selected state + this.$modal.find('.wpst-source-option').removeClass('selected'); + $option.addClass('selected'); + + // Update radio button + $option.find('input[type="radio"]').prop('checked', true); + + // Store selected source + this.selectedSource = $option.find('input[type="radio"]').val(); + }, + + /** + * Save the selected source + */ + saveSource: function() { + // Validate selection + if (!this.selectedSource) { + this.showMessage('error', 'Please select an update source.'); + return; + } + + // Show loading state + const $saveButton = $('#wpst-save-source'); + $saveButton.prop('disabled', true).html(' Saving...'); + + // Send AJAX request + $.ajax({ + url: wpstModalData.ajaxUrl, + type: 'POST', + data: { + action: 'wpst_set_update_source', + nonce: wpstModalData.nonce, + source: this.selectedSource + }, + success: function(response) { + if (response.success) { + WPSTUpdateSourceSelector.showMessage('success', response.data.message); + + // Close modal after a short delay + setTimeout(function() { + WPSTUpdateSourceSelector.closeModal(); + }, 1500); + } else { + WPSTUpdateSourceSelector.showMessage('error', response.data.message); + } + }, + error: function() { + WPSTUpdateSourceSelector.showMessage('error', 'An error occurred. Please try again.'); + }, + complete: function() { + // Reset button state + $saveButton.prop('disabled', false).text(wpstModalData.i18n.confirm); + } + }); + }, + + /** + * Show a message in the modal + * + * @param {string} type Message type (success, error) + * @param {string} message Message text + */ + showMessage: function(type, message) { + const $message = this.$modal.find('.wpst-modal-message'); + + // Set message content and type + $message.html(message).removeClass('success error').addClass(type).show(); + + // Hide message after a delay for success messages + if (type === 'success') { + setTimeout(function() { + $message.fadeOut(300); + }, 3000); + } + } + }; + + // Initialize when document is ready + $(document).ready(function() { + WPSTUpdateSourceSelector.init(); + }); + +})(jQuery); diff --git a/admin/lib/admin.php b/admin/lib/admin.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/admin/lib/admin.php @@ -0,0 +1 @@ + + + +
+
+
+

+ × +
+ +
+

+ +
+ +
+ + + + + + + +
+
+ + +
+
diff --git a/assets/README.md b/assets/README.md new file mode 100644 index 0000000..b316fd1 --- /dev/null +++ b/assets/README.md @@ -0,0 +1,39 @@ +# Plugin Assets + +This directory contains assets for the plugin, including: + +- `banner/`: Banner images for the plugin +- `icon/`: Icon images for the plugin +- `screenshots/`: Screenshots of the plugin in action + +These assets are used in the plugin's WordPress.org page and in the plugin itself. + +## Asset Requirements + +### Banner + +- Regular: 772x250 pixels +- Retina: 1544x500 pixels +- PNG or JPG format + +### Icon + +- Regular: 128x128 pixels +- Retina: 256x256 pixels +- PNG format with transparency + +### Screenshots + +- Should be at least 1200 pixels wide +- PNG or JPG format +- Should demonstrate the plugin's functionality + +## Adding Assets + +When adding new assets: + +1. Place the files in the appropriate directory +2. Update the readme.txt file to reference the new screenshots +3. Update the WordPress.org assets if the plugin is published there + +For more information about WordPress.org plugin assets, see the `.wordpress-org/WORDPRESS_ORG_ASSETS.md` file. diff --git a/assets/banner/README.md b/assets/banner/README.md new file mode 100644 index 0000000..5ba9766 --- /dev/null +++ b/assets/banner/README.md @@ -0,0 +1,26 @@ +# Banner Images + +This directory contains banner images for the plugin. + +## Required Files + +- `banner-772x250.png`: Regular banner image (772x250 pixels) +- `banner-1544x500.png`: Retina banner image (1544x500 pixels) + +## Design Guidelines + +- Keep the design simple and focused +- Ensure text is readable +- Use high-quality images +- Use consistent branding (colors, fonts, etc.) +- Test how the banner looks at different sizes + +## Creating Banner Images + +1. Use a design tool like Photoshop, GIMP, or Figma +2. Create a canvas with the correct dimensions +3. Add your plugin name, logo, and a brief description +4. Use colors that match your plugin's branding +5. Export as PNG or JPG + +For more information about WordPress.org plugin assets, see the `.wordpress-org/WORDPRESS_ORG_ASSETS.md` file. diff --git a/assets/icon/README.md b/assets/icon/README.md new file mode 100644 index 0000000..ed24d8b --- /dev/null +++ b/assets/icon/README.md @@ -0,0 +1,26 @@ +# Icon Images + +This directory contains icon images for the plugin. + +## Required Files + +- `icon-128x128.png`: Regular icon image (128x128 pixels) +- `icon-256x256.png`: Retina icon image (256x256 pixels) + +## Design Guidelines + +- Keep the design simple and recognizable +- Use a transparent background +- Ensure the icon is visible at small sizes +- Use consistent branding (colors, fonts, etc.) +- Test how the icon looks at different sizes + +## Creating Icon Images + +1. Use a design tool like Photoshop, GIMP, or Figma +2. Create a canvas with the correct dimensions +3. Add your plugin logo or a simple graphic that represents your plugin +4. Use colors that match your plugin's branding +5. Export as PNG with transparency + +For more information about WordPress.org plugin assets, see the `.wordpress-org/WORDPRESS_ORG_ASSETS.md` file. diff --git a/assets/screenshots/README.md b/assets/screenshots/README.md new file mode 100644 index 0000000..0fc82d5 --- /dev/null +++ b/assets/screenshots/README.md @@ -0,0 +1,39 @@ +# Screenshots + +This directory contains screenshots of the plugin in action. + +## Required Files + +- `screenshot-1.png`: First screenshot +- `screenshot-2.png`: Second screenshot (if applicable) +- etc. + +## Screenshot Guidelines + +- Screenshots should be at least 1200 pixels wide +- Use PNG or JPG format +- Show the plugin in action +- Focus on one feature per screenshot +- Use annotations to highlight important elements +- Use real-world examples + +## Creating Screenshots + +1. Set up a test WordPress site with your plugin activated +2. Configure the plugin with realistic settings +3. Use a screen capture tool to take screenshots +4. Edit the screenshots to add annotations if needed +5. Save as PNG or JPG + +## Screenshot Descriptions + +Screenshot descriptions are added in the `readme.txt` file under the "Screenshots" section: + +``` +== Screenshots == + +1. This is the first screenshot +2. This is the second screenshot +``` + +For more information about WordPress.org plugin assets, see the `.wordpress-org/WORDPRESS_ORG_ASSETS.md` file. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..33329a8 --- /dev/null +++ b/build.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# WordPress Plugin Build Script +# This script creates a clean build of the plugin for distribution + +# Check if version is provided +if [ -z "$1" ]; then + echo "❌ Error: Version number is required" + echo "Usage: ./build.sh " + exit 1 +fi + +VERSION=$1 +PLUGIN_SLUG="wp-plugin-starter-template" +BUILD_DIR="build/$PLUGIN_SLUG" +ZIP_FILE="$PLUGIN_SLUG-$VERSION.zip" + +# Create build directory +echo "Creating build directory..." +rm -rf "$BUILD_DIR" +mkdir -p "$BUILD_DIR" + +# Install composer dependencies +echo "Installing composer dependencies..." +composer install --no-dev --optimize-autoloader + +# Copy plugin files to build directory +echo "Copying plugin files..." +cp -R *.php "$BUILD_DIR/" +cp -R README.md LICENSE CHANGELOG.md readme.txt composer.json "$BUILD_DIR/" + +# Copy directories +echo "Copying directories..." +mkdir -p "$BUILD_DIR/admin" "$BUILD_DIR/includes" "$BUILD_DIR/languages" "$BUILD_DIR/assets" +cp -R admin/* "$BUILD_DIR/admin/" +cp -R includes/* "$BUILD_DIR/includes/" +cp -R languages/* "$BUILD_DIR/languages/" + +# Create assets directory structure +mkdir -p "$BUILD_DIR/assets/banner" "$BUILD_DIR/assets/icon" "$BUILD_DIR/assets/screenshots" + +# Copy assets if they exist +if [ -d "assets/banner" ]; then + cp -R assets/banner/* "$BUILD_DIR/assets/banner/" +fi + +if [ -d "assets/icon" ]; then + cp -R assets/icon/* "$BUILD_DIR/assets/icon/" +fi + +if [ -d "assets/screenshots" ]; then + cp -R assets/screenshots/* "$BUILD_DIR/assets/screenshots/" +fi + +# Copy vendor directory if it exists +if [ -d "vendor" ]; then + cp -R vendor "$BUILD_DIR/" +fi + +# Create ZIP file +echo "Creating ZIP file..." +cd build +zip -r "../$ZIP_FILE" "$PLUGIN_SLUG" -x "*.DS_Store" -x "*.git*" -x "*.github*" +cd .. + +# Check if ZIP file was created successfully +if [ -f "$ZIP_FILE" ]; then + echo "✅ Build successful: $ZIP_FILE created" + echo "File path: $(pwd)/$ZIP_FILE" + + # Deploy to local WordPress installation if environment variable is set + if [ -n "$WP_LOCAL_PLUGIN_DIR" ]; then + echo "\nDeploying to local WordPress installation..." + echo "Deploying to local WordPress installation..." + + # Remove existing plugin directory + rm -rf "$WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG" + + # Copy files to local WordPress installation + rsync -av --exclude=".git" --exclude=".github" --exclude=".DS_Store" \ + "$BUILD_DIR/" "$WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG" + + # Clear WordPress transients if WP-CLI is available + if command -v wp &> /dev/null; then + echo "Clearing WordPress transients..." + wp transient delete --all --path="$WP_LOCAL_PLUGIN_DIR/../.." + else + echo "⚠️ WP-CLI not found, skipping transient clearing" + fi + + echo "✅ Local deployment successful!" + echo "Plugin deployed to: $WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG" + fi +else + echo "❌ Build failed: ZIP file was not created" + exit 1 +fi diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9a27fad --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "wpallstars/wp-plugin-starter-template", + "description": "A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.", + "type": "wordpress-plugin", + "license": "GPL-2.0-or-later", + "authors": [ + { + "name": "WPALLSTARS", + "email": "info@wpallstars.com" + } + ], + "minimum-stability": "stable", + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5", + "squizlabs/php_codesniffer": "^3.5", + "wp-coding-standards/wpcs": "^2.3" + }, + "autoload": { + "psr-4": { + "WPALLSTARS\\PluginStarterTemplate\\": "includes/" + } + }, + "scripts": { + "phpcs": "phpcs --standard=WordPress", + "phpcbf": "phpcbf --standard=WordPress", + "test": "phpunit" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/includes/core.php b/includes/core.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/includes/core.php @@ -0,0 +1 @@ +\n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"POT-Creation-Date: 2025-04-17T00:00:00+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.9.0\n" +"X-Domain: wp-plugin-starter-template\n" + +#. Plugin Name of the plugin +msgid "WordPress Plugin Starter Template" +msgstr "" + +#. Plugin URI of the plugin +msgid "https://www.wpallstars.com" +msgstr "" + +#. Description of the plugin +msgid "A comprehensive starter template for WordPress plugins with best practices for AI-assisted development." +msgstr "" + +#. Author of the plugin +msgid "WPALLSTARS" +msgstr "" + +#. Author URI of the plugin +msgid "https://www.wpallstars.com" +msgstr "" + +#: admin/lib/admin.php:74 +msgid "Save Changes" +msgstr "" + +#: admin/lib/admin.php:75 +msgid "Cancel" +msgstr "" + +#: admin/lib/modal.php:67 +msgid "Close" +msgstr "" + +#: admin/lib/modal.php:68 +msgid "Confirm" +msgstr "" + +#: admin/templates/modal.php:16 +msgid "Select Update Source" +msgstr "" + +#: admin/templates/modal.php:21 +msgid "Choose your preferred source for plugin updates:" +msgstr "" + +#: admin/templates/modal.php:31 +msgid "WordPress.org" +msgstr "" + +#: admin/templates/modal.php:33 +msgid "Receive updates from the official WordPress.org repository. Recommended for most users." +msgstr "" + +#: admin/templates/modal.php:38 +msgid "GitHub" +msgstr "" + +#: admin/templates/modal.php:40 +msgid "Receive updates from the GitHub repository. May include pre-release versions." +msgstr "" + +#: admin/templates/modal.php:45 +msgid "Gitea" +msgstr "" + +#: admin/templates/modal.php:47 +msgid "Receive updates from the Gitea repository. May include pre-release versions." +msgstr "" + +#: admin/templates/modal.php:55 +msgid "Save" +msgstr "" + +#: includes/updater.php:71 +msgid "Update Source" +msgstr "" + +#: includes/updater.php:84 +msgid "Security check failed." +msgstr "" + +#: includes/updater.php:89 +msgid "You do not have permission to perform this action." +msgstr "" + +#: includes/updater.php:98 +msgid "Invalid update source." +msgstr "" + +#: includes/updater.php:107 +msgid "Update source set to %s." +msgstr "" diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..b44e607 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,25 @@ + + + + + ./tests/ + + + + + ./includes + ./admin + + ./vendor + ./tests + + + + diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..89c6deb --- /dev/null +++ b/readme.txt @@ -0,0 +1,118 @@ +=== WordPress Plugin Starter Template === +Contributors: wpallstars, your_wp_username +Donate link: https://www.wpallstars.com +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.0 +License: GPL-2.0+ +License URI: https://www.gnu.org/licenses/gpl-2.0.html + +A comprehensive starter template for WordPress plugins with best practices for AI-assisted development. + +== Description == + +The WordPress Plugin Starter Template provides a solid foundation for developing WordPress plugins with AI assistance. It includes a well-structured codebase, documentation templates, and best practices to help you create high-quality WordPress plugins efficiently. + += Key Features = + +* **Well-structured codebase** following WordPress coding standards +* **Modular architecture** for easy maintenance and extension +* **Comprehensive documentation** templates for both users and developers +* **AI-friendly workflows** with detailed guidance for AI assistants +* **Git integration** with GitHub and Gitea support +* **Update mechanism** with multiple source options (WordPress.org, GitHub, Gitea) +* **Internationalization** ready with proper text domain setup +* **Admin interface** components for building settings pages + += For Developers = + +This template is designed to be a starting point for your WordPress plugin development. It provides: + +* A clean, well-organized file structure +* OOP approach with namespaced classes +* Separation of concerns (admin, core functionality) +* Documentation templates for wiki and readme files +* GitHub Actions workflows for automated tasks +* AI workflow documentation for AI-assisted development + += Credits = + +This template is based on the experience and best practices developed while creating the [Fix 'Plugin file does not exist' Notices](https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices) plugin. + +== Installation == + +1. Download the plugin zip file +2. Log in to your WordPress admin dashboard +3. Go to Plugins > Add New +4. Click the "Upload Plugin" button at the top of the page +5. Select the zip file and click "Install Now" +6. Activate the plugin through the 'Plugins' menu in WordPress + +== Frequently Asked Questions == + += How do I use this template? = + +This template is meant to be a starting point for your own plugin development. You should: + +1. Copy the template files to your new plugin directory +2. Rename files and update namespaces to match your plugin name +3. Update plugin headers in the main PHP file +4. Customize the functionality to meet your specific needs +5. Update documentation to reflect your plugin's features + += Is this template suitable for all types of plugins? = + +Yes, this template provides a solid foundation for most WordPress plugins. It's designed to be flexible and can be adapted for various types of plugins, from simple utilities to complex applications. + += How do I contribute to this template? = + +Contributions are welcome! Please feel free to submit a pull request or open an issue on the [GitHub repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding). + +== Screenshots == + +1. This is a placeholder for your plugin's screenshots. Replace with actual screenshots of your plugin in action. + +== Changelog == + += 0.1.0 = +* Initial release with basic template structure +* Added core plugin architecture +* Added admin interface components +* Added documentation templates +* Added AI workflow documentation + +== Upgrade Notice == + += 0.1.0 = +Initial release of the WordPress Plugin Starter Template. + +== Development == + +The development of this plugin follows these principles: + +1. **Clean Code**: Following WordPress coding standards and best practices +2. **Modularity**: Keeping components separate and focused +3. **Documentation**: Comprehensive documentation for both users and developers +4. **Testing**: Thorough testing across different WordPress versions +5. **Accessibility**: Ensuring the plugin is accessible to all users +6. **Internationalization**: Making the plugin translatable + += Development Resources = + +* [GitHub Repository](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding) +* [WordPress Plugin Development Handbook](https://developer.wordpress.org/plugins/) +* [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/) + += Contributing = + +We welcome contributions to improve this template. Please feel free to: + +* Report bugs or issues +* Suggest new features or improvements +* Submit pull requests with bug fixes or enhancements + +== Credits == + +This template is maintained by [WPALLSTARS](https://www.wpallstars.com) and is based on the experience and best practices developed while creating the [Fix 'Plugin file does not exist' Notices](https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices) plugin. diff --git a/reference-plugins/README.md b/reference-plugins/README.md new file mode 100644 index 0000000..3f0ce22 --- /dev/null +++ b/reference-plugins/README.md @@ -0,0 +1,56 @@ +# Reference Plugins + +This directory is intended to contain reference plugins that can be used as inspiration for development. These plugins are not part of the actual plugin but serve as examples of best practices and implementation patterns. + +## Recommended Reference Plugins + +1. **[Fix 'Plugin file does not exist' Notices](https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices)** + - This plugin is the original inspiration for this starter template + - Demonstrates clean, modular code structure + - Shows implementation of Git Updater integration + - Provides examples of WordPress admin UI integration + +2. **[WordPress Plugin Boilerplate](https://github.com/devinvinson/WordPress-Plugin-Boilerplate)** + - A standardized, organized, object-oriented foundation for building high-quality WordPress plugins + - Follows WordPress coding standards + - Provides a clear separation of concerns + +3. **[CMB2](https://github.com/CMB2/CMB2)** + - Excellent example of metabox and form handling + - Well-documented codebase + - Demonstrates extensibility and API design + +4. **[WooCommerce](https://github.com/woocommerce/woocommerce)** + - Example of a large-scale WordPress plugin + - Demonstrates advanced features like custom post types, taxonomies, and REST API integration + - Shows how to structure a complex plugin + +## How to Use Reference Plugins + +1. **Study the Code Structure**: + - Examine how the plugin is organized + - Note the separation of concerns + - Observe naming conventions and coding standards + +2. **Analyze Implementation Patterns**: + - Look at how common WordPress patterns are implemented + - Study how the plugin integrates with WordPress hooks + - Observe error handling and security practices + +3. **Adapt, Don't Copy**: + - Use these plugins as inspiration, not as code to copy directly + - Adapt patterns to fit your specific needs + - Ensure you understand the code before using similar approaches + +## Adding Reference Plugins + +To add a reference plugin to this directory: + +1. Create a subdirectory with the plugin name +2. Include a README.md file explaining why this plugin is included as a reference +3. Add relevant code snippets or links to the original repository +4. Update this README.md file to include the new reference plugin + +## Note on Licensing + +When using code from reference plugins, always respect their licensing terms. Most WordPress plugins are licensed under GPL or compatible licenses, but always verify before using any code. diff --git a/scripts/deploy-local.sh b/scripts/deploy-local.sh new file mode 100755 index 0000000..808e2d2 --- /dev/null +++ b/scripts/deploy-local.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# WordPress Plugin Local Deployment Script +# This script deploys the plugin to a local WordPress installation for testing + +# Configuration +PLUGIN_SLUG="wp-plugin-starter-template" +SOURCE_DIR="$(pwd)" +TARGET_DIR="${WP_LOCAL_PLUGIN_DIR:-/path/to/your/local/wordpress/wp-content/plugins}/$PLUGIN_SLUG" + +# Check if WP_LOCAL_PLUGIN_DIR is set +if [ -z "$WP_LOCAL_PLUGIN_DIR" ]; then + echo "⚠️ Warning: WP_LOCAL_PLUGIN_DIR environment variable is not set." + echo "Please set it to your local WordPress plugins directory or edit this script." + echo "Example: export WP_LOCAL_PLUGIN_DIR=/path/to/your/local/wordpress/wp-content/plugins" + exit 1 +fi + +# Check if target directory exists +if [ ! -d "$(dirname "$TARGET_DIR")" ]; then + echo "❌ Error: Target directory does not exist: $(dirname "$TARGET_DIR")" + exit 1 +fi + +# Create or clean target directory +if [ -d "$TARGET_DIR" ]; then + echo "Cleaning existing plugin directory..." + rm -rf "$TARGET_DIR" +fi + +echo "Creating plugin directory..." +mkdir -p "$TARGET_DIR" + +# Copy plugin files +echo "Copying plugin files..." +rsync -av --exclude=".git" --exclude=".github" --exclude=".DS_Store" \ + --exclude="node_modules" --exclude="build" --exclude=".wordpress-org" \ + "$SOURCE_DIR/" "$TARGET_DIR/" + +# Clear WordPress transients if WP-CLI is available +if command -v wp &> /dev/null; then + echo "Clearing WordPress transients..." + wp transient delete --all --path="$(dirname "$(dirname "$TARGET_DIR")")" +else + echo "⚠️ WP-CLI not found, skipping transient clearing" +fi + +echo "✅ Deployment successful!" +echo "Plugin deployed to: $TARGET_DIR" diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..97e42b5 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,84 @@ +# Plugin Tests + +This directory contains test files for the plugin. + +## Test Structure + +- `bootstrap.php`: Sets up the test environment +- `test-core.php`: Tests for the Core class +- `test-admin.php`: Tests for the Admin class +- Add more test files as needed for additional classes + +## Running Tests + +To run the tests, you need to have PHPUnit and WP Mock installed. You can install them using Composer: + +```bash +composer install +``` + +Then, run the tests: + +```bash +./vendor/bin/phpunit +``` + +## Writing Tests + +When writing tests: + +1. Create a new file named `test-{class-name}.php` for each class you want to test +2. Extend the `WP_Mock\Tools\TestCase` class +3. Use WP Mock to mock WordPress functions +4. Write test methods for each method in your class + +Example: + +```php + 1, + 'args' => ['argument'], + 'return' => 'result', + ]); + + // Create instance of your class + $instance = new YourClass(); + + // Call the method + $result = $instance->your_method('argument'); + + // Assert the result + $this->assertEquals('expected result', $result); + } +} +``` + +## Test Coverage + +To generate a test coverage report: + +```bash +./vendor/bin/phpunit --coverage-html coverage +``` + +This will generate an HTML report in the `coverage` directory. + +## Continuous Integration + +The tests are automatically run on GitHub Actions when you push to the repository. See the `.github/workflows/tests.yml` file for details. diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..1eb529c --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,27 @@ +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); + } + + /** + * Tear down test environment + */ + public function tearDown(): void { + WP_Mock::tearDown(); + parent::tearDown(); + } + + /** + * Test constructor + */ + public function test_constructor() { + // Verify that the constructor initializes hooks + $this->assertInstanceOf(Admin::class, $this->admin); + } + + /** + * Test enqueue_admin_assets + */ + public function test_enqueue_admin_assets() { + // Set up WordPress function mocks + WP_Mock::userFunction('wp_enqueue_style', [ + '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); + } +} diff --git a/tests/test-core.php b/tests/test-core.php new file mode 100644 index 0000000..c9e680c --- /dev/null +++ b/tests/test-core.php @@ -0,0 +1,60 @@ +core = new Core(); + } + + /** + * Tear down test environment + */ + public function tearDown(): void { + WP_Mock::tearDown(); + parent::tearDown(); + } + + /** + * Test constructor + */ + public function test_constructor() { + // Verify that the constructor initializes hooks + $this->assertInstanceOf(Core::class, $this->core); + } + + /** + * Test example method + */ + public function test_filter_content() { + $content = 'Test content'; + + // Test that filter_content returns the content + $this->assertEquals($content, $this->core->filter_content($content)); + } +}