Compare commits
226
Commits
v1.0.0
..
df7f303ffb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df7f303ffb | ||
|
|
a7459aba5f | ||
|
|
66d6167cf5 | ||
|
|
8befc726bf | ||
|
|
6e9fb5a9c4 | ||
|
|
788bb6104f | ||
|
|
f6d30e92d0 | ||
|
|
a509d15acc | ||
|
|
a44826e75e | ||
|
|
3b73654202 | ||
|
|
7d3379cda4 | ||
|
|
cd38e0317a | ||
|
|
8c735ccb2b | ||
|
|
e660915402 | ||
|
|
5ca320c580 | ||
|
|
bb6de9a3cb | ||
|
|
e8fcc7e1d0 | ||
|
|
c17b6f1818 | ||
|
|
1590be3ba6 | ||
|
|
5e65d07a4f | ||
|
|
84952ff2d1 | ||
|
|
6300b687aa | ||
|
|
eb388a846d | ||
|
|
331307f8b0 | ||
|
|
57f2093adb | ||
|
|
94872a33c8 | ||
|
|
53ac0ce696 | ||
|
|
4a9649bd65 | ||
|
|
6c340ec19e | ||
|
|
0960368136 | ||
|
|
e6dcda3f6e | ||
|
|
ca5a9cf38b | ||
|
|
859161fd0c | ||
|
|
db8c84a80a | ||
|
|
b1966067ea | ||
|
|
bb31e0e934 | ||
|
|
5f598f0f7e | ||
|
|
a17a574a7e | ||
|
|
e9a967fcd0 | ||
|
|
0c4e91fcec | ||
|
|
f3d6bd2434 | ||
|
|
953bf3f6bb | ||
|
|
e5b0181baf | ||
|
|
771cc96da8 | ||
|
|
ef60ce0c9d | ||
|
|
fa92ca58df | ||
|
|
8fa2c19fe4 | ||
|
|
0f83330d85 | ||
|
|
c29841b8ae | ||
|
|
f5c8162ec7 | ||
|
|
5cd8dcc31e | ||
|
|
ce6c6e42a9 | ||
|
|
f48276cc58 | ||
|
|
3ca2fe58fa | ||
|
|
c37d2975d3 | ||
|
|
089e083f40 | ||
|
|
3c1ec14c2d | ||
|
|
189d0de673 | ||
|
|
920b1a0a7d | ||
|
|
1cfc6f5a13 | ||
|
|
13d2f92ee5 | ||
|
|
1089ea491a | ||
|
|
35d7623722 | ||
|
|
78e2929b27 | ||
|
|
d0b42262a4 | ||
|
|
999105228a | ||
|
|
b10ea120cd | ||
|
|
6eb7b2c4e3 | ||
|
|
2b726a4b46 | ||
|
|
960468f176 | ||
|
|
17375cf555 | ||
|
|
fae342fe33 | ||
|
|
cde6d979b5 | ||
|
|
c0748c0d0b | ||
|
|
64567f3d0f | ||
|
|
7783f8de79 | ||
|
|
5f95ba762e | ||
|
|
81f490efcb | ||
|
|
e823026626 | ||
|
|
f704685e96 | ||
|
|
f652e9e0c3 | ||
|
|
400632a3b3 | ||
|
|
fb0949df0a | ||
|
|
c7e01493ef | ||
|
|
4d74fe35dc | ||
|
|
d6b2349af8 | ||
|
|
572c23df89 | ||
|
|
824f2a97e8 | ||
|
|
2e25c48135 | ||
|
|
11fbce90a0 | ||
|
|
1841b6b8bd | ||
|
|
474a5d2753 | ||
|
|
78c3d03030 | ||
|
|
051bc763f8 | ||
|
|
ed160ed51b | ||
|
|
e8d81ef45b | ||
|
|
47d77c6451 | ||
|
|
d058898022 | ||
|
|
e5edff8cfa | ||
|
|
f09854329b | ||
|
|
5bdd04f592 | ||
|
|
f7515b5861 | ||
|
|
8ed22642e2 | ||
|
|
136f07d9c4 | ||
|
|
40ebbce1cc | ||
|
|
af11f827c4 | ||
|
|
bfd2d4b063 | ||
|
|
6e95542ac5 | ||
|
|
baa2a050d3 | ||
|
|
61ca9d4768 | ||
|
|
3d1bf9d113 | ||
|
|
348eb872a8 | ||
|
|
6554392dd6 | ||
|
|
ce96ea2e96 | ||
|
|
445d022232 | ||
|
|
d3e5d0d0c0 | ||
|
|
2481d63561 | ||
|
|
cdc73bc010 | ||
|
|
67c6c65611 | ||
|
|
ebdb172a14 | ||
|
|
57a4c98f46 | ||
|
|
4c1bee9dbe | ||
|
|
200cc5671d | ||
|
|
398d24ed90 | ||
|
|
ad30d716db | ||
|
|
19ec65326b | ||
|
|
3048e91a78 | ||
|
|
3926927791 | ||
|
|
728c5dcf3d | ||
|
|
109c07cfed | ||
|
|
ea628c521b | ||
|
|
ae7bd5cb89 | ||
|
|
1f4be45862 | ||
|
|
78bd0708d3 | ||
|
|
36840c46c1 | ||
|
|
aa62142e4c | ||
|
|
0ab1a1df4d | ||
|
|
69cd192f49 | ||
|
|
4ebe55b940 | ||
|
|
5b4037bf0d | ||
|
|
fd314fd7c7 | ||
|
|
546ed59a61 | ||
|
|
069dc2e8d7 | ||
|
|
9d36b47f9f | ||
|
|
5cd2a7d374 | ||
|
|
497c44c3c6 | ||
|
|
e3f11ac03f | ||
|
|
04cdd49a3f | ||
|
|
cdd9b050c7 | ||
|
|
6031751015 | ||
|
|
a885ef1e0b | ||
|
|
c930a5484a | ||
|
|
45feb7b550 | ||
|
|
cb79402c5f | ||
|
|
1af79e0bfd | ||
|
|
a88af434db | ||
|
|
4eac81ba0e | ||
|
|
92124e139f | ||
|
|
eb4e71f98f | ||
|
|
3dfd5f2658 | ||
|
|
d58f5fdb72 | ||
|
|
07d0e7e44b | ||
|
|
e9139ec9d9 | ||
|
|
7d8b9361c5 | ||
|
|
63f2520f70 | ||
|
|
fbe4eba3ff | ||
|
|
cc6acc2a4e | ||
|
|
ed7d33e2aa | ||
|
|
fb8a998487 | ||
|
|
2ac9b046b5 | ||
|
|
d1c5950dcb | ||
|
|
2e9914e325 | ||
|
|
b9fa979600 | ||
|
|
2a025ec18c | ||
|
|
95e4361cd5 | ||
|
|
6d9a9658ea | ||
|
|
7051fb1193 | ||
|
|
6527fde363 | ||
|
|
643f5c6d41 | ||
|
|
b7bf97d5b4 | ||
|
|
a5d3c09243 | ||
|
|
c7435f5a49 | ||
|
|
aa136c7a4a | ||
|
|
455edb99f9 | ||
|
|
584d774931 | ||
|
|
b2b8af4216 | ||
|
|
a0df887d5c | ||
|
|
4d69c446db | ||
|
|
4441106963 | ||
|
|
35f50aa03b | ||
|
|
6d3aeb889a | ||
|
|
b18f1c46b4 | ||
|
|
bcdbbb454c | ||
|
|
3d739915d7 | ||
|
|
51183c378e | ||
|
|
71c0a77a31 | ||
|
|
0e219975ae | ||
|
|
058ae4b64e | ||
|
|
3fa42ae1c7 | ||
|
|
275958bfdb | ||
|
|
93412896e8 | ||
|
|
6784ef4824 | ||
|
|
0874c4f59e | ||
|
|
4696cdfba6 | ||
|
|
1cf46254b7 | ||
|
|
3c1db9d4fb | ||
|
|
bfa528c90e | ||
|
|
233a64913b | ||
|
|
1c049a91c5 | ||
|
|
1e2f7a5cd8 | ||
|
|
7072f21d49 | ||
|
|
af48e84614 | ||
|
|
5083fcee50 | ||
|
|
79d1314aed | ||
|
|
2f4d88f8dd | ||
|
|
bfac63799b | ||
|
|
9d3e67d16b | ||
|
|
843696d3a8 | ||
|
|
269626438e | ||
|
|
0e6f9639f4 | ||
|
|
0de0b2ef05 | ||
|
|
342eefd471 | ||
|
|
66758ac0f8 | ||
|
|
32697533ab | ||
|
|
4a7798a8c2 | ||
|
|
c7b590870c |
No files matched your search
@@ -0,0 +1,202 @@
|
|||||||
|
# Bug Fixing Guide for AI Assistants
|
||||||
|
|
||||||
|
This document provides guidance for AI assistants to help with bug fixing for the Fix Plugin Does Not Exist Notices plugin.
|
||||||
|
|
||||||
|
## Bug Fixing Workflow
|
||||||
|
|
||||||
|
### 1. Create a Bug Fix Branch
|
||||||
|
|
||||||
|
Always start by creating a bug fix branch from the latest main branch pulled from origin (this step is mandatory):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main # Critical step - never skip this
|
||||||
|
git checkout -b fix/bug-description
|
||||||
|
```
|
||||||
|
|
||||||
|
Use a descriptive name that clearly indicates what bug is being fixed. If there's an issue number, include it in the branch name (e.g., `fix/123-plugin-activation-error`).
|
||||||
|
|
||||||
|
For more detailed git workflow guidelines, see **@.agents/git-workflow.md**.
|
||||||
|
|
||||||
|
### 2. Understand the Bug
|
||||||
|
|
||||||
|
Before fixing a bug, make sure you understand:
|
||||||
|
|
||||||
|
- What is the expected behavior?
|
||||||
|
- What is the actual behavior?
|
||||||
|
- What are the steps to reproduce the bug?
|
||||||
|
- What is the impact of the bug?
|
||||||
|
- What is the root cause of the bug?
|
||||||
|
|
||||||
|
### 3. Fix the Bug
|
||||||
|
|
||||||
|
When fixing a bug:
|
||||||
|
|
||||||
|
- Make minimal changes necessary to fix the bug
|
||||||
|
- Avoid introducing new features while fixing bugs
|
||||||
|
- Maintain backward compatibility
|
||||||
|
- Add appropriate comments explaining the fix
|
||||||
|
- Consider adding tests to prevent regression
|
||||||
|
|
||||||
|
### 4. Update Documentation
|
||||||
|
|
||||||
|
Update relevant documentation to reflect the bug fix:
|
||||||
|
|
||||||
|
- Add a description to CHANGELOG.md under an "Unreleased" section
|
||||||
|
- Update readme.txt if the bug fix affects user-facing functionality
|
||||||
|
|
||||||
|
### 5. Testing
|
||||||
|
|
||||||
|
Test the bug fix thoroughly:
|
||||||
|
|
||||||
|
- Verify that the bug is fixed
|
||||||
|
- Ensure no regression in related functionality
|
||||||
|
- Test with the latest WordPress version
|
||||||
|
- Test with the minimum supported WordPress version (5.0)
|
||||||
|
- Test with PHP 7.0+ (minimum supported version)
|
||||||
|
|
||||||
|
### 6. Commit Changes
|
||||||
|
|
||||||
|
Make atomic commits with clear messages:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Fix #123: Brief description of the bug fix"
|
||||||
|
```
|
||||||
|
|
||||||
|
If there's an issue number, reference it in the commit message.
|
||||||
|
|
||||||
|
### 7. Prepare for Release
|
||||||
|
|
||||||
|
When the bug fix is ready to be released:
|
||||||
|
|
||||||
|
1. Create a version branch for the release:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout -b v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Merge your bug fix branch into the version branch:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git merge fix/bug-description --no-ff
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Update version numbers and changelog entries
|
||||||
|
|
||||||
|
4. Follow the standard release process from this point
|
||||||
|
|
||||||
|
### 8. Push to Remote (Optional for Collaboration)
|
||||||
|
|
||||||
|
If you need to collaborate with others on the bug fix before it's ready for release:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git push github HEAD:fix/bug-description
|
||||||
|
git push gitea HEAD:fix/bug-description
|
||||||
|
```
|
||||||
|
|
||||||
|
### 9. Create Pull Request (Optional)
|
||||||
|
|
||||||
|
If the repository uses pull requests for code review, create a pull request from the bug fix branch to the version branch.
|
||||||
|
|
||||||
|
## Determining Version Increment
|
||||||
|
|
||||||
|
After fixing a bug and confirming it works, determine the appropriate version increment:
|
||||||
|
|
||||||
|
- **PATCH** (e.g., 1.6.0 → 1.6.1): For most bug fixes that don't change functionality
|
||||||
|
- **MINOR** (e.g., 1.6.0 → 1.7.0): For bug fixes that introduce new features or significant changes
|
||||||
|
- **MAJOR** (e.g., 1.6.0 → 2.0.0): For bug fixes that introduce breaking changes
|
||||||
|
|
||||||
|
**IMPORTANT**: Don't update version numbers during initial development and testing. Only create a version branch (e.g., `v2.2.3`) and update version numbers when the fix is confirmed working.
|
||||||
|
|
||||||
|
This approach is more time-efficient as it allows you to focus on fixing the bug without worrying about version updates until the fix is confirmed working.
|
||||||
|
|
||||||
|
For detailed guidelines on time-efficient development and testing, see **@.agents/incremental-development.md**.
|
||||||
|
|
||||||
|
## Testing Previous Versions
|
||||||
|
|
||||||
|
To test a previous version of the plugin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Checkout a specific tag for testing
|
||||||
|
git checkout v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
|
||||||
|
# Or create a test branch from a specific tag
|
||||||
|
git checkout v{MAJOR}.{MINOR}.{PATCH} -b test/some-feature
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hotfix Process
|
||||||
|
|
||||||
|
For critical bugs that need immediate fixing in a released version:
|
||||||
|
|
||||||
|
### 1. Create a Hotfix Branch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
git checkout -b hotfix/v{MAJOR}.{MINOR}.{PATCH+1}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Fix the Issues
|
||||||
|
|
||||||
|
Apply the minimal fix necessary to address the critical issue.
|
||||||
|
|
||||||
|
### 3. Update Version Numbers
|
||||||
|
|
||||||
|
Increment the PATCH version and update all version numbers:
|
||||||
|
|
||||||
|
- Main plugin file (fix-plugin-does-not-exist-notices.php)
|
||||||
|
- FPDEN_VERSION constant
|
||||||
|
- CHANGELOG.md
|
||||||
|
- readme.txt
|
||||||
|
- README.md
|
||||||
|
- languages/fix-plugin-does-not-exist-notices.pot (Project-Id-Version)
|
||||||
|
|
||||||
|
### 4. Commit and Push
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Hotfix: Brief description of the critical bug fix"
|
||||||
|
git push github HEAD:hotfix/v{MAJOR}.{MINOR}.{PATCH+1}
|
||||||
|
git push gitea HEAD:hotfix/v{MAJOR}.{MINOR}.{PATCH+1}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Create and Push Tag
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag -a v{MAJOR}.{MINOR}.{PATCH+1} -m "Hotfix release version {MAJOR}.{MINOR}.{PATCH+1}"
|
||||||
|
git push github refs/tags/v{MAJOR}.{MINOR}.{PATCH+1}
|
||||||
|
git push gitea refs/tags/v{MAJOR}.{MINOR}.{PATCH+1}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Bug Types and Fixing Strategies
|
||||||
|
|
||||||
|
### WordPress Compatibility Issues
|
||||||
|
|
||||||
|
- Test with the specific WordPress version where the issue occurs
|
||||||
|
- Check for deprecated functions or hooks
|
||||||
|
- Review WordPress changelog for relevant changes
|
||||||
|
|
||||||
|
### PHP Compatibility Issues
|
||||||
|
|
||||||
|
- Test with the specific PHP version where the issue occurs
|
||||||
|
- Check for deprecated PHP functions or features
|
||||||
|
- Use appropriate polyfills if necessary
|
||||||
|
|
||||||
|
### JavaScript Issues
|
||||||
|
|
||||||
|
- Test in different browsers
|
||||||
|
- Check for browser console errors
|
||||||
|
- Consider browser-specific workarounds if necessary
|
||||||
|
|
||||||
|
### CSS Issues
|
||||||
|
|
||||||
|
- Test in different browsers and screen sizes
|
||||||
|
- Use browser developer tools to inspect elements
|
||||||
|
- Consider browser-specific workarounds if necessary
|
||||||
|
|
||||||
|
### Database Issues
|
||||||
|
|
||||||
|
- Use proper database prefixing
|
||||||
|
- Sanitize database inputs
|
||||||
|
- Use prepared statements for queries
|
||||||
|
- Consider database version differences
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
# Code Quality Checks Workflow
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This document is intended for plugin developers and code reviewers working on this repository. It outlines the process for ensuring code quality before pushing changes to the repository. Following these steps will help catch issues early and save time in the review process.
|
||||||
|
|
||||||
|
## Pre-Push Checklist
|
||||||
|
|
||||||
|
Before pushing your changes to the repository, run through the following checks:
|
||||||
|
|
||||||
|
1. **Run Unit Tests**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer test
|
||||||
|
```
|
||||||
|
|
||||||
|
Ensure all tests pass. If any tests fail, resolve the issues before proceeding.
|
||||||
|
|
||||||
|
2. **Run PHP CodeSniffer**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpcs
|
||||||
|
```
|
||||||
|
|
||||||
|
This will check your code against WordPress coding standards. Fix any issues before proceeding.
|
||||||
|
|
||||||
|
3. **Run PHP Code Beautifier and Fixer**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpcbf
|
||||||
|
```
|
||||||
|
|
||||||
|
This will automatically fix many coding standard issues.
|
||||||
|
|
||||||
|
4. **Run PHPStan**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpstan
|
||||||
|
```
|
||||||
|
|
||||||
|
This will perform static analysis on your code to find potential bugs and issues.
|
||||||
|
|
||||||
|
5. **Run PHP Mess Detector**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpmd
|
||||||
|
```
|
||||||
|
|
||||||
|
This will check for potential problems like unused variables, empty catch blocks, etc.
|
||||||
|
|
||||||
|
## Common Issues and How to Fix Them
|
||||||
|
|
||||||
|
### 1. Inline Comments
|
||||||
|
|
||||||
|
All inline comments must end with proper punctuation (period, exclamation mark, or question mark).
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Incorrect comment
|
||||||
|
$var = true;
|
||||||
|
|
||||||
|
// Correct comment.
|
||||||
|
$var = true;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Superglobal Access
|
||||||
|
|
||||||
|
Never access superglobals like `$_GET`, `$_POST`, etc. directly. Always use WordPress functions to sanitize and validate input.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Incorrect
|
||||||
|
$page = $_GET['page'];
|
||||||
|
|
||||||
|
// Correct
|
||||||
|
$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||||
|
|
||||||
|
// For testing environments
|
||||||
|
if (defined('PHPUNIT_RUNNING') && PHPUNIT_RUNNING) {
|
||||||
|
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This rule is ignored in tests to allow direct access for testing purposes
|
||||||
|
$page = isset($_GET['page']) ? wp_unslash($_GET['page']) : '';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Avoid Unnecessary Else Clauses
|
||||||
|
|
||||||
|
Simplify your code by avoiding unnecessary else clauses.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Less preferred
|
||||||
|
if (condition) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preferred
|
||||||
|
if (condition) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Proper Function Spacing
|
||||||
|
|
||||||
|
Ensure proper spacing in function calls and declarations.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Incorrect
|
||||||
|
function_name($param1,$param2);
|
||||||
|
|
||||||
|
// Correct
|
||||||
|
function_name( $param1, $param2 );
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Naming Conventions
|
||||||
|
|
||||||
|
Follow WordPress naming conventions:
|
||||||
|
|
||||||
|
* Functions and variables: snake_case with plugin-specific prefix (e.g., `myplugin_function_name`)
|
||||||
|
* Classes: CamelCase
|
||||||
|
* Constants: UPPERCASE_WITH_UNDERSCORES with plugin-specific prefix (e.g., `MYPLUGIN_CONSTANT_NAME`)
|
||||||
|
|
||||||
|
## Automated Checks in CI/CD
|
||||||
|
|
||||||
|
Our CI/CD pipeline includes the following automated checks:
|
||||||
|
|
||||||
|
1. **CodeFactor**: Analyzes code quality and style
|
||||||
|
2. **Codacy**: Performs static code analysis
|
||||||
|
3. **SonarCloud**: Checks for code smells, bugs, and security vulnerabilities
|
||||||
|
4. **CodeRabbit**: Provides AI-powered code review
|
||||||
|
|
||||||
|
Although CI runs these checks, catching issues locally helps save time and minimize follow-up commits.
|
||||||
|
|
||||||
|
## Using AI to Help with Code Quality
|
||||||
|
|
||||||
|
You can use AI assistants to help improve code quality:
|
||||||
|
|
||||||
|
1. Run the code quality checks locally
|
||||||
|
2. If issues are found, ask the AI assistant to help fix them
|
||||||
|
3. Apply the suggested fixes
|
||||||
|
4. Run the checks again to verify the issues are resolved
|
||||||
|
|
||||||
|
Example prompt:
|
||||||
|
|
||||||
|
```text
|
||||||
|
I ran PHPCS and got the following errors. Can you help me fix them?
|
||||||
|
|
||||||
|
[Paste error output here]
|
||||||
|
```
|
||||||
|
|
||||||
|
For more AI assistance guidelines, see the [AI Assistant Guide](./../AGENTS.md).
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
This workflow helps maintain high code quality and accelerates the review process. Remember, it's always more efficient to resolve issues locally than to go through multiple rounds of CI/CD and code review.
|
||||||
@@ -0,0 +1,271 @@
|
|||||||
|
# Code Review Guide for AI Assistants
|
||||||
|
|
||||||
|
This document provides guidance for AI assistants to help with code review for this project.
|
||||||
|
|
||||||
|
## Code Review Checklist
|
||||||
|
|
||||||
|
### Testing with WordPress Playground
|
||||||
|
|
||||||
|
Before submitting code for review, test it with WordPress Playground:
|
||||||
|
|
||||||
|
* [ ] Test in single site environment: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=5)
|
||||||
|
* [ ] Test in multisite environment: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=18)
|
||||||
|
* [ ] Verify plugin functionality works in both environments
|
||||||
|
* [ ] Check for any JavaScript errors in the browser console
|
||||||
|
* [ ] Run Cypress tests locally: `npm run test:playground:single` and `npm run test:playground:multisite`
|
||||||
|
|
||||||
|
For more details on WordPress Playground testing, see the [Testing Framework](../.wiki/Testing.md) documentation.
|
||||||
|
|
||||||
|
When reviewing code, check for the following:
|
||||||
|
|
||||||
|
### Functionality
|
||||||
|
|
||||||
|
* [ ] Does the code work as expected?
|
||||||
|
* [ ] Does it handle edge cases appropriately?
|
||||||
|
* [ ] Are there any logical errors?
|
||||||
|
* [ ] Is error handling implemented properly?
|
||||||
|
|
||||||
|
### Code Quality
|
||||||
|
|
||||||
|
* [ ] Does the code follow WordPress coding standards?
|
||||||
|
* [ ] Is the code well-organized and easy to understand?
|
||||||
|
* [ ] Are there any code smells (duplicate code, overly complex functions, etc.)?
|
||||||
|
* [ ] Are functions and variables named appropriately?
|
||||||
|
* [ ] Are there appropriate comments and documentation?
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
* [ ] Is user input properly validated and sanitized?
|
||||||
|
* [ ] Is output properly escaped?
|
||||||
|
* [ ] Are capability checks used for user actions?
|
||||||
|
* [ ] Are nonces used for form submissions?
|
||||||
|
* [ ] Are there any potential SQL injection vulnerabilities?
|
||||||
|
* [ ] Are there any potential XSS vulnerabilities?
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
* [ ] Are there any performance bottlenecks?
|
||||||
|
* [ ] Are database queries optimized?
|
||||||
|
* [ ] Is caching used appropriately?
|
||||||
|
* [ ] Are assets (CSS, JS) properly enqueued?
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
|
||||||
|
* [ ] Is the code compatible with the minimum supported WordPress version (5.0)?
|
||||||
|
* [ ] Is the code compatible with the minimum supported PHP version (7.0)?
|
||||||
|
* [ ] Are there any browser compatibility issues?
|
||||||
|
* [ ] Are there any conflicts with other plugins?
|
||||||
|
|
||||||
|
### Internationalization
|
||||||
|
|
||||||
|
* [ ] Are all user-facing strings translatable?
|
||||||
|
* [ ] Is the correct text domain used?
|
||||||
|
* [ ] Are translation functions used correctly?
|
||||||
|
|
||||||
|
### Accessibility
|
||||||
|
|
||||||
|
* [ ] Does the code follow accessibility best practices?
|
||||||
|
* [ ] Are ARIA attributes used appropriately?
|
||||||
|
* [ ] Is keyboard navigation supported?
|
||||||
|
* [ ] Is screen reader support implemented?
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
* [ ] Are there appropriate unit tests for PHP code?
|
||||||
|
* [ ] Are there appropriate end-to-end tests for UI functionality?
|
||||||
|
* [ ] Do tests cover both single site and multisite scenarios?
|
||||||
|
* [ ] Are tests well-organized and maintainable?
|
||||||
|
* [ ] Do tests use appropriate assertions and expectations?
|
||||||
|
|
||||||
|
## Automated Code Review Tools
|
||||||
|
|
||||||
|
This project uses several automated code review tools to maintain high quality standards.
|
||||||
|
|
||||||
|
These tools are free for public repositories and should be integrated into new repositories.
|
||||||
|
|
||||||
|
**Important**: Before pushing, run local code quality checks as described in
|
||||||
|
[Code Quality Checks Workflow](./code-quality-checks.md) to catch issues early.
|
||||||
|
|
||||||
|
### 1. CodeRabbit
|
||||||
|
|
||||||
|
[CodeRabbit](https://www.coderabbit.ai/) is an AI-powered code review tool.
|
||||||
|
|
||||||
|
It provides automated feedback on pull requests.
|
||||||
|
|
||||||
|
* **Integration**: Add the CodeRabbit GitHub App to your repository
|
||||||
|
* **Benefits**: Provides AI-powered code reviews, identifies potential issues, and suggests improvements
|
||||||
|
* **Usage**: CodeRabbit automatically reviews pull requests when they are created or updated
|
||||||
|
|
||||||
|
### 2. CodeFactor
|
||||||
|
|
||||||
|
[CodeFactor](https://www.codefactor.io/) continuously monitors code quality.
|
||||||
|
|
||||||
|
It provides feedback on code style, complexity, and potential issues.
|
||||||
|
|
||||||
|
* **Integration**: Add the CodeFactor GitHub App to your repository
|
||||||
|
* **Benefits**: Provides a grade for your codebase, identifies issues, and tracks code quality over time
|
||||||
|
* **Usage**: CodeFactor automatically analyzes your codebase and provides feedback on pull requests
|
||||||
|
|
||||||
|
### 3. Codacy
|
||||||
|
|
||||||
|
[Codacy](https://www.codacy.com/) is a code quality tool.
|
||||||
|
|
||||||
|
It provides static analysis, code coverage, and code duplication detection.
|
||||||
|
|
||||||
|
* **Integration**: Add the Codacy GitHub App to your repository
|
||||||
|
* **Benefits**: Provides a grade for your codebase, identifies issues, and tracks code quality over time
|
||||||
|
* **Usage**: Codacy automatically analyzes your codebase and provides feedback on pull requests
|
||||||
|
|
||||||
|
### 4. PHPStan
|
||||||
|
|
||||||
|
[PHPStan](https://phpstan.org/) is a static analysis tool that finds errors in your code without running it.
|
||||||
|
|
||||||
|
* **Integration**: Included in the project's composer.json and GitHub Actions workflow
|
||||||
|
* **Benefits**: Detects undefined variables, methods, and properties; type-related issues; and logical errors
|
||||||
|
* **Usage**: Run `composer phpstan` or `npm run lint:phpstan` locally, or let GitHub Actions run it automatically
|
||||||
|
|
||||||
|
### 5. PHP Mess Detector
|
||||||
|
|
||||||
|
[PHP Mess Detector](https://phpmd.org/) looks for potential problems in your code.
|
||||||
|
|
||||||
|
It detects bugs, suboptimal code, overcomplicated expressions, and unused code.
|
||||||
|
|
||||||
|
* **Integration**: Included in the project's composer.json and GitHub Actions workflow
|
||||||
|
* **Benefits**: Identifies code smells, complexity issues, unused code, naming problems, and more
|
||||||
|
* **Usage**: Run `composer phpmd` or `npm run lint:phpmd` locally, or let GitHub Actions run it automatically
|
||||||
|
|
||||||
|
### Using AI Assistants with Code Review Tools
|
||||||
|
|
||||||
|
When you receive feedback from these code review tools, you can use AI assistants to help address the issues:
|
||||||
|
|
||||||
|
1. Copy the output from the code review tool
|
||||||
|
2. Paste it into your AI assistant chat
|
||||||
|
3. Ask the AI to help you understand and resolve the issues
|
||||||
|
4. Apply the suggested fixes
|
||||||
|
5. Commit the changes and verify that the issues are resolved
|
||||||
|
|
||||||
|
### Markdown Formatting Standards
|
||||||
|
|
||||||
|
When writing or updating Markdown files in this project, follow these standards:
|
||||||
|
|
||||||
|
* Always use asterisks (*) for bullet points, not hyphens (-)
|
||||||
|
* Use proper heading hierarchy (# for main title, ## for sections, etc.)
|
||||||
|
* Use code blocks with language specification for code examples
|
||||||
|
* Use relative links for internal documentation
|
||||||
|
* Include alt text for images
|
||||||
|
|
||||||
|
Example prompt for AI assistants:
|
||||||
|
|
||||||
|
```text
|
||||||
|
I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
|
||||||
|
|
||||||
|
[Paste the tool output here]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Code Review Process
|
||||||
|
|
||||||
|
### 1. Understand the Context
|
||||||
|
|
||||||
|
Before reviewing code, understand:
|
||||||
|
|
||||||
|
* What problem is the code trying to solve?
|
||||||
|
* What are the requirements?
|
||||||
|
* What are the constraints?
|
||||||
|
|
||||||
|
### 2. Review the Code
|
||||||
|
|
||||||
|
Review the code with the checklist above in mind.
|
||||||
|
|
||||||
|
### 3. Provide Feedback
|
||||||
|
|
||||||
|
When providing feedback:
|
||||||
|
|
||||||
|
* Be specific and clear
|
||||||
|
* Explain why a change is needed
|
||||||
|
* Provide examples or suggestions when possible
|
||||||
|
* Prioritize feedback (critical issues vs. minor improvements)
|
||||||
|
* Be constructive and respectful
|
||||||
|
|
||||||
|
### 4. Follow Up
|
||||||
|
|
||||||
|
After the code has been updated:
|
||||||
|
|
||||||
|
* Review the changes
|
||||||
|
* Verify that issues have been addressed
|
||||||
|
* Provide additional feedback if necessary
|
||||||
|
|
||||||
|
## Common Issues to Look For
|
||||||
|
|
||||||
|
### PHP Issues
|
||||||
|
|
||||||
|
* Undefined variables or functions
|
||||||
|
* Incorrect function parameters
|
||||||
|
* Missing return statements
|
||||||
|
* Improper error handling
|
||||||
|
* Inefficient loops or conditionals
|
||||||
|
* Hardcoded values that should be configurable
|
||||||
|
|
||||||
|
### WordPress-Specific Issues
|
||||||
|
|
||||||
|
* Incorrect hook usage
|
||||||
|
* Missing or incorrect nonces
|
||||||
|
* Missing capability checks
|
||||||
|
* Direct database queries instead of using WordPress functions
|
||||||
|
* Improper enqueuing of scripts and styles
|
||||||
|
* Not using WordPress functions for common tasks
|
||||||
|
|
||||||
|
### JavaScript Issues
|
||||||
|
|
||||||
|
* Undefined variables or functions
|
||||||
|
* Event listener memory leaks
|
||||||
|
* jQuery conflicts
|
||||||
|
* Browser compatibility issues
|
||||||
|
* Missing error handling
|
||||||
|
|
||||||
|
### CSS Issues
|
||||||
|
|
||||||
|
* Browser compatibility issues
|
||||||
|
* Specificity issues
|
||||||
|
* Unused styles
|
||||||
|
* Overriding WordPress admin styles inappropriately
|
||||||
|
|
||||||
|
## Example Feedback
|
||||||
|
|
||||||
|
### Good Feedback Example
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
In function `handle_remove_reference()`:
|
||||||
|
|
||||||
|
1. The nonce check is missing, which could lead to CSRF vulnerabilities.
|
||||||
|
Consider adding:
|
||||||
|
```php
|
||||||
|
if (!isset($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], 'fpden_remove_reference')) {
|
||||||
|
wp_die(__('Security check failed.', 'fix-plugin-does-not-exist-notices'));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. The user capability check should be more specific. Instead of:
|
||||||
|
```php
|
||||||
|
if (!current_user_can('manage_options')) {
|
||||||
|
```
|
||||||
|
Consider using:
|
||||||
|
```php
|
||||||
|
if (!current_user_can('activate_plugins')) {
|
||||||
|
```
|
||||||
|
This is more appropriate for the action being performed.
|
||||||
|
|
||||||
|
3. The success message should be translatable:
|
||||||
|
```php
|
||||||
|
// Change this:
|
||||||
|
add_settings_error('fpden', 'fpden_removed', 'Plugin reference removed successfully.', 'updated');
|
||||||
|
|
||||||
|
// To this:
|
||||||
|
add_settings_error('fpden', 'fpden_removed', __('Plugin reference removed successfully.', 'fix-plugin-does-not-exist-notices'), 'updated');
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
|
### Poor Feedback Example
|
||||||
|
|
||||||
|
```text
|
||||||
|
This code has security issues and doesn't follow best practices. Fix it.
|
||||||
|
```
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# Developer Preferences Memory
|
||||||
|
|
||||||
|
This document serves as a persistent memory for developer preferences established during coding sessions. AI assistants should refer to this document to understand the developer's preferences and update it as new preferences are established.
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
- Maintain a consistent record of developer preferences across coding sessions
|
||||||
|
- Ensure AI assistants can provide assistance that aligns with the developer's preferred coding style and practices
|
||||||
|
- Reduce the need for developers to repeatedly explain their preferences
|
||||||
|
|
||||||
|
## How to Use This Document
|
||||||
|
|
||||||
|
- **AI Assistants**: Review this document before providing assistance. Update it when new preferences are established through user feedback.
|
||||||
|
- **Developers**: Reference this document to see what preferences have been recorded. Feel free to edit it directly to add or modify preferences.
|
||||||
|
|
||||||
|
## Recorded Preferences
|
||||||
|
|
||||||
|
### File and Directory Structure
|
||||||
|
|
||||||
|
- Prefer lowercase filenames for consistency across the codebase
|
||||||
|
- Use unique folder names following best practices
|
||||||
|
- Folder references should be easily identifiable when using @mentions in AI-assisted coding
|
||||||
|
- Admin-specific functionality should be in the `admin/lib/` directory
|
||||||
|
- Core plugin functionality should be in the `includes/` directory
|
||||||
|
|
||||||
|
### Code Style
|
||||||
|
|
||||||
|
- Follow WordPress coding standards
|
||||||
|
- Use OOP best practices for WordPress plugins
|
||||||
|
- Create modular, maintainable, and efficient code structure
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
- Prefer token-efficient documentation in `AGENTS.md` that references `.agents/` files
|
||||||
|
- Document the release workflow in `AGENTS.md` and `.agents/release-process.md`
|
||||||
|
- Store environment variable documentation in `.agents/local-env-vars.md`
|
||||||
|
- Maintain consistent documentation across readme.txt, README.md, and CHANGELOG.md
|
||||||
|
|
||||||
|
### Asset Organization
|
||||||
|
|
||||||
|
- Store banner, icon, and screenshot images in `.wordpress-org/assets/`
|
||||||
|
- Store WORDPRESS_ORG files within `/wordpress-org`
|
||||||
|
- Organize files in `/assets` into relevant `/admin` folders
|
||||||
|
|
||||||
|
### Version Control
|
||||||
|
|
||||||
|
- Use standard Git practices for version control and code management
|
||||||
|
- When updating plugin versions, create a GitHub tag and trigger GitHub actions
|
||||||
|
- Follow a specific release process with proper tagging and GitHub releases
|
||||||
|
- Ensure commits are merged to the main branch as Git Updater pulls data from the readme.txt file in the primary branch
|
||||||
|
|
||||||
|
### Plugin Development
|
||||||
|
|
||||||
|
- Prefer simpler solutions over complex ones for plugins
|
||||||
|
- Use a specific formatting style for the CHANGELOG.md file, using #### for section headings
|
||||||
|
- When updating plugin versions, remember to update language files (POT/PO)
|
||||||
|
- Comment out redundant code during testing
|
||||||
|
|
||||||
|
### Potential AI Assised IDE Issues
|
||||||
|
|
||||||
|
- Check for non-standard local terminal commandline customisations that might not be understood by the AI IDE in its terminal useage and cause errors in execution or confusion in not seeing expected results, and advise on how to resolve
|
||||||
|
- Check for non-standard or multiple python and node.js versions, including homebrew versions, that might not be understood by the AI IDE in its terminal useage and cause errors in execution or confusion in not seeing expected results, and advise on how to resolve
|
||||||
@@ -0,0 +1,494 @@
|
|||||||
|
# Error Checking and Feedback Loops
|
||||||
|
|
||||||
|
This document outlines the processes for error checking, debugging, and establishing feedback loops.
|
||||||
|
|
||||||
|
The goal is to create a seamless, autonomous CI/CD pipeline.
|
||||||
|
|
||||||
|
The AI can identify, diagnose, and fix issues with minimal human intervention.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
* [GitHub Actions Workflow Monitoring](#github-actions-workflow-monitoring)
|
||||||
|
* [Local Build and Test Feedback](#local-build-and-test-feedback)
|
||||||
|
* [Code Quality Tool Integration](#code-quality-tool-integration)
|
||||||
|
* [Automated Error Resolution](#automated-error-resolution)
|
||||||
|
* [Feedback Loop Architecture](#feedback-loop-architecture)
|
||||||
|
* [When to Consult Humans](#when-to-consult-humans)
|
||||||
|
|
||||||
|
## GitHub Actions Workflow Monitoring
|
||||||
|
|
||||||
|
### Checking Workflow Status via GitHub API
|
||||||
|
|
||||||
|
AI assistants can directly monitor GitHub Actions workflows using the GitHub API.
|
||||||
|
|
||||||
|
This helps identify failures and diagnose issues:
|
||||||
|
|
||||||
|
```
|
||||||
|
github-api /repos/{owner}/{repo}/actions/runs
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step-by-Step Process
|
||||||
|
|
||||||
|
1. **Get Recent Workflow Runs**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/actions/runs
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Filter for Failed Runs**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/actions/runs?status=failure
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Get Details for a Specific Run**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/actions/runs/{run_id}
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Get Jobs for a Workflow Run**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/actions/runs/{run_id}/jobs
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Analyze Job Logs** (if accessible via API):
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/actions/jobs/{job_id}/logs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Common GitHub Actions Errors and Solutions
|
||||||
|
|
||||||
|
#### Missing or Outdated Action Versions
|
||||||
|
|
||||||
|
**Error**: `Missing download info for actions/upload-artifact@v3`
|
||||||
|
|
||||||
|
**Solution**: Update to the latest version of the action:
|
||||||
|
```yaml
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Port Configuration Issues for WordPress Multisite
|
||||||
|
|
||||||
|
**Error**: `The current host is 127.0.0.1:8888, but WordPress multisites do not support custom ports.`
|
||||||
|
|
||||||
|
**Solution**: Use port 80 for multisite environments:
|
||||||
|
```yaml
|
||||||
|
npx @wp-playground/cli server --blueprint playground/multisite-blueprint.json --port 80 --login &
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Artifact Path Syntax Issues
|
||||||
|
|
||||||
|
**Error**: Invalid path syntax for artifacts
|
||||||
|
|
||||||
|
**Solution**: Use multi-line format for better readability:
|
||||||
|
```yaml
|
||||||
|
path: |
|
||||||
|
cypress/videos
|
||||||
|
cypress/screenshots
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Concurrency Control
|
||||||
|
|
||||||
|
**Problem**: Redundant workflow runs when multiple commits land quickly
|
||||||
|
|
||||||
|
**Solution**: Add concurrency control to cancel in-progress runs:
|
||||||
|
```yaml
|
||||||
|
concurrency:
|
||||||
|
group: playground-tests-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Local Build and Test Feedback
|
||||||
|
|
||||||
|
### Monitoring Local Test Runs
|
||||||
|
|
||||||
|
AI assistants can monitor local test runs by analyzing the output of test commands.
|
||||||
|
|
||||||
|
#### PHP Unit Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer run phpunit
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Cypress Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:single
|
||||||
|
npm run test:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
#### WordPress Playground Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:playground:single
|
||||||
|
npm run test:playground:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
### Capturing and Analyzing Test Output
|
||||||
|
|
||||||
|
1. **Run Tests with Output Capture**:
|
||||||
|
```bash
|
||||||
|
npm run test:single > test-output.log 2>&1
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Analyze Output for Errors**:
|
||||||
|
```bash
|
||||||
|
cat test-output.log | grep -i 'error\|fail\|exception'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Parse Structured Test Results** (if available):
|
||||||
|
```bash
|
||||||
|
cat cypress/results/results.json
|
||||||
|
```
|
||||||
|
|
||||||
|
### Common Local Test Errors and Solutions
|
||||||
|
|
||||||
|
#### WordPress Playground Port Issues
|
||||||
|
|
||||||
|
**Error**: `The current host is 127.0.0.1:8888, but WordPress multisites do not support custom ports.`
|
||||||
|
|
||||||
|
**Solution**: Modify the port in the blueprint or test configuration:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"features": {
|
||||||
|
"networking": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Cypress Selector Errors
|
||||||
|
|
||||||
|
**Error**: `Timed out retrying after 4000ms: expected '<body...>' to have class 'wp-admin'`
|
||||||
|
|
||||||
|
**Solution**: Update selectors to be more robust and handle login states:
|
||||||
|
```javascript
|
||||||
|
cy.get('body').then(($body) => {
|
||||||
|
if ($body.hasClass('login')) {
|
||||||
|
cy.get('#user_login').type('admin');
|
||||||
|
cy.get('#user_pass').type('password');
|
||||||
|
cy.get('#wp-submit').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check for admin bar instead of body class
|
||||||
|
cy.get('#wpadminbar').should('exist');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Code Quality Tool Integration
|
||||||
|
|
||||||
|
### Automated Code Quality Checks
|
||||||
|
|
||||||
|
AI assistants can integrate with various code quality tools to identify and fix issues.
|
||||||
|
|
||||||
|
#### PHPCS (PHP CodeSniffer)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer run phpcs
|
||||||
|
```
|
||||||
|
|
||||||
|
#### ESLint (JavaScript)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint:js
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Stylelint (CSS)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint:css
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parsing Code Quality Tool Output
|
||||||
|
|
||||||
|
1. **Run Code Quality Check**:
|
||||||
|
```bash
|
||||||
|
composer run phpcs > phpcs-output.log 2>&1
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Analyze Output for Errors**:
|
||||||
|
```bash
|
||||||
|
cat phpcs-output.log | grep -i 'ERROR\|WARNING'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Automatically Fix Issues** (when possible):
|
||||||
|
```bash
|
||||||
|
composer run phpcbf
|
||||||
|
```
|
||||||
|
|
||||||
|
### Monitoring Code Quality Feedback in Pull Requests
|
||||||
|
|
||||||
|
Automated code quality tools often provide feedback directly in pull requests.
|
||||||
|
|
||||||
|
AI assistants can check these comments to identify and address issues.
|
||||||
|
|
||||||
|
#### Accessing PR Comments via GitHub API
|
||||||
|
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/pulls/{pull_number}/comments
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Accessing PR Review Comments
|
||||||
|
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/pulls/{pull_number}/reviews
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Checking CodeRabbit Feedback
|
||||||
|
|
||||||
|
CodeRabbit provides AI-powered code review comments via the GitHub API.
|
||||||
|
|
||||||
|
1. **Get PR Comments**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/pulls/{pull_number}/comments
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Filter for CodeRabbit Comments**:
|
||||||
|
Look for comments from the `coderabbitai` user.
|
||||||
|
|
||||||
|
3. **Parse Actionable Feedback**:
|
||||||
|
* Code quality issues
|
||||||
|
* Suggested improvements
|
||||||
|
* Best practice recommendations
|
||||||
|
* Specific code snippets to fix
|
||||||
|
|
||||||
|
#### Checking Codacy and CodeFactor Feedback
|
||||||
|
|
||||||
|
These tools provide automated code quality checks and post results as PR comments.
|
||||||
|
|
||||||
|
1. **Check PR Status Checks**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/commits/{sha}/check-runs
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Get Detailed Reports** (if available via API):
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/commits/{sha}/check-runs/{id}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Parse Common Issues**:
|
||||||
|
* Code style violations
|
||||||
|
* Potential bugs
|
||||||
|
* Security vulnerabilities
|
||||||
|
* Performance issues
|
||||||
|
* Duplication
|
||||||
|
|
||||||
|
#### Checking SonarCloud Analysis
|
||||||
|
|
||||||
|
SonarCloud provides detailed code quality and security analysis.
|
||||||
|
|
||||||
|
1. **Check SonarCloud Status**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/commits/{sha}/check-runs?check_name=SonarCloud
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Parse SonarCloud Issues**:
|
||||||
|
* Code smells
|
||||||
|
* Bugs
|
||||||
|
* Vulnerabilities
|
||||||
|
* Security hotspots
|
||||||
|
* Coverage gaps
|
||||||
|
|
||||||
|
### Common Code Quality Issues and Solutions
|
||||||
|
|
||||||
|
#### WordPress Coding Standards
|
||||||
|
|
||||||
|
**Error**: `ERROR: Expected snake_case for function name, but found camelCase`
|
||||||
|
|
||||||
|
**Solution**: Rename functions to follow snake_case convention:
|
||||||
|
```php
|
||||||
|
// Before
|
||||||
|
function getPluginVersion() { ... }
|
||||||
|
|
||||||
|
// After
|
||||||
|
function get_plugin_version() { ... }
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Missing Docblocks
|
||||||
|
|
||||||
|
**Error**: `ERROR: Missing doc comment for function`
|
||||||
|
|
||||||
|
**Solution**: Add proper docblocks:
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* Get the plugin version.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @return string The plugin version.
|
||||||
|
*/
|
||||||
|
function get_plugin_version() { ... }
|
||||||
|
```
|
||||||
|
|
||||||
|
## Automated Error Resolution
|
||||||
|
|
||||||
|
### Error Resolution Workflow
|
||||||
|
|
||||||
|
1. **Identify Error**: Use GitHub API or local test output to identify errors
|
||||||
|
2. **Categorize Error**: Determine error type and severity
|
||||||
|
3. **Search for Solution**: Look for patterns in known solutions
|
||||||
|
4. **Apply Fix**: Make necessary code changes
|
||||||
|
5. **Verify Fix**: Run tests again to confirm the issue is resolved
|
||||||
|
6. **Document Solution**: Update documentation with the solution
|
||||||
|
|
||||||
|
### Processing Code Quality Feedback
|
||||||
|
|
||||||
|
#### Extracting Actionable Items from PR Comments
|
||||||
|
|
||||||
|
1. **Collect All Feedback**:
|
||||||
|
```
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/pulls/{number}/comments
|
||||||
|
github-api /repos/wpallstars/wp-plugin-starter-template-for-ai-coding/pulls/{number}/reviews
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Categorize Issues**:
|
||||||
|
* Critical: Security vulnerabilities, breaking bugs
|
||||||
|
* High: Code quality violations, potential bugs
|
||||||
|
* Medium: Style issues, best practices
|
||||||
|
* Low: Documentation, minor improvements
|
||||||
|
|
||||||
|
3. **Prioritize Fixes**:
|
||||||
|
* Address critical issues first
|
||||||
|
* Group related issues for efficient fixing
|
||||||
|
* Consider dependencies between issues
|
||||||
|
|
||||||
|
4. **Create Fix Plan**:
|
||||||
|
* Document files that need changes
|
||||||
|
* Outline specific changes needed
|
||||||
|
* Note any potential side effects
|
||||||
|
|
||||||
|
#### Responding to Code Quality Tool Comments
|
||||||
|
|
||||||
|
1. **Acknowledge Feedback**: React to or reply to comments
|
||||||
|
2. **Implement Fixes**: Make the necessary code changes
|
||||||
|
3. **Explain Changes** (if needed): Add comments explaining decisions
|
||||||
|
4. **Request Review** (if needed): Ask for re-review after fixes
|
||||||
|
|
||||||
|
## Feedback Loop Architecture
|
||||||
|
|
||||||
|
### Complete Feedback Loop System
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||||
|
│ │ │ │ │ │
|
||||||
|
│ Code Changes │────▶│ Local Testing │────▶│ GitHub Actions │
|
||||||
|
│ │ │ │ │ │
|
||||||
|
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
|
||||||
|
│ │ │
|
||||||
|
│ │ │
|
||||||
|
│ │ │
|
||||||
|
┌────────▼────────┐ ┌────────▼────────┐ ┌────────▼────────┐
|
||||||
|
│ │ │ │ │ │
|
||||||
|
│ AI Assistant │◀────│ Error Analysis │◀────│ Status Check │
|
||||||
|
│ │ │ │ │ │
|
||||||
|
└────────┬────────┘ └─────────────────┘ └─────────────────┘
|
||||||
|
│
|
||||||
|
│
|
||||||
|
│
|
||||||
|
┌────────▼────────┐ ┌─────────────────┐
|
||||||
|
│ │ │ │
|
||||||
|
│ Fix Generation │────▶│ Human Review │ (only when necessary)
|
||||||
|
│ │ │ │
|
||||||
|
└─────────────────┘ └─────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Components
|
||||||
|
|
||||||
|
1. **Code Changes**: Initial code modifications
|
||||||
|
2. **Local Testing**: Immediate feedback on local environment
|
||||||
|
3. **GitHub Actions**: Remote CI/CD pipeline validation
|
||||||
|
4. **Status Check**: Monitoring workflow status via GitHub API
|
||||||
|
5. **Error Analysis**: Parsing and categorizing errors
|
||||||
|
6. **AI Assistant**: Central intelligence for error resolution
|
||||||
|
7. **Fix Generation**: Creating and implementing solutions
|
||||||
|
8. **Human Review**: Optional step for complex decisions
|
||||||
|
|
||||||
|
## Handling Direct Feedback from Code Review Tools
|
||||||
|
|
||||||
|
### Accessing and Processing CodeRabbit Feedback
|
||||||
|
|
||||||
|
CodeRabbit provides detailed AI-powered code reviews.
|
||||||
|
|
||||||
|
These can be directly accessed and processed.
|
||||||
|
|
||||||
|
#### Example CodeRabbit Feedback
|
||||||
|
|
||||||
|
```
|
||||||
|
coderabbitai bot left a comment
|
||||||
|
Actionable comments posted: 1
|
||||||
|
|
||||||
|
🧹 Nitpick comments (3)
|
||||||
|
.github/workflows/playground-tests-fix.yml (3)
|
||||||
|
9-13: Add concurrency control to avoid redundant runs.
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Processing Steps
|
||||||
|
|
||||||
|
1. **Extract Specific Recommendations**:
|
||||||
|
* Identify file paths and line numbers
|
||||||
|
* Parse suggested code changes
|
||||||
|
* Understand the rationale for changes
|
||||||
|
|
||||||
|
2. **Implement Recommendations**: Apply the suggested changes
|
||||||
|
|
||||||
|
3. **Verify Implementation**:
|
||||||
|
* Run local tests if applicable
|
||||||
|
* Commit changes with descriptive message
|
||||||
|
* Monitor CI/CD pipeline for success
|
||||||
|
|
||||||
|
### Handling SonarCloud and Codacy Feedback
|
||||||
|
|
||||||
|
These tools provide structured feedback that can be systematically addressed.
|
||||||
|
|
||||||
|
#### Example SonarCloud Feedback
|
||||||
|
|
||||||
|
```
|
||||||
|
SonarCloud Quality Gate failed
|
||||||
|
- 3 Bugs
|
||||||
|
- 5 Code Smells
|
||||||
|
- 1 Security Hotspot
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Processing Steps
|
||||||
|
|
||||||
|
1. **Access Detailed Reports**:
|
||||||
|
* Use the SonarCloud API or web interface
|
||||||
|
* Categorize issues by severity and type
|
||||||
|
|
||||||
|
2. **Address Issues Systematically**:
|
||||||
|
* Fix bugs first
|
||||||
|
* Address security hotspots
|
||||||
|
* Resolve code smells
|
||||||
|
|
||||||
|
3. **Document Resolutions**:
|
||||||
|
* Note patterns of issues for future prevention
|
||||||
|
* Update coding guidelines if necessary
|
||||||
|
|
||||||
|
## When to Consult Humans
|
||||||
|
|
||||||
|
While the goal is to create an autonomous system, there are scenarios where human input is necessary.
|
||||||
|
|
||||||
|
### Scenarios Requiring Human Consultation
|
||||||
|
|
||||||
|
1. **Product Design Decisions**: Features, UX, and strategic direction
|
||||||
|
2. **Security-Critical Changes**: Changes that could impact security posture
|
||||||
|
3. **Architectural Decisions**: Major structural changes to the codebase
|
||||||
|
4. **Deployment Approvals**: Final approval for production releases
|
||||||
|
5. **Access Requirements**: When additional permissions are needed
|
||||||
|
6. **Ambiguous Errors**: When errors have multiple possible interpretations
|
||||||
|
7. **Novel Problems**: Issues without precedent or documented solutions
|
||||||
|
8. **External Service Issues**: Problems with third-party services
|
||||||
|
|
||||||
|
### Effective Human Consultation
|
||||||
|
|
||||||
|
When consulting humans, provide:
|
||||||
|
|
||||||
|
1. **Clear Context**: Explain what you were trying to accomplish
|
||||||
|
2. **Error Details**: Provide specific error messages and logs
|
||||||
|
3. **Attempted Solutions**: Document what you've already tried
|
||||||
|
4. **Specific Questions**: Ask targeted questions rather than open-ended ones
|
||||||
|
5. **Recommendations**: Suggest possible solutions for approval
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
This error checking and feedback loop system creates a comprehensive framework for AI-driven development.
|
||||||
|
|
||||||
|
By systematically monitoring, analyzing, and resolving errors, the AI assistant can maintain high code quality.
|
||||||
|
|
||||||
|
For related workflows, refer to the other documents in the `.agents/` directory.
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
# Feature Development Guide for AI Assistants
|
||||||
|
|
||||||
|
This document provides guidance for AI assistants to help with feature development for the Fix Plugin Does Not Exist Notices plugin.
|
||||||
|
|
||||||
|
## Feature Development Workflow
|
||||||
|
|
||||||
|
### 1. Create a Feature Branch
|
||||||
|
|
||||||
|
Always start by creating a feature branch from the latest main branch pulled from origin (this step is mandatory):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main # Critical step - never skip this
|
||||||
|
git checkout -b feature/descriptive-name
|
||||||
|
```
|
||||||
|
|
||||||
|
Use a descriptive name that clearly indicates what the feature is about. If there's an issue number, include it in the branch name (e.g., `feature/123-update-source-selector`).
|
||||||
|
|
||||||
|
For more detailed git workflow guidelines, see **@.agents/git-workflow.md**.
|
||||||
|
|
||||||
|
### 2. Implement the Feature
|
||||||
|
|
||||||
|
When implementing a new feature:
|
||||||
|
|
||||||
|
- Follow WordPress coding standards
|
||||||
|
- Ensure all strings are translatable
|
||||||
|
- Add appropriate comments
|
||||||
|
- Consider performance implications
|
||||||
|
- Maintain backward compatibility
|
||||||
|
- Review reference plugins in the `reference-plugins/` directory for inspiration and best practices
|
||||||
|
|
||||||
|
### 3. Update Documentation
|
||||||
|
|
||||||
|
Update relevant documentation to reflect the new feature:
|
||||||
|
|
||||||
|
- Add a description to CHANGELOG.md under an "Unreleased" section
|
||||||
|
- Update readme.txt if the feature affects user-facing functionality
|
||||||
|
- Update README.md with the new feature description
|
||||||
|
- Update inline documentation/comments
|
||||||
|
- Update wiki documentation in the `.wiki` directory:
|
||||||
|
- Create or update feature-specific pages
|
||||||
|
- Update the Home.md page if necessary
|
||||||
|
- Add the feature to any relevant existing pages
|
||||||
|
- Add screenshots or examples if applicable
|
||||||
|
- Remember that any feature addition will require a version increment in all relevant files
|
||||||
|
|
||||||
|
For detailed guidelines on maintaining wiki documentation, see **@.agents/wiki-documentation.md**.
|
||||||
|
|
||||||
|
### 4. Testing
|
||||||
|
|
||||||
|
Test the feature 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 in different environments (if possible)
|
||||||
|
|
||||||
|
### 5. Commit Changes
|
||||||
|
|
||||||
|
Make atomic commits with clear messages:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Add feature: descriptive name"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Prepare for Release
|
||||||
|
|
||||||
|
When the feature is ready to be released:
|
||||||
|
|
||||||
|
1. Create a version branch with the appropriate version number (typically increment the minor version for features):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Example: from 2.2.0 to 2.3.0
|
||||||
|
git checkout -b v{MAJOR}.{MINOR+1}.0
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Now update version numbers in all required files:
|
||||||
|
|
||||||
|
- Main plugin file (wp-fix-plugin-does-not-exist-notices.php)
|
||||||
|
- CHANGELOG.md (add a new version section)
|
||||||
|
- readme.txt
|
||||||
|
- README.md
|
||||||
|
- languages/wp-fix-plugin-does-not-exist-notices.pot (Project-Id-Version)
|
||||||
|
|
||||||
|
3. Commit the version updates:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Version {MAJOR}.{MINOR+1}.0 - [brief description]"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Tag the version as stable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag -a v{MAJOR}.{MINOR+1}.0-stable -m "Stable version {MAJOR}.{MINOR+1}.0"
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Follow the standard release process from this point
|
||||||
|
|
||||||
|
**IMPORTANT**: Don't update version numbers during initial development and testing. Only create a version branch and update version numbers when the feature is confirmed working.
|
||||||
|
|
||||||
|
For detailed guidelines on time-efficient development and testing, see **@.agents/incremental-development.md**.
|
||||||
|
|
||||||
|
### 7. Push to Remote (Optional for Collaboration)
|
||||||
|
|
||||||
|
If you need to collaborate with others on the feature before it's ready for release:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git push github HEAD:feature/descriptive-name
|
||||||
|
git push gitea HEAD:feature/descriptive-name
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8. Create Pull Request (Optional)
|
||||||
|
|
||||||
|
If the repository uses pull requests for code review, create a pull request from the feature branch to the version branch.
|
||||||
|
|
||||||
|
## Code Standards and Best Practices
|
||||||
|
|
||||||
|
### PHP Coding Standards
|
||||||
|
|
||||||
|
- Follow [WordPress PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/)
|
||||||
|
- Use tabs for indentation, not spaces
|
||||||
|
- Use proper naming conventions:
|
||||||
|
- Class names: `Class_Name`
|
||||||
|
- Function names: `function_name`
|
||||||
|
- Variable names: `$variable_name`
|
||||||
|
|
||||||
|
### JavaScript Coding Standards
|
||||||
|
|
||||||
|
- Follow [WordPress JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/)
|
||||||
|
- Use tabs for indentation, not spaces
|
||||||
|
- Use proper naming conventions:
|
||||||
|
- Function names: `functionName`
|
||||||
|
- Variable names: `variableName`
|
||||||
|
|
||||||
|
### Internationalization (i18n)
|
||||||
|
|
||||||
|
- Wrap all user-facing strings in appropriate translation functions:
|
||||||
|
- `__()` for simple strings
|
||||||
|
- `_e()` for echoed strings
|
||||||
|
- `esc_html__()` for escaped strings
|
||||||
|
- `esc_html_e()` for escaped and echoed strings
|
||||||
|
- Always use the plugin's text domain: `fix-plugin-does-not-exist-notices`
|
||||||
|
|
||||||
|
### Security Best Practices
|
||||||
|
|
||||||
|
- Validate and sanitize all input
|
||||||
|
- Escape all output
|
||||||
|
- Use nonces for form submissions
|
||||||
|
- Use capability checks for user actions
|
||||||
|
|
||||||
|
## Working in Multi-Repository Workspaces
|
||||||
|
|
||||||
|
When developing features in a workspace with multiple repositories:
|
||||||
|
|
||||||
|
1. **Verify Repository Context**:
|
||||||
|
- Confirm you're working in the correct repository before suggesting or implementing features
|
||||||
|
- Use `pwd` and `git remote -v` to verify the current repository
|
||||||
|
|
||||||
|
2. **Feature Verification**:
|
||||||
|
- Before implementing a feature, verify it doesn't already exist in the current repository
|
||||||
|
- Don't assume features from other repositories should be implemented in this one
|
||||||
|
- Use `codebase-retrieval` to search for existing functionality
|
||||||
|
|
||||||
|
3. **Repository-Specific Implementation**:
|
||||||
|
- Implement features appropriate for this specific plugin's purpose
|
||||||
|
- Maintain consistency with the current repository's architecture and coding style
|
||||||
|
- Don't copy code directly from other repositories without adaptation
|
||||||
|
|
||||||
|
4. **Cross-Repository Inspiration**:
|
||||||
|
- If implementing a feature inspired by another repository, explicitly note that it's a new feature
|
||||||
|
- Adapt the feature to fit the current repository's needs and architecture
|
||||||
|
- Document the inspiration source in code comments
|
||||||
|
|
||||||
|
For detailed guidelines on working in multi-repository workspaces, see **@.agents/multi-repo-workspace.md**.
|
||||||
|
|
||||||
|
## Feature Types and Implementation Guidelines
|
||||||
|
|
||||||
|
### Admin Interface Features
|
||||||
|
|
||||||
|
When adding features to the admin interface:
|
||||||
|
|
||||||
|
- Use WordPress admin UI components for consistency
|
||||||
|
- Follow WordPress admin UI patterns
|
||||||
|
- Ensure accessibility compliance
|
||||||
|
- Add appropriate help text
|
||||||
|
|
||||||
|
### Plugin Functionality Features
|
||||||
|
|
||||||
|
When adding core functionality:
|
||||||
|
|
||||||
|
- Ensure compatibility with WordPress hooks system
|
||||||
|
- Consider performance impact
|
||||||
|
- Maintain backward compatibility
|
||||||
|
- Add appropriate error handling
|
||||||
|
|
||||||
|
### Integration Features
|
||||||
|
|
||||||
|
When adding integration with other plugins or services:
|
||||||
|
|
||||||
|
- Make integrations optional when possible
|
||||||
|
- Check if the integrated plugin/service is available before using it
|
||||||
|
- Provide fallback functionality when the integration is not available
|
||||||
|
- Document the integration requirements
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# Folder Structure
|
||||||
|
|
||||||
|
This document outlines the folder structure of the plugin and explains the purpose of each directory.
|
||||||
|
|
||||||
|
## Root Directories
|
||||||
|
|
||||||
|
- **admin/** - Contains admin-specific functionality and assets
|
||||||
|
- **includes/** - Contains core plugin functionality and classes
|
||||||
|
- **languages/** - Contains translation files
|
||||||
|
- **scripts/** - Contains build and deployment scripts
|
||||||
|
- **.agents/** - Contains documentation for AI assistants
|
||||||
|
- **.github/** - Contains GitHub-specific files like workflows
|
||||||
|
- **.wordpress-org/** - Contains WordPress.org assets like banners and screenshots
|
||||||
|
|
||||||
|
## Admin Directory Structure
|
||||||
|
|
||||||
|
- **admin/css/** - Admin-specific CSS files
|
||||||
|
- **admin/js/** - Admin-specific JavaScript files
|
||||||
|
- **admin/images/** - Admin-specific images
|
||||||
|
- **admin/partials/** - Admin-specific template partials
|
||||||
|
- **admin/settings/** - Admin settings functionality
|
||||||
|
- **admin/tools/** - Admin tools functionality
|
||||||
|
- **admin/lib/** - Admin-specific library files and helper functions
|
||||||
|
- **admin/lib/admin.php** - Admin class for handling admin-specific functionality
|
||||||
|
- **admin/lib/modal.php** - Modal class for handling the update source selector modal
|
||||||
|
|
||||||
|
## Includes Directory
|
||||||
|
|
||||||
|
The `includes/` directory contains the core plugin functionality:
|
||||||
|
|
||||||
|
- **includes/core.php** - Core class for handling the main plugin functionality
|
||||||
|
- **includes/plugin.php** - Main plugin class that initializes all components
|
||||||
|
- **includes/updater.php** - Updater class for handling plugin updates
|
||||||
|
|
||||||
|
## File Naming Conventions
|
||||||
|
|
||||||
|
- All PHP files in the `includes/` directory use lowercase filenames
|
||||||
|
- All directories use lowercase names
|
||||||
|
- JavaScript and CSS files use kebab-case (e.g., `update-source-selector.js`)
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
1. **Unique Directory Names**: Each directory should have a unique name to avoid confusion
|
||||||
|
2. **Logical Organization**: Files should be organized logically by function
|
||||||
|
3. **Consistent Naming**: File and directory names should follow consistent naming conventions
|
||||||
|
4. **Clear Separation**: Admin functionality should be separate from core functionality
|
||||||
|
5. **Minimal Dependencies**: Files should have minimal dependencies on other files
|
||||||
|
|
||||||
|
## @mentions for AI Assistants
|
||||||
|
|
||||||
|
When referring to files or directories in AI conversations, use the following format:
|
||||||
|
|
||||||
|
- **@includes/plugin.php** - Main plugin class
|
||||||
|
- **@includes/core.php** - Core functionality
|
||||||
|
- **@admin/lib/admin.php** - Admin functionality
|
||||||
|
- **@admin/lib/modal.php** - Modal functionality
|
||||||
|
- **@includes/updater.php** - Updater functionality
|
||||||
|
- **@admin/js/update-source-selector.js** - Update source selector JavaScript
|
||||||
|
- **@admin/css/update-source-selector.css** - Update source selector CSS
|
||||||
@@ -0,0 +1,255 @@
|
|||||||
|
# Git Workflow Guide for AI Assistants
|
||||||
|
|
||||||
|
This document provides guidance for AI assistants to help with git workflow management for the Fix Plugin Does Not Exist Notices plugin.
|
||||||
|
|
||||||
|
## Core Git Workflow Principles
|
||||||
|
|
||||||
|
### 1. Always Start from Latest Main Branch
|
||||||
|
|
||||||
|
Before creating any new branch, always ensure you're working with the latest code from the main branch by pulling from the origin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
This critical step ensures that your new branch includes all the latest changes from the remote repository and reduces the chance of merge conflicts later. Never skip this step, as working from an outdated main branch can lead to integration problems.
|
||||||
|
|
||||||
|
### 2. One Issue Per Branch
|
||||||
|
|
||||||
|
Create a separate branch for each issue or feature you're working on:
|
||||||
|
|
||||||
|
- For bug fixes: `fix/issue-description` or `fix/issue-number-description`
|
||||||
|
- For features: `feature/descriptive-name`
|
||||||
|
- For small improvements: `patch/descriptive-name`
|
||||||
|
- For code restructuring: `refactor/descriptive-name`
|
||||||
|
|
||||||
|
**Important**: Use descriptive names without version numbers for development branches. This allows focusing on the changes without worrying about version updates until the changes are confirmed working.
|
||||||
|
|
||||||
|
Only create version branches (e.g., `v2.2.3`) when changes are ready for release, and only then update version numbers in files.
|
||||||
|
|
||||||
|
This approach keeps changes focused, makes code review easier, and provides clear rollback points if needed.
|
||||||
|
|
||||||
|
### 3. Pull Request for Each Issue
|
||||||
|
|
||||||
|
Create a separate pull request for each issue or feature. This ensures:
|
||||||
|
|
||||||
|
- Each change can be reviewed independently
|
||||||
|
- Issues can be merged as soon as they're ready
|
||||||
|
- Changes can be reverted individually if needed
|
||||||
|
- CI/CD checks can run on focused changes
|
||||||
|
|
||||||
|
## Detailed Workflow
|
||||||
|
|
||||||
|
### Starting a New Task
|
||||||
|
|
||||||
|
1. **Update Main Branch from Origin**
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
This step is mandatory before creating any new branch to ensure you're working with the latest code.
|
||||||
|
|
||||||
|
2. **Create a New Branch**
|
||||||
|
```bash
|
||||||
|
git checkout -b [branch-type]/[description]
|
||||||
|
```
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```bash
|
||||||
|
git checkout -b fix/123-plugin-activation-error
|
||||||
|
git checkout -b feature/update-source-selector
|
||||||
|
git checkout -b patch/2.2.1
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Make Your Changes**
|
||||||
|
- Make focused changes related only to the specific issue
|
||||||
|
- Commit regularly with clear, descriptive messages
|
||||||
|
- Reference issue numbers in commit messages when applicable
|
||||||
|
|
||||||
|
4. **Testing Approach**
|
||||||
|
|
||||||
|
For efficient development:
|
||||||
|
- **Local Testing (Default)**: Test without updating version numbers
|
||||||
|
```bash
|
||||||
|
# Get current version from plugin file
|
||||||
|
CURRENT_VERSION=$(grep -o "Version: [0-9.]*" wp-fix-plugin-does-not-exist-notices.php | cut -d' ' -f2)
|
||||||
|
|
||||||
|
# Build and deploy with current version
|
||||||
|
./build.sh $CURRENT_VERSION
|
||||||
|
```
|
||||||
|
- **Remote Testing (When Requested)**: Push development branch to remote
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "[Brief description] for remote testing"
|
||||||
|
git push origin [branch-name]
|
||||||
|
```
|
||||||
|
- **Version Creation**: Only when changes are confirmed working
|
||||||
|
```bash
|
||||||
|
# Create version branch
|
||||||
|
git checkout -b v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
|
||||||
|
# Update version numbers in all required files
|
||||||
|
# Commit version updates
|
||||||
|
git add .
|
||||||
|
git commit -m "Version {MAJOR}.{MINOR}.{PATCH} - Brief description"
|
||||||
|
|
||||||
|
# Tag as stable
|
||||||
|
git tag -a v{MAJOR}.{MINOR}.{PATCH}-stable -m "Stable version {MAJOR}.{MINOR}.{PATCH}"
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Push Branch to Remote (When Needed)**
|
||||||
|
```bash
|
||||||
|
git push origin [branch-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating a Pull Request
|
||||||
|
|
||||||
|
1. **Ensure Tests Pass Locally**
|
||||||
|
- Run any available tests to ensure your changes work as expected
|
||||||
|
- Fix any issues before creating a pull request
|
||||||
|
|
||||||
|
2. **Create Pull Request**
|
||||||
|
- Create a pull request from your branch to the main branch
|
||||||
|
- Include a clear description of the changes
|
||||||
|
- Reference any related issues
|
||||||
|
- Assign reviewers if appropriate
|
||||||
|
|
||||||
|
3. **Address Review Feedback**
|
||||||
|
- Make requested changes
|
||||||
|
- Push additional commits to the same branch
|
||||||
|
- Respond to comments
|
||||||
|
|
||||||
|
### CI/CD Integration
|
||||||
|
|
||||||
|
Each pull request should pass through CI/CD checks before being merged. This ensures that all changes are compatible with the existing codebase and meet quality standards.
|
||||||
|
|
||||||
|
1. **Automated Tests**
|
||||||
|
- Unit tests
|
||||||
|
- Integration tests
|
||||||
|
- Code style checks
|
||||||
|
- Compatibility checks
|
||||||
|
|
||||||
|
2. **Manual Review**
|
||||||
|
- Code review by team members
|
||||||
|
- Functional testing in test environment
|
||||||
|
- Verification of feature requirements
|
||||||
|
|
||||||
|
3. **Approval Process**
|
||||||
|
- Required approvals before merging
|
||||||
|
- Final checks for conflicts with other pending PRs
|
||||||
|
- Verification that all CI/CD checks have passed
|
||||||
|
|
||||||
|
4. **Compatibility with Unmerged PRs**
|
||||||
|
- When multiple PRs are in progress simultaneously, ensure each PR is compatible with the main branch
|
||||||
|
- For related changes, consider using feature flags to allow independent merging
|
||||||
|
- Document dependencies between PRs in the PR description
|
||||||
|
|
||||||
|
### Handling Concurrent Development
|
||||||
|
|
||||||
|
When working on multiple issues simultaneously:
|
||||||
|
|
||||||
|
1. **Keep Branches Independent**
|
||||||
|
- Always create new branches from the latest main branch pulled from origin, not from other feature branches
|
||||||
|
- This ensures each PR can be merged independently and contains all the latest changes
|
||||||
|
|
||||||
|
2. **Handle Conflicts Proactively**
|
||||||
|
- If main has been updated with other changes while you're working:
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
git checkout your-branch
|
||||||
|
git merge main
|
||||||
|
```
|
||||||
|
- Resolve any conflicts locally before pushing
|
||||||
|
|
||||||
|
3. **Coordinate on Dependent Changes**
|
||||||
|
- If changes depend on each other, note this in the PR description
|
||||||
|
- Consider using the "Depends on #PR-number" notation in PR descriptions
|
||||||
|
|
||||||
|
## Release Process
|
||||||
|
|
||||||
|
When preparing for a release:
|
||||||
|
|
||||||
|
1. **Ensure All Required PRs are Merged**
|
||||||
|
- All features and fixes planned for the release should be merged to main
|
||||||
|
|
||||||
|
2. **Create a Release Branch**
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
git checkout -b v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Follow Standard Release Process**
|
||||||
|
- Update version numbers
|
||||||
|
- Update changelogs
|
||||||
|
- Create tag
|
||||||
|
- See **@.agents/release-process.md** for complete details
|
||||||
|
|
||||||
|
## Contributing to External Repositories
|
||||||
|
|
||||||
|
When working on issues for external repositories (pull/merge requests):
|
||||||
|
|
||||||
|
### 1. Clearly Indicate Testing Status
|
||||||
|
|
||||||
|
In the PR description and comments, clearly indicate the testing status:
|
||||||
|
|
||||||
|
- **Not tested**: "This PR addresses [issue] but has not been tested locally or remotely. It's ready for community/maintainer testing."
|
||||||
|
- **Locally tested**: "This PR has been tested in a local WordPress environment and [describe results]."
|
||||||
|
- **Remotely tested**: "This PR has been tested with a remote build and [describe results]."
|
||||||
|
|
||||||
|
### 2. Provide Testing Instructions
|
||||||
|
|
||||||
|
Include clear instructions for maintainers on how to test the changes:
|
||||||
|
|
||||||
|
- Steps to reproduce the original issue (if applicable)
|
||||||
|
- Steps to verify the fix or feature
|
||||||
|
- Any specific environments or configurations needed for testing
|
||||||
|
|
||||||
|
### 3. Be Responsive to Feedback
|
||||||
|
|
||||||
|
Monitor the PR for feedback from maintainers and be prepared to make additional changes if requested.
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
### Commit Messages
|
||||||
|
|
||||||
|
- Use present tense ("Add feature" not "Added feature")
|
||||||
|
- Start with a verb
|
||||||
|
- Keep the first line under 50 characters
|
||||||
|
- Reference issues when relevant: "Fix #123: Resolve plugin detection issue"
|
||||||
|
- For more complex changes, add a detailed description after the first line
|
||||||
|
|
||||||
|
### Branch Management
|
||||||
|
|
||||||
|
- Delete branches after they've been merged
|
||||||
|
- Keep branch names descriptive but concise
|
||||||
|
- Use consistent naming conventions
|
||||||
|
|
||||||
|
### Code Review
|
||||||
|
|
||||||
|
- Review code thoroughly before approving
|
||||||
|
- Test changes locally when possible
|
||||||
|
- Provide constructive feedback
|
||||||
|
- See **@.agents/code-review.md** for detailed code review guidelines
|
||||||
|
|
||||||
|
### Suggested Improvements
|
||||||
|
|
||||||
|
If you identify potential improvements outside the scope of the current issue:
|
||||||
|
|
||||||
|
1. **Document the Suggestion**
|
||||||
|
- Note the suggestion in the PR comments
|
||||||
|
- Create a new issue for the suggestion
|
||||||
|
- Be specific about the benefits and implementation details
|
||||||
|
|
||||||
|
2. **Create a Separate Branch**
|
||||||
|
- Don't include unrelated improvements in the current PR
|
||||||
|
- Create a new branch from the latest main branch for the suggested improvement
|
||||||
|
- Submit a separate PR for the suggestion
|
||||||
|
|
||||||
|
3. **Ensure Compatibility**
|
||||||
|
- Make sure the suggested improvement is compatible with any unmerged PRs
|
||||||
|
- If the improvement depends on changes in another PR, note this dependency
|
||||||
|
- Consider how the improvement will interact with other pending changes
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
# Incremental Development and Testing Guide
|
||||||
|
|
||||||
|
This document provides guidance for AI assistants to help with incremental development and testing for the Fix Plugin Does Not Exist Notices plugin.
|
||||||
|
|
||||||
|
## Time-Efficient Development Principles
|
||||||
|
|
||||||
|
### Branch Naming for Development
|
||||||
|
|
||||||
|
1. **Initial Development Branches**
|
||||||
|
- Use descriptive names without version numbers:
|
||||||
|
- `fix/issue-description` - For bug fixes
|
||||||
|
- `feature/descriptive-name` - For new features
|
||||||
|
- `patch/descriptive-name` - For small improvements
|
||||||
|
- `refactor/descriptive-name` - For code restructuring
|
||||||
|
- **Don't update version numbers** during this phase
|
||||||
|
- Focus on implementing and testing the changes
|
||||||
|
|
||||||
|
2. **Version Branches**
|
||||||
|
- Only create after changes are confirmed working:
|
||||||
|
- `v{MAJOR}.{MINOR}.{PATCH}` (e.g., `v2.2.3`)
|
||||||
|
- Only update version numbers at this point
|
||||||
|
- This minimizes unnecessary version updates
|
||||||
|
|
||||||
|
### Version Numbering Guidelines
|
||||||
|
|
||||||
|
1. **Patch Versions (X.Y.Z → X.Y.Z+1)**
|
||||||
|
- Use for bug fixes and small improvements
|
||||||
|
- Example: `v2.2.3`
|
||||||
|
|
||||||
|
2. **Minor Versions (X.Y.Z → X.Y+1.0)**
|
||||||
|
- Use for new features or significant improvements
|
||||||
|
- Example: `v2.3.0`
|
||||||
|
|
||||||
|
3. **Major Versions (X.Y.Z → X+1.0.0)**
|
||||||
|
- Only increment when numerous features and fixes are tested and confirmed stable
|
||||||
|
- Reserved for breaking changes or significant overhauls
|
||||||
|
- Example: `v3.0.0`
|
||||||
|
|
||||||
|
### Marking Stable Versions
|
||||||
|
|
||||||
|
When the user confirms that changes are working correctly:
|
||||||
|
|
||||||
|
1. Create a version branch and update version numbers
|
||||||
|
2. Tag the version branch as stable
|
||||||
|
```bash
|
||||||
|
git tag -a v{MAJOR}.{MINOR}.{PATCH}-stable -m "Stable version {MAJOR}.{MINOR}.{PATCH}"
|
||||||
|
```
|
||||||
|
3. Document in the PR or issue that this version has been confirmed stable
|
||||||
|
|
||||||
|
## Local Testing Workflow
|
||||||
|
|
||||||
|
### 1. Create a Descriptive Branch for Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Ensure you have the latest main branch
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
# Create a descriptive branch (without version numbers)
|
||||||
|
git checkout -b fix/plugin-activation-error
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Make Changes Without Updating Version Numbers
|
||||||
|
|
||||||
|
During the development and testing phase:
|
||||||
|
|
||||||
|
- Implement the necessary changes
|
||||||
|
- **Don't update version numbers** in any files yet
|
||||||
|
- Focus on the functionality
|
||||||
|
|
||||||
|
### 3. Build and Deploy Locally
|
||||||
|
|
||||||
|
For local testing, use the current version number from the main plugin file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Get the current version from the plugin file
|
||||||
|
CURRENT_VERSION=$(grep -o "Version: [0-9.]*" wp-fix-plugin-does-not-exist-notices.php | cut -d' ' -f2)
|
||||||
|
|
||||||
|
# Build and deploy with current version
|
||||||
|
./build.sh $CURRENT_VERSION
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
|
||||||
|
1. Create a build directory
|
||||||
|
2. Copy required files to the build directory
|
||||||
|
3. Deploy the plugin to your local WordPress testing environment
|
||||||
|
|
||||||
|
**Note**: For local testing iterations, you do not need to commit changes, push to remote repositories, or create tags unless specifically requested.
|
||||||
|
|
||||||
|
### 4. Test and Evaluate
|
||||||
|
|
||||||
|
Test the changes thoroughly in the local environment:
|
||||||
|
|
||||||
|
- Verify that the specific issue is fixed or feature works as expected
|
||||||
|
- Check for any regressions or new issues
|
||||||
|
- Document the results
|
||||||
|
|
||||||
|
### 5. Based on Testing Results
|
||||||
|
|
||||||
|
- **If changes need further refinement**: Continue working in the same branch
|
||||||
|
- **If changes work as expected**: Proceed to version branch creation
|
||||||
|
|
||||||
|
### 6. Creating a Version Branch
|
||||||
|
|
||||||
|
When changes are confirmed working and ready for release:
|
||||||
|
|
||||||
|
1. Create a version branch with the appropriate version number:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Determine the appropriate version increment (patch, minor, or major)
|
||||||
|
# based on the nature of the changes
|
||||||
|
git checkout -b v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Now update version numbers in all required files:
|
||||||
|
|
||||||
|
- Main plugin file (wp-fix-plugin-does-not-exist-notices.php)
|
||||||
|
- CHANGELOG.md (add a new version section)
|
||||||
|
- readme.txt
|
||||||
|
- README.md
|
||||||
|
- languages/wp-fix-plugin-does-not-exist-notices.pot (Project-Id-Version)
|
||||||
|
|
||||||
|
3. Commit the version updates:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Version {MAJOR}.{MINOR}.{PATCH} - [brief description]"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Tag the version as stable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag -a v{MAJOR}.{MINOR}.{PATCH}-stable -m "Stable version {MAJOR}.{MINOR}.{PATCH}"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remote Testing Workflow
|
||||||
|
|
||||||
|
When the user specifically requests remote testing:
|
||||||
|
|
||||||
|
### 1. Commit Changes to Remote Repository
|
||||||
|
|
||||||
|
If testing a development branch (without version updates):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "[brief description] for remote testing"
|
||||||
|
git push origin [branch-name]
|
||||||
|
```
|
||||||
|
|
||||||
|
If testing a version branch (with version updates):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Version {MAJOR}.{MINOR}.{PATCH} - [brief description]"
|
||||||
|
git push origin v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Create and Push Tag (For Version Branches Only)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag -a v{MAJOR}.{MINOR}.{PATCH} -m "Version {MAJOR}.{MINOR}.{PATCH} for remote testing"
|
||||||
|
git push origin v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
```
|
||||||
|
|
||||||
|
This will trigger GitHub Actions to build the installable ZIP file.
|
||||||
|
|
||||||
|
### 3. Verify Remote Build
|
||||||
|
|
||||||
|
Check that the GitHub Actions workflow completed successfully and the ZIP file is available for download.
|
||||||
|
|
||||||
|
### 4. Test and Evaluate
|
||||||
|
|
||||||
|
Test the remotely built version and document the results.
|
||||||
|
|
||||||
|
## Contributing to External Repositories
|
||||||
|
|
||||||
|
When working on issues for external repositories (pull/merge requests):
|
||||||
|
|
||||||
|
### 1. Clearly Indicate Testing Status
|
||||||
|
|
||||||
|
In the PR description and comments, clearly indicate the testing status:
|
||||||
|
|
||||||
|
- **Not tested**: "This PR addresses [issue] but has not been tested locally or remotely. It's ready for community/maintainer testing."
|
||||||
|
- **Locally tested**: "This PR has been tested in a local WordPress environment and [describe results]."
|
||||||
|
- **Remotely tested**: "This PR has been tested with a remote build and [describe results]."
|
||||||
|
|
||||||
|
### 2. Provide Testing Instructions
|
||||||
|
|
||||||
|
Include clear instructions for maintainers on how to test the changes:
|
||||||
|
|
||||||
|
- Steps to reproduce the original issue (if applicable)
|
||||||
|
- Steps to verify the fix or feature
|
||||||
|
- Any specific environments or configurations needed for testing
|
||||||
|
|
||||||
|
### 3. Be Responsive to Feedback
|
||||||
|
|
||||||
|
Monitor the PR for feedback from maintainers and be prepared to make additional changes if requested.
|
||||||
|
|
||||||
|
## Rollback Procedure
|
||||||
|
|
||||||
|
If a change causes issues after release:
|
||||||
|
|
||||||
|
### 1. Identify the Last Stable Version
|
||||||
|
|
||||||
|
Find the last version that was marked as stable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git tag -l "*-stable"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Create a New Branch from the Stable Version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout v{MAJOR}.{MINOR}.{PATCH}-stable
|
||||||
|
git checkout -b fix/rollback-based-fix
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Make Necessary Changes
|
||||||
|
|
||||||
|
Implement the fix based on the stable version. Don't update version numbers yet.
|
||||||
|
|
||||||
|
### 4. Test the Changes
|
||||||
|
|
||||||
|
Test thoroughly to ensure the fix resolves the issues.
|
||||||
|
|
||||||
|
### 5. When Confirmed Working
|
||||||
|
|
||||||
|
Create a version branch with an incremented patch version and update all version numbers as described in the "Creating a Version Branch" section.
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Local Development Environment Variables
|
||||||
|
|
||||||
|
This file contains important paths and URLs for local development.
|
||||||
|
|
||||||
|
## Repository Paths
|
||||||
|
|
||||||
|
- Local development repository: ~/Git/wp-fix-plugin-does-not-exist-notices
|
||||||
|
- LocalWP plugin testing site storage: ~/Local/plugin-testing/app/wp-fix-plugin-does-not-exist-notices
|
||||||
|
- LocalWP plugin testing site configuration: ~/Local/plugin-testing/conf/
|
||||||
|
|
||||||
|
## URLs
|
||||||
|
|
||||||
|
- LocalWP plugin testing URL: <http://plugin-testing.local/>
|
||||||
|
- PHP details: <http://plugin-testing.local/local-phpinfo.php>
|
||||||
|
- XDebug info: <http://plugin-testing.local/local-xdebuginfo.php>
|
||||||
|
- Adminer Evo: <http://localhost:10010/?username=root&db=local>
|
||||||
|
- Mailpit: <http://localhost:10000/>
|
||||||
|
|
||||||
|
## Build and Deploy Scripts
|
||||||
|
|
||||||
|
- Build script: ~/Git/wp-fix-plugin-does-not-exist-notices/build.sh
|
||||||
|
- Local deploy script: ~/Git/wp-fix-plugin-does-not-exist-notices/deploy-local.sh
|
||||||
@@ -0,0 +1,331 @@
|
|||||||
|
# Local Testing Guide for AI Assistants
|
||||||
|
|
||||||
|
This guide provides instructions for AI coding assistants to set up and run local
|
||||||
|
WordPress testing environments for this plugin.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Three testing approaches are available:
|
||||||
|
|
||||||
|
1. **WordPress Playground CLI** - Quick browser-based testing (recommended for AI)
|
||||||
|
2. **LocalWP** - Full local WordPress environment
|
||||||
|
3. **wp-env** - Docker-based WordPress environment
|
||||||
|
|
||||||
|
Each approach has trade-offs. Choose based on the testing needs.
|
||||||
|
|
||||||
|
## Quick Reference
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Playground CLI (fastest for AI testing)
|
||||||
|
npm run playground:start # Start single site
|
||||||
|
npm run playground:start:multisite # Start multisite
|
||||||
|
npm run playground:stop # Stop server
|
||||||
|
npm run playground:status # Check status
|
||||||
|
|
||||||
|
# LocalWP (full environment)
|
||||||
|
npm run localwp:create # Create single site
|
||||||
|
npm run localwp:create:multisite # Create multisite
|
||||||
|
npm run localwp:sync # Sync plugin changes
|
||||||
|
npm run localwp:reset # Reset to clean state
|
||||||
|
|
||||||
|
# wp-env (Docker-based)
|
||||||
|
npm run start # Start wp-env
|
||||||
|
npm run stop # Stop wp-env
|
||||||
|
```
|
||||||
|
|
||||||
|
## WordPress Playground CLI
|
||||||
|
|
||||||
|
Uses `@wp-playground/cli` version 3.0.22+ for instant WordPress testing.
|
||||||
|
|
||||||
|
### When to Use
|
||||||
|
|
||||||
|
* Quick plugin functionality testing
|
||||||
|
* Verifying admin UI changes
|
||||||
|
* Testing single site vs multisite behavior
|
||||||
|
* CI/CD pipeline testing (note: may be flaky in GitHub Actions)
|
||||||
|
|
||||||
|
### Starting Playground
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Single site on port 8888
|
||||||
|
npm run playground:start
|
||||||
|
|
||||||
|
# Multisite on port 8889
|
||||||
|
npm run playground:start:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
### Accessing the Site
|
||||||
|
|
||||||
|
After starting, the script provides access details:
|
||||||
|
|
||||||
|
* **Single Site**: http://localhost:8888
|
||||||
|
* **Multisite**: http://localhost:8889
|
||||||
|
* **Admin Login**: admin / password
|
||||||
|
|
||||||
|
### Blueprint Configuration
|
||||||
|
|
||||||
|
Blueprints define the WordPress setup. Located in `playground/`:
|
||||||
|
|
||||||
|
* `blueprint.json` - Single site configuration
|
||||||
|
* `multisite-blueprint.json` - Multisite configuration
|
||||||
|
|
||||||
|
Blueprints install:
|
||||||
|
* Plugin Toggle (debugging helper)
|
||||||
|
* Kadence Blocks (testing with block plugins)
|
||||||
|
|
||||||
|
### Stopping Playground
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run playground:stop
|
||||||
|
```
|
||||||
|
|
||||||
|
### Status Check
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run playground:status
|
||||||
|
```
|
||||||
|
|
||||||
|
Shows running processes and port usage.
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
If Playground fails to start:
|
||||||
|
|
||||||
|
1. Check if ports 8888/8889 are in use: `lsof -i :8888`
|
||||||
|
2. Check logs: `cat .playground.log`
|
||||||
|
3. Stop any orphaned processes: `npm run playground:stop`
|
||||||
|
4. Ensure npm dependencies are installed: `npm install`
|
||||||
|
|
||||||
|
## LocalWP Integration
|
||||||
|
|
||||||
|
LocalWP provides a full WordPress environment with database persistence.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
* LocalWP installed at `/Applications/Local.app` (macOS)
|
||||||
|
* Local Sites directory at `~/Local Sites/`
|
||||||
|
|
||||||
|
### When to Use
|
||||||
|
|
||||||
|
* Testing database migrations
|
||||||
|
* Long-term development environment
|
||||||
|
* Testing with specific PHP/MySQL versions
|
||||||
|
* Network/multisite configuration testing
|
||||||
|
* Testing WP-CLI commands
|
||||||
|
|
||||||
|
### Creating Sites
|
||||||
|
|
||||||
|
LocalWP requires manual site creation through the GUI.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run localwp:create
|
||||||
|
```
|
||||||
|
|
||||||
|
This guides you through:
|
||||||
|
|
||||||
|
1. Opening LocalWP
|
||||||
|
2. Creating a site with standardized name
|
||||||
|
3. Syncing plugin files
|
||||||
|
|
||||||
|
### URL Patterns
|
||||||
|
|
||||||
|
Sites use consistent naming:
|
||||||
|
|
||||||
|
* **Single Site**: `wp-plugin-starter-template-single.local`
|
||||||
|
* **Multisite**: `wp-plugin-starter-template-multisite.local`
|
||||||
|
|
||||||
|
### Syncing Plugin Files
|
||||||
|
|
||||||
|
After making code changes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run localwp:sync
|
||||||
|
```
|
||||||
|
|
||||||
|
This uses rsync to copy plugin files, excluding:
|
||||||
|
* node_modules
|
||||||
|
* vendor
|
||||||
|
* tests
|
||||||
|
* .git
|
||||||
|
* dist
|
||||||
|
|
||||||
|
### Resetting
|
||||||
|
|
||||||
|
To reset the plugin to a clean state:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run localwp:reset
|
||||||
|
```
|
||||||
|
|
||||||
|
### Site Information
|
||||||
|
|
||||||
|
View all LocalWP sites:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./bin/localwp-setup.sh info
|
||||||
|
```
|
||||||
|
|
||||||
|
## wp-env (Docker)
|
||||||
|
|
||||||
|
Docker-based environment using `@wordpress/env`.
|
||||||
|
|
||||||
|
### When to Use
|
||||||
|
|
||||||
|
* Consistent environment across machines
|
||||||
|
* PHPUnit testing
|
||||||
|
* WP-CLI operations
|
||||||
|
* CI/CD testing
|
||||||
|
|
||||||
|
### Starting
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run start # or: wp-env start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:phpunit # Single site tests
|
||||||
|
npm run test:phpunit:multisite # Multisite tests
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running WP-CLI Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wp-env run cli wp plugin list
|
||||||
|
wp-env run cli wp option get siteurl
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing Workflows for AI Assistants
|
||||||
|
|
||||||
|
### Verifying a Code Change
|
||||||
|
|
||||||
|
1. Make the code change
|
||||||
|
2. Start Playground: `npm run playground:start`
|
||||||
|
3. Navigate to relevant admin page
|
||||||
|
4. Verify expected behavior
|
||||||
|
5. Stop Playground: `npm run playground:stop`
|
||||||
|
|
||||||
|
### Testing Multisite Functionality
|
||||||
|
|
||||||
|
1. Start multisite: `npm run playground:start:multisite`
|
||||||
|
2. Navigate to Network Admin
|
||||||
|
3. Test network-wide functionality
|
||||||
|
4. Test per-site functionality
|
||||||
|
5. Stop: `npm run playground:stop`
|
||||||
|
|
||||||
|
### Running PHPUnit Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Single site
|
||||||
|
composer test
|
||||||
|
|
||||||
|
# Multisite
|
||||||
|
WP_MULTISITE=1 composer test
|
||||||
|
|
||||||
|
# Specific test file
|
||||||
|
vendor/bin/phpunit tests/phpunit/test-core.php
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Cypress E2E Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# With Playground (headless)
|
||||||
|
npm run test:playground:single
|
||||||
|
npm run test:playground:multisite
|
||||||
|
|
||||||
|
# With wp-env (headless)
|
||||||
|
npm run test:e2e:single
|
||||||
|
npm run test:e2e:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Comparison
|
||||||
|
|
||||||
|
| Feature | Playground CLI | LocalWP | wp-env |
|
||||||
|
|---------|---------------|---------|--------|
|
||||||
|
| Setup Time | Instant | 5-10 min | 2-5 min |
|
||||||
|
| Persistence | None | Full | Partial |
|
||||||
|
| PHP Versions | Limited | Many | Limited |
|
||||||
|
| Database | In-memory | MySQL | MySQL |
|
||||||
|
| WP-CLI | Yes | Yes | Yes |
|
||||||
|
| Multisite | Yes | Yes | Yes |
|
||||||
|
| GitHub Actions | Flaky | N/A | Works |
|
||||||
|
| Best For | Quick testing | Full dev | CI/Testing |
|
||||||
|
|
||||||
|
## Common Issues
|
||||||
|
|
||||||
|
### Port Already in Use
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check what's using the port
|
||||||
|
lsof -i :8888
|
||||||
|
|
||||||
|
# Kill the process if needed
|
||||||
|
kill $(lsof -t -i :8888)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Playground Won't Start
|
||||||
|
|
||||||
|
1. Ensure dependencies installed: `npm install`
|
||||||
|
2. Check Node.js version: `node --version` (requires 18+)
|
||||||
|
3. Check logs: `cat .playground.log`
|
||||||
|
|
||||||
|
### LocalWP Site Not Found
|
||||||
|
|
||||||
|
The script expects sites at:
|
||||||
|
* `~/Local Sites/wp-plugin-starter-template-single/`
|
||||||
|
* `~/Local Sites/wp-plugin-starter-template-multisite/`
|
||||||
|
|
||||||
|
Verify the site name matches exactly.
|
||||||
|
|
||||||
|
### wp-env Docker Issues
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Restart Docker
|
||||||
|
wp-env stop
|
||||||
|
docker system prune -f
|
||||||
|
wp-env start
|
||||||
|
```
|
||||||
|
|
||||||
|
## Blueprint Reference
|
||||||
|
|
||||||
|
Blueprints use JSON format. Key steps:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
|
||||||
|
"landingPage": "/wp-admin/",
|
||||||
|
"login": true,
|
||||||
|
"features": {
|
||||||
|
"networking": true,
|
||||||
|
"phpVersion": "7.4"
|
||||||
|
},
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"step": "defineWpConfigConsts",
|
||||||
|
"consts": {
|
||||||
|
"WP_DEBUG": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"step": "wp-cli",
|
||||||
|
"command": "wp plugin install plugin-toggle --activate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For multisite, add:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"step": "enableMultisite"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
* [WordPress Playground CLI](https://wordpress.github.io/wordpress-playground/)
|
||||||
|
* [WordPress Playground Blueprints](https://wordpress.github.io/wordpress-playground/blueprints)
|
||||||
|
* [LocalWP Documentation](https://localwp.com/help-docs/)
|
||||||
|
* [@wordpress/env Documentation](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/)
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
# 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
|
||||||
@@ -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.
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
# 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. Run code quality checks
|
||||||
|
4. Build and test the plugin
|
||||||
|
5. Commit version changes
|
||||||
|
6. Create version tags
|
||||||
|
7. Push to remote repositories
|
||||||
|
8. 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. Run Code Quality Checks
|
||||||
|
|
||||||
|
Before building the plugin, run code quality checks to ensure the code meets standards:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run unit tests
|
||||||
|
composer test
|
||||||
|
|
||||||
|
# Run PHP CodeSniffer
|
||||||
|
composer phpcs
|
||||||
|
|
||||||
|
# Run PHP Code Beautifier and Fixer if needed
|
||||||
|
composer phpcbf
|
||||||
|
|
||||||
|
# Run PHPStan
|
||||||
|
composer phpstan
|
||||||
|
|
||||||
|
# Run PHP Mess Detector
|
||||||
|
composer phpmd
|
||||||
|
```
|
||||||
|
|
||||||
|
Fix any issues found by these tools before proceeding. See the [Code Quality Checks Workflow](./code-quality-checks.md) for more details.
|
||||||
|
|
||||||
|
### 4. 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
|
||||||
|
|
||||||
|
### 5. 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]"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. 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.
|
||||||
|
|
||||||
|
### 7. Push to Remote Repositories
|
||||||
|
|
||||||
|
Push the version branch and tags to remote repositories:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List remote tags (replace 'github' and 'gitea' if your remotes have different names)
|
||||||
|
git ls-remote --tags github
|
||||||
|
git ls-remote --tags gitea
|
||||||
|
```
|
||||||
|
|
||||||
|
If the tags (e.g., `v{MAJOR}.{MINOR}.{PATCH}` and `v{MAJOR}.{MINOR}.{PATCH}-stable`) already exist remotely but point to the wrong commit, delete them from the remote first:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Delete incorrect remote tags (replace 'github', 'gitea', and tag names)
|
||||||
|
git push github --delete v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
git push github --delete v{MAJOR}.{MINOR}.{PATCH}-stable
|
||||||
|
git push gitea --delete v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
git push gitea --delete v{MAJOR}.{MINOR}.{PATCH}-stable
|
||||||
|
```
|
||||||
|
|
||||||
|
Once you've confirmed the tags don't exist remotely or have deleted incorrect ones, push the new local tags:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Push to GitHub
|
||||||
|
git push github refs/heads/v{MAJOR}.{MINOR}.{PATCH}:refs/heads/v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
git push github --tags
|
||||||
|
|
||||||
|
# Push to Gitea
|
||||||
|
git push gitea refs/heads/v{MAJOR}.{MINOR}.{PATCH}:refs/heads/v{MAJOR}.{MINOR}.{PATCH}
|
||||||
|
git push gitea --tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8. 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:
|
||||||
|
- Update the Changelog.md file in the .wiki directory to match the main CHANGELOG.md
|
||||||
|
- Add the new version information to the Home.md file in the Latest Updates section
|
||||||
|
- Ensure all wiki pages are up-to-date with the new features or changes
|
||||||
|
- Verify that the _Sidebar.md file has the correct navigation structure
|
||||||
|
2. Verify that GitHub Actions workflows are running correctly:
|
||||||
|
- Check that the release workflow created the release with the correct assets
|
||||||
|
- Check that the sync-wiki workflow synced the wiki changes
|
||||||
|
- Fix any permissions issues in the workflow files if needed
|
||||||
|
3. Announce the release in relevant channels
|
||||||
|
4. Monitor for any issues or feedback
|
||||||
|
5. Start planning the next release
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
# 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
|
||||||
|
- Starter Prompt (must be listed before Installation Guide)
|
||||||
|
- 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. **Always ensure the Changelog.md in the wiki is updated to match the main CHANGELOG.md file**
|
||||||
|
4. **Always ensure the _Sidebar.md file has the correct navigation structure with Starter Prompt listed before Installation Guide**
|
||||||
|
5. Commit and push the changes to the `main` branch
|
||||||
|
6. The GitHub Actions workflow will automatically sync the changes with the GitHub wiki
|
||||||
|
|
||||||
|
### Creating New Pages
|
||||||
|
|
||||||
|
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 **@.agents/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
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"root_files": {
|
|
||||||
"allow": [
|
|
||||||
"readme.txt",
|
|
||||||
"changelog.txt",
|
|
||||||
"STANDARDS.md",
|
|
||||||
"DEVELOPMENT.md",
|
|
||||||
"RELEASING.md",
|
|
||||||
"LAUNCH.md",
|
|
||||||
"TESTING.md",
|
|
||||||
"STABILITY.md"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
---
|
||||||
|
engines:
|
||||||
|
markdownlint:
|
||||||
|
enabled: true
|
||||||
|
config_file: .markdownlint.json
|
||||||
|
phpmd:
|
||||||
|
enabled: true
|
||||||
|
phpcs:
|
||||||
|
enabled: true
|
||||||
|
stylelint:
|
||||||
|
enabled: false
|
||||||
|
shellcheck:
|
||||||
|
enabled: false
|
||||||
|
# Disable tools that are causing issues
|
||||||
|
eslint:
|
||||||
|
enabled: false
|
||||||
|
eslint-8:
|
||||||
|
enabled: false
|
||||||
|
eslint-9:
|
||||||
|
enabled: false
|
||||||
|
trivy:
|
||||||
|
enabled: false
|
||||||
|
semgrep:
|
||||||
|
enabled: false
|
||||||
|
checkov:
|
||||||
|
enabled: false
|
||||||
|
pmd:
|
||||||
|
enabled: false
|
||||||
|
pmd-7:
|
||||||
|
enabled: false
|
||||||
|
lizard:
|
||||||
|
enabled: false
|
||||||
|
jshint:
|
||||||
|
enabled: false
|
||||||
|
csslint:
|
||||||
|
enabled: false
|
||||||
|
jacksonlinter:
|
||||||
|
enabled: false
|
||||||
|
spectral:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
duplication:
|
||||||
|
enabled: true
|
||||||
|
exclude_patterns:
|
||||||
|
- "tests/**"
|
||||||
|
- "vendor/**"
|
||||||
|
- "node_modules/**"
|
||||||
|
|
||||||
|
metrics:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
exclude_paths:
|
||||||
|
- "vendor/**"
|
||||||
|
- "node_modules/**"
|
||||||
|
- "build/**"
|
||||||
|
- "dist/**"
|
||||||
|
- "bin/**"
|
||||||
|
- ".github/**"
|
||||||
|
- "tests/**"
|
||||||
|
- "*.lock"
|
||||||
|
- "*.json"
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
# Files excluded from the release builds (scripts/build-release.sh, wp dist-archive).
|
|
||||||
# The WordPress.org build also leaves out the files in .distignore-wporg.
|
|
||||||
.git
|
|
||||||
.gitattributes
|
|
||||||
.gitignore
|
|
||||||
.distignore
|
|
||||||
.distignore-wporg
|
|
||||||
# WordPress.org SVN assets (banners) and their source; admin/images/banner.svg ships instead.
|
|
||||||
.wordpress-org
|
|
||||||
.woodpecker.yml
|
|
||||||
# Development tools and CI (composer.json lists development tools only).
|
|
||||||
.github
|
|
||||||
.editorconfig
|
|
||||||
.gitleaks.toml
|
|
||||||
.aidevops.json
|
|
||||||
composer.json
|
|
||||||
composer.lock
|
|
||||||
phpcs.xml.dist
|
|
||||||
phpcs.xml
|
|
||||||
phpstan.neon.dist
|
|
||||||
phpstan.neon
|
|
||||||
phpstan-baseline.neon
|
|
||||||
phpstan-plugin.neon
|
|
||||||
/dist
|
|
||||||
.DS_Store
|
|
||||||
.aider*
|
|
||||||
# Local AI tooling state (aidevops), never part of the plugin.
|
|
||||||
.agents
|
|
||||||
.security-analysis
|
|
||||||
*.bak
|
|
||||||
.metadata_never_index
|
|
||||||
.syncing
|
|
||||||
AGENTS.md
|
|
||||||
CONTRIBUTING.md
|
|
||||||
DEVELOPMENT.md
|
|
||||||
LAUNCH.md
|
|
||||||
SECURITY.md
|
|
||||||
STANDARDS.md
|
|
||||||
RELEASING.md
|
|
||||||
ROADMAP.md
|
|
||||||
STABILITY.md
|
|
||||||
TESTING.md
|
|
||||||
/scripts
|
|
||||||
reference-plugins
|
|
||||||
project-documents
|
|
||||||
node_modules
|
|
||||||
/vendor
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# Files left out of the WordPress.org build, on top of .distignore
|
|
||||||
# (rsync exclude patterns; a leading / anchors to the plugin folder).
|
|
||||||
# Plugins hosted on WordPress.org may not install or update code from
|
|
||||||
# anywhere else, so updates from GitHub stay in GitHub releases only.
|
|
||||||
# scripts/build-release.sh also removes the Git Updater header lines
|
|
||||||
# (GitHub Plugin URI, Primary Branch, Release Asset) from wp-plugin-starter-template.php.
|
|
||||||
/includes/github-updater/
|
|
||||||
# Keep README.md: the admin Read Me tab shows it (admin/data/readme.php).
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es2021: true,
|
||||||
|
node: true,
|
||||||
|
'cypress/globals': true
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended'
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
'cypress'
|
||||||
|
],
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
sourceType: 'module'
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'no-console': 'warn',
|
||||||
|
'no-unused-vars': 'warn'
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
cy: 'readonly',
|
||||||
|
Cypress: 'readonly',
|
||||||
|
describe: 'readonly',
|
||||||
|
it: 'readonly',
|
||||||
|
expect: 'readonly',
|
||||||
|
beforeEach: 'readonly',
|
||||||
|
afterEach: 'readonly',
|
||||||
|
before: 'readonly',
|
||||||
|
after: 'readonly',
|
||||||
|
jQuery: 'readonly',
|
||||||
|
wpstData: 'readonly',
|
||||||
|
wpstModalData: 'readonly',
|
||||||
|
wp: 'readonly'
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"globals": {
|
||||||
|
"wp": "readonly",
|
||||||
|
"wpstData": "readonly",
|
||||||
|
"wpstModalData": "readonly",
|
||||||
|
"Cypress": "readonly",
|
||||||
|
"cy": "readonly",
|
||||||
|
"describe": "readonly",
|
||||||
|
"it": "readonly",
|
||||||
|
"before": "readonly",
|
||||||
|
"beforeEach": "readonly",
|
||||||
|
"module": "readonly"
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2018,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"indent": ["error", 2],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"quotes": ["error", "single"],
|
||||||
|
"semi": ["error", "always"]
|
||||||
|
},
|
||||||
|
"ignorePatterns": ["vendor/**", "node_modules/**", "build/**", "dist/**", "bin/**"]
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Opt out of AI model training
|
|
||||||
* ai-training=false
|
|
||||||
|
|
||||||
# Keep development files out of release archives (git archive).
|
|
||||||
/.distignore export-ignore
|
|
||||||
/.distignore-wporg export-ignore
|
|
||||||
/.gitattributes export-ignore
|
|
||||||
/.gitignore export-ignore
|
|
||||||
/.woodpecker.yml export-ignore
|
|
||||||
/DEVELOPMENT.md export-ignore
|
|
||||||
/RELEASING.md export-ignore
|
|
||||||
/ROADMAP.md export-ignore
|
|
||||||
/STABILITY.md export-ignore
|
|
||||||
/TESTING.md export-ignore
|
|
||||||
/scripts export-ignore
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
name: Bug report
|
|
||||||
description: Something in WP Plugin Starter does not work as it should.
|
|
||||||
labels: ["bug"]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Security problems: please do not report them here. See SECURITY.md.
|
|
||||||
- type: textarea
|
|
||||||
id: what
|
|
||||||
attributes:
|
|
||||||
label: What happened
|
|
||||||
description: What you saw, and what you expected instead.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: steps
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
description: The feature involved, its settings, and what you clicked.
|
|
||||||
placeholder: |
|
|
||||||
1. Turn on …
|
|
||||||
2. Open …
|
|
||||||
3. See …
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: version
|
|
||||||
attributes:
|
|
||||||
label: WP Plugin Starter version
|
|
||||||
description: Shown on the Plugins screen.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: dropdown
|
|
||||||
id: source
|
|
||||||
attributes:
|
|
||||||
label: Installed from
|
|
||||||
options:
|
|
||||||
- GitHub release
|
|
||||||
- WordPress.org
|
|
||||||
- Other
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: environment
|
|
||||||
attributes:
|
|
||||||
label: WordPress and PHP versions
|
|
||||||
description: Tools → Site Health → Info shows both.
|
|
||||||
placeholder: WordPress 6.8, PHP 8.3
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: log
|
|
||||||
attributes:
|
|
||||||
label: Messages in debug.log
|
|
||||||
description: Lines from wp-content/debug.log that mention wpstarter, if any. Remove anything private first.
|
|
||||||
render: text
|
|
||||||
- type: textarea
|
|
||||||
id: more
|
|
||||||
attributes:
|
|
||||||
label: Anything else
|
|
||||||
description: Theme, other plugins involved, multisite, screenshots.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Security problem
|
|
||||||
url: https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/SECURITY.md
|
|
||||||
about: Report security problems privately, never in a public issue.
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
name: Feature request
|
|
||||||
description: Suggest a feature or an improvement.
|
|
||||||
labels: ["enhancement"]
|
|
||||||
body:
|
|
||||||
- type: textarea
|
|
||||||
id: problem
|
|
||||||
attributes:
|
|
||||||
label: The problem
|
|
||||||
description: What is slow, missing or annoying today, and for whom.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: idea
|
|
||||||
attributes:
|
|
||||||
label: What WP Plugin Starter could do
|
|
||||||
description: What it would do on its own, without new settings where possible.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: replaces
|
|
||||||
attributes:
|
|
||||||
label: Plugin it would replace
|
|
||||||
description: If another plugin does this now, its name and WordPress.org page.
|
|
||||||
- type: textarea
|
|
||||||
id: more
|
|
||||||
attributes:
|
|
||||||
label: Anything else
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
name: 'Create Plugin Zip'
|
||||||
|
description: 'Creates a zip file of the WordPress plugin, excluding unnecessary files'
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Create plugin zip
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p dist
|
||||||
|
echo "Creating plugin zip file..."
|
||||||
|
zip -r dist/plugin.zip . \
|
||||||
|
-x "node_modules/**" "dist/**" ".git/**" ".github/**" ".wiki/**" "cypress/**" "playground/**" "tests/**" "vendor/**"
|
||||||
|
echo "Plugin zip created at dist/plugin.zip"
|
||||||
|
ls -la dist/
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# Weekly updates for the pinned GitHub Actions and the Composer development
|
|
||||||
# tools (composer.json; the plugin itself has no Composer dependencies).
|
|
||||||
# Each ecosystem's updates come grouped in one pull request.
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: github-actions
|
|
||||||
directory: /
|
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
groups:
|
|
||||||
actions:
|
|
||||||
patterns: ["*"]
|
|
||||||
|
|
||||||
- package-ecosystem: composer
|
|
||||||
directory: /
|
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
versioning-strategy: lockfile-only
|
|
||||||
groups:
|
|
||||||
dev-tools:
|
|
||||||
patterns: ["*"]
|
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
description: Configuration for AI behavior when interacting with Codacy's MCP Server
|
||||||
|
applyTo: '**'
|
||||||
|
---
|
||||||
|
---
|
||||||
|
# Codacy Rules
|
||||||
|
Configuration for AI behavior when interacting with Codacy's MCP Server
|
||||||
|
|
||||||
|
## CRITICAL: After ANY successful `edit_file` or `reapply` operation
|
||||||
|
- YOU MUST IMMEDIATELY run the `codacy_cli_analyze` tool from Codacy's MCP Server for each file that was edited, with:
|
||||||
|
- `rootPath`: set to the workspace path
|
||||||
|
- `file`: set to the path of the edited file
|
||||||
|
- `tool`: leave empty or unset
|
||||||
|
- If any issues are found in the new edits, propose and apply fixes for them.
|
||||||
|
- > NOTE: Failure to follow this rule is considered a critical error.
|
||||||
|
|
||||||
|
## When you tried to run the `codacy_cli_analyze` tool and the Codacy CLI is not installed
|
||||||
|
- Ask the user 'Codacy CLI is not installed. Would you like me to install it now?'
|
||||||
|
- If the user responds with "yes", run the `codacy_cli_install` tool and then continue with the original task
|
||||||
|
- If the user responds with "no", instruct the user that they can disable automatic analysis in the extension settings
|
||||||
|
- Wait for the user to respond before proceeding with any other actions
|
||||||
|
|
||||||
|
## After every response
|
||||||
|
- If you made any file edits in this conversation, verify you ran `codacy_cli_analyze` tool from Codacy's MCP Server
|
||||||
|
|
||||||
|
## When there are no Codacy MCP Server tools available, or the MCP Server is not reachable
|
||||||
|
- Suggest the user the following troubleshooting steps:
|
||||||
|
- Try to reset the MCP on the extension
|
||||||
|
- If the user is using VSCode, suggest them to review their Copilot > MCP settings in Github, under their organization or personal account. Refer them to Settings > Copilot > Enable MCP servers in Copilot. Suggested URL (https://github.com/settings/copilot/features) or https://github.com/organizations/{organization-name}/settings/copilot/features (This can only be done by their organization admins / owners)
|
||||||
|
- If none of the above steps work, suggest the user to contact Codacy support
|
||||||
|
|
||||||
|
## Trying to call a tool that needs a rootPath as a parameter
|
||||||
|
- Always use the standard, non-URL-encoded file system path
|
||||||
|
|
||||||
|
## CRITICAL: Dependencies and Security Checks
|
||||||
|
- IMMEDIATELY after ANY of these actions:
|
||||||
|
- Running npm/yarn/pnpm install
|
||||||
|
- Adding dependencies to package.json
|
||||||
|
- Adding requirements to requirements.txt
|
||||||
|
- Adding dependencies to pom.xml
|
||||||
|
- Adding dependencies to build.gradle
|
||||||
|
- Any other package manager operations
|
||||||
|
- You MUST run the `codacy_cli_analyze` tool with:
|
||||||
|
- `rootPath`: set to the workspace path
|
||||||
|
- `tool`: set to "trivy"
|
||||||
|
- `file`: leave empty or unset
|
||||||
|
- If any vulnerabilities are found because of the newly added packages:
|
||||||
|
- Stop all other operations
|
||||||
|
- Propose and apply fixes for the security issues
|
||||||
|
- Only continue with the original task after security issues are resolved
|
||||||
|
- EXAMPLE:
|
||||||
|
- After: npm install react-markdown
|
||||||
|
- Do: Run codacy_cli_analyze with trivy
|
||||||
|
- Before: Continuing with any other tasks
|
||||||
|
|
||||||
|
## General
|
||||||
|
- Repeat the relevant steps for each modified file.
|
||||||
|
- "Propose fixes" means to both suggest and, if possible, automatically apply the fixes.
|
||||||
|
- You MUST NOT wait for the user to ask for analysis or remind you to run the tool.
|
||||||
|
- Do not run `codacy_cli_analyze` looking for changes in duplicated code or code complexity metrics.
|
||||||
|
- Complexity metrics are different from complexity issues. When trying to fix complexity in a repository or file, focus on solving the complexity issues and ignore the complexity metric.
|
||||||
|
- Do not run `codacy_cli_analyze` looking for changes in code coverage.
|
||||||
|
- Do not try to manually install Codacy CLI using either brew, npm, npx, or any other package manager.
|
||||||
|
- If the Codacy CLI is not installed, just run the `codacy_cli_analyze` tool from Codacy's MCP Server.
|
||||||
|
- When calling `codacy_cli_analyze`, only send provider, organization and repository if the project is a git repository.
|
||||||
|
|
||||||
|
## Whenever a call to a Codacy tool that uses `repository` or `organization` as a parameter returns a 404 error
|
||||||
|
- Offer to run the `codacy_setup_repository` tool to add the repository to Codacy
|
||||||
|
- If the user accepts, run the `codacy_setup_repository` tool
|
||||||
|
- Do not ever try to run the `codacy_setup_repository` tool on your own
|
||||||
|
- After setup, immediately retry the action that failed (only retry once)
|
||||||
|
---
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
## What and why
|
|
||||||
|
|
||||||
<!-- What changed, and the problem it solves. Link the issue: Resolves #123. -->
|
|
||||||
|
|
||||||
## How it was tested
|
|
||||||
|
|
||||||
<!-- The steps you took on a real WordPress site, and what you saw. -->
|
|
||||||
|
|
||||||
- [ ] `scripts/lint.sh` passes.
|
|
||||||
- [ ] Tested the changed feature on a WordPress site, with no new messages
|
|
||||||
mentioning `wpstarter` in `debug.log`.
|
|
||||||
- [ ] WordPress 6.2 with PHP 7.4, if this uses a core function. <!-- or n/a -->
|
|
||||||
- [ ] Kadence light and dark mode, if this changes front-end styles. <!-- or n/a -->
|
|
||||||
|
|
||||||
## Checklist
|
|
||||||
|
|
||||||
- [ ] Changelog lines in `README.md`, `changelog.txt` and `readme.txt`.
|
|
||||||
- [ ] New options, post meta, transients or cron hooks are removed in `uninstall.php`.
|
|
||||||
- [ ] New features are off by default.
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
# Checks for every pull request and every push to main. Run the same checks
|
|
||||||
# locally with scripts/lint.sh, scripts/preflight-release.sh,
|
|
||||||
# scripts/plugin-check.sh and scripts/smoke-test.sh (DEVELOPMENT.md).
|
|
||||||
#
|
|
||||||
# Lint runs on every push. The release and smoke-test jobs take longer, so
|
|
||||||
# draft pull requests skip them until they are marked ready for review.
|
|
||||||
# Actions are pinned to commit SHAs; Dependabot keeps them up to date.
|
|
||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ci-${{ github.event.pull_request.number || github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Lint (PHP 7.4)
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 15
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
|
|
||||||
with:
|
|
||||||
php-version: "7.4"
|
|
||||||
coverage: none
|
|
||||||
tools: composer:v2
|
|
||||||
|
|
||||||
- name: Composer cache folder
|
|
||||||
id: composer-cache
|
|
||||||
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
||||||
with:
|
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
|
||||||
key: composer-${{ hashFiles('composer.lock') }}
|
|
||||||
restore-keys: composer-
|
|
||||||
|
|
||||||
- name: Install development tools
|
|
||||||
run: composer install --no-interaction --no-progress --prefer-dist
|
|
||||||
|
|
||||||
# PHPStan's result cache: the latest run's is restored, so only files
|
|
||||||
# changed since then are analysed again.
|
|
||||||
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
||||||
with:
|
|
||||||
path: .cache/phpstan
|
|
||||||
key: phpstan-${{ github.run_id }}
|
|
||||||
restore-keys: phpstan-
|
|
||||||
|
|
||||||
- name: PHP syntax (7.4), JavaScript syntax, ShellCheck, PHPCS, PHPStan
|
|
||||||
run: scripts/lint.sh php js shell phpcs phpstan
|
|
||||||
|
|
||||||
- name: actionlint
|
|
||||||
run: docker run --rm -v "$PWD:/repo" --workdir /repo rhysd/actionlint:1.7.12 -color
|
|
||||||
|
|
||||||
release:
|
|
||||||
name: Release build, preflight and Plugin Check
|
|
||||||
needs: lint
|
|
||||||
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 20
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
|
|
||||||
with:
|
|
||||||
php-version: "7.4"
|
|
||||||
coverage: none
|
|
||||||
tools: none
|
|
||||||
|
|
||||||
- name: Preflight
|
|
||||||
run: scripts/preflight-release.sh --offline --no-docker
|
|
||||||
|
|
||||||
- name: Build both zips
|
|
||||||
run: scripts/build-release.sh --out dist
|
|
||||||
|
|
||||||
- name: Plugin Check
|
|
||||||
run: |
|
|
||||||
args=()
|
|
||||||
for zip in dist/*.zip; do
|
|
||||||
args+=(--zip "$zip")
|
|
||||||
done
|
|
||||||
scripts/plugin-check.sh "${args[@]}" --keep-output dist/plugin-check
|
|
||||||
|
|
||||||
- name: Keep the zips and reports for testing
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
||||||
with:
|
|
||||||
name: ${{ github.event.repository.name }}-build-${{ github.sha }}
|
|
||||||
path: dist/
|
|
||||||
retention-days: 7
|
|
||||||
if-no-files-found: ignore
|
|
||||||
|
|
||||||
smoke:
|
|
||||||
name: Smoke test (WordPress ${{ matrix.wp }}, PHP ${{ matrix.php }})
|
|
||||||
needs: lint
|
|
||||||
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 20
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
# Minimums (readme.txt, plugin header).
|
|
||||||
- wp: "6.2"
|
|
||||||
php: "7.4"
|
|
||||||
- wp: latest
|
|
||||||
php: "8.3"
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Smoke test
|
|
||||||
run: scripts/smoke-test.sh --wp "${{ matrix.wp }}" --php "${{ matrix.php }}" --keep-log debug.log
|
|
||||||
|
|
||||||
- name: Keep debug.log
|
|
||||||
if: failure()
|
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
||||||
with:
|
|
||||||
name: debug-log-wp${{ matrix.wp }}-php${{ matrix.php }}
|
|
||||||
path: debug.log
|
|
||||||
retention-days: 7
|
|
||||||
if-no-files-found: ignore
|
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
name: Code Quality
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, feature/* ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
phpcs:
|
||||||
|
name: PHP CodeSniffer
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
with:
|
||||||
|
clean: 'true'
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.1'
|
||||||
|
extensions: mbstring, intl, zip
|
||||||
|
tools: composer:v2
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
- name: Install WordPress Coding Standards
|
||||||
|
run: |
|
||||||
|
composer require --dev wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer
|
||||||
|
vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs
|
||||||
|
|
||||||
|
- name: Run PHPCS
|
||||||
|
run: composer phpcs
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Run PHPCBF (report only)
|
||||||
|
run: |
|
||||||
|
echo "Running PHPCBF in dry-run mode to show what would be fixed"
|
||||||
|
composer phpcbf -- --dry-run
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
phpstan:
|
||||||
|
name: PHPStan Static Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.1'
|
||||||
|
extensions: mbstring, intl, zip
|
||||||
|
tools: composer:v2, phpstan
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
- name: Install PHPStan WordPress stubs
|
||||||
|
run: composer require --dev szepeviktor/phpstan-wordpress
|
||||||
|
|
||||||
|
- name: Run PHPStan
|
||||||
|
run: composer phpstan
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
phpmd:
|
||||||
|
name: PHP Mess Detector
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.1'
|
||||||
|
extensions: mbstring, intl, zip
|
||||||
|
tools: composer:v2, phpmd
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
- name: Run PHPMD
|
||||||
|
run: composer phpmd
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
# NOTE: SonarCloud job is disabled because SONAR_TOKEN is not properly configured.
|
||||||
|
# To enable, configure a valid SONAR_TOKEN secret and uncomment this job.
|
||||||
|
# Generate a token at: https://sonarcloud.io/account/security
|
||||||
|
#
|
||||||
|
# sonarcloud:
|
||||||
|
# name: SonarCloud Analysis
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout code
|
||||||
|
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
# with:
|
||||||
|
# fetch-depth: 0
|
||||||
|
#
|
||||||
|
# - name: Set up JDK 17
|
||||||
|
# uses: actions/setup-java@v4
|
||||||
|
# with:
|
||||||
|
# java-version: 17
|
||||||
|
# distribution: 'temurin'
|
||||||
|
#
|
||||||
|
# - name: Cache SonarCloud packages
|
||||||
|
# uses: actions/cache@v4
|
||||||
|
# with:
|
||||||
|
# path: ~/.sonar/cache
|
||||||
|
# key: ${{ runner.os }}-sonar
|
||||||
|
# restore-keys: ${{ runner.os }}-sonar
|
||||||
|
#
|
||||||
|
# - name: Check if SonarCloud token is set
|
||||||
|
# id: check_sonar_token
|
||||||
|
# run: |
|
||||||
|
# if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then
|
||||||
|
# echo "SONAR_TOKEN is not set, skipping SonarCloud analysis"
|
||||||
|
# echo "skip=true" >> $GITHUB_OUTPUT
|
||||||
|
# else
|
||||||
|
# echo "skip=false" >> $GITHUB_OUTPUT
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# - name: SonarCloud Scan
|
||||||
|
# if: steps.check_sonar_token.outputs.skip != 'true'
|
||||||
|
# uses: SonarSource/sonarqube-scan-action@master
|
||||||
|
# env:
|
||||||
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
# with:
|
||||||
|
# args: >
|
||||||
|
# -Dsonar.projectKey=wpallstars_wp-plugin-starter-template-for-ai-coding
|
||||||
|
# -Dsonar.organization=wpallstars
|
||||||
|
# -Dsonar.sources=.
|
||||||
|
# -Dsonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**,cypress/**,playground/**,.wiki/**
|
||||||
|
# -Dsonar.sourceEncoding=UTF-8
|
||||||
|
# continue-on-error: true
|
||||||
|
|
||||||
|
codacy:
|
||||||
|
name: Codacy Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check if Codacy token is set
|
||||||
|
id: check_codacy_token
|
||||||
|
run: |
|
||||||
|
if [ -z "${{ secrets.CODACY_PROJECT_TOKEN }}" ]; then
|
||||||
|
echo "CODACY_PROJECT_TOKEN is not set, running Codacy without upload"
|
||||||
|
echo "skip_upload=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "skip_upload=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Run Codacy Analysis CLI
|
||||||
|
uses: codacy/codacy-analysis-cli-action@v4
|
||||||
|
with:
|
||||||
|
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||||
|
verbose: true
|
||||||
|
output: results.sarif
|
||||||
|
format: sarif
|
||||||
|
# Limit the number of issues to prevent GitHub Code Scanning rejection
|
||||||
|
gh-code-scanning-compat: true
|
||||||
|
max-allowed-issues: 20
|
||||||
|
# Limit tools to prevent timeouts and stay under GitHub's 20 runs limit
|
||||||
|
tool: phpcs,phpmd,markdownlint
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Upload SARIF results file
|
||||||
|
if: steps.check_codacy_token.outputs.skip_upload != 'true'
|
||||||
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
|
with:
|
||||||
|
sarif_file: results.sarif
|
||||||
|
continue-on-error: true
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
name: PHPUnit Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, feature/* ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: PHP ${{ matrix.php }} - WP ${{ matrix.wp }} - ${{ matrix.multisite && 'Multisite' || 'Single Site' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php: [ '7.4', '8.0' ]
|
||||||
|
wp: [ 'latest' ]
|
||||||
|
multisite: [ false, true ]
|
||||||
|
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_DATABASE: wordpress_test
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
|
||||||
|
|
||||||
|
- name: Install WordPress test suite
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "Installing WordPress test suite with multisite=${{ matrix.multisite }}"
|
||||||
|
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp }} false ${{ matrix.multisite && 'true' || 'false' }}
|
||||||
|
echo "WordPress test suite installed successfully"
|
||||||
|
|
||||||
|
- name: Run PHPUnit tests
|
||||||
|
env:
|
||||||
|
WP_PHPUNIT__DIR: /tmp/wordpress-tests-lib
|
||||||
|
WP_TESTS_DIR: /tmp/wordpress-tests-lib
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.multisite }}" = "true" ]; then
|
||||||
|
WP_MULTISITE=1 composer test
|
||||||
|
else
|
||||||
|
composer test
|
||||||
|
fi
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
name: WordPress Playground Tests Fix
|
||||||
|
|
||||||
|
# DISABLED: WordPress Playground CLI doesn't work reliably in GitHub Actions CI environments
|
||||||
|
# The server fails to start within timeout periods. These tests should be run locally instead.
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Disable automatic triggers - only run manually if needed for debugging
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
debug:
|
||||||
|
description: 'Enable debug mode'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
# Commented out triggers that cause CI noise:
|
||||||
|
# push:
|
||||||
|
# branches: [ main, feature/* ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ main ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
playground-test:
|
||||||
|
name: WordPress Playground Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Allow failures since WordPress Playground CLI can be unreliable in CI environments
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Add WordPress Playground CLI to dependencies
|
||||||
|
run: |
|
||||||
|
echo "Installing WordPress Playground CLI..."
|
||||||
|
npm install --save-dev @wp-playground/cli @wp-playground/blueprints @wp-playground/client
|
||||||
|
echo "WordPress Playground CLI installed"
|
||||||
|
npx @wp-playground/cli --version
|
||||||
|
|
||||||
|
- name: Create plugin zip
|
||||||
|
uses: ./.github/actions/create-plugin-zip
|
||||||
|
|
||||||
|
- name: Run tests with WordPress Playground
|
||||||
|
run: |
|
||||||
|
# Set base URL for Cypress
|
||||||
|
export CYPRESS_BASE_URL=http://localhost:8888
|
||||||
|
|
||||||
|
# Check if blueprint file exists
|
||||||
|
echo "Checking blueprint file..."
|
||||||
|
ls -la playground/
|
||||||
|
cat playground/blueprint.json
|
||||||
|
|
||||||
|
# Start WordPress Playground with our blueprint
|
||||||
|
echo "Starting WordPress Playground server..."
|
||||||
|
npx @wp-playground/cli server --blueprint playground/blueprint.json --port 8888 --login &
|
||||||
|
SERVER_PID=$!
|
||||||
|
|
||||||
|
# Wait for WordPress Playground to be ready (increased timeout to 180s)
|
||||||
|
echo "Waiting for WordPress Playground to be ready..."
|
||||||
|
TIMEOUT=180
|
||||||
|
ELAPSED=0
|
||||||
|
while ! curl -s http://localhost:8888 > /dev/null 2>&1; do
|
||||||
|
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||||
|
echo "Timeout waiting for WordPress Playground to start"
|
||||||
|
kill $SERVER_PID || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting... ($ELAPSED/$TIMEOUT seconds)"
|
||||||
|
sleep 5
|
||||||
|
ELAPSED=$((ELAPSED + 5))
|
||||||
|
done
|
||||||
|
echo "WordPress Playground is ready after $ELAPSED seconds"
|
||||||
|
|
||||||
|
# Run Cypress tests against WordPress Playground
|
||||||
|
echo "Running Cypress tests..."
|
||||||
|
npx cypress run --spec "cypress/e2e/playground-single-site.cy.js"
|
||||||
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Kill the server process
|
||||||
|
kill $SERVER_PID || true
|
||||||
|
|
||||||
|
# Return the test exit code
|
||||||
|
exit $TEST_EXIT_CODE
|
||||||
|
|
||||||
|
- name: Upload Cypress artifacts
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cypress-playground-results
|
||||||
|
path: |
|
||||||
|
cypress/videos
|
||||||
|
cypress/screenshots
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
name: WordPress Playground Tests
|
||||||
|
|
||||||
|
# Re-enabled with @wp-playground/cli v3.0.22 which has improved CI stability.
|
||||||
|
# Tests use continue-on-error: true so they won't block PRs if flaky.
|
||||||
|
#
|
||||||
|
# To run locally:
|
||||||
|
# npm run playground:start
|
||||||
|
# npm run playground:start:multisite
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, feature/* ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
debug:
|
||||||
|
description: 'Enable debug mode'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
code-quality:
|
||||||
|
name: Code Quality Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Verify package.json and package-lock.json
|
||||||
|
run: |
|
||||||
|
echo "Verifying package.json and package-lock.json are in sync"
|
||||||
|
npm install --dry-run --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Lint JavaScript files
|
||||||
|
run: npm run lint:js
|
||||||
|
|
||||||
|
playground-single-test:
|
||||||
|
name: WordPress Playground Single Site Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: code-quality
|
||||||
|
# Allow failures since WordPress Playground CLI can be unreliable in CI environments
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Verify WordPress Playground CLI
|
||||||
|
run: |
|
||||||
|
echo "WordPress Playground CLI version:"
|
||||||
|
npx @wp-playground/cli --version
|
||||||
|
|
||||||
|
- name: Create plugin zip
|
||||||
|
uses: ./.github/actions/create-plugin-zip
|
||||||
|
|
||||||
|
- name: Run tests with WordPress Playground
|
||||||
|
run: |
|
||||||
|
# Set base URL for Cypress
|
||||||
|
export CYPRESS_BASE_URL=http://127.0.0.1:8888
|
||||||
|
|
||||||
|
# Check if blueprint file exists
|
||||||
|
echo "Checking blueprint file..."
|
||||||
|
ls -la playground/
|
||||||
|
cat playground/blueprint.json
|
||||||
|
|
||||||
|
# Start WordPress Playground with our blueprint (using @wp-playground/cli 3.x)
|
||||||
|
echo "Starting WordPress Playground server..."
|
||||||
|
npx @wp-playground/cli server \
|
||||||
|
--blueprint playground/blueprint.json \
|
||||||
|
--port 8888 \
|
||||||
|
--login \
|
||||||
|
--php 8.0 \
|
||||||
|
--verbosity normal \
|
||||||
|
2>&1 | tee playground-server.log &
|
||||||
|
SERVER_PID=$!
|
||||||
|
|
||||||
|
# Wait for WordPress Playground to be ready
|
||||||
|
echo "Waiting for WordPress Playground to be ready..."
|
||||||
|
TIMEOUT=120
|
||||||
|
ELAPSED=0
|
||||||
|
while ! curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8888 2>/dev/null | grep -q "200\|302"; do
|
||||||
|
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||||
|
echo "Timeout waiting for WordPress Playground to start"
|
||||||
|
echo "=== Server log ==="
|
||||||
|
cat playground-server.log || true
|
||||||
|
kill $SERVER_PID 2>/dev/null || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Check if server process is still running
|
||||||
|
if ! kill -0 $SERVER_PID 2>/dev/null; then
|
||||||
|
echo "Server process died unexpectedly"
|
||||||
|
echo "=== Server log ==="
|
||||||
|
cat playground-server.log || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting... ($ELAPSED/$TIMEOUT seconds)"
|
||||||
|
sleep 5
|
||||||
|
ELAPSED=$((ELAPSED + 5))
|
||||||
|
done
|
||||||
|
echo "WordPress Playground is ready after $ELAPSED seconds"
|
||||||
|
|
||||||
|
# Run Cypress tests against WordPress Playground
|
||||||
|
echo "Running Cypress tests..."
|
||||||
|
npx cypress run --spec "cypress/e2e/playground-single-site.cy.js"
|
||||||
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Kill the server process
|
||||||
|
kill $SERVER_PID 2>/dev/null || true
|
||||||
|
|
||||||
|
# Return the test exit code
|
||||||
|
exit $TEST_EXIT_CODE
|
||||||
|
|
||||||
|
- name: Upload Cypress artifacts
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cypress-single-site-results
|
||||||
|
path: |
|
||||||
|
cypress/videos
|
||||||
|
cypress/screenshots
|
||||||
|
|
||||||
|
playground-multisite-test:
|
||||||
|
name: WordPress Playground Multisite Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [code-quality, playground-single-test]
|
||||||
|
# DISABLED: WordPress Multisite does not support custom ports (requires port 80/443).
|
||||||
|
# This is a fundamental WordPress limitation. Multisite tests can only run locally
|
||||||
|
# where port 80 can be used. See: https://developer.wordpress.org/advanced-administration/multisite/
|
||||||
|
if: false
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Verify WordPress Playground CLI
|
||||||
|
run: |
|
||||||
|
echo "WordPress Playground CLI version:"
|
||||||
|
npx @wp-playground/cli --version
|
||||||
|
|
||||||
|
- name: Create plugin zip
|
||||||
|
uses: ./.github/actions/create-plugin-zip
|
||||||
|
|
||||||
|
- name: Run tests with WordPress Playground
|
||||||
|
run: |
|
||||||
|
# Set base URL for Cypress
|
||||||
|
export CYPRESS_BASE_URL=http://127.0.0.1:8889
|
||||||
|
|
||||||
|
# Check if blueprint file exists
|
||||||
|
echo "Checking multisite blueprint file..."
|
||||||
|
ls -la playground/
|
||||||
|
cat playground/multisite-blueprint.json
|
||||||
|
|
||||||
|
# Start WordPress Playground with our blueprint (using @wp-playground/cli 3.x)
|
||||||
|
# Use a different port for multisite to avoid conflicts with single site tests
|
||||||
|
echo "Starting WordPress Playground server for multisite..."
|
||||||
|
npx @wp-playground/cli server \
|
||||||
|
--blueprint playground/multisite-blueprint.json \
|
||||||
|
--port 8889 \
|
||||||
|
--login \
|
||||||
|
--php 8.0 \
|
||||||
|
--verbosity normal \
|
||||||
|
2>&1 | tee playground-server.log &
|
||||||
|
SERVER_PID=$!
|
||||||
|
|
||||||
|
# Wait for WordPress Playground to be ready
|
||||||
|
echo "Waiting for WordPress Playground to be ready..."
|
||||||
|
TIMEOUT=120
|
||||||
|
ELAPSED=0
|
||||||
|
while ! curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8889 2>/dev/null | grep -q "200\|302"; do
|
||||||
|
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||||
|
echo "Timeout waiting for WordPress Playground to start"
|
||||||
|
echo "=== Server log ==="
|
||||||
|
cat playground-server.log || true
|
||||||
|
kill $SERVER_PID 2>/dev/null || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Check if server process is still running
|
||||||
|
if ! kill -0 $SERVER_PID 2>/dev/null; then
|
||||||
|
echo "Server process died unexpectedly"
|
||||||
|
echo "=== Server log ==="
|
||||||
|
cat playground-server.log || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting... ($ELAPSED/$TIMEOUT seconds)"
|
||||||
|
sleep 5
|
||||||
|
ELAPSED=$((ELAPSED + 5))
|
||||||
|
done
|
||||||
|
echo "WordPress Playground is ready after $ELAPSED seconds"
|
||||||
|
|
||||||
|
# Run Cypress tests against WordPress Playground
|
||||||
|
echo "Running Cypress multisite tests..."
|
||||||
|
npx cypress run --spec "cypress/e2e/playground-multisite.cy.js"
|
||||||
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Kill the server process
|
||||||
|
kill $SERVER_PID 2>/dev/null || true
|
||||||
|
|
||||||
|
# Return the test exit code
|
||||||
|
exit $TEST_EXIT_CODE
|
||||||
|
|
||||||
|
- name: Upload Cypress artifacts
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cypress-multisite-results
|
||||||
|
path: |
|
||||||
|
cypress/videos
|
||||||
|
cypress/screenshots
|
||||||
|
|
||||||
|
performance-test:
|
||||||
|
name: WordPress Performance Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: code-quality
|
||||||
|
# Allow failures since performance tests can be flaky in CI environments
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: WordPress Performance Tests
|
||||||
|
uses: swissspidy/wp-performance-action@v2.0.3
|
||||||
|
with:
|
||||||
|
plugins: |
|
||||||
|
./
|
||||||
|
urls: |
|
||||||
|
/
|
||||||
|
/wp-admin/
|
||||||
|
# Don't pass blueprint - let the action use its own internal setup.
|
||||||
|
# Our blueprint includes features that may conflict with the action's Lighthouse setup.
|
||||||
|
wp-version: 'latest'
|
||||||
|
php-version: '8.0'
|
||||||
|
iterations: 5
|
||||||
|
repetitions: 1
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
name: Release - Build and publish plugin releases
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
- 'v*-stable'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build and Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
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-for-ai-coding
|
||||||
|
cp -R *.php README.md LICENSE CHANGELOG.md readme.txt composer.json build/wp-plugin-starter-template-for-ai-coding/
|
||||||
|
cp -R admin includes languages vendor build/wp-plugin-starter-template-for-ai-coding/
|
||||||
|
mkdir -p build/wp-plugin-starter-template-for-ai-coding/assets/banner build/wp-plugin-starter-template-for-ai-coding/assets/icon build/wp-plugin-starter-template-for-ai-coding/assets/screenshots
|
||||||
|
if [ -d "assets/banner" ]; then cp -R assets/banner/* build/wp-plugin-starter-template-for-ai-coding/assets/banner/; fi
|
||||||
|
if [ -d "assets/icon" ]; then cp -R assets/icon/* build/wp-plugin-starter-template-for-ai-coding/assets/icon/; fi
|
||||||
|
if [ -d "assets/screenshots" ]; then cp -R assets/screenshots/* build/wp-plugin-starter-template-for-ai-coding/assets/screenshots/; fi
|
||||||
|
|
||||||
|
- name: Create ZIP file
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
zip -r ../wp-plugin-starter-template-for-ai-coding-${{ env.VERSION }}.zip wp-plugin-starter-template-for-ai-coding -x "*.DS_Store" -x "*.git*"
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
- name: Extract changelog
|
||||||
|
id: extract_changelog
|
||||||
|
run: |
|
||||||
|
CHANGELOG=$(grep -A 20 "#### \[${{ env.VERSION }}\]" CHANGELOG.md | sed -n '/####/,/####/p' | sed '$d')
|
||||||
|
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$CHANGELOG" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: wp-plugin-starter-template-for-ai-coding-${{ env.VERSION }}.zip
|
||||||
|
name: v${{ env.VERSION }} - WordPress Plugin Starter Template
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
body: |
|
||||||
|
# WordPress Plugin Starter Template v${{ env.VERSION }}
|
||||||
|
|
||||||
|
${{ env.CHANGELOG }}
|
||||||
|
|
||||||
|
[View full changelog](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/CHANGELOG.md)
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
name: SonarCloud Analysis
|
||||||
|
|
||||||
|
# DISABLED: Using SonarCloud Automatic Analysis instead of CI-based analysis.
|
||||||
|
# Custom Quality Gates require a paid plan, which isn't suitable for FOSS projects.
|
||||||
|
# The free Automatic Analysis provides code quality feedback without coverage requirements.
|
||||||
|
#
|
||||||
|
# To re-enable CI-based analysis:
|
||||||
|
# 1. Uncomment the triggers below
|
||||||
|
# 2. Disable Automatic Analysis on SonarCloud.io
|
||||||
|
# 3. Consider upgrading to a paid plan for custom Quality Gate settings
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Disabled - using Automatic Analysis instead
|
||||||
|
# push:
|
||||||
|
# branches: [ main, feature/* ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ main ]
|
||||||
|
# types: [opened, synchronize, reopened]
|
||||||
|
workflow_dispatch: # Keep manual trigger for testing
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sonarcloud:
|
||||||
|
name: SonarCloud
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
|
|
||||||
|
- name: Check if SonarCloud token is set
|
||||||
|
id: check_token
|
||||||
|
run: |
|
||||||
|
if [ -z "${{ secrets.SONARCLOUD_GITHUB }}" ]; then
|
||||||
|
echo "SONARCLOUD_GITHUB is not set, skipping SonarCloud analysis"
|
||||||
|
echo "skip=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "skip=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: SonarCloud Scan
|
||||||
|
if: steps.check_token.outputs.skip != 'true'
|
||||||
|
uses: SonarSource/sonarqube-scan-action@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONARCLOUD_GITHUB }}
|
||||||
|
with:
|
||||||
|
args: >
|
||||||
|
-Dsonar.projectKey=wpallstars_wp-plugin-starter-template-for-ai-coding
|
||||||
|
-Dsonar.organization=wpallstars
|
||||||
|
-Dsonar.sources=.
|
||||||
|
-Dsonar.tests=tests
|
||||||
|
-Dsonar.sourceEncoding=UTF-8
|
||||||
|
-Dsonar.cpd.exclusions=tests/**
|
||||||
|
-Dsonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**,cypress/**,playground/**,.wiki/**
|
||||||
|
-Dsonar.php.coverage.reportPaths=coverage.xml
|
||||||
|
-Dsonar.php.tests.reportPath=test-report.xml
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
name: Sync Wiki - Update GitHub wiki from .wiki directory
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- '.wiki/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-wiki:
|
||||||
|
name: Sync Wiki to GitHub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
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
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
name: Tests - Run PHP compatibility and unit 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.4', '8.0']
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
clean: 'true'
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extensions: mbstring, intl, zip
|
||||||
|
tools: composer:v2
|
||||||
|
|
||||||
|
- name: Clear Composer Cache
|
||||||
|
run: composer clear-cache
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
# - name: Debug test file content
|
||||||
|
# run: echo "--- Debugging tests/test-admin.php lines 75-95 ---" && sed -n '75,95p' tests/test-admin.php && echo "--- End Debugging ---"
|
||||||
|
|
||||||
|
# - name: Run tests
|
||||||
|
# run: ./vendor/bin/phpunit
|
||||||
|
|
||||||
|
code-style:
|
||||||
|
name: Code Style
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
clean: 'true'
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
extensions: mbstring, intl, zip
|
||||||
|
tools: composer:v2, phpcs
|
||||||
|
|
||||||
|
- name: Clear Composer Cache
|
||||||
|
run: composer clear-cache
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
- name: Run PHPCS
|
||||||
|
run: composer run phpcs
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Run PHPCBF (report only)
|
||||||
|
run: |
|
||||||
|
echo "Running PHPCBF in dry-run mode to show what would be fixed"
|
||||||
|
composer run phpcbf -- --dry-run
|
||||||
|
continue-on-error: true
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
name: WordPress Tests
|
||||||
|
|
||||||
|
# DISABLED: WordPress Playground CLI doesn't work reliably in GitHub Actions CI environments
|
||||||
|
# The server fails to start within timeout periods. These tests should be run locally instead.
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Disable automatic triggers - only run manually if needed for debugging
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
debug:
|
||||||
|
description: 'Enable debug mode'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
# Commented out triggers that cause CI noise:
|
||||||
|
# push:
|
||||||
|
# branches: [ main, feature/* ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ main ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
code-quality:
|
||||||
|
name: Code Quality Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Verify package.json and package-lock.json
|
||||||
|
run: |
|
||||||
|
echo "Verifying package.json and package-lock.json are in sync"
|
||||||
|
npm install --dry-run --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Lint JavaScript files
|
||||||
|
run: npm run lint:js
|
||||||
|
|
||||||
|
# Note about e2e tests
|
||||||
|
- name: Note about e2e tests
|
||||||
|
run: |
|
||||||
|
echo "Note: We now use WordPress Playground for e2e tests instead of Docker."
|
||||||
|
echo "Please run tests locally before submitting PRs using:"
|
||||||
|
echo "npm run test:playground:single"
|
||||||
|
echo "npm run test:playground:multisite"
|
||||||
|
echo "Or use the online WordPress Playground links in the documentation."
|
||||||
|
|
||||||
|
# Use WordPress Playground for e2e tests
|
||||||
|
e2e-test:
|
||||||
|
name: WordPress Playground Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: code-quality
|
||||||
|
# Allow failures since WordPress Playground CLI can be unreliable in CI environments
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Install WordPress Playground CLI
|
||||||
|
run: npm install --save-dev @wp-playground/cli
|
||||||
|
|
||||||
|
- name: Create plugin zip
|
||||||
|
uses: ./.github/actions/create-plugin-zip
|
||||||
|
|
||||||
|
- name: Run tests with WordPress Playground
|
||||||
|
run: |
|
||||||
|
# Set base URL for Cypress
|
||||||
|
export CYPRESS_BASE_URL=http://localhost:8888
|
||||||
|
|
||||||
|
# Start WordPress Playground with our blueprint
|
||||||
|
npx @wp-playground/cli server --blueprint playground/blueprint.json --port 8888 --login &
|
||||||
|
SERVER_PID=$!
|
||||||
|
|
||||||
|
# Wait for WordPress Playground to be ready (increased timeout to 180s)
|
||||||
|
echo "Waiting for WordPress Playground to be ready..."
|
||||||
|
TIMEOUT=180
|
||||||
|
ELAPSED=0
|
||||||
|
while ! curl -s http://localhost:8888 > /dev/null 2>&1; do
|
||||||
|
if [ $ELAPSED -ge $TIMEOUT ]; then
|
||||||
|
echo "Timeout waiting for WordPress Playground to start"
|
||||||
|
kill $SERVER_PID || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting... ($ELAPSED/$TIMEOUT seconds)"
|
||||||
|
sleep 5
|
||||||
|
ELAPSED=$((ELAPSED + 5))
|
||||||
|
done
|
||||||
|
echo "WordPress Playground is ready after $ELAPSED seconds"
|
||||||
|
|
||||||
|
# Run tests against WordPress Playground
|
||||||
|
npx cypress run --spec "cypress/e2e/playground-single-site.cy.js"
|
||||||
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
|
# Kill the server process
|
||||||
|
kill $SERVER_PID || true
|
||||||
|
|
||||||
|
# Return the test exit code
|
||||||
|
exit $TEST_EXIT_CODE
|
||||||
|
|
||||||
|
- name: Upload Cypress artifacts
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cypress-results
|
||||||
|
path: |
|
||||||
|
cypress/videos
|
||||||
|
cypress/screenshots
|
||||||
+45
-54
@@ -1,51 +1,35 @@
|
|||||||
# macOS
|
# Operating System Files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
Icon
|
|
||||||
._*
|
|
||||||
.DocumentRevisions-V100
|
|
||||||
.fseventsd
|
|
||||||
.Spotlight-V100
|
|
||||||
.TemporaryItems
|
|
||||||
.Trashes
|
|
||||||
.VolumeIcon.icns
|
|
||||||
.com.apple.timemachine.donotpresent
|
|
||||||
.AppleDB
|
|
||||||
.AppleDesktop
|
|
||||||
Network Trash Folder
|
|
||||||
Temporary Items
|
|
||||||
.apdisk
|
|
||||||
|
|
||||||
# Windows
|
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
Thumbs.db:encryptable
|
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
ehthumbs_vista.db
|
Desktop.ini
|
||||||
*.stackdump
|
|
||||||
[Dd]esktop.ini
|
|
||||||
$RECYCLE.BIN/
|
$RECYCLE.BIN/
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msix
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
*.lnk
|
|
||||||
|
|
||||||
# Development & Local Environment
|
# IDE Files
|
||||||
.aider*
|
.idea/
|
||||||
.git_status_output.txt
|
.vscode/
|
||||||
.git_status_temp.txt
|
*.sublime-project
|
||||||
project-documents/
|
*.sublime-workspace
|
||||||
reference-plugins/
|
*.komodoproject
|
||||||
*.bak*
|
.komodotools/
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Dependency Directories
|
||||||
node_modules/
|
node_modules/
|
||||||
package-lock.json
|
|
||||||
.cache/
|
|
||||||
vendor/
|
vendor/
|
||||||
|
bower_components/
|
||||||
|
|
||||||
# WordPress specific
|
# Build Files
|
||||||
*.log
|
build/
|
||||||
|
dist/
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Composer
|
||||||
|
composer.phar
|
||||||
|
|
||||||
|
# WordPress
|
||||||
wp-config.php
|
wp-config.php
|
||||||
wp-content/advanced-cache.php
|
wp-content/advanced-cache.php
|
||||||
wp-content/backup-db/
|
wp-content/backup-db/
|
||||||
@@ -54,20 +38,27 @@ wp-content/blogs.dir/
|
|||||||
wp-content/cache/
|
wp-content/cache/
|
||||||
wp-content/upgrade/
|
wp-content/upgrade/
|
||||||
wp-content/uploads/
|
wp-content/uploads/
|
||||||
|
wp-content/wp-cache-config.php
|
||||||
|
wp-content/plugins/hello.php
|
||||||
|
|
||||||
# IDE & Editors
|
# Log Files
|
||||||
.vscode/
|
*.log
|
||||||
.idea/
|
logs/
|
||||||
*.sublime-project
|
error_log
|
||||||
*.sublime-workspace
|
|
||||||
|
# Environment Files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Temporary Files
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*~
|
||||||
|
|
||||||
# Keep .woodpecker.yml if needed for CI/CD
|
# Test Coverage
|
||||||
# .woodpecker.yml
|
coverage/
|
||||||
|
.phpunit.result.cache
|
||||||
# aidevops runtime state
|
|
||||||
.agents/loop-state/
|
|
||||||
|
|
||||||
# Release builds (scripts/build-release.sh)
|
|
||||||
/dist/
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# gitleaks: secret scan of the Git history (DEVELOPMENT.md → Secrets in history).
|
|
||||||
# Keep gitleaks' own rules; list only checked false positives here, each with
|
|
||||||
# its reason and as narrow as possible.
|
|
||||||
|
|
||||||
[extend]
|
|
||||||
useDefault = true
|
|
||||||
|
|
||||||
[[allowlists]]
|
|
||||||
description = "Fluent Forms field keys (el_ and a uniqid()) in starter forms, not secrets"
|
|
||||||
condition = "AND"
|
|
||||||
paths = ['''^starters/fluentform\.json$''']
|
|
||||||
regexTarget = "line"
|
|
||||||
regexes = ['''"uniqElKey": "el_[0-9.]+"''']
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"MD012": false,
|
||||||
|
"MD022": false,
|
||||||
|
"MD031": false,
|
||||||
|
"MD032": false,
|
||||||
|
"MD013": {
|
||||||
|
"line_length": 120,
|
||||||
|
"code_blocks": false
|
||||||
|
},
|
||||||
|
"MD024": {
|
||||||
|
"siblings_only": true
|
||||||
|
},
|
||||||
|
"MD040": false,
|
||||||
|
"MD041": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"MD004": {
|
||||||
|
"style": "asterisk"
|
||||||
|
},
|
||||||
|
"MD007": {
|
||||||
|
"indent": 2
|
||||||
|
},
|
||||||
|
"MD013": false,
|
||||||
|
"MD033": false,
|
||||||
|
"MD040": true,
|
||||||
|
"MD041": false,
|
||||||
|
"MD046": {
|
||||||
|
"style": "fenced"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"ask": [
|
||||||
|
"Read(!./**)",
|
||||||
|
"Edit(!./**)"
|
||||||
|
],
|
||||||
|
"allow": [
|
||||||
|
"Read(./**)",
|
||||||
|
"Edit(./**)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"memoryImport": {},
|
||||||
|
"monitoring": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "stylelint-config-standard",
|
||||||
|
"rules": {
|
||||||
|
"alpha-value-notation": "percentage",
|
||||||
|
"color-function-notation": "modern",
|
||||||
|
"font-weight-notation": "numeric",
|
||||||
|
"media-feature-range-notation": "context"
|
||||||
|
},
|
||||||
|
"ignoreFiles": [
|
||||||
|
"vendor/**",
|
||||||
|
"node_modules/**",
|
||||||
|
"build/**",
|
||||||
|
"dist/**",
|
||||||
|
"bin/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
# AI Workflow Documentation
|
||||||
|
|
||||||
|
This document provides an overview of the AI-assisted development workflows for this plugin.
|
||||||
|
|
||||||
|
## Introduction to AI-Assisted Development
|
||||||
|
|
||||||
|
AI-assisted development uses artificial intelligence tools to help with coding, documentation, testing, and other development tasks. This plugin is designed to work seamlessly with AI assistants to make development faster and more efficient.
|
||||||
|
|
||||||
|
## Setting Up Your AI Environment
|
||||||
|
|
||||||
|
### Required Files
|
||||||
|
|
||||||
|
To get the most out of AI-assisted development, make sure to include these files in your AI IDE context:
|
||||||
|
|
||||||
|
1. **AGENTS.md**: Contains essential information about the project structure and conventions
|
||||||
|
2. **.agents/**: Directory containing detailed workflow documentation for common tasks
|
||||||
|
|
||||||
|
### Pinning Files in AI IDEs
|
||||||
|
|
||||||
|
For the best results, pin these files in your AI IDE chat context:
|
||||||
|
|
||||||
|
- **Claude**: Use the "Pin" feature to keep files in context
|
||||||
|
- **GitHub Copilot**: Use the "Pin" feature in the chat interface
|
||||||
|
- **ChatGPT**: Use the "Pin" feature in the Advanced Data Analysis mode
|
||||||
|
- **Other AI IDEs**: Refer to your specific IDE's documentation for pinning files
|
||||||
|
|
||||||
|
## AI Workflow Files
|
||||||
|
|
||||||
|
The `.agents/` directory contains detailed guides for common development tasks:
|
||||||
|
|
||||||
|
1. **plugin-customization.md**: Guide for customizing the plugin for specific needs
|
||||||
|
2. **feature-development.md**: Workflow for developing new features
|
||||||
|
3. **bug-fixing.md**: Process for identifying and fixing bugs
|
||||||
|
4. **testing.md**: Guide for writing and running tests
|
||||||
|
5. **documentation.md**: Workflow for updating documentation
|
||||||
|
6. **release-process.md**: Steps for creating new releases
|
||||||
|
7. **wiki-documentation.md**: Guide for maintaining wiki documentation
|
||||||
|
|
||||||
|
## Using the Starter Prompt
|
||||||
|
|
||||||
|
The [Starter Prompt](Starter-Prompt) is a comprehensive guide for AI tools to help customize the template for your specific plugin. It includes:
|
||||||
|
|
||||||
|
1. **Project Overview**: Description of the plugin and its purpose
|
||||||
|
2. **Customization Steps**: Detailed steps for customizing the template
|
||||||
|
3. **File Structure**: Overview of the plugin's file structure
|
||||||
|
4. **Coding Standards**: Guidelines for code style and quality
|
||||||
|
5. **Testing Requirements**: Instructions for testing the plugin
|
||||||
|
|
||||||
|
## AI-Assisted Development Workflows
|
||||||
|
|
||||||
|
### Customizing the Plugin
|
||||||
|
|
||||||
|
1. Open your AI IDE and pin the `AGENTS.md` file and `.agents/` directory
|
||||||
|
2. Provide the Starter Prompt to the AI
|
||||||
|
3. Follow the AI's guidance to customize the plugin
|
||||||
|
4. Review and test the changes
|
||||||
|
|
||||||
|
### Developing New Features
|
||||||
|
|
||||||
|
1. Define the feature requirements
|
||||||
|
2. Ask the AI to help design the feature
|
||||||
|
3. Implement the feature with AI assistance
|
||||||
|
4. Write tests for the feature
|
||||||
|
5. Update documentation
|
||||||
|
|
||||||
|
### Fixing Bugs
|
||||||
|
|
||||||
|
1. Describe the bug to the AI
|
||||||
|
2. Ask the AI to help identify the cause
|
||||||
|
3. Implement the fix with AI assistance
|
||||||
|
4. Write tests to prevent regression
|
||||||
|
5. Update documentation if necessary
|
||||||
|
|
||||||
|
### Writing Tests
|
||||||
|
|
||||||
|
1. Describe the functionality to be tested
|
||||||
|
2. Ask the AI to help write unit tests
|
||||||
|
3. Ask the AI to help write end-to-end tests
|
||||||
|
4. Run the tests and fix any issues
|
||||||
|
|
||||||
|
### Updating Documentation
|
||||||
|
|
||||||
|
1. Describe the changes that need documentation
|
||||||
|
2. Ask the AI to help update the relevant documentation files
|
||||||
|
3. Review and refine the documentation
|
||||||
|
|
||||||
|
## Best Practices for AI-Assisted Development
|
||||||
|
|
||||||
|
1. **Be Specific**: Provide clear, detailed instructions to the AI
|
||||||
|
2. **Review Carefully**: Always review AI-generated code before committing
|
||||||
|
3. **Iterative Approach**: Work with the AI in small, iterative steps
|
||||||
|
4. **Provide Context**: Keep relevant files in the AI's context
|
||||||
|
5. **Ask Questions**: If you're unsure about something, ask the AI to explain
|
||||||
|
6. **Test Thoroughly**: Always test AI-generated code
|
||||||
|
|
||||||
|
## Troubleshooting AI Assistance
|
||||||
|
|
||||||
|
If you encounter issues with AI assistance:
|
||||||
|
|
||||||
|
1. **Refresh Context**: Sometimes the AI may lose context. Try refreshing the conversation or repinning files
|
||||||
|
2. **Be More Specific**: Provide more detailed instructions
|
||||||
|
3. **Break Down Tasks**: Divide complex tasks into smaller, manageable parts
|
||||||
|
4. **Provide Examples**: Show examples of what you want
|
||||||
|
5. **Try Different Approaches**: If one approach doesn't work, try a different one
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
AI-assisted development can significantly speed up your workflow and improve code quality. By following these guidelines and using the provided AI workflow documentation, you can make the most of AI tools in your development process.
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Architecture Overview
|
||||||
|
|
||||||
|
This document provides an overview of the plugin's architecture, explaining the core components and how they interact.
|
||||||
|
|
||||||
|
## Directory Structure
|
||||||
|
|
||||||
|
The plugin follows a structured organization to maintain clean separation of concerns:
|
||||||
|
|
||||||
|
```
|
||||||
|
wp-plugin-starter-template/
|
||||||
|
├── admin/ # Admin-specific functionality
|
||||||
|
│ ├── css/ # Admin stylesheets
|
||||||
|
│ ├── js/ # Admin JavaScript files
|
||||||
|
│ └── lib/ # Admin PHP classes
|
||||||
|
├── assets/ # Frontend assets
|
||||||
|
│ ├── css/ # Frontend stylesheets
|
||||||
|
│ ├── js/ # Frontend JavaScript files
|
||||||
|
│ └── images/ # Images used by the plugin
|
||||||
|
├── includes/ # Core plugin functionality
|
||||||
|
│ ├── core.php # Core functionality class
|
||||||
|
│ ├── plugin.php # Main plugin class
|
||||||
|
│ └── Multisite/ # Multisite-specific functionality
|
||||||
|
├── languages/ # Translation files
|
||||||
|
├── tests/ # Test files
|
||||||
|
│ ├── e2e/ # End-to-end tests
|
||||||
|
│ └── unit/ # Unit tests
|
||||||
|
├── cypress/ # Cypress testing files
|
||||||
|
│ └── e2e/ # End-to-end test specifications
|
||||||
|
├── bin/ # Utility scripts
|
||||||
|
│ └── setup-test-env.sh # Test environment setup script
|
||||||
|
├── .github/ # GitHub-specific files
|
||||||
|
│ └── workflows/ # GitHub Actions workflows
|
||||||
|
├── .agents/ # AI workflow documentation
|
||||||
|
├── .wiki/ # Wiki documentation
|
||||||
|
│ ├── Testing-Framework.md # Testing framework documentation
|
||||||
|
│ └── Multisite-Development.md # Multisite development guide
|
||||||
|
└── wp-plugin-starter-template.php # Main plugin file
|
||||||
|
```
|
||||||
|
|
||||||
|
## Core Components
|
||||||
|
|
||||||
|
### Main Plugin File
|
||||||
|
|
||||||
|
The `wp-plugin-starter-template.php` file serves as the entry point for WordPress. It:
|
||||||
|
|
||||||
|
1. Defines plugin metadata
|
||||||
|
2. Prevents direct access
|
||||||
|
3. Defines plugin constants
|
||||||
|
4. Loads the main plugin class
|
||||||
|
5. Initializes the plugin
|
||||||
|
|
||||||
|
### Plugin Class
|
||||||
|
|
||||||
|
The `Plugin` class in `includes/plugin.php` is the main controller for the plugin. It:
|
||||||
|
|
||||||
|
1. Initializes core functionality
|
||||||
|
2. Sets up hooks and filters
|
||||||
|
3. Manages plugin activation/deactivation
|
||||||
|
4. Handles plugin updates
|
||||||
|
|
||||||
|
### Core Class
|
||||||
|
|
||||||
|
The `Core` class in `includes/core.php` contains the core functionality of the plugin. It:
|
||||||
|
|
||||||
|
1. Implements the main plugin features
|
||||||
|
2. Provides utility methods
|
||||||
|
3. Manages data processing
|
||||||
|
|
||||||
|
### Admin Class
|
||||||
|
|
||||||
|
The `Admin` class in `admin/lib/admin.php` handles all admin-specific functionality. It:
|
||||||
|
|
||||||
|
1. Creates admin menu pages
|
||||||
|
2. Registers settings
|
||||||
|
3. Enqueues admin assets
|
||||||
|
4. Processes admin form submissions
|
||||||
|
|
||||||
|
### Multisite Support
|
||||||
|
|
||||||
|
The `Multisite` class in `includes/Multisite/class-multisite.php` provides a foundation for multisite functionality.
|
||||||
|
|
||||||
|
It:
|
||||||
|
|
||||||
|
1. Serves as a placeholder for multisite features
|
||||||
|
2. Can be extended for custom multisite functionality
|
||||||
|
3. Provides examples of multisite-specific methods
|
||||||
|
|
||||||
|
## Object-Oriented Approach
|
||||||
|
|
||||||
|
The plugin follows object-oriented programming principles:
|
||||||
|
|
||||||
|
1. **Encapsulation**: Each class encapsulates its own functionality
|
||||||
|
2. **Inheritance**: Classes can extend others to inherit functionality
|
||||||
|
3. **Namespaces**: PHP namespaces are used to avoid conflicts
|
||||||
|
4. **Autoloading**: PSR-4 autoloading for efficient class loading
|
||||||
|
|
||||||
|
## Hook System
|
||||||
|
|
||||||
|
The plugin integrates with WordPress through its hook system:
|
||||||
|
|
||||||
|
1. **Actions**: Used to add functionality at specific points
|
||||||
|
2. **Filters**: Used to modify data before it's used by WordPress
|
||||||
|
|
||||||
|
## Data Flow
|
||||||
|
|
||||||
|
1. WordPress loads the main plugin file
|
||||||
|
2. The Plugin class is instantiated
|
||||||
|
3. The Plugin class initializes the Core class
|
||||||
|
4. The Plugin class initializes the Admin class (in admin context)
|
||||||
|
5. WordPress hooks trigger plugin functionality as needed
|
||||||
|
|
||||||
|
## Extensibility
|
||||||
|
|
||||||
|
The plugin is designed to be extensible:
|
||||||
|
|
||||||
|
1. **Filters**: Key data points can be modified via filters
|
||||||
|
2. **Actions**: Additional functionality can be added via actions
|
||||||
|
3. **Class Structure**: Classes can be extended to add or modify functionality
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
The plugin includes a comprehensive testing framework:
|
||||||
|
|
||||||
|
1. **Unit Tests**: For testing individual components
|
||||||
|
2. **End-to-End Tests**: For testing the plugin as a whole
|
||||||
|
3. **WordPress Environment**: Using wp-env for local testing
|
||||||
|
4. **Multisite Testing**: Support for testing in multisite environments
|
||||||
|
5. **Continuous Integration**: Automated tests via GitHub Actions
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
This architecture provides a solid foundation for WordPress plugin development.
|
||||||
|
|
||||||
|
It follows best practices and modern coding standards.
|
||||||
|
|
||||||
|
It's designed to be maintainable, extensible, and easy to understand.
|
||||||
|
|
||||||
|
For testing framework details, see [Testing Framework](Testing-Framework.md).
|
||||||
|
|
||||||
|
For multisite development, refer to [Multisite Development](Multisite-Development.md).
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
This page documents all notable changes to the WordPress Plugin Starter Template.
|
||||||
|
|
||||||
|
## Version 0.1.6 (2025-04-19)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
|
## Version 0.1.5 (2025-04-19)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Release workflow to use correct plugin directory name
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Testing setup with wp-env and Cypress
|
||||||
|
- Multisite compatibility
|
||||||
|
- npm scripts for development and testing
|
||||||
|
|
||||||
|
## Version 0.1.3 (2025-04-19)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Improved AI IDE context recommendations in documentation
|
||||||
|
- Enhanced Starter Prompt with guidance on pinning AGENTS.md and .agents/
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated README.md and readme.txt with AI IDE context recommendations
|
||||||
|
- Improved documentation for AI-assisted development
|
||||||
|
- Moved Starter Prompt to the wiki for better organization
|
||||||
|
|
||||||
|
## Version 0.1.2 (2025-04-18)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- STARTER-PROMPT.md with comprehensive guide for customizing the template
|
||||||
|
- Additional AI workflow files for better development guidance
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated documentation files with improved instructions
|
||||||
|
|
||||||
|
## Version 0.1.1 (2025-04-18)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated LICENSE file with correct GPL-2.0 text
|
||||||
|
|
||||||
|
## Version 0.1.0 (2025-04-17)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Initial release with basic template structure
|
||||||
|
- 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
|
||||||
@@ -0,0 +1,290 @@
|
|||||||
|
# Coding Standards
|
||||||
|
|
||||||
|
This document outlines the coding standards used in this plugin. Following these standards ensures consistency, readability, and maintainability of the codebase.
|
||||||
|
|
||||||
|
## PHP Coding Standards
|
||||||
|
|
||||||
|
This plugin follows the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/) with some additional guidelines.
|
||||||
|
|
||||||
|
### File Structure
|
||||||
|
|
||||||
|
* Each PHP file should begin with the PHP opening tag `<?php` (no closing tag)
|
||||||
|
* Files should use the Unix line endings (LF)
|
||||||
|
* Files should be encoded in UTF-8 without BOM
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
* **Classes**: Use `PascalCase` for class names
|
||||||
|
```php
|
||||||
|
class MyClassName {}
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Methods and Functions**: Use `snake_case` for method and function names
|
||||||
|
```php
|
||||||
|
function my_function_name() {}
|
||||||
|
public function my_method_name() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Variables**: Use `snake_case` for variable names
|
||||||
|
```php
|
||||||
|
$my_variable_name = 'value';
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Constants**: Use `UPPERCASE_WITH_UNDERSCORES` for constants
|
||||||
|
```php
|
||||||
|
define('MY_CONSTANT', 'value');
|
||||||
|
const MY_CLASS_CONSTANT = 'value';
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Namespaces**: Use `PascalCase` for namespace segments
|
||||||
|
```php
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate;
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Hooks**: Prefix hooks with the plugin's prefix
|
||||||
|
```php
|
||||||
|
do_action('wpst_hook_name');
|
||||||
|
apply_filters('wpst_filter_name', $value);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Indentation and Formatting
|
||||||
|
|
||||||
|
* Use 4 spaces for indentation (not tabs)
|
||||||
|
* Opening braces for classes and functions should be on the same line
|
||||||
|
* Control structures should have one space between the statement and the opening parenthesis
|
||||||
|
* Each line should be no longer than 100 characters
|
||||||
|
|
||||||
|
```php
|
||||||
|
if ($condition) {
|
||||||
|
// Code here
|
||||||
|
} elseif ($another_condition) {
|
||||||
|
// More code
|
||||||
|
} else {
|
||||||
|
// Default code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* All classes, methods, and functions should be documented using PHPDoc
|
||||||
|
* Include a description, parameters, return values, and exceptions
|
||||||
|
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* Short description of the function.
|
||||||
|
*
|
||||||
|
* Longer description if needed.
|
||||||
|
*
|
||||||
|
* @param string $param1 Description of the parameter.
|
||||||
|
* @param int $param2 Description of the parameter.
|
||||||
|
* @return bool Description of the return value.
|
||||||
|
* @throws Exception When something goes wrong.
|
||||||
|
*/
|
||||||
|
function my_function($param1, $param2) {
|
||||||
|
// Function code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Object-Oriented Programming
|
||||||
|
|
||||||
|
* Each class should have a single responsibility
|
||||||
|
* Use visibility declarations for all properties and methods (public, protected, private)
|
||||||
|
* Use type hints for parameters and return types when possible
|
||||||
|
|
||||||
|
```php
|
||||||
|
class MyClass {
|
||||||
|
/**
|
||||||
|
* Property description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $property;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description.
|
||||||
|
*
|
||||||
|
* @param string $param Description of the parameter.
|
||||||
|
* @return bool Description of the return value.
|
||||||
|
*/
|
||||||
|
public function my_method(string $param): bool {
|
||||||
|
// Method code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## JavaScript Coding Standards
|
||||||
|
|
||||||
|
This plugin follows the [WordPress JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/).
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
* **Variables and Functions**: Use `camelCase` for variable and function names
|
||||||
|
```javascript
|
||||||
|
var myVariableName = 'value';
|
||||||
|
function myFunctionName() {}
|
||||||
|
```
|
||||||
|
|
||||||
|
* **Constants**: Use `UPPERCASE_WITH_UNDERSCORES` for constants
|
||||||
|
```javascript
|
||||||
|
var MY_CONSTANT = 'value';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Indentation and Formatting
|
||||||
|
|
||||||
|
* Use 4 spaces for indentation (not tabs)
|
||||||
|
* Opening braces should be on the same line as the statement
|
||||||
|
* Each line should be no longer than 100 characters
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
if (condition) {
|
||||||
|
// Code here
|
||||||
|
} else if (anotherCondition) {
|
||||||
|
// More code
|
||||||
|
} else {
|
||||||
|
// Default code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* Use JSDoc for documenting functions and objects
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* Short description of the function.
|
||||||
|
*
|
||||||
|
* @param {string} param1 - Description of the parameter.
|
||||||
|
* @param {number} param2 - Description of the parameter.
|
||||||
|
* @returns {boolean} Description of the return value.
|
||||||
|
*/
|
||||||
|
function myFunction(param1, param2) {
|
||||||
|
// Function code
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS Coding Standards
|
||||||
|
|
||||||
|
This plugin follows the [WordPress CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/).
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
|
||||||
|
* Use lowercase for selectors
|
||||||
|
* Use hyphens to separate words in class and ID names
|
||||||
|
* Prefix classes and IDs with the plugin's prefix
|
||||||
|
|
||||||
|
```css
|
||||||
|
.wpst-container {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wpst-header {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Indentation and Formatting
|
||||||
|
|
||||||
|
* Use 4 spaces for indentation (not tabs)
|
||||||
|
* Each property should be on its own line
|
||||||
|
* Include a space after the colon in property declarations
|
||||||
|
* End each declaration with a semicolon
|
||||||
|
* Use single quotes for attribute selectors and property values
|
||||||
|
|
||||||
|
```css
|
||||||
|
.wpst-container {
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px;
|
||||||
|
font-family: 'Helvetica', sans-serif;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Automated Code Checking
|
||||||
|
|
||||||
|
This plugin uses automated tools to enforce coding standards:
|
||||||
|
|
||||||
|
### Local Development Tools
|
||||||
|
|
||||||
|
1. **PHP_CodeSniffer (PHPCS)**: Checks PHP code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
composer run phpcs
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **PHP Code Beautifier and Fixer (PHPCBF)**: Automatically fixes some coding standard violations
|
||||||
|
```bash
|
||||||
|
composer run phpcbf
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **ESLint**: Checks JavaScript code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
npm run lint:js
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Stylelint**: Checks CSS code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
npm run lint:css
|
||||||
|
```
|
||||||
|
|
||||||
|
### Continuous Integration Tools
|
||||||
|
|
||||||
|
This project integrates with several code quality tools that automatically analyze your code when you create a pull request. These tools are free for public repositories and should be integrated into any new repositories based on this template.
|
||||||
|
|
||||||
|
1. **CodeRabbit**: AI-powered code review tool
|
||||||
|
* Provides automated feedback on pull requests
|
||||||
|
* Identifies potential issues and suggests improvements
|
||||||
|
* [Website](https://www.coderabbit.ai/)
|
||||||
|
|
||||||
|
2. **CodeFactor**: Continuous code quality monitoring
|
||||||
|
* Provides a grade for your codebase
|
||||||
|
* Identifies issues related to code style, complexity, and potential bugs
|
||||||
|
* Tracks code quality over time
|
||||||
|
* [Website](https://www.codefactor.io/)
|
||||||
|
|
||||||
|
3. **Codacy**: Code quality and static analysis
|
||||||
|
* Provides a grade for your codebase
|
||||||
|
* Identifies issues related to code style, security, and performance
|
||||||
|
* Tracks code quality over time
|
||||||
|
* [Website](https://www.codacy.com/)
|
||||||
|
|
||||||
|
4. **SonarCloud**: Code quality and security analysis
|
||||||
|
* Provides detailed analysis of code quality
|
||||||
|
* Identifies security vulnerabilities and technical debt
|
||||||
|
* Tracks code quality over time
|
||||||
|
* [Website](https://sonarcloud.io/)
|
||||||
|
|
||||||
|
### How to Pass Code Quality Checks
|
||||||
|
|
||||||
|
To ensure your code passes the quality checks from these tools, follow these guidelines:
|
||||||
|
|
||||||
|
1. **Run Local Checks First**
|
||||||
|
* Before pushing your code, run PHPCS and PHPCBF locally
|
||||||
|
* Fix any issues identified by these tools
|
||||||
|
|
||||||
|
2. **Address Common Issues**
|
||||||
|
* **Indentation**: Use 4 spaces for indentation (not tabs)
|
||||||
|
* **Line Length**: Keep lines under 100 characters
|
||||||
|
* **Naming Conventions**: Follow WordPress naming conventions
|
||||||
|
* **Documentation**: Add PHPDoc comments to classes, methods, and functions
|
||||||
|
* **Error Handling**: Implement proper error handling
|
||||||
|
* **Security**: Validate and sanitize input, escape output
|
||||||
|
* **Markdown**: Use asterisks (*) for bullet points, not hyphens (-)
|
||||||
|
|
||||||
|
3. **Using AI Assistants with Code Quality Tools**
|
||||||
|
* When you receive feedback from code quality tools, you can use AI assistants to help address the issues
|
||||||
|
* Copy the output from the code quality tool and paste it into your AI assistant chat
|
||||||
|
* Ask the AI to help you understand and resolve the issues
|
||||||
|
* Example prompt:
|
||||||
|
|
||||||
|
```text
|
||||||
|
I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
|
||||||
|
|
||||||
|
[Paste the tool output here]
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Iterative Improvement**
|
||||||
|
* Address issues one at a time, starting with the most critical
|
||||||
|
* Commit and push your changes to see if they resolve the issues
|
||||||
|
* Continue this process until all issues are resolved
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
Following these coding standards ensures that the plugin's code is consistent, readable, and maintainable. All contributors should adhere to these standards when submitting code to the project.
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to this project! This document provides guidelines and instructions for contributing.
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
By participating in this project, you agree to abide by our code of conduct:
|
||||||
|
|
||||||
|
- Be respectful and inclusive
|
||||||
|
- Be patient and welcoming
|
||||||
|
- Be considerate
|
||||||
|
- Be collaborative
|
||||||
|
- Be open-minded
|
||||||
|
|
||||||
|
## How to Contribute
|
||||||
|
|
||||||
|
### Reporting Bugs
|
||||||
|
|
||||||
|
If you find a bug, please report it by creating an issue on GitHub:
|
||||||
|
|
||||||
|
1. Go to the [Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) page
|
||||||
|
2. Click "New Issue"
|
||||||
|
3. Select "Bug Report"
|
||||||
|
4. Fill out the template with as much detail as possible
|
||||||
|
5. Submit the issue
|
||||||
|
|
||||||
|
Please include:
|
||||||
|
|
||||||
|
- A clear, descriptive title
|
||||||
|
- Steps to reproduce the bug
|
||||||
|
- Expected behavior
|
||||||
|
- Actual behavior
|
||||||
|
- Screenshots (if applicable)
|
||||||
|
- Your environment (WordPress version, PHP version, browser, etc.)
|
||||||
|
|
||||||
|
### Suggesting Enhancements
|
||||||
|
|
||||||
|
If you have an idea for an enhancement:
|
||||||
|
|
||||||
|
1. Go to the [Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) page
|
||||||
|
2. Click "New Issue"
|
||||||
|
3. Select "Feature Request"
|
||||||
|
4. Fill out the template with as much detail as possible
|
||||||
|
5. Submit the issue
|
||||||
|
|
||||||
|
Please include:
|
||||||
|
|
||||||
|
- A clear, descriptive title
|
||||||
|
- A detailed description of the enhancement
|
||||||
|
- Why this enhancement would be useful
|
||||||
|
- Any relevant examples or mockups
|
||||||
|
|
||||||
|
### Pull Requests
|
||||||
|
|
||||||
|
If you want to contribute code:
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create a new branch for your feature or bugfix
|
||||||
|
3. Make your changes
|
||||||
|
4. Run tests to ensure your changes don't break anything
|
||||||
|
5. Submit a pull request
|
||||||
|
|
||||||
|
#### Pull Request Process
|
||||||
|
|
||||||
|
1. Fork the repository on [GitHub](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/) or [Gitea](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/)
|
||||||
|
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/wp-plugin-starter-template-for-ai-coding.git`
|
||||||
|
3. Create your feature branch: `git checkout -b feature/amazing-feature`
|
||||||
|
4. Make your changes
|
||||||
|
5. Commit your changes: `git commit -m 'Add some amazing feature'`
|
||||||
|
6. Push to the branch: `git push origin feature/amazing-feature`
|
||||||
|
7. Submit a pull request
|
||||||
|
|
||||||
|
#### Pull Request Guidelines
|
||||||
|
|
||||||
|
- Follow the coding standards (see [Coding Standards](Coding-Standards))
|
||||||
|
- Write tests for your changes
|
||||||
|
- Update documentation as needed
|
||||||
|
- Keep pull requests focused on a single change
|
||||||
|
- Write a clear, descriptive title and description
|
||||||
|
- Reference any related issues
|
||||||
|
- Ensure your code passes the automated code quality checks (see below)
|
||||||
|
|
||||||
|
#### Code Quality Tools
|
||||||
|
|
||||||
|
This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and will automatically analyze your code when you create a pull request:
|
||||||
|
|
||||||
|
1. **CodeRabbit**: AI-powered code review tool
|
||||||
|
- [Website](https://www.coderabbit.ai/)
|
||||||
|
- Provides automated feedback on pull requests
|
||||||
|
|
||||||
|
2. **CodeFactor**: Continuous code quality monitoring
|
||||||
|
- [Website](https://www.codefactor.io/)
|
||||||
|
- Provides a grade for your codebase
|
||||||
|
|
||||||
|
3. **Codacy**: Code quality and static analysis
|
||||||
|
- [Website](https://www.codacy.com/)
|
||||||
|
- Identifies issues related to code style, security, and performance
|
||||||
|
|
||||||
|
4. **SonarCloud**: Code quality and security analysis
|
||||||
|
- [Website](https://sonarcloud.io/)
|
||||||
|
- Provides detailed analysis of code quality and security
|
||||||
|
|
||||||
|
#### Using AI Assistants with Code Quality Tools
|
||||||
|
|
||||||
|
When you receive feedback from these code quality tools, you can use AI assistants to help address the issues:
|
||||||
|
|
||||||
|
1. Copy the output from the code quality tool
|
||||||
|
2. Paste it into your AI assistant chat
|
||||||
|
3. Ask the AI to help you understand and resolve the issues
|
||||||
|
4. Apply the suggested fixes
|
||||||
|
5. Commit the changes and verify that the issues are resolved
|
||||||
|
|
||||||
|
Example prompt for AI assistants:
|
||||||
|
|
||||||
|
```text
|
||||||
|
I received the following feedback from [Tool Name]. Please help me understand and resolve these issues:
|
||||||
|
|
||||||
|
[Paste the tool output here]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Environment
|
||||||
|
|
||||||
|
To set up your development environment:
|
||||||
|
|
||||||
|
1. Clone the repository: `git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git`
|
||||||
|
2. Install dependencies: `composer install && npm install`
|
||||||
|
3. Start the development environment: `npm run start`
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
Before submitting a pull request, make sure to run the tests:
|
||||||
|
|
||||||
|
* PHP Unit Tests: `npm run test:php`
|
||||||
|
* End-to-End Tests: `npm run test:e2e`
|
||||||
|
* Coding Standards: `npm run lint:php`
|
||||||
|
|
||||||
|
#### Code Quality Checks
|
||||||
|
|
||||||
|
To ensure your code meets the quality standards, run these commands before submitting a pull request:
|
||||||
|
|
||||||
|
* Check coding standards: `composer run phpcs`
|
||||||
|
* Fix coding standards automatically: `composer run phpcbf`
|
||||||
|
* Check JavaScript coding standards: `npm run lint:js`
|
||||||
|
* Check CSS coding standards: `npm run lint:css`
|
||||||
|
|
||||||
|
These checks will help identify and fix issues before they are caught by the automated code quality tools in the pull request process.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
If you're adding a new feature or changing existing functionality, please update the documentation:
|
||||||
|
|
||||||
|
* Update the README.md file if necessary
|
||||||
|
* Update the readme.txt file if necessary
|
||||||
|
* Update or create wiki pages as needed
|
||||||
|
* Update code comments
|
||||||
|
|
||||||
|
## Community
|
||||||
|
|
||||||
|
Join our community to discuss the project:
|
||||||
|
|
||||||
|
* [GitHub Discussions](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/discussions)
|
||||||
|
* [Gitea Issues](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
|
||||||
|
|
||||||
|
## Recognition
|
||||||
|
|
||||||
|
Contributors will be recognized in the following ways:
|
||||||
|
|
||||||
|
* Added to the contributors list in readme.txt
|
||||||
|
* Mentioned in release notes for significant contributions
|
||||||
|
* Thanked in the Changelog for specific contributions
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
By contributing to this project, you agree that your contributions will be licensed under the project's [GPL-2.0+ License](https://www.gnu.org/licenses/gpl-2.0.html).
|
||||||
|
|
||||||
|
## Questions?
|
||||||
|
|
||||||
|
If you have any questions about contributing, please open an issue or contact the maintainers.
|
||||||
|
|
||||||
|
Thank you for your contributions!
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
# Customization Guide
|
||||||
|
|
||||||
|
This guide provides detailed instructions on how to customize the plugin starter template for your specific needs.
|
||||||
|
|
||||||
|
## Basic Customization
|
||||||
|
|
||||||
|
### Renaming the Plugin
|
||||||
|
|
||||||
|
1. **Main Plugin File**: Rename `wp-plugin-starter-template.php` to match your plugin name (e.g., `my-awesome-plugin.php`)
|
||||||
|
|
||||||
|
2. **Update Plugin Header**: Edit the plugin header in your main plugin file:
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* Plugin Name: My Awesome Plugin
|
||||||
|
* Plugin URI: https://www.example.com
|
||||||
|
* Description: A brief description of your plugin
|
||||||
|
* Version: 0.1.0
|
||||||
|
* Author: Your Name
|
||||||
|
* Author URI: https://www.example.com
|
||||||
|
* License: GPL-2.0+
|
||||||
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
|
* Text Domain: my-awesome-plugin
|
||||||
|
* Domain Path: /languages
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Update Text Domain**: Change the text domain throughout the codebase from `wp-plugin-starter-template` to your plugin's text domain
|
||||||
|
|
||||||
|
### Updating Namespaces
|
||||||
|
|
||||||
|
1. **Change Namespace**: Update all namespace references from `WPALLSTARS\PluginStarterTemplate` to your own namespace (e.g., `MyCompany\MyAwesomePlugin`)
|
||||||
|
|
||||||
|
2. **Update Autoloading**: Modify the `composer.json` file to reflect your new namespace:
|
||||||
|
```json
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"MyCompany\\MyAwesomePlugin\\": "includes/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Run Composer**: After updating the namespace, run `composer dump-autoload` to update the autoloader
|
||||||
|
|
||||||
|
### Customizing Documentation
|
||||||
|
|
||||||
|
1. **README.md**: Update the README.md file with your plugin's information
|
||||||
|
2. **readme.txt**: Update the readme.txt file for WordPress.org compatibility
|
||||||
|
3. **CHANGELOG.md**: Start a fresh changelog for your plugin
|
||||||
|
4. **Wiki Documentation**: Customize the wiki documentation to match your plugin
|
||||||
|
|
||||||
|
## Advanced Customization
|
||||||
|
|
||||||
|
### Adding Custom Functionality
|
||||||
|
|
||||||
|
1. **Core Functionality**: Modify the `includes/core.php` file to implement your core functionality
|
||||||
|
|
||||||
|
2. **Admin Interface**: Customize the `admin/lib/admin.php` file to create your admin interface
|
||||||
|
|
||||||
|
3. **Frontend Features**: Add frontend functionality as needed
|
||||||
|
|
||||||
|
### Customizing Assets
|
||||||
|
|
||||||
|
1. **CSS**: Modify or add stylesheets in the `assets/css/` directory
|
||||||
|
2. **JavaScript**: Customize JavaScript files in the `assets/js/` directory
|
||||||
|
3. **Images**: Add your own images to the `assets/images/` directory
|
||||||
|
|
||||||
|
### Adding Custom Post Types
|
||||||
|
|
||||||
|
If your plugin needs custom post types, add them to the Core class:
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function register_post_types() {
|
||||||
|
register_post_type('my_custom_post', [
|
||||||
|
'labels' => [
|
||||||
|
'name' => __('Custom Posts', 'my-awesome-plugin'),
|
||||||
|
'singular_name' => __('Custom Post', 'my-awesome-plugin'),
|
||||||
|
],
|
||||||
|
'public' => true,
|
||||||
|
'has_archive' => true,
|
||||||
|
'supports' => ['title', 'editor', 'thumbnail'],
|
||||||
|
'menu_icon' => 'dashicons-admin-post',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding Custom Taxonomies
|
||||||
|
|
||||||
|
For custom taxonomies, add them to the Core class:
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function register_taxonomies() {
|
||||||
|
register_taxonomy('custom_category', 'my_custom_post', [
|
||||||
|
'labels' => [
|
||||||
|
'name' => __('Custom Categories', 'my-awesome-plugin'),
|
||||||
|
'singular_name' => __('Custom Category', 'my-awesome-plugin'),
|
||||||
|
],
|
||||||
|
'hierarchical' => true,
|
||||||
|
'show_admin_column' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding Settings Pages
|
||||||
|
|
||||||
|
To add a settings page, customize the Admin class:
|
||||||
|
|
||||||
|
```php
|
||||||
|
public function add_menu_pages() {
|
||||||
|
add_menu_page(
|
||||||
|
__('My Plugin Settings', 'my-awesome-plugin'),
|
||||||
|
__('My Plugin', 'my-awesome-plugin'),
|
||||||
|
'manage_options',
|
||||||
|
'my-awesome-plugin',
|
||||||
|
[$this, 'render_settings_page'],
|
||||||
|
'dashicons-admin-generic',
|
||||||
|
100
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render_settings_page() {
|
||||||
|
include plugin_dir_path(__FILE__) . '../templates/settings-page.php';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customizing Update Mechanism
|
||||||
|
|
||||||
|
The template includes functionality for updates from different sources. Customize the update source options in the main plugin file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* GitHub Plugin URI: username/repository
|
||||||
|
* GitHub Branch: main
|
||||||
|
* Primary Branch: main
|
||||||
|
* Release Branch: main
|
||||||
|
* Release Asset: true
|
||||||
|
* Requires at least: 5.0
|
||||||
|
* Requires PHP: 7.0
|
||||||
|
* Update URI: https://example.com/plugin-updates
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing Your Customizations
|
||||||
|
|
||||||
|
After making your customizations, it's important to test your plugin:
|
||||||
|
|
||||||
|
1. **Unit Tests**: Update and run the unit tests to ensure your core functionality works correctly
|
||||||
|
2. **End-to-End Tests**: Update and run the end-to-end tests to test the plugin as a whole
|
||||||
|
3. **Manual Testing**: Test your plugin in different WordPress environments
|
||||||
|
|
||||||
|
## Building Your Plugin
|
||||||
|
|
||||||
|
Once you've customized the plugin to your needs, build it for distribution:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build.sh {VERSION}
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a ZIP file that you can install in WordPress or distribute to users.
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
By following this customization guide, you can transform the plugin starter template into a fully functional plugin that meets your specific needs. Remember to maintain the same level of code quality and documentation as you customize the template.
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
# Error Checking and Feedback Loops
|
||||||
|
|
||||||
|
This document explains how to check for code quality issues and get feedback from automated tools in our development workflow.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
* [Overview](#overview)
|
||||||
|
* [Local Error Checking](#local-error-checking)
|
||||||
|
* [CI/CD Feedback Loops](#cicd-feedback-loops)
|
||||||
|
* [Common Issues and Solutions](#common-issues-and-solutions)
|
||||||
|
* [Improving Code Quality](#improving-code-quality)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Our development process includes multiple layers of error checking and feedback loops to ensure high code quality:
|
||||||
|
|
||||||
|
1. **Local Development**: Run linters and tests locally before committing
|
||||||
|
2. **Pull Request**: Automated checks run when you create or update a PR
|
||||||
|
3. **Code Review**: Human reviewers provide feedback on your code
|
||||||
|
4. **Continuous Integration**: Tests run in various environments to ensure compatibility
|
||||||
|
|
||||||
|
## Local Error Checking
|
||||||
|
|
||||||
|
### PHP Code Quality Checks
|
||||||
|
|
||||||
|
Run these commands locally to check for PHP code quality issues:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all PHP code quality checks
|
||||||
|
npm run lint:php
|
||||||
|
|
||||||
|
# Run specific checks
|
||||||
|
npm run lint:phpcs # PHP CodeSniffer
|
||||||
|
npm run lint:phpstan # PHPStan static analysis
|
||||||
|
npm run lint:phpmd # PHP Mess Detector
|
||||||
|
```
|
||||||
|
|
||||||
|
### JavaScript/CSS Checks
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run ESLint for JavaScript files
|
||||||
|
npm run lint:js
|
||||||
|
|
||||||
|
# Run stylelint for CSS files
|
||||||
|
npm run lint:css
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Tests Locally
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run Cypress tests for single site
|
||||||
|
npm run test:playground:single
|
||||||
|
|
||||||
|
# Run Cypress tests for multisite
|
||||||
|
npm run test:playground:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
## CI/CD Feedback Loops
|
||||||
|
|
||||||
|
When you push code or create a pull request, several automated checks run:
|
||||||
|
|
||||||
|
### GitHub Actions Workflows
|
||||||
|
|
||||||
|
* **Code Quality**: Runs PHP CodeSniffer, PHPStan, and PHP Mess Detector
|
||||||
|
* **WordPress Tests**: Runs tests in WordPress environments
|
||||||
|
* **WordPress Playground Tests**: Runs tests in WordPress Playground environments
|
||||||
|
* **Tests - Run PHP compatibility and unit tests**: Checks compatibility with different PHP versions
|
||||||
|
|
||||||
|
### Third-Party Code Quality Services
|
||||||
|
|
||||||
|
* **CodeFactor**: Provides automated code reviews and quality grades
|
||||||
|
* **Codacy**: Analyzes code quality and security issues
|
||||||
|
* **SonarCloud**: Detects bugs, vulnerabilities, and code smells
|
||||||
|
|
||||||
|
## Common Issues and Solutions
|
||||||
|
|
||||||
|
### PHP CodeSniffer Issues
|
||||||
|
|
||||||
|
* **Indentation**: Use tabs for indentation in PHP files
|
||||||
|
* **Spacing**: Add spaces after commas, around operators, and after control structures
|
||||||
|
* **Naming Conventions**: Use snake_case for functions and variables in PHP
|
||||||
|
* **DocBlocks**: Add proper documentation for functions and classes
|
||||||
|
|
||||||
|
### PHPStan Issues
|
||||||
|
|
||||||
|
* **Undefined Variables**: Ensure all variables are defined before use
|
||||||
|
* **Type Errors**: Use proper type hints and return types
|
||||||
|
* **Null Checks**: Add null checks for variables that might be null
|
||||||
|
|
||||||
|
### JavaScript/CSS Issues
|
||||||
|
|
||||||
|
* **ESLint Errors**: Follow JavaScript best practices
|
||||||
|
* **Stylelint Errors**: Follow CSS best practices
|
||||||
|
* **Accessibility Issues**: Ensure UI elements are accessible
|
||||||
|
|
||||||
|
## Improving Code Quality
|
||||||
|
|
||||||
|
### Best Practices
|
||||||
|
|
||||||
|
* **Write Tests First**: Use test-driven development (TDD) when possible
|
||||||
|
* **Small PRs**: Keep pull requests small and focused on a single issue
|
||||||
|
* **Regular Commits**: Commit frequently with clear messages
|
||||||
|
* **Code Reviews**: Request code reviews from team members
|
||||||
|
* **Documentation**: Keep documentation up-to-date
|
||||||
|
|
||||||
|
### Using AI Assistants
|
||||||
|
|
||||||
|
AI assistants can help you understand and fix code quality issues:
|
||||||
|
|
||||||
|
1. Copy the error message or feedback
|
||||||
|
2. Paste it into your AI assistant chat
|
||||||
|
3. Ask for help understanding and fixing the issue
|
||||||
|
4. Apply the suggested fixes
|
||||||
|
5. Run the checks again to verify the issue is resolved
|
||||||
|
|
||||||
|
### Continuous Learning
|
||||||
|
|
||||||
|
* Review the code quality reports regularly
|
||||||
|
* Learn from feedback and improve your coding practices
|
||||||
|
* Stay updated on best practices for WordPress development
|
||||||
|
|
||||||
|
## Related Documentation
|
||||||
|
|
||||||
|
* [Testing Framework](Testing.md)
|
||||||
|
* [Code Review Guide](../.ai-workflows/code-review.md)
|
||||||
|
* [Architecture Overview](Architecture-Overview.md)
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
# Extending the Plugin
|
||||||
|
|
||||||
|
This guide explains how to extend the plugin's functionality through various extension points.
|
||||||
|
|
||||||
|
## Extension Points
|
||||||
|
|
||||||
|
The plugin is designed with extensibility in mind, providing several ways to extend or modify its functionality:
|
||||||
|
|
||||||
|
1. **Action Hooks**: Add custom functionality at specific points
|
||||||
|
2. **Filter Hooks**: Modify data or behavior
|
||||||
|
3. **Class Extension**: Extend existing classes to add or modify functionality
|
||||||
|
4. **Template Overrides**: Customize the plugin's output
|
||||||
|
|
||||||
|
## Using Action Hooks
|
||||||
|
|
||||||
|
Action hooks allow you to add custom functionality at specific points in the plugin's execution. Here are some examples:
|
||||||
|
|
||||||
|
### Available Actions
|
||||||
|
|
||||||
|
- `wpst_plugin_init`: Fires when the plugin is initialized
|
||||||
|
- `wpst_before_process`: Fires before the plugin processes data
|
||||||
|
- `wpst_after_process`: Fires after the plugin processes data
|
||||||
|
- `wpst_admin_init`: Fires when the admin functionality is initialized
|
||||||
|
|
||||||
|
### Example: Adding Custom Functionality
|
||||||
|
|
||||||
|
```php
|
||||||
|
add_action('wpst_plugin_init', 'my_custom_init_function');
|
||||||
|
|
||||||
|
function my_custom_init_function() {
|
||||||
|
// Your custom initialization code here
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example: Adding Custom Admin Functionality
|
||||||
|
|
||||||
|
```php
|
||||||
|
add_action('wpst_admin_init', 'my_custom_admin_function');
|
||||||
|
|
||||||
|
function my_custom_admin_function() {
|
||||||
|
// Your custom admin initialization code here
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using Filter Hooks
|
||||||
|
|
||||||
|
Filter hooks allow you to modify data or behavior at specific points. Here are some examples:
|
||||||
|
|
||||||
|
### Available Filters
|
||||||
|
|
||||||
|
- `wpst_settings`: Filter the plugin settings
|
||||||
|
- `wpst_process_data`: Filter the data being processed
|
||||||
|
- `wpst_admin_tabs`: Filter the admin tabs
|
||||||
|
- `wpst_display_output`: Filter the output before display
|
||||||
|
|
||||||
|
### Example: Modifying Settings
|
||||||
|
|
||||||
|
```php
|
||||||
|
add_filter('wpst_settings', 'my_custom_settings_filter');
|
||||||
|
|
||||||
|
function my_custom_settings_filter($settings) {
|
||||||
|
// Modify the settings array
|
||||||
|
$settings['custom_option'] = 'custom_value';
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example: Modifying Output
|
||||||
|
|
||||||
|
```php
|
||||||
|
add_filter('wpst_display_output', 'my_custom_output_filter');
|
||||||
|
|
||||||
|
function my_custom_output_filter($output) {
|
||||||
|
// Modify the output
|
||||||
|
$output = str_replace('original', 'modified', $output);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Extending Classes
|
||||||
|
|
||||||
|
You can extend the plugin's classes to add or modify functionality.
|
||||||
|
|
||||||
|
### Example: Extending the Core Class
|
||||||
|
|
||||||
|
```php
|
||||||
|
use WPALLSTARS\PluginStarterTemplate\Core;
|
||||||
|
|
||||||
|
class My_Extended_Core extends Core {
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
// Add your custom initialization here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override an existing method
|
||||||
|
public function filter_content($content) {
|
||||||
|
// Modify the content
|
||||||
|
$content = parent::filter_content($content);
|
||||||
|
$content = str_replace('original', 'modified', $content);
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a new method
|
||||||
|
public function custom_method() {
|
||||||
|
// Your custom method implementation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example: Extending the Admin Class
|
||||||
|
|
||||||
|
```php
|
||||||
|
use WPALLSTARS\PluginStarterTemplate\Admin\Admin;
|
||||||
|
|
||||||
|
class My_Extended_Admin extends Admin {
|
||||||
|
public function __construct($core) {
|
||||||
|
parent::__construct($core);
|
||||||
|
// Add your custom initialization here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override an existing method
|
||||||
|
public function enqueue_admin_assets($hook) {
|
||||||
|
parent::enqueue_admin_assets($hook);
|
||||||
|
// Add your custom assets
|
||||||
|
wp_enqueue_script(
|
||||||
|
'my-custom-script',
|
||||||
|
plugin_dir_url(__FILE__) . 'js/custom-script.js',
|
||||||
|
['jquery'],
|
||||||
|
'1.0.0',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a new method
|
||||||
|
public function custom_admin_method() {
|
||||||
|
// Your custom method implementation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating Add-ons
|
||||||
|
|
||||||
|
You can create separate add-on plugins that extend the functionality of the main plugin.
|
||||||
|
|
||||||
|
### Example: Basic Add-on Structure
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin Name: My Awesome Add-on
|
||||||
|
* Description: Extends the WordPress Plugin Starter Template with awesome features
|
||||||
|
* Version: 1.0.0
|
||||||
|
* Author: Your Name
|
||||||
|
* License: GPL-2.0+
|
||||||
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
|
* Text Domain: my-awesome-addon
|
||||||
|
* Requires: WordPress Plugin Starter Template
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Check if the main plugin is active
|
||||||
|
if (!class_exists('WPALLSTARS\\PluginStarterTemplate\\Plugin')) {
|
||||||
|
add_action('admin_notices', 'my_addon_missing_main_plugin_notice');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function my_addon_missing_main_plugin_notice() {
|
||||||
|
echo '<div class="error"><p>';
|
||||||
|
echo __('My Awesome Add-on requires the WordPress Plugin Starter Template to be installed and activated.', 'my-awesome-addon');
|
||||||
|
echo '</p></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the add-on
|
||||||
|
add_action('wpst_plugin_init', 'initialize_my_addon');
|
||||||
|
|
||||||
|
function initialize_my_addon() {
|
||||||
|
// Your add-on initialization code here
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Best Practices for Extensions
|
||||||
|
|
||||||
|
1. **Use Namespaces**: Use PHP namespaces to avoid conflicts with other plugins
|
||||||
|
2. **Follow Coding Standards**: Maintain the same coding standards as the main plugin
|
||||||
|
3. **Document Your Extensions**: Provide clear documentation for your extensions
|
||||||
|
4. **Test Thoroughly**: Test your extensions with different WordPress versions
|
||||||
|
5. **Version Compatibility**: Specify which versions of the main plugin your extension is compatible with
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
By using these extension points, you can customize and extend the plugin's functionality to meet your specific needs without modifying the core plugin files. This approach ensures that your customizations will continue to work even when the main plugin is updated.
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
# 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 `AGENTS.md` file
|
||||||
|
2. Workflow guidelines in the `.agents/` 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 `.agents/` 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).
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# WordPress Plugin Starter Template
|
||||||
|
|
||||||
|
Welcome to the documentation wiki for the WordPress Plugin Starter Template.
|
||||||
|
|
||||||
|
This template provides a solid foundation for developing WordPress plugins with best practices for AI-assisted development.
|
||||||
|
|
||||||
|
## Latest Updates
|
||||||
|
|
||||||
|
- Version 0.1.6: Fixed GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
- Version 0.1.5: Added testing setup with wp-env and Cypress, multisite compatibility
|
||||||
|
|
||||||
|
## Quick Links
|
||||||
|
|
||||||
|
- [Starter Prompt](Starter-Prompt)
|
||||||
|
- [Installation Guide](Installation-Guide)
|
||||||
|
- [Usage Instructions](Usage-Instructions)
|
||||||
|
- [Frequently Asked Questions](Frequently-Asked-Questions)
|
||||||
|
- [Contributing](Contributing)
|
||||||
|
- [Changelog](Changelog)
|
||||||
|
|
||||||
|
## About This Template
|
||||||
|
|
||||||
|
The WordPress Plugin Starter Template is designed to help developers quickly create new WordPress plugins with a solid foundation of best practices. It incorporates modern coding standards, comprehensive documentation, and AI-assisted development workflows.
|
||||||
|
|
||||||
|
This template is based on the experience gained from developing the "Fix 'Plugin file does not exist' Notices" plugin and other successful WordPress plugins.
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
|
||||||
|
- **Object-Oriented Architecture**: Well-structured, maintainable code using OOP principles
|
||||||
|
- **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts
|
||||||
|
- **Comprehensive Documentation**: Detailed documentation for both users and developers
|
||||||
|
- **Testing Framework**: PHPUnit setup for unit testing
|
||||||
|
- **Internationalization Ready**: Full support for translation and localization
|
||||||
|
- **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates
|
||||||
|
- **AI Workflow Documentation**: Detailed guides for AI-assisted development
|
||||||
|
- **Wiki Documentation**: Ready-to-use wiki structure for comprehensive documentation
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
To get started with this template, check out the [Starter Prompt](Starter-Prompt) for a comprehensive guide on customizing the template for your specific plugin needs.
|
||||||
|
|
||||||
|
**Important**: For the best AI assistance, add the AGENTS.md file and .agents/ directory to your AI IDE chat context. In most AI IDEs, you can pin these files to ensure they're considered in each message.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
If you encounter any issues or have questions about the template, please check the [Frequently Asked Questions](Frequently-Asked-Questions) section. If you still need help, you can [open an issue](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) on GitHub.
|
||||||
@@ -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.
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
# Multisite Development
|
||||||
|
|
||||||
|
This guide explains how to extend the WordPress Plugin Starter Template for multisite environments.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
WordPress Multisite allows you to run multiple WordPress sites from a single installation.
|
||||||
|
|
||||||
|
The plugin template includes a basic structure for multisite-specific functionality.
|
||||||
|
|
||||||
|
You can extend this to add features for multisite environments.
|
||||||
|
|
||||||
|
## Directory Structure
|
||||||
|
|
||||||
|
The plugin includes a dedicated directory for multisite-specific functionality:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
includes/
|
||||||
|
└── Multisite/
|
||||||
|
├── class-multisite.php # Base class for multisite functionality
|
||||||
|
└── README.md # Documentation for multisite development
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### 1. Understand the Base Class
|
||||||
|
|
||||||
|
The `Multisite` class in `includes/Multisite/class-multisite.php` provides a foundation for multisite functionality.
|
||||||
|
|
||||||
|
It includes:
|
||||||
|
|
||||||
|
* A constructor for initialization
|
||||||
|
* Example methods for multisite functionality
|
||||||
|
|
||||||
|
### 2. Load Multisite Classes
|
||||||
|
|
||||||
|
To use multisite-specific functionality, you need to load and initialize the classes in your main plugin file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Load multisite support classes if in multisite environment
|
||||||
|
if ( is_multisite() ) {
|
||||||
|
require_once WP_PLUGIN_STARTER_TEMPLATE_PATH . 'includes/Multisite/class-multisite.php';
|
||||||
|
|
||||||
|
// Initialize multisite support
|
||||||
|
$multisite = new WPALLSTARS\PluginStarterTemplate\Multisite\Multisite();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Extend the Base Class
|
||||||
|
|
||||||
|
You can extend the base `Multisite` class or create additional classes in the `Multisite` directory.
|
||||||
|
|
||||||
|
This allows you to implement specific features:
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate\Multisite;
|
||||||
|
|
||||||
|
class Domain_Mapping extends Multisite {
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
// Add hooks for domain mapping functionality
|
||||||
|
add_action( 'init', array( $this, 'register_domain_mapping' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register_domain_mapping() {
|
||||||
|
// Implement domain mapping functionality
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Multisite Features
|
||||||
|
|
||||||
|
Here are some common features you might want to implement for multisite environments:
|
||||||
|
|
||||||
|
### Network Admin Pages
|
||||||
|
|
||||||
|
To add pages to the network admin menu:
|
||||||
|
|
||||||
|
```php
|
||||||
|
add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) );
|
||||||
|
|
||||||
|
public function add_network_menu() {
|
||||||
|
add_submenu_page(
|
||||||
|
'settings.php',
|
||||||
|
__( 'Plugin Settings', 'your-text-domain' ),
|
||||||
|
__( 'Plugin Settings', 'your-text-domain' ),
|
||||||
|
'manage_network_options',
|
||||||
|
'your-plugin-slug',
|
||||||
|
array( $this, 'render_network_settings' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Site Creation Hooks
|
||||||
|
|
||||||
|
To perform actions when a new site is created:
|
||||||
|
|
||||||
|
```php
|
||||||
|
add_action( 'wp_initialize_site', array( $this, 'on_site_creation' ), 10, 2 );
|
||||||
|
|
||||||
|
public function on_site_creation( $new_site, $args ) {
|
||||||
|
// Get the blog ID
|
||||||
|
$blog_id = $new_site->blog_id;
|
||||||
|
|
||||||
|
// Switch to the new blog
|
||||||
|
switch_to_blog( $blog_id );
|
||||||
|
|
||||||
|
// Perform site-specific setup
|
||||||
|
update_option( 'your_plugin_option', 'default_value' );
|
||||||
|
|
||||||
|
// Restore the current blog
|
||||||
|
restore_current_blog();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Network Settings
|
||||||
|
|
||||||
|
To save network-wide settings:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Process network settings form
|
||||||
|
add_action( 'network_admin_edit_your_plugin_action', array( $this, 'save_network_settings' ) );
|
||||||
|
|
||||||
|
public function save_network_settings() {
|
||||||
|
// Check nonce
|
||||||
|
check_admin_referer( 'your_plugin_nonce' );
|
||||||
|
|
||||||
|
// Save settings
|
||||||
|
update_site_option( 'your_plugin_network_option', sanitize_text_field( $_POST['your_option'] ) );
|
||||||
|
|
||||||
|
// Redirect back to settings page
|
||||||
|
wp_redirect( add_query_arg( array(
|
||||||
|
'page' => 'your-plugin-slug',
|
||||||
|
'updated' => 'true'
|
||||||
|
), network_admin_url( 'settings.php' ) ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing Multisite Functionality
|
||||||
|
|
||||||
|
To test your multisite functionality, use the testing framework included in the plugin template:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Set up multisite environment
|
||||||
|
npm run setup:multisite
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
npm run test:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
For more details on testing, see the [Testing Framework](Testing-Framework.md) documentation.
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
1. **Always Check for Multisite**: Use `is_multisite()` to check if the current installation is a multisite network.
|
||||||
|
|
||||||
|
2. **Use Network-Specific Functions**: WordPress provides specific functions for multisite.
|
||||||
|
Use `update_site_option()` instead of `update_option()` for network-wide settings.
|
||||||
|
|
||||||
|
3. **Handle Blog Switching Properly**: When working with specific sites, use `switch_to_blog()`.
|
||||||
|
Always call `restore_current_blog()` when done.
|
||||||
|
|
||||||
|
4. **Respect Network Admin Capabilities**: Use capabilities like `manage_network_options` for network admin.
|
||||||
|
|
||||||
|
5. **Test in Both Environments**: Test in both single site and multisite to ensure compatibility.
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
By following this guide, you can extend the WordPress Plugin Starter Template.
|
||||||
|
|
||||||
|
The included structure provides a solid foundation for multisite features.
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
# WordPress Playground Testing
|
||||||
|
|
||||||
|
This document explains how to use WordPress Playground for testing our plugin.
|
||||||
|
|
||||||
|
## What is WordPress Playground?
|
||||||
|
|
||||||
|
[WordPress Playground](https://wordpress.org/playground/) is a project that runs WordPress entirely in the browser.
|
||||||
|
|
||||||
|
It uses WebAssembly, which means:
|
||||||
|
|
||||||
|
* No server required - WordPress runs in the browser
|
||||||
|
* Fast startup times
|
||||||
|
* Isolated testing environment
|
||||||
|
* Works well with CI/CD pipelines
|
||||||
|
|
||||||
|
## Using WordPress Playground Online
|
||||||
|
|
||||||
|
The easiest way to test our plugin with WordPress Playground is to use the online version:
|
||||||
|
|
||||||
|
1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=2)
|
||||||
|
|
||||||
|
2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=2)
|
||||||
|
|
||||||
|
These links automatically set up WordPress with multisite enabled and WP_DEBUG enabled.
|
||||||
|
|
||||||
|
Both the Plugin Toggle and Kadence Blocks plugins are pre-activated.
|
||||||
|
|
||||||
|
## WP-CLI Commands for WordPress Playground
|
||||||
|
|
||||||
|
WordPress Playground supports WP-CLI commands for programmatic interaction.
|
||||||
|
|
||||||
|
Here are some useful commands for testing:
|
||||||
|
|
||||||
|
### General Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Get WordPress version
|
||||||
|
wp core version
|
||||||
|
|
||||||
|
# List installed plugins
|
||||||
|
wp plugin list
|
||||||
|
|
||||||
|
# Install a plugin
|
||||||
|
wp plugin install plugin-slug
|
||||||
|
|
||||||
|
# Activate a plugin
|
||||||
|
wp plugin activate plugin-slug
|
||||||
|
|
||||||
|
# Deactivate a plugin
|
||||||
|
wp plugin deactivate plugin-slug
|
||||||
|
|
||||||
|
# Get plugin status
|
||||||
|
wp plugin status plugin-slug
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multisite Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List all sites in the network
|
||||||
|
wp site list
|
||||||
|
|
||||||
|
# Create a new site
|
||||||
|
wp site create --slug=testsite
|
||||||
|
|
||||||
|
# Delete a site
|
||||||
|
wp site delete 2
|
||||||
|
|
||||||
|
# Network activate a plugin
|
||||||
|
wp plugin activate plugin-slug --network
|
||||||
|
|
||||||
|
# Activate a plugin for a specific site
|
||||||
|
wp plugin activate plugin-slug --url=example.com/testsite
|
||||||
|
|
||||||
|
# Create a new user and add them to a site
|
||||||
|
wp user create testuser test@example.com --role=editor
|
||||||
|
wp user add-role testuser editor --url=example.com/testsite
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run a specific test
|
||||||
|
wp scaffold plugin-tests my-plugin
|
||||||
|
wp test run --filter=test_function_name
|
||||||
|
|
||||||
|
# Check for PHP errors
|
||||||
|
wp site health check
|
||||||
|
|
||||||
|
# Export/import content for testing
|
||||||
|
wp export
|
||||||
|
wp import
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Activation in Multisite
|
||||||
|
|
||||||
|
In a WordPress multisite environment, there are two ways to activate plugins:
|
||||||
|
|
||||||
|
1. **Network Activation**: Activates a plugin for all sites in the network
|
||||||
|
* In the WordPress admin, go to Network Admin > Plugins
|
||||||
|
* Click "Network Activate" under the plugin
|
||||||
|
* Or use WP-CLI: `wp plugin install plugin-name --activate-network`
|
||||||
|
|
||||||
|
2. **Per-Site Activation**: Activates a plugin for a specific site
|
||||||
|
* In the WordPress admin, go to the specific site's admin area
|
||||||
|
* Go to Plugins and activate the plugin for that site only
|
||||||
|
* Or use WP-CLI: `wp plugin activate plugin-name --url=site-url`
|
||||||
|
|
||||||
|
Our multisite blueprint uses network activation for the Plugin Toggle plugin as an example.
|
||||||
|
|
||||||
|
## Running Tests with WordPress Playground
|
||||||
|
|
||||||
|
We have two blueprints for testing:
|
||||||
|
|
||||||
|
1. `playground/blueprint.json` - For single site testing
|
||||||
|
2. `playground/multisite-blueprint.json` - For multisite testing
|
||||||
|
|
||||||
|
To run tests with WordPress Playground:
|
||||||
|
|
||||||
|
1. Open the appropriate WordPress Playground link:
|
||||||
|
* [Single site](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=2)
|
||||||
|
* [Multisite](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=2)
|
||||||
|
|
||||||
|
2. Test the plugin manually in the browser
|
||||||
|
|
||||||
|
## Local Testing with HTML Files
|
||||||
|
|
||||||
|
We've also included HTML files that embed WordPress Playground:
|
||||||
|
|
||||||
|
1. Open `playground/index.html` in your browser for single site testing
|
||||||
|
2. Open `playground/multisite.html` in your browser for multisite testing
|
||||||
|
3. Open `playground/test.html` in your browser for a unified interface with buttons to switch between single site and multisite
|
||||||
|
|
||||||
|
You can serve these files locally with a simple HTTP server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using Python
|
||||||
|
python -m http.server 8888 --directory playground
|
||||||
|
|
||||||
|
# Then open http://localhost:8888/index.html in your browser
|
||||||
|
# Or open http://localhost:8888/multisite.html for multisite testing
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using wp-now
|
||||||
|
|
||||||
|
Alternatively, you can use [wp-now](https://github.com/WordPress/playground-tools/tree/trunk/packages/wp-now).
|
||||||
|
|
||||||
|
This tool from the WordPress Playground team makes it easy to run WordPress locally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install wp-now globally
|
||||||
|
npm install -g @wp-playground/wp-now
|
||||||
|
|
||||||
|
# Start a WordPress instance with the current plugin
|
||||||
|
wp-now start
|
||||||
|
|
||||||
|
# Start with multisite enabled
|
||||||
|
wp-now start --multisite
|
||||||
|
|
||||||
|
# Start with specific PHP and WordPress versions
|
||||||
|
wp-now start --php 8.0 --wp 6.2
|
||||||
|
|
||||||
|
# Start with WP_DEBUG enabled
|
||||||
|
wp-now start --wp-debug
|
||||||
|
```
|
||||||
|
|
||||||
|
This will start a local WordPress instance with your plugin installed and activated.
|
||||||
|
|
||||||
|
## Customizing Blueprints
|
||||||
|
|
||||||
|
You can customize the blueprints to suit your testing needs.
|
||||||
|
|
||||||
|
See the [WordPress Playground Blueprints documentation](https://wordpress.github.io/wordpress-playground/blueprints/) for details.
|
||||||
|
|
||||||
|
## WordPress Playground JavaScript API
|
||||||
|
|
||||||
|
WordPress Playground provides a JavaScript API for programmatic interaction with WordPress.
|
||||||
|
|
||||||
|
This is useful for automated testing and CI/CD integration.
|
||||||
|
|
||||||
|
### Basic Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Import the WordPress Playground client
|
||||||
|
import { createWordPressPlayground } from '@wp-playground/client';
|
||||||
|
|
||||||
|
// Create a playground instance
|
||||||
|
const playground = await createWordPressPlayground({
|
||||||
|
iframe: document.getElementById('wp-playground'),
|
||||||
|
remoteUrl: 'https://playground.wordpress.net/remote.html',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run a blueprint
|
||||||
|
await playground.run({
|
||||||
|
steps: [
|
||||||
|
{ step: 'enableMultisite' },
|
||||||
|
{ step: 'wp-cli', command: 'wp site create --slug=testsite' },
|
||||||
|
{ step: 'wp-cli', command: 'wp plugin install plugin-toggle kadence-blocks --activate-network' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run WP-CLI commands
|
||||||
|
const result = await playground.run({
|
||||||
|
step: 'wp-cli',
|
||||||
|
command: 'wp plugin list --format=json'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Parse the JSON output
|
||||||
|
const plugins = JSON.parse(result.output);
|
||||||
|
console.log(plugins);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automated Testing
|
||||||
|
|
||||||
|
You can use the JavaScript API with testing frameworks like Jest or Cypress:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
describe('Plugin Tests', () => {
|
||||||
|
let playground;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
playground = await createWordPressPlayground({
|
||||||
|
iframe: document.getElementById('wp-playground'),
|
||||||
|
remoteUrl: 'https://playground.wordpress.net/remote.html',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set up WordPress with our blueprint
|
||||||
|
await playground.run({
|
||||||
|
steps: [
|
||||||
|
{ step: 'enableMultisite' },
|
||||||
|
{ step: 'wp-cli', command: 'wp site create --slug=testsite' },
|
||||||
|
{ step: 'wp-cli', command: 'wp plugin install plugin-toggle kadence-blocks --activate-network' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Plugin is activated', async () => {
|
||||||
|
const result = await playground.run({
|
||||||
|
step: 'wp-cli',
|
||||||
|
command: 'wp plugin list --format=json'
|
||||||
|
});
|
||||||
|
|
||||||
|
const plugins = JSON.parse(result.output);
|
||||||
|
const pluginToggle = plugins.find(plugin => plugin.name === 'plugin-toggle');
|
||||||
|
expect(pluginToggle.status).toBe('active');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## CI/CD Integration
|
||||||
|
|
||||||
|
We have a GitHub Actions workflow that uses WordPress Playground for testing.
|
||||||
|
|
||||||
|
See `.github/workflows/playground-tests.yml` for details.
|
||||||
|
|
||||||
|
### Example GitHub Actions Workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
playground-test:
|
||||||
|
name: WordPress Playground Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Install WordPress Playground CLI
|
||||||
|
run: npm install -g @wordpress/playground-tools
|
||||||
|
|
||||||
|
- name: Create plugin zip
|
||||||
|
run: |
|
||||||
|
mkdir -p dist
|
||||||
|
zip -r dist/plugin.zip . -x "node_modules/*" "dist/*" ".git/*"
|
||||||
|
|
||||||
|
- name: Run tests with WordPress Playground
|
||||||
|
run: |
|
||||||
|
# Start WordPress Playground with our blueprint
|
||||||
|
wp-playground start --blueprint playground/blueprint.json --port 8888 &
|
||||||
|
|
||||||
|
# Wait for WordPress Playground to be ready
|
||||||
|
echo "Waiting for WordPress Playground to be ready..."
|
||||||
|
timeout 60 bash -c 'until curl -s http://localhost:8888; do sleep 2; done'
|
||||||
|
|
||||||
|
# Run Cypress tests against WordPress Playground
|
||||||
|
npm run test:single:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
## Performance Testing
|
||||||
|
|
||||||
|
We also use [WP Performance Tests GitHub Action](https://github.com/marketplace/actions/wp-performance-tests).
|
||||||
|
|
||||||
|
This action tests our plugin against various WordPress and PHP versions to ensure good performance.
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
# Release Process
|
||||||
|
|
||||||
|
This document outlines the process for creating and publishing new releases of the plugin.
|
||||||
|
|
||||||
|
## Version Numbering
|
||||||
|
|
||||||
|
This plugin follows [Semantic Versioning](https://semver.org/) (SemVer):
|
||||||
|
|
||||||
|
- **MAJOR version** (x.0.0): Incompatible API changes
|
||||||
|
- **MINOR version** (0.x.0): Add functionality in a backward-compatible manner
|
||||||
|
- **PATCH version** (0.0.x): Backward-compatible bug fixes
|
||||||
|
|
||||||
|
## Pre-Release Checklist
|
||||||
|
|
||||||
|
Before creating a new release, complete the following checklist:
|
||||||
|
|
||||||
|
1. **Code Review**: Ensure all code has been reviewed and approved
|
||||||
|
2. **Testing**: Verify that all tests pass
|
||||||
|
- Unit tests
|
||||||
|
- End-to-end tests
|
||||||
|
- Manual testing in different environments
|
||||||
|
3. **Documentation**: Update all relevant documentation
|
||||||
|
- README.md
|
||||||
|
- readme.txt
|
||||||
|
- Wiki pages
|
||||||
|
- Code comments
|
||||||
|
4. **Changelog**: Update CHANGELOG.md with all changes since the last release
|
||||||
|
5. **Version Numbers**: Update version numbers in:
|
||||||
|
- Main plugin file header
|
||||||
|
- Plugin initialization
|
||||||
|
- readme.txt
|
||||||
|
- package.json (if applicable)
|
||||||
|
- composer.json (if applicable)
|
||||||
|
|
||||||
|
## Creating a Release
|
||||||
|
|
||||||
|
### Manual Release Process
|
||||||
|
|
||||||
|
1. **Create a Release Branch**:
|
||||||
|
```bash
|
||||||
|
git checkout -b release/x.y.z
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Update Version Numbers**:
|
||||||
|
- Update the version number in the main plugin file header
|
||||||
|
- Update the version number in the plugin initialization
|
||||||
|
- Update the "Stable tag" in readme.txt
|
||||||
|
- Update the version in package.json and composer.json (if applicable)
|
||||||
|
|
||||||
|
3. **Update Changelog**:
|
||||||
|
- Add a new section to CHANGELOG.md for the new version
|
||||||
|
- Add a new section to the Changelog in readme.txt
|
||||||
|
- Add a new section to the Upgrade Notice in readme.txt
|
||||||
|
|
||||||
|
4. **Commit Changes**:
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Bump version to x.y.z"
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Create a Pull Request**:
|
||||||
|
- Push the release branch to GitHub
|
||||||
|
- Create a pull request against the main branch
|
||||||
|
- Have the pull request reviewed and approved
|
||||||
|
|
||||||
|
6. **Merge the Pull Request**:
|
||||||
|
- Merge the pull request into the main branch
|
||||||
|
|
||||||
|
7. **Create a Release Tag**:
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull
|
||||||
|
git tag -a vx.y.z -m "Version x.y.z"
|
||||||
|
git push origin vx.y.z
|
||||||
|
```
|
||||||
|
|
||||||
|
8. **Create a GitHub Release**:
|
||||||
|
- Go to the GitHub repository
|
||||||
|
- Click on "Releases"
|
||||||
|
- Click "Draft a new release"
|
||||||
|
- Select the tag you just created
|
||||||
|
- Add a title and description
|
||||||
|
- Upload the built plugin ZIP file
|
||||||
|
- Publish the release
|
||||||
|
|
||||||
|
### Automated Release Process
|
||||||
|
|
||||||
|
This plugin uses GitHub Actions to automate the release process:
|
||||||
|
|
||||||
|
1. **Create a Release Branch**:
|
||||||
|
```bash
|
||||||
|
git checkout -b release/x.y.z
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Update Version Numbers and Changelog** (as described above)
|
||||||
|
|
||||||
|
3. **Commit Changes**:
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Bump version to x.y.z"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Create a Pull Request** (as described above)
|
||||||
|
|
||||||
|
5. **Merge the Pull Request** (as described above)
|
||||||
|
|
||||||
|
6. **Create a Release Tag**:
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull
|
||||||
|
git tag -a vx.y.z -m "Version x.y.z"
|
||||||
|
git push origin vx.y.z
|
||||||
|
```
|
||||||
|
|
||||||
|
7. **Automated GitHub Release**:
|
||||||
|
- The GitHub Actions workflow will automatically:
|
||||||
|
- Build the plugin
|
||||||
|
- Create a GitHub release
|
||||||
|
- Upload the built plugin ZIP file
|
||||||
|
- Update the wiki (if configured)
|
||||||
|
|
||||||
|
## Post-Release Tasks
|
||||||
|
|
||||||
|
After creating a release, complete the following tasks:
|
||||||
|
|
||||||
|
1. **Verify the Release**:
|
||||||
|
- Check that the GitHub release was created successfully
|
||||||
|
- Download the ZIP file and verify its contents
|
||||||
|
- Test the plugin by installing it from the ZIP file
|
||||||
|
|
||||||
|
2. **Update Documentation**:
|
||||||
|
- Update any external documentation that references the plugin version
|
||||||
|
- Update the plugin's website (if applicable)
|
||||||
|
|
||||||
|
3. **Announce the Release**:
|
||||||
|
- Announce the release on relevant channels (blog, social media, etc.)
|
||||||
|
- Notify users who have reported issues that are fixed in this release
|
||||||
|
|
||||||
|
4. **Start Planning the Next Release**:
|
||||||
|
- Create issues for the next release
|
||||||
|
- Update the project roadmap
|
||||||
|
|
||||||
|
## Hotfix Process
|
||||||
|
|
||||||
|
For critical bugs that need to be fixed immediately:
|
||||||
|
|
||||||
|
1. **Create a Hotfix Branch**:
|
||||||
|
```bash
|
||||||
|
git checkout -b hotfix/x.y.z
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Fix the Bug**:
|
||||||
|
- Make the necessary changes to fix the bug
|
||||||
|
- Add tests to prevent regression
|
||||||
|
|
||||||
|
3. **Update Version Numbers and Changelog** (as described above)
|
||||||
|
|
||||||
|
4. **Commit Changes**:
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "Hotfix: description of the fix"
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Create a Pull Request** (as described above)
|
||||||
|
|
||||||
|
6. **Merge the Pull Request** (as described above)
|
||||||
|
|
||||||
|
7. **Create a Release Tag and GitHub Release** (as described above)
|
||||||
|
|
||||||
|
## Release Branches
|
||||||
|
|
||||||
|
This plugin uses the following branch strategy:
|
||||||
|
|
||||||
|
- **main**: The main development branch
|
||||||
|
- **release/x.y.z**: Temporary branches for preparing releases
|
||||||
|
- **hotfix/x.y.z**: Temporary branches for hotfixes
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
Following this release process ensures that releases are consistent, well-documented, and properly tested. It also helps users understand what has changed between versions and how to upgrade safely.
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
# WordPress Plugin Starter Template - AI Assistant Prompt
|
||||||
|
|
||||||
|
This document provides a comprehensive prompt to help you get started with creating your own WordPress plugin using this starter template with the assistance of AI tools like GitHub Copilot, Claude, or ChatGPT.
|
||||||
|
|
||||||
|
## Important: Optimize AI Context
|
||||||
|
|
||||||
|
**Before starting, add the AGENTS.md file and .agents/ directory to your AI IDE chat context.** In most AI IDEs, you can pin these files to ensure they're considered in each message. This will help the AI understand the project structure and follow the established best practices.
|
||||||
|
|
||||||
|
## Initial Setup Prompt
|
||||||
|
|
||||||
|
Use the following prompt to guide the AI assistant in helping you set up your new plugin based on this template:
|
||||||
|
|
||||||
|
```
|
||||||
|
I'm creating a new WordPress plugin based on the wp-plugin-starter-template-for-ai-coding template. Please help me customize this template for my specific plugin needs.
|
||||||
|
|
||||||
|
Here are the details for my new plugin:
|
||||||
|
|
||||||
|
- Plugin Name: [YOUR PLUGIN NAME]
|
||||||
|
- Plugin Slug: [YOUR-PLUGIN-SLUG]
|
||||||
|
- Text Domain: [your-plugin-text-domain]
|
||||||
|
- Namespace: [VENDOR]\[PluginName]
|
||||||
|
- Description: [BRIEF DESCRIPTION OF YOUR PLUGIN]
|
||||||
|
- Version: 0.1.0 (starting version)
|
||||||
|
- Author: [YOUR NAME/ORGANIZATION]
|
||||||
|
- Author URI: [YOUR WEBSITE]
|
||||||
|
- License: GPL-2.0+ (or specify another compatible license)
|
||||||
|
- Requires WordPress: [MINIMUM WP VERSION, e.g., 5.0]
|
||||||
|
- Requires PHP: [MINIMUM PHP VERSION, e.g., 7.0]
|
||||||
|
- GitHub Repository: [YOUR GITHUB REPO URL]
|
||||||
|
- Gitea Repository (if applicable): [YOUR GITEA REPO URL]
|
||||||
|
|
||||||
|
I need help with the following tasks:
|
||||||
|
|
||||||
|
1. Updating all template placeholders with my plugin information
|
||||||
|
2. Customizing the plugin structure for my specific needs
|
||||||
|
3. Setting up the initial functionality for my plugin
|
||||||
|
|
||||||
|
I've added the AGENTS.md and .agents/ directory to the chat context to ensure you have all the necessary information about the project structure and best practices.
|
||||||
|
|
||||||
|
Please guide me through this process step by step, starting with identifying all files that need to be updated with my plugin information.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Files That Need Updating
|
||||||
|
|
||||||
|
The AI will help you identify and update the following files with your plugin information:
|
||||||
|
|
||||||
|
1. **Main Plugin File**: Rename `wp-plugin-starter-template.php` to `your-plugin-slug.php` and update all plugin header information
|
||||||
|
2. **README.md**: Update with your plugin details, features, and installation instructions
|
||||||
|
3. **readme.txt**: Update WordPress.org plugin repository information
|
||||||
|
4. **CHANGELOG.md**: Initialize with your starting version
|
||||||
|
5. **composer.json**: Update package name and description
|
||||||
|
6. **languages/pot file**: Rename and update the POT file
|
||||||
|
7. **.github/workflows/**: Update GitHub Actions workflows with your repository information
|
||||||
|
8. **.wiki/**: Update wiki documentation with your plugin information
|
||||||
|
9. **AGENTS.md**: Update AI assistant guidance for your specific plugin
|
||||||
|
10. **includes/plugin.php**: Update namespace and class references
|
||||||
|
11. **includes/core.php**: Update namespace and customize core functionality
|
||||||
|
12. **admin/lib/admin.php**: Update namespace and customize admin functionality
|
||||||
|
|
||||||
|
## Customization Process
|
||||||
|
|
||||||
|
After providing the initial information, follow this process with your AI assistant:
|
||||||
|
|
||||||
|
### 1. File Renaming
|
||||||
|
|
||||||
|
Ask the AI to help you identify all files that need to be renamed:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please list all files that need to be renamed to match my plugin slug, and provide the commands to rename them.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Namespace Updates
|
||||||
|
|
||||||
|
Ask the AI to help you update all namespace references:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please help me update all namespace references from WPALLSTARS\PluginStarterTemplate to [VENDOR]\[PluginName] throughout the codebase.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Text Domain Updates
|
||||||
|
|
||||||
|
Ask the AI to help you update all text domain references:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please help me update all text domain references from 'wp-plugin-starter-template' to '[your-plugin-text-domain]' throughout the codebase.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Function Prefix Updates
|
||||||
|
|
||||||
|
Ask the AI to help you update any function prefixes:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please help me update any function prefixes from 'wpst_' to '[your_prefix]_' throughout the codebase.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Customizing Core Functionality
|
||||||
|
|
||||||
|
Ask the AI to help you customize the core functionality for your specific plugin needs:
|
||||||
|
|
||||||
|
```
|
||||||
|
Now I'd like to customize the core functionality for my plugin. Here's what my plugin should do:
|
||||||
|
|
||||||
|
[DESCRIBE YOUR PLUGIN'S CORE FUNCTIONALITY]
|
||||||
|
|
||||||
|
Please help me modify the includes/core.php file to implement this functionality.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Customizing Admin Interface
|
||||||
|
|
||||||
|
Ask the AI to help you customize the admin interface for your specific plugin needs:
|
||||||
|
|
||||||
|
```
|
||||||
|
I'd like to customize the admin interface for my plugin. Here's what I need in the admin area:
|
||||||
|
|
||||||
|
[DESCRIBE YOUR PLUGIN'S ADMIN INTERFACE NEEDS]
|
||||||
|
|
||||||
|
Please help me modify the admin/lib/admin.php file and any other necessary files to implement this.
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7. Testing Setup
|
||||||
|
|
||||||
|
Ask the AI to help you set up testing for your plugin:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please help me update the testing setup to match my plugin's namespace and functionality. I want to ensure I have proper test coverage for the core features.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Additional Customization Areas
|
||||||
|
|
||||||
|
Depending on your plugin's needs, you might want to ask the AI for help with:
|
||||||
|
|
||||||
|
1. **Custom Post Types**: Setting up custom post types and taxonomies
|
||||||
|
2. **Settings API**: Implementing WordPress Settings API for your plugin options
|
||||||
|
3. **Shortcodes**: Creating shortcodes for front-end functionality
|
||||||
|
4. **Widgets**: Developing WordPress widgets
|
||||||
|
5. **REST API**: Adding custom REST API endpoints
|
||||||
|
6. **Blocks**: Creating Gutenberg blocks
|
||||||
|
7. **Internationalization**: Ensuring proper i18n setup
|
||||||
|
8. **Database Tables**: Creating custom database tables if needed
|
||||||
|
9. **Cron Jobs**: Setting up WordPress cron jobs
|
||||||
|
10. **User Roles and Capabilities**: Managing custom user roles and capabilities
|
||||||
|
|
||||||
|
## Final Review
|
||||||
|
|
||||||
|
Once you've completed the customization, ask the AI to help you review everything:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please help me review all the changes we've made to ensure:
|
||||||
|
|
||||||
|
1. All template placeholders have been replaced with my plugin information
|
||||||
|
2. All namespaces, text domains, and function prefixes have been updated consistently
|
||||||
|
3. The plugin structure matches my specific needs
|
||||||
|
4. The initial functionality is properly implemented
|
||||||
|
5. All documentation (README.md, readme.txt, wiki) is updated and consistent
|
||||||
|
|
||||||
|
Are there any issues or inconsistencies that need to be addressed?
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building and Testing
|
||||||
|
|
||||||
|
Finally, ask the AI to guide you through building and testing your plugin:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please guide me through the process of building and testing my plugin:
|
||||||
|
|
||||||
|
1. How do I use the build script to create a deployable version?
|
||||||
|
2. What tests should I run to ensure everything is working correctly?
|
||||||
|
3. How do I set up a local testing environment?
|
||||||
|
4. What should I check before releasing the first version?
|
||||||
|
```
|
||||||
|
|
||||||
|
## Optimizing AI Assistance
|
||||||
|
|
||||||
|
To ensure the AI assistant has all the necessary context about your plugin's structure and best practices:
|
||||||
|
|
||||||
|
```
|
||||||
|
Please add the AGENTS.md and .agents/ directory to your AI IDE chat context. In most AI IDEs, you can pin these files to ensure they're considered in each message. This will help the AI understand the project structure and follow the established best practices.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remember
|
||||||
|
|
||||||
|
- This template is designed to be a starting point. Feel free to add, remove, or modify components as needed for your specific plugin.
|
||||||
|
- The AI assistant can help you understand the existing code and make appropriate modifications, but you should review all changes to ensure they meet your requirements.
|
||||||
|
- Always test your plugin thoroughly before releasing it.
|
||||||
|
- Keep documentation updated as you develop your plugin.
|
||||||
|
- Pin the AGENTS.md and .agents/ files in your AI IDE chat to ensure the AI has the necessary context for each interaction.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
This plugin is based on the [WordPress Plugin Starter Template for AI Coding](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding) by WPALLSTARS.
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
# WordPress Plugin Testing Framework
|
||||||
|
|
||||||
|
This document outlines how to set up and run tests for our plugin.
|
||||||
|
|
||||||
|
It covers both single site and multisite WordPress environments.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Our plugin is designed to work with both standard WordPress installations and WordPress Multisite.
|
||||||
|
|
||||||
|
This testing framework allows you to verify functionality in both environments.
|
||||||
|
|
||||||
|
## Setting Up the Test Environment
|
||||||
|
|
||||||
|
We use `@wordpress/env` and Cypress for testing our plugin.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
* Node.js (v14 or higher)
|
||||||
|
* npm or yarn
|
||||||
|
* Docker and Docker Compose
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
1. Clone the repository:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git
|
||||||
|
cd wp-plugin-starter-template-for-ai-coding
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing in Single Site WordPress
|
||||||
|
|
||||||
|
1. Set up the single site environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run setup:single
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
* Start a WordPress environment using wp-env
|
||||||
|
* Activate our plugin
|
||||||
|
|
||||||
|
2. Run Cypress tests for single site:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:single
|
||||||
|
```
|
||||||
|
|
||||||
|
For headless testing:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:single:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Access the site manually:
|
||||||
|
* Site: <http://localhost:8888>
|
||||||
|
* Admin login: admin / password
|
||||||
|
|
||||||
|
## Testing in WordPress Multisite
|
||||||
|
|
||||||
|
1. Set up the multisite environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run setup:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
* Start a WordPress environment using wp-env
|
||||||
|
* Configure it as a multisite installation
|
||||||
|
* Create a test subsite
|
||||||
|
* Network activate our plugin
|
||||||
|
|
||||||
|
2. Run Cypress tests for multisite:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
For headless testing:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:multisite:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Access the sites manually:
|
||||||
|
* Main site: <http://localhost:8888>
|
||||||
|
* Test subsite: <http://localhost:8888/testsite>
|
||||||
|
* Admin login: admin / password
|
||||||
|
|
||||||
|
## Continuous Integration
|
||||||
|
|
||||||
|
We use GitHub Actions to automatically run tests on pull requests.
|
||||||
|
|
||||||
|
The workflow is defined in `.github/workflows/wordpress-tests.yml` and runs tests in both environments.
|
||||||
|
|
||||||
|
## Writing Tests
|
||||||
|
|
||||||
|
### Single Site Tests
|
||||||
|
|
||||||
|
Add new single site tests to `cypress/e2e/single-site.cy.js`.
|
||||||
|
|
||||||
|
### Multisite Tests
|
||||||
|
|
||||||
|
Add new multisite tests to `cypress/e2e/multisite.cy.js`.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
1. **Database connection errors**: Make sure Docker is running and ports 8888 and 8889 are available.
|
||||||
|
|
||||||
|
2. **Multisite conversion fails**: Check the wp-env logs for details:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wp-env logs
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Plugin not activated**: Run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For single site
|
||||||
|
wp-env run cli wp plugin activate wp-plugin-starter-template-for-ai-coding
|
||||||
|
|
||||||
|
# For multisite
|
||||||
|
wp-env run cli wp plugin activate wp-plugin-starter-template-for-ai-coding --network
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getting Help
|
||||||
|
|
||||||
|
If you encounter any issues, please open an issue on our GitHub repository with:
|
||||||
|
|
||||||
|
* A description of the problem
|
||||||
|
* Steps to reproduce
|
||||||
|
* Any error messages
|
||||||
|
* Your environment details (OS, Node.js version, etc.)
|
||||||
@@ -0,0 +1,259 @@
|
|||||||
|
# Testing Framework
|
||||||
|
|
||||||
|
This document explains how to use the testing framework for our plugin.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
* [Overview](#overview)
|
||||||
|
* [Prerequisites](#prerequisites)
|
||||||
|
* [Testing Approaches](#testing-approaches)
|
||||||
|
* [wp-env Approach](#1-wp-env-approach)
|
||||||
|
* [WordPress Playground Approach](#2-wordpress-playground-approach)
|
||||||
|
* [Writing Tests](#writing-tests)
|
||||||
|
* [CI/CD Integration](#cicd-integration)
|
||||||
|
* [Troubleshooting](#troubleshooting)
|
||||||
|
* [PHPUnit Tests](#phpunit-tests)
|
||||||
|
* [Future Improvements](#future-improvements)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Our testing framework uses:
|
||||||
|
|
||||||
|
See also:
|
||||||
|
|
||||||
|
* [Architecture Overview](Architecture-Overview.md) – high-level design
|
||||||
|
* [Multisite Development](Multisite-Development.md) – deeper multisite guidance
|
||||||
|
|
||||||
|
Components:
|
||||||
|
|
||||||
|
* **wp-env**: For setting up WordPress environments (both single site and multisite)
|
||||||
|
* **WordPress Playground**: For browser-based testing without Docker
|
||||||
|
* **Cypress**: For end-to-end testing
|
||||||
|
* **PHPUnit**: For unit testing (coming soon)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
1. **Node.js**: Version 16 or higher
|
||||||
|
2. **npm**: For package management
|
||||||
|
3. **Docker**: For running WordPress environments with wp-env (not needed for WordPress Playground)
|
||||||
|
4. **PHP**: Version 7.4 or higher (for future PHPUnit tests)
|
||||||
|
5. **Composer**: For managing PHP dependencies
|
||||||
|
|
||||||
|
## Testing Approaches
|
||||||
|
|
||||||
|
We provide two main approaches for testing:
|
||||||
|
|
||||||
|
1. **wp-env**: Traditional approach using Docker
|
||||||
|
2. **WordPress Playground**: Browser-based approach without Docker
|
||||||
|
|
||||||
|
### 1. wp-env Approach
|
||||||
|
|
||||||
|
#### Setting Up Test Environments
|
||||||
|
|
||||||
|
We provide scripts to easily set up test environments:
|
||||||
|
|
||||||
|
##### Single Site Environment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Set up a single site environment
|
||||||
|
npm run setup:single
|
||||||
|
|
||||||
|
# You can also use the unified setup script:
|
||||||
|
bash bin/setup-test-env.sh single
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
|
||||||
|
1. Start a WordPress single site environment using wp-env
|
||||||
|
2. Install and activate our plugin
|
||||||
|
3. Configure WordPress for testing
|
||||||
|
|
||||||
|
##### Multisite Environment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Set up a multisite environment
|
||||||
|
npm run setup:multisite
|
||||||
|
|
||||||
|
# Or via the setup script:
|
||||||
|
bash bin/setup-test-env.sh multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
|
||||||
|
1. Start a WordPress multisite environment using wp-env
|
||||||
|
2. Install and activate our plugin network-wide
|
||||||
|
3. Create a test subsite
|
||||||
|
4. Configure WordPress for testing
|
||||||
|
|
||||||
|
#### Running Tests
|
||||||
|
|
||||||
|
We have Cypress tests for both single site and multisite environments:
|
||||||
|
|
||||||
|
##### Single Site Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run tests in browser (interactive mode)
|
||||||
|
npm run test:single
|
||||||
|
|
||||||
|
# Run tests headless (CI mode)
|
||||||
|
npm run test:single:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Multisite Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run tests in browser (interactive mode)
|
||||||
|
npm run test:multisite
|
||||||
|
|
||||||
|
# Run tests headless (CI mode)
|
||||||
|
npm run test:multisite:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
##### All-in-One Commands
|
||||||
|
|
||||||
|
We also provide all-in-one commands that set up the environment and run the tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Set up single site environment and run tests
|
||||||
|
npm run test:e2e:single
|
||||||
|
|
||||||
|
# Set up multisite environment and run tests
|
||||||
|
npm run test:e2e:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. WordPress Playground Approach
|
||||||
|
|
||||||
|
WordPress Playground runs WordPress entirely in the browser using WebAssembly. This means:
|
||||||
|
|
||||||
|
* No server required - WordPress runs in the browser
|
||||||
|
* Fast startup times
|
||||||
|
* Isolated testing environment
|
||||||
|
* Works well with CI/CD pipelines
|
||||||
|
|
||||||
|
#### Using WordPress Playground Online
|
||||||
|
|
||||||
|
The easiest way to test our plugin with WordPress Playground is to use the online version:
|
||||||
|
|
||||||
|
1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/blueprint.json&_t=2)
|
||||||
|
|
||||||
|
2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/main/playground/multisite-blueprint.json&_t=2)
|
||||||
|
|
||||||
|
These links automatically set up WordPress with multisite enabled and WP_DEBUG enabled.
|
||||||
|
|
||||||
|
Both the Plugin Toggle and Kadence Blocks plugins are pre-activated.
|
||||||
|
|
||||||
|
#### Local Testing with HTML Files
|
||||||
|
|
||||||
|
We've also included HTML files that embed WordPress Playground:
|
||||||
|
|
||||||
|
1. Open `playground/index.html` in your browser for single site testing
|
||||||
|
2. Open `playground/multisite.html` in your browser for multisite testing
|
||||||
|
3. Open `playground/test.html` in your browser for a unified interface with buttons to switch between single site and multisite
|
||||||
|
|
||||||
|
You can serve these files locally with a simple HTTP server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using Python
|
||||||
|
python -m http.server 8888 --directory playground
|
||||||
|
|
||||||
|
# Then open http://localhost:8888/index.html in your browser
|
||||||
|
# Or open http://localhost:8888/test.html for a unified single/multisite switcher
|
||||||
|
```
|
||||||
|
|
||||||
|
## Writing Tests
|
||||||
|
|
||||||
|
### Cypress Tests
|
||||||
|
|
||||||
|
We have custom Cypress commands to make testing WordPress easier:
|
||||||
|
|
||||||
|
* `cy.loginAsAdmin()`: Logs in as the admin user
|
||||||
|
* `cy.activatePlugin(pluginSlug)`: Activates a plugin
|
||||||
|
* `cy.networkActivatePlugin(pluginSlug)`: Network activates a plugin in multisite
|
||||||
|
|
||||||
|
Example test:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
describe('WordPress Single Site Tests', () => {
|
||||||
|
it('Can login to the admin area', () => {
|
||||||
|
cy.loginAsAdmin();
|
||||||
|
cy.get('body.wp-admin').should('exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Plugin is activated', () => {
|
||||||
|
cy.loginAsAdmin();
|
||||||
|
cy.visit('/wp-admin/plugins.php');
|
||||||
|
cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]')
|
||||||
|
.should('have.class', 'active');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## CI/CD Integration
|
||||||
|
|
||||||
|
We have GitHub Actions workflows for running tests in CI/CD:
|
||||||
|
|
||||||
|
* `.github/workflows/wordpress-tests.yml`: Runs wp-env e2e tests
|
||||||
|
* `.github/workflows/playground-tests.yml`: Runs Playground e2e tests
|
||||||
|
* `.github/workflows/phpunit.yml`: Runs PHPUnit tests (coming soon)
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
1. **Docker not running**: Make sure Docker is running before starting wp-env
|
||||||
|
2. **Port conflicts**: If ports 8888 or 8889 are in use, wp-env will fail to start
|
||||||
|
3. **wp-env not installed**: Run `npm install -g @wordpress/env` to install wp-env globally
|
||||||
|
4. **WordPress Playground not loading**: Check your network connection and try refreshing the page
|
||||||
|
5. **Tests failing**: Check the error messages in the console and fix the issues
|
||||||
|
|
||||||
|
### Error Checking and Feedback Loops
|
||||||
|
|
||||||
|
For information on code quality issues and automated tool feedback, see the
|
||||||
|
[Error Checking and Feedback Loops](Error-Checking-Feedback-Loops.md) documentation.
|
||||||
|
|
||||||
|
### Debugging
|
||||||
|
|
||||||
|
1. **Cypress debugging**: Use `cy.debug()` to pause test execution
|
||||||
|
2. **wp-env debugging**: Run `wp-env logs` to see WordPress logs
|
||||||
|
3. **GitHub Actions debugging**: Check the workflow logs for detailed error messages
|
||||||
|
|
||||||
|
## PHPUnit Tests
|
||||||
|
|
||||||
|
We use PHPUnit for unit testing PHP code. The tests are located in the `tests/phpunit` directory.
|
||||||
|
|
||||||
|
### Running PHPUnit Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run PHPUnit tests for single site
|
||||||
|
npm run test:phpunit
|
||||||
|
|
||||||
|
# Run PHPUnit tests for multisite
|
||||||
|
npm run test:phpunit:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
### Writing PHPUnit Tests
|
||||||
|
|
||||||
|
Here's an example of a PHPUnit test for the Multisite class:
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
class MultisiteTest extends WP_UnitTestCase {
|
||||||
|
|
||||||
|
public function test_is_multisite_compatible() {
|
||||||
|
$multisite = new WP_Plugin_Starter_Template_For_AI_Coding\Multisite\Multisite();
|
||||||
|
$this->assertTrue($multisite->is_multisite_compatible());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_get_network_sites() {
|
||||||
|
$multisite = new WP_Plugin_Starter_Template_For_AI_Coding\Multisite\Multisite();
|
||||||
|
$sites = $multisite->get_network_sites();
|
||||||
|
$this->assertIsArray($sites);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Future Improvements
|
||||||
|
|
||||||
|
1. **Performance tests**: Add performance testing
|
||||||
|
2. **Accessibility tests**: Add accessibility testing
|
||||||
|
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
This guide provides solutions to common issues you might encounter when using or developing with this plugin.
|
||||||
|
|
||||||
|
## Installation Issues
|
||||||
|
|
||||||
|
### Plugin Installation Fails
|
||||||
|
|
||||||
|
**Problem**: The plugin fails to install in WordPress.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that your WordPress version meets the minimum requirement (5.0+)
|
||||||
|
2. Check that your PHP version meets the minimum requirement (7.0+)
|
||||||
|
3. Ensure the ZIP file is properly formatted and contains all required files
|
||||||
|
4. Try installing the plugin manually by uploading the unzipped folder to the `wp-content/plugins` directory
|
||||||
|
|
||||||
|
### Activation Error
|
||||||
|
|
||||||
|
**Problem**: You receive an error when activating the plugin.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Check the error message for specific details
|
||||||
|
2. Verify that all plugin dependencies are installed and activated
|
||||||
|
3. Check your server's error logs for more information
|
||||||
|
4. Temporarily deactivate other plugins to check for conflicts
|
||||||
|
|
||||||
|
## Development Issues
|
||||||
|
|
||||||
|
### Composer Dependencies
|
||||||
|
|
||||||
|
**Problem**: Composer fails to install dependencies.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that you have Composer installed and up to date
|
||||||
|
2. Check that your PHP version meets the requirements for all dependencies
|
||||||
|
3. Try clearing Composer's cache: `composer clear-cache`
|
||||||
|
4. Run `composer install --verbose` to see detailed error messages
|
||||||
|
|
||||||
|
### NPM Dependencies
|
||||||
|
|
||||||
|
**Problem**: NPM fails to install dependencies.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that you have Node.js and NPM installed and up to date
|
||||||
|
2. Try clearing NPM's cache: `npm cache clean --force`
|
||||||
|
3. Delete the `node_modules` directory and run `npm install` again
|
||||||
|
4. Run `npm install --verbose` to see detailed error messages
|
||||||
|
|
||||||
|
### WordPress Environment (wp-env)
|
||||||
|
|
||||||
|
**Problem**: The WordPress environment fails to start.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that Docker is installed and running
|
||||||
|
2. Check that the Docker daemon has enough resources allocated
|
||||||
|
3. Try stopping and removing existing containers: `npm run wp-env stop && npm run wp-env clean`
|
||||||
|
4. Run `npm run wp-env start --debug` to see detailed error messages
|
||||||
|
|
||||||
|
### Unit Tests
|
||||||
|
|
||||||
|
**Problem**: Unit tests are failing.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that you have PHPUnit installed and configured correctly
|
||||||
|
2. Check that all dependencies are installed: `composer install`
|
||||||
|
3. Run tests with verbose output: `./vendor/bin/phpunit --verbose`
|
||||||
|
4. Check for syntax errors in your PHP files
|
||||||
|
|
||||||
|
### End-to-End Tests
|
||||||
|
|
||||||
|
**Problem**: End-to-end tests are failing.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that the WordPress environment is running: `npm run start`
|
||||||
|
2. Check that Cypress is installed correctly: `npx cypress verify`
|
||||||
|
3. Run tests in interactive mode to debug: `npm run test:e2e`
|
||||||
|
4. Check for issues with selectors or timing in your test scripts
|
||||||
|
|
||||||
|
## Plugin Functionality Issues
|
||||||
|
|
||||||
|
### Plugin Settings Not Saving
|
||||||
|
|
||||||
|
**Problem**: Changes to plugin settings are not being saved.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Check for JavaScript errors in the browser console
|
||||||
|
2. Verify that the settings form is submitting correctly
|
||||||
|
3. Check that the WordPress nonce is being verified correctly
|
||||||
|
4. Ensure that the user has the necessary permissions to save settings
|
||||||
|
|
||||||
|
### Plugin Conflicts
|
||||||
|
|
||||||
|
**Problem**: The plugin conflicts with other plugins.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Deactivate other plugins one by one to identify the conflict
|
||||||
|
2. Check for JavaScript errors in the browser console
|
||||||
|
3. Check for PHP errors in the server logs
|
||||||
|
4. Contact the developers of both plugins to report the conflict
|
||||||
|
|
||||||
|
### Performance Issues
|
||||||
|
|
||||||
|
**Problem**: The plugin is causing performance issues.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Check if the plugin is making excessive database queries
|
||||||
|
2. Verify that assets (CSS/JS) are being properly enqueued and minified
|
||||||
|
3. Consider implementing caching for resource-intensive operations
|
||||||
|
4. Use a profiling tool to identify bottlenecks
|
||||||
|
|
||||||
|
## Update Issues
|
||||||
|
|
||||||
|
### Update Fails
|
||||||
|
|
||||||
|
**Problem**: The plugin fails to update.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that your WordPress version meets the requirements for the new version
|
||||||
|
2. Check that your PHP version meets the requirements for the new version
|
||||||
|
3. Try updating manually by downloading the new version and replacing the old files
|
||||||
|
4. Check for file permission issues on your server
|
||||||
|
|
||||||
|
### Lost Settings After Update
|
||||||
|
|
||||||
|
**Problem**: Plugin settings are lost after updating.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Check if the plugin includes a data migration process for updates
|
||||||
|
2. Verify that the settings are being stored in the database correctly
|
||||||
|
3. Restore settings from a backup if available
|
||||||
|
4. Contact plugin support for assistance
|
||||||
|
|
||||||
|
## Multisite Issues
|
||||||
|
|
||||||
|
### Plugin Not Working on Multisite
|
||||||
|
|
||||||
|
**Problem**: The plugin doesn't work correctly on a multisite installation.
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
1. Verify that the plugin is network activated if required
|
||||||
|
2. Check that the plugin is compatible with multisite (it should be!)
|
||||||
|
3. Ensure that the plugin has the necessary permissions on each site
|
||||||
|
4. Check for multisite-specific settings or options
|
||||||
|
|
||||||
|
## Getting Additional Help
|
||||||
|
|
||||||
|
If you're still experiencing issues after trying these troubleshooting steps:
|
||||||
|
|
||||||
|
1. Check the [Frequently Asked Questions](Frequently-Asked-Questions) for more information
|
||||||
|
2. Search for similar issues in the [GitHub Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
|
||||||
|
3. Create a new issue with detailed information about your problem
|
||||||
|
4. Contact the plugin developers for direct support
|
||||||
|
|
||||||
|
## Reporting Bugs
|
||||||
|
|
||||||
|
If you've identified a bug in the plugin:
|
||||||
|
|
||||||
|
1. Go to the [GitHub Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) page
|
||||||
|
2. Click "New Issue"
|
||||||
|
3. Select "Bug Report"
|
||||||
|
4. Fill out the template with as much detail as possible
|
||||||
|
5. Submit the issue
|
||||||
|
|
||||||
|
Please include:
|
||||||
|
|
||||||
|
- A clear description of the bug
|
||||||
|
- Steps to reproduce the issue
|
||||||
|
- Your environment details (WordPress version, PHP version, etc.)
|
||||||
|
- Any relevant error messages or screenshots
|
||||||
@@ -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
|
||||||
|
- `.agents/`: 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 <version>
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
## User Documentation
|
||||||
|
|
||||||
|
* [Home](Home)
|
||||||
|
* [Starter Prompt](Starter-Prompt)
|
||||||
|
* [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)
|
||||||
|
* [Testing Framework](Testing-Framework)
|
||||||
|
* [Multisite Development](Multisite-Development)
|
||||||
|
* [Release Process](Release-Process)
|
||||||
|
|
||||||
|
## AI Documentation
|
||||||
|
|
||||||
|
* [AI Workflow Documentation](AI-Workflow-Documentation)
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
* [Changelog](Changelog)
|
||||||
|
* [Contributing](Contributing)
|
||||||
@@ -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).
|
||||||
@@ -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/)
|
||||||
@@ -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/)
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 635 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 185 KiB |
@@ -1,129 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
WP Plugin Starter banner (WordPress.org banners and the Read Me tab).
|
|
||||||
Source: .wordpress-org/banner.svg. Edit that, then run scripts/build-banner.sh.
|
|
||||||
Branding follows wpallstars.com: navy, red and cream, Zilla Slab italic
|
|
||||||
headings, the wpallstars plugin stack in red only, the logo's arc of five stars and its red double stripes (here with cream between).
|
|
||||||
-->
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1544" height="500" viewBox="0 0 1544 500">
|
|
||||||
<title>WPALLSTARS WP Plugin Starter: Built with AI</title>
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
||||||
<stop offset="0" stop-color="#000c1f"/>
|
|
||||||
<stop offset="0.55" stop-color="#001537"/>
|
|
||||||
<stop offset="1" stop-color="#0d264d"/>
|
|
||||||
</linearGradient>
|
|
||||||
<radialGradient id="glow-blue" cx="1214" cy="270" r="440" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop offset="0" stop-color="#bb0000" stop-opacity="0.45"/>
|
|
||||||
<stop offset="1" stop-color="#bb0000" stop-opacity="0"/>
|
|
||||||
</radialGradient>
|
|
||||||
<radialGradient id="glow-red" cx="200" cy="580" r="520" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop offset="0" stop-color="#bb0000" stop-opacity="0.2"/>
|
|
||||||
<stop offset="1" stop-color="#bb0000" stop-opacity="0"/>
|
|
||||||
</radialGradient>
|
|
||||||
<radialGradient id="glow-gold" cx="1214" cy="76" r="120" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop offset="0" stop-color="#ffc94d" stop-opacity="0.45"/>
|
|
||||||
<stop offset="1" stop-color="#ffc94d" stop-opacity="0"/>
|
|
||||||
</radialGradient>
|
|
||||||
<radialGradient id="dots-fade" cx="1214" cy="260" r="560" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop offset="0" stop-color="#fff" stop-opacity="1"/>
|
|
||||||
<stop offset="1" stop-color="#fff" stop-opacity="0"/>
|
|
||||||
</radialGradient>
|
|
||||||
<pattern id="dots" width="28" height="28" patternUnits="userSpaceOnUse">
|
|
||||||
<circle cx="14" cy="14" r="1.5" fill="#ffffea" fill-opacity="0.12"/>
|
|
||||||
</pattern>
|
|
||||||
<mask id="dots-mask">
|
|
||||||
<rect width="1544" height="500" fill="url(#dots-fade)"/>
|
|
||||||
</mask>
|
|
||||||
<linearGradient id="gold" x1="0" y1="0" x2="0" y2="1">
|
|
||||||
<stop offset="0" stop-color="#ffe08a"/>
|
|
||||||
<stop offset="1" stop-color="#f5a524"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="gold-text" x1="96" y1="280" x2="700" y2="340" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop offset="0" stop-color="#ffd970"/>
|
|
||||||
<stop offset="1" stop-color="#f5a524"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="top-red" x1="0" y1="0" x2="1" y2="1">
|
|
||||||
<stop offset="0" stop-color="#ef4444"/>
|
|
||||||
<stop offset="1" stop-color="#bb0000"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="top-cream" x1="0" y1="0" x2="1" y2="1">
|
|
||||||
<stop offset="0" stop-color="#ff8a8a"/>
|
|
||||||
<stop offset="1" stop-color="#e03131"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="top-blue" x1="0" y1="0" x2="1" y2="1">
|
|
||||||
<stop offset="0" stop-color="#c81e1e"/>
|
|
||||||
<stop offset="1" stop-color="#7a0000"/>
|
|
||||||
</linearGradient>
|
|
||||||
<!-- A five-pointed star, radius 1, centred on 0,0 -->
|
|
||||||
<polygon id="star" points="0,-1 0.2245,-0.309 0.9511,-0.309 0.3633,0.118 0.5878,0.809 0,0.382 -0.5878,0.809 -0.3633,0.118 -0.9511,-0.309 -0.2245,-0.309"/>
|
|
||||||
</defs>
|
|
||||||
|
|
||||||
<!-- Background -->
|
|
||||||
<rect width="1544" height="500" fill="url(#bg)"/>
|
|
||||||
<rect width="1544" height="500" fill="url(#glow-red)"/>
|
|
||||||
<rect width="1544" height="500" fill="url(#glow-blue)"/>
|
|
||||||
<rect width="1544" height="500" fill="url(#dots)" mask="url(#dots-mask)"/>
|
|
||||||
|
|
||||||
<!-- wpallstars.com's red double lines, with a cream line between them. -->
|
|
||||||
<g>
|
|
||||||
<rect y="0" width="1544" height="6" fill="#bb0000"/>
|
|
||||||
<rect y="6" width="1544" height="5" fill="#ffffea"/>
|
|
||||||
<rect y="11" width="1544" height="6" fill="#bb0000"/>
|
|
||||||
<rect y="483" width="1544" height="6" fill="#bb0000"/>
|
|
||||||
<rect y="489" width="1544" height="5" fill="#ffffea"/>
|
|
||||||
<rect y="494" width="1544" height="6" fill="#bb0000"/>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- The picture: scaled down a little so it keeps clear of the stripes -->
|
|
||||||
<g transform="translate(1214 248) scale(0.86) translate(-1214 -248)">
|
|
||||||
<!-- The stack: red, cream and blue layers, each with a top face and two sides -->
|
|
||||||
<g stroke-linejoin="round">
|
|
||||||
<g transform="translate(0 350)">
|
|
||||||
<polygon points="1064,0 1214,87 1214,117 1064,30" fill="#5c0000"/>
|
|
||||||
<polygon points="1214,87 1364,0 1364,30 1214,117" fill="#420000"/>
|
|
||||||
<polygon points="1214,-87 1364,0 1214,87 1064,0" fill="url(#top-blue)"/>
|
|
||||||
<polygon points="1214,-61 1319,0 1214,61 1109,0" fill="none" stroke="#ffffff" stroke-opacity="0.3" stroke-width="2"/>
|
|
||||||
</g>
|
|
||||||
<g transform="translate(0 294)">
|
|
||||||
<polygon points="1064,0 1214,87 1214,117 1064,30" fill="#c22424"/>
|
|
||||||
<polygon points="1214,87 1364,0 1364,30 1214,117" fill="#9e1414"/>
|
|
||||||
<polygon points="1214,-87 1364,0 1214,87 1064,0" fill="url(#top-cream)"/>
|
|
||||||
<polygon points="1214,-61 1319,0 1214,61 1109,0" fill="none" stroke="#001537" stroke-opacity="0.18" stroke-width="2"/>
|
|
||||||
</g>
|
|
||||||
<g transform="translate(0 238)">
|
|
||||||
<polygon points="1064,0 1214,87 1214,117 1064,30" fill="#940000"/>
|
|
||||||
<polygon points="1214,87 1364,0 1364,30 1214,117" fill="#700000"/>
|
|
||||||
<polygon points="1214,-87 1364,0 1214,87 1064,0" fill="url(#top-red)"/>
|
|
||||||
<!-- The WordPress Plugins icon (Dashicons admin-plugins, GPLv2 or later),
|
|
||||||
laid flat on the top face: icon x runs along the top-right edge and
|
|
||||||
icon y along the top-left edge, each 20-unit side 66% of the face.
|
|
||||||
Turned 45 degrees so the plug points along the back-left edge. -->
|
|
||||||
<g transform="matrix(4.95 2.871 -4.95 2.871 1214 -57.42)">
|
|
||||||
<path fill="#5c0000" fill-opacity="0.55" transform="translate(0.3 0.3) rotate(-45 10 10)" d="M13.11 4.36L9.87 7.6 8 5.73l3.24-3.24c.35-.34 1.05-.2 1.56.32.52.51.66 1.21.31 1.55zm-8 1.77l.91-1.12 9.01 9.01-1.19.84c-.71.71-2.63 1.16-3.82 1.16H6.14L4.9 17.26c-.59.59-1.54.59-2.12 0-.59-.58-.59-1.53 0-2.12l1.24-1.24v-3.88c0-1.13.4-3.19 1.09-3.89zm7.26 3.97l3.24-3.24c.34-.35 1.04-.21 1.55.31.52.51.66 1.21.31 1.55l-3.24 3.25z"/>
|
|
||||||
<path fill="#ffffea" transform="rotate(-45 10 10)" d="M13.11 4.36L9.87 7.6 8 5.73l3.24-3.24c.35-.34 1.05-.2 1.56.32.52.51.66 1.21.31 1.55zm-8 1.77l.91-1.12 9.01 9.01-1.19.84c-.71.71-2.63 1.16-3.82 1.16H6.14L4.9 17.26c-.59.59-1.54.59-2.12 0-.59-.58-.59-1.53 0-2.12l1.24-1.24v-3.88c0-1.13.4-3.19 1.09-3.89zm7.26 3.97l3.24-3.24c.34-.35 1.04-.21 1.55.31.52.51.66 1.21.31 1.55l-3.24 3.25z"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- The logo's arc of five stars: gold in the middle, floating above the stack -->
|
|
||||||
<circle cx="1214" cy="76" r="120" fill="url(#glow-gold)"/>
|
|
||||||
<g stroke-linejoin="round">
|
|
||||||
<g fill="#bb0000" stroke="#ffffea" stroke-width="5">
|
|
||||||
<use xlink:href="#star" transform="translate(1043 150) scale(17)" stroke-width="0.3"/>
|
|
||||||
<use xlink:href="#star" transform="translate(1110 100) scale(26)" stroke-width="0.2"/>
|
|
||||||
<use xlink:href="#star" transform="translate(1318 100) scale(26)" stroke-width="0.2"/>
|
|
||||||
<use xlink:href="#star" transform="translate(1385 150) scale(17)" stroke-width="0.3"/>
|
|
||||||
</g>
|
|
||||||
<use xlink:href="#star" transform="translate(1214 78) scale(54)" fill="url(#gold)" stroke="#ffffea" stroke-width="0.11"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
|
|
||||||
<!-- Words -->
|
|
||||||
<g font-family="Zilla Slab" text-rendering="geometricPrecision">
|
|
||||||
<text x="98" y="128" font-size="27" font-weight="600" letter-spacing="5" fill="#ff999b">WPALLSTARS</text>
|
|
||||||
<text x="92" y="240" font-size="104" font-weight="700" font-style="italic" letter-spacing="-1" fill="#ffffea">WP Plugin Starter</text>
|
|
||||||
<text x="96" y="326" font-size="72" font-weight="700" font-style="italic" fill="url(#gold-text)">Built with AI</text>
|
|
||||||
<text x="98" y="396" font-size="33" font-weight="500" fill="#c2cad6">A clean start for WordPress plugins, made with aidevops.</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 7.7 KiB |
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"core": null,
|
||||||
|
"plugins": [
|
||||||
|
"."
|
||||||
|
],
|
||||||
|
"themes": [],
|
||||||
|
"config": {
|
||||||
|
"WP_DEBUG": true,
|
||||||
|
"WP_DEBUG_LOG": true,
|
||||||
|
"WP_DEBUG_DISPLAY": false
|
||||||
|
},
|
||||||
|
"mappings": {
|
||||||
|
"wp-content/mu-plugins": "./mu-plugins",
|
||||||
|
"wp-content/plugins/wp-plugin-starter-template-for-ai-coding": "."
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"core": null,
|
||||||
|
"plugins": [
|
||||||
|
"."
|
||||||
|
],
|
||||||
|
"themes": [],
|
||||||
|
"config": {
|
||||||
|
"WP_DEBUG": true,
|
||||||
|
"WP_DEBUG_LOG": true,
|
||||||
|
"WP_DEBUG_DISPLAY": false,
|
||||||
|
"WP_ALLOW_MULTISITE": true,
|
||||||
|
"MULTISITE": true,
|
||||||
|
"SUBDOMAIN_INSTALL": false,
|
||||||
|
"PATH_CURRENT_SITE": "/",
|
||||||
|
"SITE_ID_CURRENT_SITE": 1,
|
||||||
|
"BLOG_ID_CURRENT_SITE": 1
|
||||||
|
},
|
||||||
|
"mappings": {
|
||||||
|
"wp-content/mu-plugins": "./mu-plugins",
|
||||||
|
"wp-content/plugins/wp-plugin-starter-template-for-ai-coding": "."
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,51 +1,188 @@
|
|||||||
# WP Plugin Starter — agent guide
|
# AI Assistant Guide for WordPress Plugin Development
|
||||||
|
|
||||||
The wpallstars starter plugin: what every wpallstars plugin is made from.
|
This guide helps AI assistants understand the project structure, workflows, and best practices for this repository.
|
||||||
It has no features of its own, only the parts every plugin needs.
|
|
||||||
|
|
||||||
**Read `STANDARDS.md` before any change.** It holds the rules every plugin
|
## IMPORTANT: Repository Context
|
||||||
made from the starter shares: structure and core files, code rules, Updates
|
|
||||||
from GitHub, releases, front-end styling and dark mode, and testing. This
|
|
||||||
repository holds the master copy of it and of every core file
|
|
||||||
(`scripts/core-files.txt`). This file holds only what is the starter's own.
|
|
||||||
|
|
||||||
| Placeholder in `STANDARDS.md` | WP Plugin Starter |
|
This workspace may contain multiple repository folders.
|
||||||
|---|---|
|
|
||||||
| `{slug}` | `wp-plugin-starter-template` (main file `wp-plugin-starter-template.php`) |
|
|
||||||
| `{prefix}` | `wpstarter` |
|
|
||||||
| `{Prefix}` | `WPStarter` |
|
|
||||||
| `{PREFIX}` | `WPSTARTER` |
|
|
||||||
| `{Name}` | WP Plugin Starter |
|
|
||||||
| `{css}` | `wps` |
|
|
||||||
|
|
||||||
User docs: `README.md` (developers, and the Read Me tab) and `readme.txt`.
|
Always focus ONLY on the current repository you're working in.
|
||||||
Development: `DEVELOPMENT.md`. Releases: `RELEASING.md`; launch state:
|
|
||||||
`LAUNCH.md`.
|
|
||||||
|
|
||||||
## What belongs here
|
Avoid hallucinating functionality from other repositories in the workspace.
|
||||||
|
|
||||||
- Only what every plugin needs. A part one plugin needs stays in that
|
* **Current Repository**: wp-plugin-starter-template-for-ai-coding
|
||||||
plugin (its `{Prefix}_Setup`, a feature or its own files). When a lesson
|
* **Repository Purpose**: A starter template for WordPress plugins with AI-assisted development
|
||||||
from a plugin applies to all of them, change the core file here first,
|
* **Repository Scope**: All code changes and discussions should be limited to THIS repository only
|
||||||
then run `scripts/sync-core.sh` in each plugin (`--check` lists what
|
|
||||||
differs). Keep core files free of any one plugin's names, examples and
|
|
||||||
paths: this repository is public.
|
|
||||||
- `includes/class-wpstarter-setup.php` stays empty of features, so the
|
|
||||||
settings screen shows the empty General tab and the Read Me tab. Test a
|
|
||||||
core change in a plugin that uses it, then here.
|
|
||||||
- `scripts/rename-plugin.sh` must keep working on a fresh copy: after a
|
|
||||||
change to names in core files, try it on a throwaway clone (rename, lint,
|
|
||||||
smoke test).
|
|
||||||
- The banner source is `.wordpress-org/banner.svg`: the wpallstars plugin
|
|
||||||
stack picture in red only, on wpallstars branding. Rebuild it with
|
|
||||||
`scripts/build-banner.sh`.
|
|
||||||
- This repository is public. Never name private repositories, their
|
|
||||||
issues, or local paths in it (commits, docs, comments or examples).
|
|
||||||
- Every plugin made from the starter keeps the **Built with AI** credit to
|
|
||||||
aidevops (https://aidevops.sh) in `README.md` and `readme.txt`.
|
|
||||||
|
|
||||||
## Test sites
|
## Project Overview
|
||||||
|
|
||||||
Install the GitHub build on a local test site with
|
* **Plugin Name**: WordPress Plugin Starter Template
|
||||||
`scripts/preview-site.sh` (see `DEVELOPMENT.md`), or install the GitHub
|
* **Plugin Slug**: wp-plugin-starter-template
|
||||||
zip from `scripts/build-release.sh` on any test site.
|
* **Text Domain**: wp-plugin-starter-template
|
||||||
|
* **Namespace**: WPALLSTARS\PluginStarterTemplate
|
||||||
|
* **Version**: 0.1.15
|
||||||
|
* **Requires WordPress**: 5.0+
|
||||||
|
* **Requires PHP**: 7.4+
|
||||||
|
* **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
|
||||||
|
* **.agents/**: Documentation for AI assistants
|
||||||
|
* **.wiki/**: Wiki documentation templates
|
||||||
|
|
||||||
|
## Coding Standards
|
||||||
|
|
||||||
|
This project follows the [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/):
|
||||||
|
|
||||||
|
* Use 4 spaces for indentation, not tabs (this is a project-specific override of WordPress standards)
|
||||||
|
* 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
|
||||||
|
* Use asterisks (*) for bullet points in all Markdown files, not hyphens (-)
|
||||||
|
* Add periods to the end of all inline comments
|
||||||
|
|
||||||
|
### Code Quality Tools
|
||||||
|
|
||||||
|
This project uses several automated code quality tools to ensure high standards:
|
||||||
|
|
||||||
|
1. **PHP_CodeSniffer (PHPCS)**: Checks PHP code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
composer run phpcs
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **PHP Code Beautifier and Fixer (PHPCBF)**: Automatically fixes some coding standard violations
|
||||||
|
```bash
|
||||||
|
composer run phpcbf
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **ESLint**: Checks JavaScript code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
npm run lint:js
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Stylelint**: Checks CSS code against the WordPress Coding Standards
|
||||||
|
```bash
|
||||||
|
npm run lint:css
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Continuous Integration Tools**: The project integrates with several code quality tools:
|
||||||
|
* **CodeRabbit**: AI-powered code review tool
|
||||||
|
* **CodeFactor**: Continuous code quality monitoring
|
||||||
|
* **Codacy**: Code quality and static analysis
|
||||||
|
* **SonarCloud**: Code quality and security analysis
|
||||||
|
|
||||||
|
Always run PHPCS and PHPCBF locally before committing code to ensure it meets the project's coding standards.
|
||||||
|
|
||||||
|
## Common Tasks
|
||||||
|
|
||||||
|
For detailed instructions on releases, features, bugs, and testing, see **@.agents/release-process.md**.
|
||||||
|
|
||||||
|
For local testing with WordPress Playground, LocalWP, and wp-env, see **@.agents/local-testing-guide.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.
|
||||||
|
|
||||||
|
7. **Consistent Markdown Formatting**: Always use asterisks (*) for bullet points in Markdown files, not hyphens (-).
|
||||||
|
|
||||||
|
## 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
|
||||||
|
* Use asterisks (*) for bullet points in all Markdown files
|
||||||
|
|
||||||
|
## 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
|
||||||
|
4. Reference these preferences in future interactions
|
||||||
|
|
||||||
|
This ensures consistency across coding sessions and reduces the need for developers to repeatedly explain their preferences.
|
||||||
|
|
||||||
|
## Autonomous CI/CD and Error Handling
|
||||||
|
|
||||||
|
This repository is set up for autonomous CI/CD with minimal human intervention.
|
||||||
|
|
||||||
|
As an AI assistant, you should:
|
||||||
|
|
||||||
|
1. **Monitor CI/CD Pipelines**: Use the GitHub API to check workflow status and identify failures
|
||||||
|
2. **Diagnose Issues**: Analyze error logs and determine root causes
|
||||||
|
3. **Implement Fixes**: Make necessary code changes to resolve issues
|
||||||
|
4. **Verify Solutions**: Ensure fixes pass all tests and quality checks
|
||||||
|
5. **Document Resolutions**: Update documentation with solutions for future reference
|
||||||
|
|
||||||
|
For detailed instructions on establishing feedback loops and error checking processes, see **@.agents/error-checking-feedback-loops.md**.
|
||||||
|
|
||||||
|
### When to Consult Humans
|
||||||
|
|
||||||
|
Only consult humans for:
|
||||||
|
|
||||||
|
* Product design decisions
|
||||||
|
* Security-critical changes
|
||||||
|
* Major architectural decisions
|
||||||
|
* Access to information not available through APIs or terminal
|
||||||
|
* Novel problems without precedent or documented solutions
|
||||||
+142
@@ -0,0 +1,142 @@
|
|||||||
|
All notable changes to this project should be documented both here and in the main Readme files.
|
||||||
|
|
||||||
|
#### [0.1.15] - 2025-11-24
|
||||||
|
|
||||||
|
#### Release
|
||||||
|
|
||||||
|
- Maintenance release
|
||||||
|
|
||||||
|
#### [0.1.14] - 2025-11-24
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- Renamed .ai-assistant.md to AGENTS.md
|
||||||
|
- Renamed .ai-workflows directory to .agents
|
||||||
|
- Updated all references in documentation and codebase
|
||||||
|
|
||||||
|
#### [0.1.13] - 2023-04-23
|
||||||
|
|
||||||
|
#### Improved
|
||||||
|
|
||||||
|
- Improved code quality with proper type declarations
|
||||||
|
- Fixed inconsistent variable naming (camelCase to snake_case)
|
||||||
|
- Improved path handling in admin class
|
||||||
|
- Added textdomain loading functionality
|
||||||
|
- Removed unused phpcs:ignore comment
|
||||||
|
- Implemented proper return type declarations
|
||||||
|
|
||||||
|
#### [0.1.12] - 2023-04-22
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
- Fixed WordPress mocking in unit tests
|
||||||
|
- Added proper mocking for WordPress functions in tests
|
||||||
|
- Improved code quality tool configurations
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- Detailed code quality checks workflow documentation
|
||||||
|
- Updated documentation for better workflow efficiency
|
||||||
|
|
||||||
|
#### [0.1.11] - 2023-04-21
|
||||||
|
|
||||||
|
#### Improved
|
||||||
|
|
||||||
|
- Improved code quality with comprehensive fixes
|
||||||
|
- Fixed indentation issues in PHP files
|
||||||
|
- Updated CSS formatting with modern notation
|
||||||
|
- Fixed JavaScript issues with proper global variables
|
||||||
|
- Improved security by using filter_input() instead of direct superglobal access
|
||||||
|
- Standardized naming conventions across the codebase
|
||||||
|
- Fixed documentation and comments for better clarity
|
||||||
|
|
||||||
|
#### [0.1.10] - 2025-04-20
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
- Fixed formatting issues in markdown files for better code quality
|
||||||
|
- Improved URL formatting with angle brackets
|
||||||
|
- Standardized list formatting across documentation files
|
||||||
|
|
||||||
|
#### [0.1.9] - 2025-04-18
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- Alphabetized AI IDE list in README.md
|
||||||
|
|
||||||
|
#### [0.1.8] - 2025-04-19
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- More informative badges to README.md (Build Status, Requirements, WP.org placeholders, Release, Issues, Contributors, Wiki).
|
||||||
|
|
||||||
|
#### [0.1.7] - 2025-04-19
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
- GitHub Actions tests workflow with proper file paths and dependencies
|
||||||
|
|
||||||
|
#### Improved
|
||||||
|
|
||||||
|
- Workflow names for better clarity in GitHub Actions UI
|
||||||
|
|
||||||
|
#### [0.1.6] - 2025-04-19
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
- GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
|
#### [0.1.5] - 2025-04-19
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
- Release workflow to use correct plugin directory name
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- Testing setup with wp-env and Cypress
|
||||||
|
- Multisite compatibility
|
||||||
|
- npm scripts for development and testing
|
||||||
|
|
||||||
|
#### [0.1.3] - 2025-04-19
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- Improved AI IDE context recommendations in documentation
|
||||||
|
- Enhanced Starter Prompt with guidance on pinning AGENTS.md and .agents/
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- Updated README.md and readme.txt with AI IDE context recommendations
|
||||||
|
- Improved documentation for AI-assisted development
|
||||||
|
- Moved Starter Prompt to the wiki for better organization
|
||||||
|
|
||||||
|
#### [0.1.2] - 2025-04-18
|
||||||
|
|
||||||
|
#### Added
|
||||||
|
|
||||||
|
- STARTER-PROMPT.md with comprehensive guide for customizing the template
|
||||||
|
- Additional AI workflow files for better development guidance
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- Updated documentation files with improved instructions
|
||||||
|
|
||||||
|
#### [0.1.1] - 2025-04-18
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- Updated LICENSE file with correct GPL-2.0 text
|
||||||
|
|
||||||
|
#### [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
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# Contributing to WP Plugin Starter
|
|
||||||
|
|
||||||
Thank you for helping. Bug reports, fixes and ideas are all welcome.
|
|
||||||
|
|
||||||
## Reporting a problem
|
|
||||||
|
|
||||||
Open an issue with the **Bug report** form. Include the versions, the steps
|
|
||||||
and any messages from `wp-content/debug.log`. Security problems go through
|
|
||||||
`SECURITY.md`, never a public issue.
|
|
||||||
|
|
||||||
## Suggesting a feature
|
|
||||||
|
|
||||||
Open an issue with the **Feature request** form before writing code. Each
|
|
||||||
setting makes a choice for the plugin's users, so a new one has to earn its
|
|
||||||
place: say what the feature does on its own and what problem it solves.
|
|
||||||
|
|
||||||
## Pull requests
|
|
||||||
|
|
||||||
1. Read `STANDARDS.md` (how features, settings, migrations and front-end
|
|
||||||
styles work, the code rules and testing), `AGENTS.md` (what is this
|
|
||||||
plugin's own) and `DEVELOPMENT.md` (set-up and checks).
|
|
||||||
2. Keep each pull request to one change. Features are off by default.
|
|
||||||
3. Run `scripts/lint.sh` and fix what it finds in the code.
|
|
||||||
4. Test on a real WordPress site, including WordPress 6.2 with PHP 7.4 if
|
|
||||||
you use a core function, and Kadence light and dark mode if you change
|
|
||||||
front-end styles.
|
|
||||||
5. Add a line to the changelogs: `README.md` (details), `changelog.txt`
|
|
||||||
(for users) and `readme.txt` (one short line).
|
|
||||||
|
|
||||||
CI runs the checks on every pull request. Write the pull request description
|
|
||||||
so a reviewer knows what changed, why, and how you tested it.
|
|
||||||
|
|
||||||
## Licence
|
|
||||||
|
|
||||||
WP Plugin Starter is GPL-2.0-or-later. By contributing, you agree your work is
|
|
||||||
released under the same licence.
|
|
||||||
-206
@@ -1,206 +0,0 @@
|
|||||||
# Development
|
|
||||||
|
|
||||||
How changes are made and checked in every plugin made from the wpallstars
|
|
||||||
starter plugin. This file is the same in each of them (names as
|
|
||||||
placeholders: `STANDARDS.md` lists them, and the plugin's `AGENTS.md` gives
|
|
||||||
its values). Rules for features, code, styling and testing: `STANDARDS.md`;
|
|
||||||
the plugin's own rules: `AGENTS.md`. Releases: `RELEASING.md`.
|
|
||||||
|
|
||||||
## Workflow
|
|
||||||
|
|
||||||
1. Open or pick an issue that says what should change and how to check it.
|
|
||||||
2. Work on a branch in its own worktree, never on `main`. Branch names:
|
|
||||||
`feature/…`, `bugfix/…`, `chore/…`.
|
|
||||||
3. Commit small, working steps. Run `scripts/lint.sh` before pushing.
|
|
||||||
4. Push and open a pull request (`Resolves #N`). Open it as a draft while
|
|
||||||
the work is in progress: CI lints every push, and the longer release and
|
|
||||||
smoke-test jobs start when the pull request is marked ready for review.
|
|
||||||
5. Check the change on the shared preview site (`scripts/preview-site.sh`,
|
|
||||||
`STANDARDS.md` → Testing), in light and dark mode for front-end styles.
|
|
||||||
6. Merge once CI passes. Releases are separate: `RELEASING.md`.
|
|
||||||
|
|
||||||
## Set up
|
|
||||||
|
|
||||||
Needs PHP 7.4 or later, Composer 2, Node.js (syntax checks only),
|
|
||||||
ShellCheck and Docker (release checks and smoke test). actionlint is
|
|
||||||
optional locally; CI runs it.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
composer install
|
|
||||||
```
|
|
||||||
|
|
||||||
`composer.json` lists development tools only. The plugin has no Composer
|
|
||||||
dependencies, and `vendor/`, `composer.*`, the tool configuration and
|
|
||||||
`.github/` are left out of release zips (`.distignore`; the preflight fails
|
|
||||||
if one gets in).
|
|
||||||
|
|
||||||
## Checks
|
|
||||||
|
|
||||||
Every pull request and every push to `main` runs these in GitHub Actions
|
|
||||||
(`.github/workflows/ci.yml`). Each one runs the same way locally.
|
|
||||||
|
|
||||||
| Check | Command | What it finds |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| PHP syntax | `scripts/lint.sh php` | Syntax errors; CI uses PHP 7.4, the minimum. |
|
|
||||||
| JavaScript syntax | `scripts/lint.sh js` | Syntax errors (`node --check`). |
|
|
||||||
| Shell scripts | `scripts/lint.sh shell` | ShellCheck findings in `scripts/`. |
|
|
||||||
| Workflows | `scripts/lint.sh workflows` | actionlint findings in `.github/workflows/`. |
|
|
||||||
| Coding standards | `scripts/lint.sh phpcs` | WordPress Coding Standards: escaping, sanitising, nonces, prepared SQL, i18n, PHP 7.4 and WordPress 6.2 compatibility (`phpcs.xml.dist`). |
|
|
||||||
| Static analysis | `scripts/lint.sh phpstan` | Unknown functions, classes and methods, wrong argument counts and types, dead code (PHPStan level 5, `phpstan.neon.dist`). |
|
|
||||||
| Release build | `scripts/preflight-release.sh --offline` | Versions, headers, `readme.txt`, presets (where the plugin has them) and the contents of both zips. |
|
|
||||||
| Plugin Check | `scripts/plugin-check.sh` | The WordPress.org review tool, on both zips. |
|
|
||||||
| Smoke test | `scripts/smoke-test.sh --wp 6.2 --php 7.4` and `scripts/smoke-test.sh` | Installs the GitHub zip, loads the site and admin screens with default settings and with every feature on, runs cron, uninstalls. Fails on any PHP message, a failed page or leftover options. |
|
|
||||||
|
|
||||||
`scripts/lint.sh` with no arguments runs the first six.
|
|
||||||
|
|
||||||
The scripts work out which plugin they are in from its main file
|
|
||||||
(`scripts/lib/plugin.sh`): the PHP file at the top of the repository with a
|
|
||||||
`Plugin Name:` header gives the slug (its file name), the name, the class
|
|
||||||
prefix (`@package`) and the constant prefix (`define('<PREFIX>_VERSION', …)`).
|
|
||||||
Environment overrides use that prefix, for example
|
|
||||||
`{PREFIX}_PREVIEW_SITE` or `{PREFIX}_DB_IMAGE`. Checks for parts only some
|
|
||||||
plugins have (presets and starter data, the replaced plugins count) run
|
|
||||||
when their files exist, so the same scripts serve every plugin made from the
|
|
||||||
starter.
|
|
||||||
|
|
||||||
### Coding standards
|
|
||||||
|
|
||||||
`phpcs.xml.dist` uses the WordPress ruleset. The plugin's own style
|
|
||||||
differs from it in a few places (spacing, `array()`, file names, Yoda
|
|
||||||
conditions), and those sniffs are off; the comments in the file say why.
|
|
||||||
Security, database and compatibility sniffs stay on. Fix findings in the
|
|
||||||
code. Where a finding is intended, add an inline
|
|
||||||
`// phpcs:ignore Sniff.Name -- reason` on that line only.
|
|
||||||
|
|
||||||
`vendor/bin/phpcbf` fixes what it can automatically.
|
|
||||||
|
|
||||||
### Static analysis
|
|
||||||
|
|
||||||
PHPStan reads the code with WordPress's stubs and PHP 7.4's functions.
|
|
||||||
`scripts/phpstan-bootstrap.php` defines the constants WordPress and the
|
|
||||||
plugin set while loading. Classes and functions of other plugins the code
|
|
||||||
uses (WP-CLI, WooCommerce and the like) are ignored in `phpstan-plugin.neon`,
|
|
||||||
because the code uses them only after checking they are loaded.
|
|
||||||
|
|
||||||
`phpstan-baseline.neon` is empty: every finding fails the check. Fix the
|
|
||||||
code. Where PHPStan or the stubs are wrong (a custom `wp_hash()` scheme, a
|
|
||||||
check for a method newer WordPress versions have, variables a closure
|
|
||||||
changes by reference), add an entry under `ignoreErrors` with the
|
|
||||||
identifier, the file and the reason: in `phpstan.neon.dist` for the files
|
|
||||||
every plugin made from the starter shares, in `phpstan-plugin.neon` for the
|
|
||||||
plugin's own files and extra paths. Never put findings in the baseline to
|
|
||||||
get a change through.
|
|
||||||
|
|
||||||
### Secrets in history
|
|
||||||
|
|
||||||
Scan the whole Git history before the repository goes public, and after
|
|
||||||
importing code from elsewhere:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --rm -v "$PWD:/repo:ro" ghcr.io/gitleaks/gitleaks:latest git /repo --redact --no-banner
|
|
||||||
```
|
|
||||||
|
|
||||||
In a linked worktree, also mount the main repository's `.git` folder at
|
|
||||||
the same path. `.gitleaks.toml` lists the false positives with reasons. A
|
|
||||||
real secret is rotated first, then removed from history.
|
|
||||||
|
|
||||||
### Smoke test
|
|
||||||
|
|
||||||
`scripts/smoke-test.sh` starts a throwaway WordPress in Docker (MariaDB,
|
|
||||||
Apache and WP-CLI images for the chosen PHP version), so nothing touches
|
|
||||||
the shared preview site. CI runs it on WordPress 6.2 with PHP 7.4 and on
|
|
||||||
the latest WordPress with PHP 8.3. Every feature with an on/off setting is
|
|
||||||
switched on at once, except one with the key `maintenance` (a maintenance
|
|
||||||
mode would answer every visitor page with its notice). `--keep-log FILE` saves `debug.log`; CI keeps it as an artifact
|
|
||||||
when the test fails.
|
|
||||||
|
|
||||||
## Test site resources
|
|
||||||
|
|
||||||
Test sites run the plugin alongside many others (a plugin that recommends
|
|
||||||
plugins is tested with all of them active). PHP's defaults are too small for that: OPcache fills
|
|
||||||
and restarts, admin requests queue behind two workers, and the slowdowns
|
|
||||||
look like bugs. Size every test site, shared or throwaway, with room to
|
|
||||||
spare:
|
|
||||||
|
|
||||||
| Setting | Where (LocalWP, nginx) | Value | PHP or Local default |
|
|
||||||
|---|---|---|---|
|
|
||||||
| `opcache.memory_consumption` | `conf/php/php.ini.hbs` | `1024` | 128 |
|
|
||||||
| `opcache.interned_strings_buffer` | `conf/php/php.ini.hbs` | `64` | 8 |
|
|
||||||
| `opcache.max_accelerated_files` | `conf/php/php.ini.hbs` | `50000` | 10000 |
|
|
||||||
| `memory_limit` | `conf/php/php.ini.hbs` | `768M` | 256M |
|
|
||||||
| `pm.max_children` | `conf/php/php-fpm.d/www.conf.hbs` | `5` | 2 |
|
|
||||||
|
|
||||||
Measured on a shared test site with 72 plugins installed: OPcache used
|
|
||||||
509 MB of 512 MB and restarted, then 315 MB of 1 GB with 31,723 PHP files
|
|
||||||
cached; pages peaked at 352 MB of memory; the busiest hour needed 5 workers.
|
|
||||||
|
|
||||||
- LocalWP keeps these per site in `<site>/conf/`. Edit the `.hbs`
|
|
||||||
templates, not the generated files under Local's `run/` folder, then
|
|
||||||
stop and start the site in Local: it rebuilds the configuration only on
|
|
||||||
start. Add a comment with the date and reason next to each change.
|
|
||||||
- The OPcache lines sit inside `{{#unless apache}}`: on an Apache site,
|
|
||||||
move them out or set them in Apache's own configuration.
|
|
||||||
- Check after the restart: Site Health → Info → Server shows the new values.
|
|
||||||
- Raise them again when a site needs more, and update this table in the
|
|
||||||
starter.
|
|
||||||
- To test low-resource warnings, lower a value on a throwaway site, never
|
|
||||||
the shared one.
|
|
||||||
- Docker sites (`scripts/smoke-test.sh`, step 4 in `STANDARDS.md` →
|
|
||||||
Testing) take the same values in a `.ini` file mounted into
|
|
||||||
`/usr/local/etc/php/conf.d/`.
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
Dependabot (`.github/dependabot.yml`) opens one pull request a week for
|
|
||||||
the GitHub Actions and one for the Composer tools. Actions are pinned to
|
|
||||||
commit SHAs with the version in a comment; keep it that way when editing
|
|
||||||
workflows. Do not add third-party actions that only save a few lines of
|
|
||||||
shell.
|
|
||||||
|
|
||||||
## While private: checks are advisory
|
|
||||||
|
|
||||||
The repository is private until it is released, so Actions minutes cost
|
|
||||||
money and most code-review services are paid. Until then, work moves fast:
|
|
||||||
|
|
||||||
- No branch protection or required checks on `main`. A failing check does
|
|
||||||
not block a merge, so a merge never waits on an unrelated failure.
|
|
||||||
- Fix any failure your change causes before merging. For a failure your
|
|
||||||
change did not cause, open an issue with the run link and the first error,
|
|
||||||
and merge anyway.
|
|
||||||
- Draft pull requests run only the lint job. A new push cancels the run for
|
|
||||||
the previous one.
|
|
||||||
- The build zips and Plugin Check reports are kept for seven days on each
|
|
||||||
run (artifact `<repository>-build-…`) for testing a branch on a site.
|
|
||||||
- Review apps that are already installed (CodeRabbit, qlty, Socket) give
|
|
||||||
advice only. A rate-limited or missing review never holds up a merge.
|
|
||||||
|
|
||||||
## At public launch: full sweep
|
|
||||||
|
|
||||||
Making the repository public needs the owner's say. Do this sweep in the
|
|
||||||
same step, while the code-review services are free for
|
|
||||||
public repositories. It goes through the whole codebase once, then keeps
|
|
||||||
it at that standard:
|
|
||||||
|
|
||||||
1. Turn on the free reviewers for the whole codebase, not just new
|
|
||||||
changes: CodeRabbit full review, Codacy, SonarCloud (SonarQube Cloud)
|
|
||||||
and qlty, plus GitHub's CodeQL (PHP and JavaScript), Dependabot
|
|
||||||
security alerts, secret scanning with push protection, and OpenSSF
|
|
||||||
Scorecard. Socket keeps checking dependencies.
|
|
||||||
2. Fix what they find in the code, in small pull requests by area
|
|
||||||
(security first). Each finding is either fixed, explained in an inline
|
|
||||||
comment, or marked as a false positive in that service with the reason.
|
|
||||||
3. Raise the PHPStan level one step at a time (6, then higher if the
|
|
||||||
findings are real bugs and not noise). The baseline is already empty.
|
|
||||||
4. Require the CI checks on `main` (Lint, Release build, both Smoke
|
|
||||||
tests) with a branch ruleset, without "branch must be up to date": the
|
|
||||||
checks are fast, and changelog lines conflict on every merge.
|
|
||||||
5. Turn on private vulnerability reporting (Settings → Security), which
|
|
||||||
`SECURITY.md` asks reporters to use, and add the CI badge to
|
|
||||||
`README.md`. `SECURITY.md`, `CONTRIBUTING.md` and the issue and pull
|
|
||||||
request templates are already in place.
|
|
||||||
6. Run `workflows/public-launch-checklist.md` from the AI DevOps framework
|
|
||||||
for anything public: no private paths, site names or secrets in the code,
|
|
||||||
history, issues or docs. Run the history scan above again for commits
|
|
||||||
made since the last one.
|
|
||||||
|
|
||||||
What a plugin has already done ahead of launch is in its `LAUNCH.md`.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# WP Plugin Starter — launch state
|
|
||||||
|
|
||||||
The starter is released on GitHub only. It is not meant for WordPress.org:
|
|
||||||
it has no features, and plugins made from it are submitted under their own
|
|
||||||
names. `RELEASING.md` → WordPress.org applies to those plugins, each with its
|
|
||||||
own `LAUNCH.md`.
|
|
||||||
|
|
||||||
`scripts/preflight-release.sh` and `scripts/plugin-check.sh` still run on
|
|
||||||
every release, so the core files stay ready for a plugin's submission.
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# Add Comprehensive Testing Framework for Single Site and Multisite
|
||||||
|
|
||||||
|
This PR adds a comprehensive testing framework for our WordPress plugin template.
|
||||||
|
|
||||||
|
It allows testing in both single site and multisite WordPress environments.
|
||||||
|
|
||||||
|
The focus is purely on testing functionality, not on adding multisite-specific features.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
* Added wp-env configuration for both single site and multisite environments
|
||||||
|
* Created Cypress e2e tests for both environments
|
||||||
|
* Added GitHub Actions workflow to run tests automatically on PRs
|
||||||
|
* Created a unified setup script for test environments
|
||||||
|
* Added detailed documentation in the wiki
|
||||||
|
* Updated README.md to reference the new testing approach
|
||||||
|
* Added placeholder files for multisite functionality
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
The testing framework can be used as follows:
|
||||||
|
|
||||||
|
### Single Site Testing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Set up single site environment
|
||||||
|
npm run setup:single
|
||||||
|
|
||||||
|
# Run tests in interactive mode
|
||||||
|
npm run test:single
|
||||||
|
|
||||||
|
# Run tests in headless mode
|
||||||
|
npm run test:single:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multisite Testing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Set up multisite environment
|
||||||
|
npm run setup:multisite
|
||||||
|
|
||||||
|
# Run tests in interactive mode
|
||||||
|
npm run test:multisite
|
||||||
|
|
||||||
|
# Run tests in headless mode
|
||||||
|
npm run test:multisite:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Detailed documentation is available in the [Testing Framework](.wiki/Testing-Framework.md) wiki page.
|
||||||
|
|
||||||
|
## Inspiration
|
||||||
|
|
||||||
|
This implementation was inspired by the e2e testing approach in
|
||||||
|
[wp-multisite-waas issue #55](https://github.com/superdav42/wp-multisite-waas/issues/55).
|
||||||
|
|
||||||
|
It focuses on testing our plugin in different WordPress environments.
|
||||||
|
|
||||||
|
It does not add domain mapping or other multisite-specific functionality from that plugin.
|
||||||
@@ -1,108 +1,606 @@
|
|||||||

|
# WordPress Plugin Starter Template for AI Coding
|
||||||
|
|
||||||
# WP Plugin Starter
|
[](https://www.gnu.org/licenses/gpl-2.0.html) [](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/actions/workflows/tests.yml) [](https://wordpress.org/about/requirements/) [](https://wordpress.org/about/requirements/) [](https://wordpress.org/plugins/your-plugin-slug/) [](https://wordpress.org/plugins/your-plugin-slug/reviews/) [](https://wordpress.org/plugins/your-plugin-slug/) [](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/releases) [](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) [](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/graphs/contributors) [](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/wiki)  [](https://www.codefactor.io/repository/github/wpallstars/wp-plugin-starter-template-for-ai-coding) [](https://sonarcloud.io/summary/new_code?id=wpallstars_wp-plugin-starter-template-for-ai-coding) [](https://sonarcloud.io/summary/new_code?id=wpallstars_wp-plugin-starter-template-for-ai-coding) [](https://sonarcloud.io/summary/new_code?id=wpallstars_wp-plugin-starter-template-for-ai-coding) [](https://sonarcloud.io/summary/new_code?id=wpallstars_wp-plugin-starter-template-for-ai-coding) [](https://sonarcloud.io/summary/new_code?id=wpallstars_wp-plugin-starter-template-for-ai-coding) [](https://app.codacy.com/gh/wpallstars/wp-plugin-starter-template-for-ai-coding/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||||
|
|
||||||
A clean start for a WordPress plugin: a settings screen, a Read Me tab, updates from GitHub and release scripts, ready for your features.
|
A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.
|
||||||
|
|
||||||
WP Plugin Starter is what wpallstars plugins are made from. It has no features of its own: it holds the parts every plugin needs, built and tested in real plugins, so a new plugin starts with them working and spends its time on what makes it different.
|
## Description
|
||||||
|
|
||||||
If this saves you time, headaches and costs, feel free to [buy me a coffee](https://buymeacoffee.com/marcusquinn), or whatever you like, to invest in making more things open-source.
|
The WordPress Plugin Starter Template provides a solid foundation for developing WordPress plugins.
|
||||||
|
|
||||||
Version: {WPSTARTER_VERSION}
|
It incorporates best practices, modern coding standards, and a comprehensive structure.
|
||||||
|
|
||||||
## What you get
|
This template is based on experience from developing successful WordPress plugins.
|
||||||
|
|
||||||
- **A settings screen** (Settings → WP Plugin Starter) that features fill by declaring their settings: switches, numbers, text, lists, choices and Media Library pictures, saved instantly with no Save button, searchable, in tabs. With no features yet it shows one empty tab.
|
### Key Features
|
||||||
- **A Read Me tab** that shows this file, banner included, so users read the same guide inside WordPress as on GitHub.
|
|
||||||
- **Features as classes**: one file per feature, off by default, with settings, hooks, one-off imports from the plugins it replaces and clean uninstall.
|
|
||||||
- **Replaced plugins**: a feature that does another plugin's job imports its settings once, waits while that plugin is active, and the Plugins screen suggests deactivating and deleting it.
|
|
||||||
- **Updates from GitHub**: the shared wpallstars updater (`includes/github-updater/`). Sites get each GitHub release as a normal WordPress update. Every wpallstars plugin carries a copy and only the newest copy on a site runs, so they are all checked together, once.
|
|
||||||
- **Two builds of each version**: the GitHub release, and a WordPress.org build without the updater, as WordPress.org requires.
|
|
||||||
- **Scripts and CI**: lint (PHP 7.4, WordPress coding and security rules, PHPStan), a smoke test on a real WordPress, the release build, a preflight check of both zips, Plugin Check, a preview site, the banner build, and `scripts/sync-core.sh` to keep each plugin's shared parts the same as the starter's.
|
|
||||||
- **Shared rules for people and AI**: `STANDARDS.md` (structure, code rules, releases, styling, testing), `DEVELOPMENT.md` (set-up and checks) and `RELEASING.md`, the same in every plugin made from the starter.
|
|
||||||
|
|
||||||
## Start a plugin
|
* **Object-Oriented Architecture**: Well-structured, maintainable code using OOP principles
|
||||||
|
* **Namespace Support**: Modern PHP namespacing for better organization and avoiding conflicts
|
||||||
|
* **Comprehensive Documentation**: Detailed documentation for both users and developers
|
||||||
|
* **Testing Framework**: PHPUnit setup for unit testing and Cypress for e2e testing
|
||||||
|
* **Internationalization Ready**: Full support for translation and localization
|
||||||
|
* **Update Source Selection**: Choose between WordPress.org, GitHub, or Gitea for plugin updates
|
||||||
|
* **AI Workflow Documentation**: Detailed guides for AI-assisted development
|
||||||
|
* **Wiki Documentation**: Ready-to-use wiki structure for comprehensive documentation
|
||||||
|
* **Multisite Compatible**: Fully tested and compatible with WordPress multisite installations
|
||||||
|
|
||||||
1. On GitHub, choose **Use this template** to make your repository, and clone it.
|
### How to Use This Template
|
||||||
2. Give it its names: `scripts/rename-plugin.sh --slug my-plugin --name "My Plugin" --prefix MyPlugin`. Add `--css mp` for a short CSS prefix and `--repo owner/repo` if it is not under wpallstars. Review with `git diff`, then commit.
|
|
||||||
3. Replace this README, `readme.txt`, `changelog.txt` and `AGENTS.md` with your plugin's own, and its banner (`.wordpress-org/banner.svg`, then `scripts/build-banner.sh`).
|
|
||||||
4. Add features: a class in `includes/features/` listed in `MyPlugin_Setup::FEATURES` (see Developers below and `STANDARDS.md`).
|
|
||||||
5. Keep the shared parts up to date: change them in the starter first, then run `scripts/sync-core.sh` in each plugin (`--check` lists what differs).
|
|
||||||
|
|
||||||
The easiest way to do all of this is with [aidevops](https://aidevops.sh): open the repository with it and describe the plugin you want. It reads `AGENTS.md` and `STANDARDS.md`, builds the features, tests them on a real site and runs the release checks.
|
1. Clone or download this repository
|
||||||
|
2. **Important**: Begin by reading the [Starter Prompt](.wiki/Starter-Prompt.md) file for detailed instructions
|
||||||
|
3. Add the AGENTS.md file and .agents/ directory to your AI IDE chat context (pin them if possible)
|
||||||
|
4. Use the prompt in the Starter Prompt file to guide the AI in customizing the template for your plugin
|
||||||
|
5. Rename files and update namespaces to match your plugin
|
||||||
|
6. Customize the functionality for your specific needs
|
||||||
|
7. Update documentation to reflect your plugin's features
|
||||||
|
8. Build and test your plugin
|
||||||
|
|
||||||
## Where to find it
|
### AI-Assisted Development
|
||||||
|
|
||||||
Go to **Settings → WP Plugin Starter**. The screen has two groups of tabs:
|
This template includes comprehensive documentation for AI-assisted development:
|
||||||
|
|
||||||
- **Settings**: General, empty until features add settings. Changes save instantly; there is no Save button. **Search features** (next to the plugin name) finds settings on every tab.
|
* **AGENTS.md**: Guide for AI assistants to understand the project structure
|
||||||
- **About**: this Read Me.
|
* **.agents/**: Detailed workflow documentation for common development tasks
|
||||||
|
* **Starter Prompt**: Prompt for AI tools to customize the template ([wiki](.wiki/Starter-Prompt.md))
|
||||||
|
|
||||||
**Report a problem**, at the top right of the screen, opens the plugin’s [GitHub issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues) in a new tab. Say what you did, what you expected and what happened, with the versions of WordPress, PHP and WP Plugin Starter. Leave out passwords, licence keys and personal data, since issues are public. **Buy me a coffee**, next to it, opens the maker’s [Buy Me a Coffee](https://buymeacoffee.com/marcusquinn) page in a new tab.
|
**Important**: For the best AI assistance, add AGENTS.md and .agents/ to your AI IDE chat context.
|
||||||
|
|
||||||
## Requirements
|
In most AI IDEs, you can pin these files to ensure they're considered in each message.
|
||||||
|
|
||||||
- WordPress 6.2 or later
|
## Installation
|
||||||
- PHP 7.4 or later
|
|
||||||
|
|
||||||
## Updates and releases
|
1. Clone or download this repository
|
||||||
|
2. Read the [Starter Prompt](.wiki/Starter-Prompt.md) file for detailed instructions
|
||||||
|
3. Add the AGENTS.md file and .agents/ directory to your AI IDE chat context
|
||||||
|
4. Use the prompt in the Starter Prompt file to guide the AI in customizing the template
|
||||||
|
5. Rename files and update namespaces to match your plugin
|
||||||
|
6. Customize the functionality for your specific needs
|
||||||
|
7. Update documentation to reflect your plugin's features
|
||||||
|
8. Build and test your plugin
|
||||||
|
|
||||||
There are two builds of each version:
|
## Usage
|
||||||
|
|
||||||
- **GitHub release** (`wp-plugin-starter-template-X.Y.Z.zip` on the repository’s Releases page): everything, including the shared updater in `includes/github-updater/`, so sites get each release as a normal update.
|
### Getting Started
|
||||||
- **WordPress.org**: the same files without the updater (listed in `.distignore-wporg`) and without the `GitHub Plugin URI`, `Primary Branch` and `Release Asset` header lines, because plugins hosted there may not install or update code from elsewhere.
|
|
||||||
|
|
||||||
The updater waits while Git Updater is active, so the two never both update a plugin.
|
To get started with this template, follow these steps:
|
||||||
|
|
||||||
Releasing on GitHub:
|
1. In your terminal, navigate to the folder you keep you Git repositories (eg: `~/Git/`), then clone this repository to your local machine:
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git
|
||||||
|
```
|
||||||
|
|
||||||
1. Merge the version change (`Version:` and `WPSTARTER_VERSION` in `wp-plugin-starter-template.php`, `Stable tag:` in `readme.txt`) to `main`.
|
2. Open the [Starter Prompt](.wiki/Starter-Prompt.md) file and follow the instructions to customize the template for your plugin.
|
||||||
2. Straight away, tag that commit `vX.Y.Z` and publish a GitHub release with `wp-plugin-starter-template-X.Y.Z.zip` attached. `scripts/build-release.sh --ref vX.Y.Z` builds it (and the WordPress.org zip) from the tag with `.distignore` applied, everything inside a `wp-plugin-starter-template/` folder; `scripts/preflight-release.sh` and `scripts/plugin-check.sh` check them first. Sites pick the latest release whose tag is a plain version number and the asset whose name starts with `wp-plugin-starter-template`, so never attach the WordPress.org zip. Full steps: `RELEASING.md`.
|
|
||||||
3. Sites offer the update when they next check (within 12 hours, or at once with **Check again** on the Updates screen).
|
|
||||||
|
|
||||||
Mark test builds as pre-releases on GitHub (or tag them with letters, such as `v1.2.0-rc1`): sites never offer those. Do not add an `Update URI` header: WordPress.org rejects it, and Plugin Check reports it as an updater.
|
3. Add the AGENTS.md file and .agents/ directory to your AI IDE chat context.
|
||||||
|
|
||||||
|
4. Use an AI assistant like GitHub Copilot, Claude, or ChatGPT to help you customize the template by providing the prompt from the Starter Prompt file.
|
||||||
|
|
||||||
|
### Development Environment
|
||||||
|
|
||||||
|
This template includes configuration for WordPress Environment (wp-env) to make local development easier:
|
||||||
|
|
||||||
|
1. Install Node.js dependencies:
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Start the WordPress environment:
|
||||||
|
```bash
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
3. For testing in different WordPress environments:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For single site testing
|
||||||
|
npm run setup:single
|
||||||
|
|
||||||
|
# For multisite testing
|
||||||
|
npm run setup:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
See [Testing Framework](.wiki/Testing-Framework.md) for more details on our testing approach.
|
||||||
|
|
||||||
|
4. Access your local WordPress site at <http://localhost:8888> (admin credentials: admin/password)
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
The template includes multiple testing approaches:
|
||||||
|
|
||||||
|
#### WordPress Playground Testing (No Docker Required)
|
||||||
|
|
||||||
|
Test your plugin directly in the browser without any local setup:
|
||||||
|
|
||||||
|
1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=5)
|
||||||
|
|
||||||
|
2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=18)
|
||||||
|
|
||||||
|
For more details, see the [Playground Testing](.wiki/Playground-Testing.md) documentation.
|
||||||
|
|
||||||
|
#### PHP Unit Tests
|
||||||
|
|
||||||
|
1. Install Composer dependencies:
|
||||||
|
```bash
|
||||||
|
composer install
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run PHP unit tests:
|
||||||
|
```bash
|
||||||
|
npm run test:php
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Check PHP coding standards:
|
||||||
|
```bash
|
||||||
|
npm run lint:php
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Fix PHP coding standards issues:
|
||||||
|
```bash
|
||||||
|
npm run fix:php
|
||||||
|
```
|
||||||
|
|
||||||
|
#### End-to-End Tests
|
||||||
|
|
||||||
|
1. Start the WordPress environment:
|
||||||
|
```bash
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run Cypress tests in interactive mode:
|
||||||
|
```bash
|
||||||
|
npm run test:e2e
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run Cypress tests in headless mode:
|
||||||
|
```bash
|
||||||
|
npm run test:e2e:headless
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building for Production
|
||||||
|
|
||||||
|
Use the included build script to create a deployable version of your plugin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Or directly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build.sh {VERSION}
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a ZIP file that you can install in WordPress.
|
||||||
|
|
||||||
|
### Using with Git Updater
|
||||||
|
|
||||||
|
If you've installed this plugin from GitHub or Gitea, you'll need Git Updater to receive updates:
|
||||||
|
|
||||||
|
1. Install the Git Updater plugin from [git-updater.com/git-updater/](https://git-updater.com/git-updater/)
|
||||||
|
2. Go to Settings > Git Updater > Remote Management
|
||||||
|
3. Click the "Refresh Cache" button to ensure Git Updater recognizes the latest version
|
||||||
|
4. Updates will now appear in your WordPress dashboard when available
|
||||||
|
|
||||||
|
### Choosing Your Update Source
|
||||||
|
|
||||||
|
This template includes functionality that allows users to choose where they want to receive updates from:
|
||||||
|
|
||||||
|
1. In the Plugins list, find your plugin
|
||||||
|
2. Click the "Update Source" link next to the plugin
|
||||||
|
3. Select your preferred update source:
|
||||||
|
* **WordPress.org**: Updates from the official WordPress.org repository
|
||||||
|
* **GitHub**: Updates directly from the GitHub repo
|
||||||
|
* **Gitea**: Updates directly from the Gitea repo
|
||||||
|
4. Click "Save" to apply your preference
|
||||||
|
|
||||||
|
## Frequently Asked Questions
|
||||||
|
|
||||||
|
### How do I customize this template for my plugin?
|
||||||
|
|
||||||
|
See the [Starter Prompt](.wiki/Starter-Prompt.md) file for detailed instructions on customizing this template for your specific plugin needs. Make sure to add the AGENTS.md file and .agents/ directory to your AI IDE chat context for the best results.
|
||||||
|
|
||||||
|
### What files do I need to update with my plugin information?
|
||||||
|
|
||||||
|
The main files you need to update include:
|
||||||
|
|
||||||
|
1. Main plugin file (rename and update header)
|
||||||
|
2. README.md
|
||||||
|
3. readme.txt
|
||||||
|
4. CHANGELOG.md
|
||||||
|
5. composer.json
|
||||||
|
6. package.json
|
||||||
|
7. languages/pot file
|
||||||
|
8. .github/workflows/
|
||||||
|
9. .wiki/
|
||||||
|
10. AGENTS.md
|
||||||
|
11. includes/plugin.php
|
||||||
|
12. includes/core.php
|
||||||
|
13. admin/lib/admin.php
|
||||||
|
|
||||||
|
### How do I build and test my plugin?
|
||||||
|
|
||||||
|
Use the included build.sh script to create a deployable version of your plugin:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build.sh {VERSION}
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create a ZIP file that you can install in WordPress.
|
||||||
|
|
||||||
|
### How do I add custom functionality to my plugin?
|
||||||
|
|
||||||
|
Customize the includes/core.php file to implement your core functionality and the admin/lib/admin.php file for admin-specific functionality.
|
||||||
|
|
||||||
|
### Is this template compatible with WordPress multisite?
|
||||||
|
|
||||||
|
Yes, this template is fully compatible with WordPress multisite installations.
|
||||||
|
|
||||||
|
We have a testing framework that allows you to verify functionality in both environments.
|
||||||
|
|
||||||
|
You can test multisite compatibility in two ways:
|
||||||
|
|
||||||
|
1. Using WordPress Playground (no Docker required):
|
||||||
|
* [Open Multisite in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=18)
|
||||||
|
|
||||||
|
2. Using wp-env (requires Docker):
|
||||||
|
```bash
|
||||||
|
npm run setup:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
For more details on our testing approach, see the [Testing Framework](.wiki/Testing-Framework.md)
|
||||||
|
and [Playground Testing](.wiki/Playground-Testing.md) documentation.
|
||||||
|
|
||||||
|
## Support & Feedback
|
||||||
|
|
||||||
|
If you need help with this template, there are several ways to get support:
|
||||||
|
|
||||||
|
* [GitHub Issues](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
|
||||||
|
* [Gitea Issues](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||||
|
|
||||||
|
1. Fork the repository on [GitHub](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/) or [Gitea](https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding/)
|
||||||
|
2. Create your feature branch: `git checkout -b feature/amazing-feature`
|
||||||
|
3. Commit your changes: `git commit -m 'Add some amazing feature'`
|
||||||
|
4. Push to the branch: `git push origin feature/amazing-feature`
|
||||||
|
5. Submit a pull request
|
||||||
|
|
||||||
|
For more detailed information, see the [Contributing Guide](.wiki/Contributing.md).
|
||||||
|
|
||||||
|
### Code Quality Tools
|
||||||
|
|
||||||
|
This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and should be integrated into any new repositories based on this template:
|
||||||
|
|
||||||
|
1. **CodeRabbit**: AI-powered code review tool
|
||||||
|
* [Website](https://www.coderabbit.ai/)
|
||||||
|
* Provides automated feedback on pull requests
|
||||||
|
|
||||||
|
2. **CodeFactor**: Continuous code quality monitoring
|
||||||
|
* [Website](https://www.codefactor.io/)
|
||||||
|
* Provides a grade for your codebase
|
||||||
|
|
||||||
|
3. **Codacy**: Code quality and static analysis
|
||||||
|
* [Website](https://www.codacy.com/)
|
||||||
|
* Identifies issues related to code style, security, and performance
|
||||||
|
* Requires a `CODACY_PROJECT_TOKEN` secret in your GitHub repository settings
|
||||||
|
* To set up Codacy:
|
||||||
|
1. Go to [Codacy](https://www.codacy.com/) and sign in with your GitHub account
|
||||||
|
2. Add your repository to Codacy
|
||||||
|
3. Go to your project settings > Integrations > Project API
|
||||||
|
4. Generate a project API token
|
||||||
|
5. Add the token as a secret named `CODACY_PROJECT_TOKEN` in your GitHub repository settings
|
||||||
|
6. Note: Codacy tokens are project-specific, so they need to be added at the repository level. However, you can use GitHub Actions to securely pass these tokens between repositories if needed.
|
||||||
|
|
||||||
|
4. **SonarCloud**: Code quality and security analysis
|
||||||
|
* [Website](https://sonarcloud.io/)
|
||||||
|
* Provides detailed analysis of code quality and security
|
||||||
|
* Requires a `SONAR_TOKEN` secret in your GitHub repository settings
|
||||||
|
* To set up SonarCloud:
|
||||||
|
1. Go to [SonarCloud](https://sonarcloud.io/) and sign in with your GitHub account
|
||||||
|
2. Create a new organization or use an existing one
|
||||||
|
3. Add your repository to SonarCloud
|
||||||
|
4. Generate a token in SonarCloud (Account > Security > Tokens)
|
||||||
|
5. Add the token as a secret named `SONAR_TOKEN` in your GitHub repository or organization settings (see "GitHub Secrets Management" section below)
|
||||||
|
|
||||||
|
5. **PHP_CodeSniffer (PHPCS)**: PHP code style checker
|
||||||
|
* Enforces WordPress Coding Standards
|
||||||
|
* Automatically runs in GitHub Actions workflow
|
||||||
|
* Run locally with `composer phpcs`
|
||||||
|
|
||||||
|
6. **PHP Code Beautifier and Fixer (PHPCBF)**: Automatically fixes coding standard violations
|
||||||
|
* Run locally with `composer phpcbf`
|
||||||
|
|
||||||
|
7. **PHPStan**: PHP static analysis tool
|
||||||
|
* Detects bugs and errors without running the code
|
||||||
|
* Run locally with `composer phpstan`
|
||||||
|
|
||||||
|
8. **PHP Mess Detector (PHPMD)**: Analyzes code for potential problems
|
||||||
|
* Identifies complex code, unused parameters, etc.
|
||||||
|
* Run locally with `composer phpmd`
|
||||||
|
|
||||||
|
For detailed setup instructions, see the [Code Quality Setup Guide](docs/code-quality-setup.md).
|
||||||
|
|
||||||
|
### Using AI Assistants with Code Quality Tools
|
||||||
|
|
||||||
|
When you receive feedback from these code quality tools, you can use AI assistants to help address the issues:
|
||||||
|
|
||||||
|
1. Copy the output from the code quality tool
|
||||||
|
2. Paste it into your AI assistant chat
|
||||||
|
3. Ask the AI to help you understand and resolve the issues
|
||||||
|
4. Apply the suggested fixes
|
||||||
|
5. Commit the changes and verify that the issues are resolved
|
||||||
|
|
||||||
|
For more information on coding standards and how to pass code quality checks, see the [Coding Standards Guide](.wiki/Coding-Standards.md).
|
||||||
|
|
||||||
|
### GitHub Secrets Management
|
||||||
|
|
||||||
|
GitHub offers three levels of secrets management, each with different scopes and use cases:
|
||||||
|
|
||||||
|
1. **Organization Secrets** (recommended for teams and organizations):
|
||||||
|
* Available at: GitHub Organization > Settings > Secrets and variables > Actions
|
||||||
|
* Scope: Can be shared across multiple repositories within the organization
|
||||||
|
* Benefits: Centralized management, reduced duplication, easier rotation
|
||||||
|
* Recommended for: `SONAR_TOKEN` and other tokens that apply to multiple repositories
|
||||||
|
* Note: You can restrict which repositories can access organization secrets
|
||||||
|
* Note: Codacy tokens (`CODACY_PROJECT_TOKEN`) are project-specific and should be set at the repository level
|
||||||
|
|
||||||
|
2. **Repository Secrets**:
|
||||||
|
* Available at: Repository > Settings > Secrets and variables > Actions
|
||||||
|
* Scope: Limited to a single repository
|
||||||
|
* Benefits: Repository-specific, higher isolation
|
||||||
|
* Recommended for: `CODACY_PROJECT_TOKEN` and other repository-specific credentials or tokens that shouldn't be shared
|
||||||
|
|
||||||
|
3. **Environment Secrets**:
|
||||||
|
* Available at: Repository > Settings > Environments > (select environment) > Environment secrets
|
||||||
|
* Scope: Limited to specific deployment environments (e.g., production, staging)
|
||||||
|
* Benefits: Environment-specific, can have approval requirements
|
||||||
|
* Recommended for: Deployment credentials that vary between environments
|
||||||
|
|
||||||
|
For code quality tools like SonarCloud, organization secrets are recommended if you have multiple repositories that use these tools. This approach reduces management overhead and ensures consistent configuration across projects. For Codacy, since tokens are project-specific, they should be set at the repository level.
|
||||||
|
|
||||||
|
### Local Environment Setup for Code Quality Tools
|
||||||
|
|
||||||
|
To run code quality tools locally before committing to GitHub:
|
||||||
|
|
||||||
|
1. **Install dependencies**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer install
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Run PHP CodeSniffer**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpcs
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Fix coding standards automatically**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpcbf
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Run PHPStan static analysis**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpstan
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Run PHP Mess Detector**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer phpmd
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Run all linters at once**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer lint
|
||||||
|
```
|
||||||
|
|
||||||
|
7. **Set up environment variables for SonarCloud and Codacy**:
|
||||||
|
|
||||||
|
* **For macOS/Linux**:
|
||||||
|
```bash
|
||||||
|
export SONAR_TOKEN=your_sonar_token
|
||||||
|
export CODACY_PROJECT_TOKEN=your_codacy_token
|
||||||
|
```
|
||||||
|
|
||||||
|
* **For Windows (Command Prompt)**:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
set SONAR_TOKEN=your_sonar_token
|
||||||
|
set CODACY_PROJECT_TOKEN=your_codacy_token
|
||||||
|
```
|
||||||
|
|
||||||
|
* **For Windows (PowerShell)**:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:SONAR_TOKEN="your_sonar_token"
|
||||||
|
$env:CODACY_PROJECT_TOKEN="your_codacy_token"
|
||||||
|
```
|
||||||
|
|
||||||
|
8. **Create a .env file** (alternative approach):
|
||||||
|
|
||||||
|
```env
|
||||||
|
# .env (already included in .gitignore to prevent committing secrets)
|
||||||
|
SONAR_TOKEN=your_sonar_token
|
||||||
|
CODACY_PROJECT_TOKEN=your_codacy_token
|
||||||
|
```
|
||||||
|
|
||||||
|
Then load these variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using a tool like dotenv
|
||||||
|
source .env
|
||||||
|
```
|
||||||
|
|
||||||
|
9. **Run SonarCloud locally**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install SonarScanner
|
||||||
|
npm install -g sonarqube-scanner
|
||||||
|
|
||||||
|
# Run analysis
|
||||||
|
sonar-scanner \
|
||||||
|
-Dsonar.projectKey=your_project_key \
|
||||||
|
-Dsonar.organization=your_organization \
|
||||||
|
-Dsonar.sources=. \
|
||||||
|
-Dsonar.host.url=https://sonarcloud.io \
|
||||||
|
-Dsonar.login=$SONAR_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
10. **Run Codacy locally**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install Codacy CLI
|
||||||
|
npm install -g codacy-coverage
|
||||||
|
|
||||||
|
# Run analysis
|
||||||
|
codacy-analysis-cli analyze --directory . --project-token $CODACY_PROJECT_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
For more detailed instructions, see the [Code Quality Setup Guide](docs/code-quality-setup.md).
|
||||||
|
|
||||||
|
By running these tools locally, you can identify and fix issues before pushing your code to GitHub, ensuring smoother CI/CD workflows.
|
||||||
|
|
||||||
## Developers
|
## Developers
|
||||||
|
|
||||||
A feature is a class in `includes/features/class-wpstarter-{name}.php` that extends `WPStarter_Feature`, listed in `WPStarter_Setup::FEATURES`. It declares its settings in `settings()`, adds its hooks in `boot()` (returning early unless `self::enabled()`), and can import another plugin’s settings once in `migrate()` with `self::import_setting()`. Anything only this plugin needs goes in `WPStarter_Setup` (`includes/class-wpstarter-setup.php`): features, settings tabs, header links, settings version and its own helpers. The other files in `includes/` and `admin/` are the starter’s core files: `STANDARDS.md` → Structure.
|
### AI-Powered Development
|
||||||
|
|
||||||
Filters:
|
This repository is configured to work with various AI-powered development tools. You can use any of the following AI IDEs to contribute to this project:
|
||||||
|
|
||||||
- `wpstarter_features`: register a feature class that extends `WPStarter_Feature`.
|
* [Augment Code](https://www.augmentcode.com/) - AI-powered coding assistant
|
||||||
- `wpstarter_settings_schema`: add or change settings. Each entry sets `type` (bool, int, text, url, lines, domains, select, multi, times or media, a picture from the Media Library stored as its attachment ID), `default`, `label`, `description` and either `tab` or `parent`; select and multi also take `options` (an array or a callable), and multi takes `open` to keep saved values that are not currently registered. A child setting can take `hidden` (true): it is not shown or searched, for wiring that code sets. `reload` (true) makes the saved message ask to reload the page, for changes that show only after a page load. `replaces` (slug => name) shows which plugin a feature replaces. Settings render and save automatically.
|
* [Bolt](https://www.bolt.new/) - AI-powered code editor
|
||||||
- `wpstarter_admin_tabs`: add or reorder admin tabs. Each tab sets `label`, `group` (settings, discover or about), a `render` callback and an optional `capability`; tabs the current user lacks the capability for are hidden.
|
* [Cline](https://cline.bot/) - AI terminal assistant
|
||||||
- `wpstarter_admin_script_deps` and `wpstarter_admin_script_data`: the settings screen script’s dependencies and the data it reads as `wpstarterAdmin` (both with the active tab).
|
* [Cody](https://sourcegraph.com/cody) - Sourcegraph's AI coding assistant
|
||||||
- `wpstarter_can_change_settings`: return false to stop the current user changing WP Plugin Starter’s settings (on top of `manage_options`).
|
* [Continue](https://continue.dev/) - Open-source AI coding assistant
|
||||||
- `wpstarter_replaced_plugin_extras`: what a replaced plugin does on this site that WP Plugin Starter does not (plain names, plugin folder). The Plugins screen names them instead of saying the plugin can go.
|
* [Cursor](https://cursor.com/) - AI-first code editor
|
||||||
- `wpstarter_stored_active_plugins` and `wpstarter_plugins_skipped`: for code that skips plugins on some requests, the active plugin files as stored and whether some are skipped on this request, so features still count those plugins as active.
|
* [Loveable](https://lovable.dev/) - AI development environment
|
||||||
- `wpallstars_github_plugins` (GitHub builds, shared updater): change which plugins update from GitHub releases (plugin file => `repo` as owner/repo, `asset_only`, `version`, `name`).
|
* [Roo Code](https://roocode.com/) - AI pair programmer
|
||||||
- `wpallstars_github_token` (GitHub builds, shared updater): GitHub token for a repository (token, owner/repo), for private repositories; defaults to the `WPALLSTARS_GITHUB_TOKEN` constant.
|
* [v0](https://v0.dev/) - AI-powered design and development tool
|
||||||
- `wpallstars_github_updater_enabled` and `wpallstars_github_updater_early` (GitHub builds, shared updater): whether it runs (false while Git Updater is active) and whether plugins also on WordPress.org take GitHub releases first.
|
* [Windsurf](https://www.windsurf.com/) - AI coding assistant
|
||||||
|
|
||||||
Actions:
|
The repository includes configuration files for all these tools to ensure a consistent development experience.
|
||||||
|
|
||||||
- `wpstarter_admin_enqueue`: enqueue the plugin’s own admin styles and scripts on its settings screen (active tab), depending on `wpstarter-admin`. Its script can use `wpstarterAdmin.api` (`post`, `speak`, `errorMessage`).
|
### Git Updater Integration
|
||||||
- `wpstarter_setting_saved`: a setting was saved from the admin screen.
|
|
||||||
- `wpstarter_setting_panel`: print status at the top of a setting’s options panel (setting key, schema entry); wrap it in `<div class="wps-panel-note">`.
|
|
||||||
- `wpstarter_settings_tab_after`: print a section after a settings tab’s cards (tab slug).
|
|
||||||
|
|
||||||
Read a setting with `WPStarter_Settings::get( 'key' )`.
|
This template is designed to work seamlessly with the Git Updater plugin for updates from GitHub and Gitea. To ensure proper integration:
|
||||||
|
|
||||||
## Uninstall
|
1. **Required Headers**: The plugin includes specific headers in the main plugin file that Git Updater uses to determine update sources and branches:
|
||||||
|
```php
|
||||||
|
* GitHub Plugin URI: wpallstars/wp-plugin-starter-template-for-ai-coding
|
||||||
|
* GitHub Branch: main
|
||||||
|
* Primary Branch: main
|
||||||
|
* Release Branch: main
|
||||||
|
* Release Asset: true
|
||||||
|
* Gitea Plugin URI: https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding
|
||||||
|
* Gitea Branch: main
|
||||||
|
```
|
||||||
|
|
||||||
Deleting the plugin removes its settings, its cached data, who hid lines of the Plugins screen notice about replaced plugins, and the cached GitHub releases.
|
2. **Tagging Releases**: When creating a new release, always tag it with the 'v' prefix (e.g., `v0.1.2`) to ensure GitHub Actions can create the proper release assets.
|
||||||
|
|
||||||
|
3. **GitHub Actions**: The repository includes a GitHub Actions workflow that automatically builds the plugin and creates a release with the .zip file when a new tag is pushed.
|
||||||
|
|
||||||
|
4. **Update Source Selection**: The template includes a feature that allows users to choose their preferred update source (WordPress.org, GitHub, or Gitea).
|
||||||
|
|
||||||
|
For more information on Git Updater integration, see the [Git Updater Required Headers documentation](https://git-updater.com/knowledge-base/required-headers/).
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### 1.0.0
|
### 0.1.13
|
||||||
|
|
||||||
- A fresh start, made from the parts every wpallstars plugin needs, taken from plugins in daily use: the settings screen with search, the Read Me tab, features as classes, replaced plugins, the shared GitHub updater, the release and check scripts, CI and the shared rules (`STANDARDS.md`, `DEVELOPMENT.md`, `RELEASING.md`). Earlier versions of this starter are retired; start again from this one.
|
* Improved: Code quality with proper type declarations
|
||||||
- New: `scripts/rename-plugin.sh` gives a copy of the starter its own names, and `scripts/sync-core.sh` keeps a plugin's core files the same as the starter's (`--check` lists any that differ).
|
* Fixed: Inconsistent variable naming (camelCase to snake_case)
|
||||||
|
* Improved: Path handling in admin class
|
||||||
|
* Added: Textdomain loading functionality
|
||||||
|
* Removed: Unused phpcs:ignore comment
|
||||||
|
* Implemented: Proper return type declarations
|
||||||
|
|
||||||
## Built with AI
|
### 0.1.12
|
||||||
|
|
||||||
WP Plugin Starter is built and maintained with [aidevops](https://aidevops.sh), the same developer's open-source AI harness for creating and managing anything online with AI, plugins like this one included. It is free on [GitHub](https://github.com/marcusquinn/aidevops).
|
* Fixed: WordPress mocking in unit tests
|
||||||
|
* Added: Proper mocking for WordPress functions in tests
|
||||||
|
* Improved: Code quality tool configurations
|
||||||
|
* Added: Detailed code quality checks workflow documentation
|
||||||
|
* Updated: Documentation for better workflow efficiency
|
||||||
|
|
||||||
|
### 0.1.11
|
||||||
|
|
||||||
|
* Improved: Code quality with comprehensive fixes
|
||||||
|
* Fixed: Indentation issues in PHP files
|
||||||
|
* Updated: CSS formatting with modern notation
|
||||||
|
* Fixed: JavaScript issues with proper global variables
|
||||||
|
* Improved: Security by using filter_input() instead of direct superglobal access
|
||||||
|
* Standardized: Naming conventions across the codebase
|
||||||
|
* Fixed: Documentation and comments for better clarity
|
||||||
|
|
||||||
|
### 0.1.10
|
||||||
|
|
||||||
|
* Fixed: Formatting issues in markdown files for better code quality
|
||||||
|
* Fixed: Improved URL formatting with angle brackets
|
||||||
|
* Fixed: Standardized list formatting across documentation files
|
||||||
|
|
||||||
|
### 0.1.9
|
||||||
|
|
||||||
|
* Changed: Alphabetized AI IDE list.
|
||||||
|
|
||||||
|
### 0.1.8
|
||||||
|
|
||||||
|
* Added: More informative badges (Build Status, Requirements, WP.org placeholders, Release, Issues, Contributors, Wiki).
|
||||||
|
|
||||||
|
### 0.1.7
|
||||||
|
|
||||||
|
* Fixed: GitHub Actions tests workflow with proper file paths and dependencies
|
||||||
|
|
||||||
|
### 0.1.6
|
||||||
|
|
||||||
|
* Fixed: GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
|
### 0.1.5
|
||||||
|
|
||||||
|
* Fixed: Release workflow to use correct plugin directory name
|
||||||
|
* Added: Testing setup with wp-env and Cypress
|
||||||
|
* Added: Multisite compatibility
|
||||||
|
* Added: npm scripts for development and testing
|
||||||
|
|
||||||
|
### 0.1.3
|
||||||
|
|
||||||
|
* Added: Improved AI IDE context recommendations in documentation
|
||||||
|
* Enhanced: Starter Prompt with guidance on pinning AGENTS.md and .agents/
|
||||||
|
* Moved: Starter Prompt to the wiki for better organization
|
||||||
|
* Updated: README.md and readme.txt with AI IDE context recommendations
|
||||||
|
* Improved: Documentation for AI-assisted development
|
||||||
|
|
||||||
|
### 0.1.2
|
||||||
|
|
||||||
|
* Added: STARTER-PROMPT.md with comprehensive guide for customizing the template
|
||||||
|
* Updated: Documentation files with improved instructions
|
||||||
|
* Added: Additional AI workflow files for better development guidance
|
||||||
|
|
||||||
|
### 0.1.1
|
||||||
|
|
||||||
|
* Updated: LICENSE file with correct GPL-2.0 text
|
||||||
|
|
||||||
|
### 0.1.0
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
|
[View full changelog](CHANGELOG.md)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GPL-2.0-or-later.
|
This project is licensed under the GPL-2.0+ License - see the [LICENSE](LICENSE) file for details.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
This template is based on the experience gained from developing the ["Fix 'Plugin file does not exist' Notices"](https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices) plugin by WPALLSTARS.
|
||||||
-130
@@ -1,130 +0,0 @@
|
|||||||
# Releasing
|
|
||||||
|
|
||||||
How every plugin made from the wpallstars starter plugin is released. This
|
|
||||||
file is the same in each of them (names as placeholders: `STANDARDS.md`
|
|
||||||
lists them, and the plugin's `AGENTS.md` gives its values). The plugin's own
|
|
||||||
submission state and guideline review: `LAUNCH.md`.
|
|
||||||
|
|
||||||
Releases on GitHub and the WordPress.org submission need the owner's say.
|
|
||||||
None of the scripts below tags, publishes, uploads or commits anything.
|
|
||||||
|
|
||||||
## Scripts
|
|
||||||
|
|
||||||
| Script | What it does |
|
|
||||||
|--------|--------------|
|
|
||||||
| `scripts/build-release.sh [--ref REF] [--out DIR]` | Builds both zips from a Git ref (default `HEAD`) into `dist/` (gitignored), with `SHA256SUMS`. Files come from Git, never the working tree. |
|
|
||||||
| `scripts/preflight-release.sh [--ref REF] [--strict] [--offline]` | Checks versions, headers, readme, both zips (layout, development files, PHP 7.4 and JS syntax, updater code), remote assets, presets and starter data where the plugin has them, and the Git tag. Errors stop a release; `--strict` also fails on warnings, for a WordPress.org submission. |
|
|
||||||
| `scripts/plugin-check.sh [--ref REF] [--zip FILE]` | Runs Plugin Check on both zips in a disposable WordPress in Docker, then removes it. |
|
|
||||||
|
|
||||||
The two builds of each version:
|
|
||||||
|
|
||||||
| Zip | Contents | Goes to |
|
|
||||||
|-----|----------|---------|
|
|
||||||
| `{slug}-X.Y.Z.zip` | Files in Git, less `.distignore` | GitHub release asset |
|
|
||||||
| `wordpress-org-{slug}-X.Y.Z.zip` | The same, less `.distignore-wporg` (the GitHub updater) and the `GitHub Plugin URI`, `Primary Branch` and `Release Asset` header lines | WordPress.org only |
|
|
||||||
|
|
||||||
Sites install the release asset whose name starts with `{slug}` (the shared
|
|
||||||
GitHub updater, and Git Updater where it is still active), so the
|
|
||||||
WordPress.org zip is named differently and must never be attached to a
|
|
||||||
GitHub release.
|
|
||||||
|
|
||||||
Plugin Check reports the GitHub updater as an updater
|
|
||||||
(`plugin_updater_detected`, `update_modification_detected`, and
|
|
||||||
`OffloadedContent` for its raw.githubusercontent.com address) and its shared
|
|
||||||
`wpallstars_` names as unprefixed, in the GitHub zip; `scripts/plugin-check.sh`
|
|
||||||
lists those as expected there and fails on the updater findings in the
|
|
||||||
WordPress.org zip.
|
|
||||||
|
|
||||||
## GitHub release
|
|
||||||
|
|
||||||
1. In a pull request, set the version in `{slug}.php` (`Version:` and
|
|
||||||
`{PREFIX}_VERSION`) and `readme.txt` (`Stable tag:`), rename the
|
|
||||||
changelog's Unreleased section to the version in `readme.txt`,
|
|
||||||
`changelog.txt` and `README.md`, and add an upgrade notice if people need
|
|
||||||
to act. `readme.txt` keeps only the newest version, in short, and must stay
|
|
||||||
under 10 KB; `changelog.txt` keeps every version in full.
|
|
||||||
Numbers only (`1.2.3`): sites still on Git Updater offer a `Version:` on
|
|
||||||
`main` to every site, and the shared updater skips tags with letters.
|
|
||||||
2. On the pull request's branch: `scripts/preflight-release.sh` (no errors) and
|
|
||||||
`scripts/plugin-check.sh` (no errors).
|
|
||||||
3. Merge, then straight away:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git fetch origin
|
|
||||||
scripts/preflight-release.sh --ref origin/main # no errors before tagging
|
|
||||||
git tag -a vX.Y.Z origin/main -m "{Name} X.Y.Z"
|
|
||||||
scripts/build-release.sh --ref vX.Y.Z
|
|
||||||
git push origin vX.Y.Z
|
|
||||||
gh release create vX.Y.Z dist/{slug}-X.Y.Z.zip --title "{Name} X.Y.Z" --notes-file <notes>
|
|
||||||
```
|
|
||||||
|
|
||||||
Sites with the shared updater see the release when they next check.
|
|
||||||
Sites still on Git Updater are offered the `Version:` on `main` before the
|
|
||||||
release exists, so do this in the same sitting as the merge.
|
|
||||||
4. Check the release has exactly one asset, `{slug}-X.Y.Z.zip`, and on a
|
|
||||||
site with the previous version that **Check again** on the Updates screen
|
|
||||||
shows the update and that it installs.
|
|
||||||
|
|
||||||
Sites read the repository without signing in, so it must be public for sites
|
|
||||||
to get updates. While it is private, a test site can use a read-only token
|
|
||||||
in `WPALLSTARS_GITHUB_TOKEN` (`wp-config.php`; it serves every plugin with
|
|
||||||
the shared updater). Making it public needs the owner's say; do the quality
|
|
||||||
sweep in `DEVELOPMENT.md` → At public launch in the same step.
|
|
||||||
|
|
||||||
## WordPress.org
|
|
||||||
|
|
||||||
Guidelines: [Detailed Plugin Guidelines](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/),
|
|
||||||
[Planning, submitting and maintaining](https://developer.wordpress.org/plugins/wordpress-org/planning-submitting-and-maintaining-plugins/),
|
|
||||||
[Plugin readmes](https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/),
|
|
||||||
[Plugin assets](https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/),
|
|
||||||
[Using Subversion](https://developer.wordpress.org/plugins/wordpress-org/how-to-use-subversion/).
|
|
||||||
|
|
||||||
Before submitting, work through the plugin's `LAUNCH.md`: what
|
|
||||||
`scripts/preflight-release.sh --strict` still reports, and a review of the
|
|
||||||
code against each guideline (no code from elsewhere, external services,
|
|
||||||
scripts and styles shipped with the plugin, links, admin notices, defaults,
|
|
||||||
files outside the plugin folder, uninstall, GPL, name and trademarks, a
|
|
||||||
complete plugin).
|
|
||||||
|
|
||||||
### Submitting
|
|
||||||
|
|
||||||
1. `scripts/build-release.sh --ref vX.Y.Z` (a version already released on
|
|
||||||
GitHub), then `scripts/preflight-release.sh --ref vX.Y.Z --strict` passes,
|
|
||||||
or every warning is accepted.
|
|
||||||
2. `scripts/plugin-check.sh --ref vX.Y.Z` reports no errors; read every
|
|
||||||
warning.
|
|
||||||
3. Test the WordPress.org zip on a clean site (latest WordPress and 6.2 with
|
|
||||||
PHP 7.4), with `WP_DEBUG` on: activate, turn each feature on and off,
|
|
||||||
deactivate, delete. `debug.log` stays empty.
|
|
||||||
4. Signed in as the owner's WordPress.org account, upload
|
|
||||||
`dist/wordpress-org-{slug}-X.Y.Z.zip` at
|
|
||||||
[Add your plugin](https://wordpress.org/plugins/developers/add/), and ask
|
|
||||||
for the `{slug}` slug in the notes.
|
|
||||||
5. Review takes about 1 to 10 business days. Reply to the reviewer's email
|
|
||||||
from the same account; fix issues in the repository, not in a copy.
|
|
||||||
|
|
||||||
### After approval (Subversion)
|
|
||||||
|
|
||||||
The SVN repository is `https://plugins.svn.wordpress.org/{slug}/` (or the
|
|
||||||
slug given). It is for releases only, not development. The SVN password is
|
|
||||||
separate from the account password and is set on the WordPress.org profile
|
|
||||||
(see Using Subversion). Install Subversion first (`brew install subversion`).
|
|
||||||
|
|
||||||
1. Check out the empty repository: `svn co https://plugins.svn.wordpress.org/{slug}/ svn-{slug}`.
|
|
||||||
2. Unzip the WordPress.org build's `{slug}/` folder into `trunk/` (no zip
|
|
||||||
files in SVN), `svn add` new files, `svn rm` removed ones.
|
|
||||||
3. Copy trunk to the tag: `svn cp trunk tags/X.Y.Z`. `Stable tag:` in
|
|
||||||
`trunk/readme.txt` and `tags/X.Y.Z/readme.txt` must be `X.Y.Z`; never
|
|
||||||
`trunk`.
|
|
||||||
4. Put the banners, icons and screenshots in `assets/`.
|
|
||||||
5. `svn ci -m "Release X.Y.Z"`, then check the plugin page and download.
|
|
||||||
6. Consider release confirmation emails (Plugin Handbook → Release
|
|
||||||
Confirmation Emails), so a release goes out only after it is confirmed.
|
|
||||||
|
|
||||||
Each later WordPress.org release: build from the tag that is already on GitHub,
|
|
||||||
`--strict` preflight, Plugin Check, then steps 2 to 5. Readme-only changes
|
|
||||||
(such as raising Tested up to) go to trunk and the current tag.
|
|
||||||
|
|
||||||
Once listed, sites with the GitHub build update from WordPress.org, unless
|
|
||||||
the plugin returns true from `wpallstars_github_updater_early` (a setting
|
|
||||||
such as Early updates from GitHub), which keeps them on GitHub releases.
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
# Security policy
|
|
||||||
|
|
||||||
## Supported versions
|
|
||||||
|
|
||||||
Security fixes go into the latest release only. Update to it before
|
|
||||||
reporting, and check that the problem is still there.
|
|
||||||
|
|
||||||
## Reporting a vulnerability
|
|
||||||
|
|
||||||
Please do not open a public issue, pull request or discussion for a
|
|
||||||
security problem.
|
|
||||||
|
|
||||||
Report it privately on GitHub: open the repository's **Security** tab and
|
|
||||||
choose **Report a vulnerability**. Include:
|
|
||||||
|
|
||||||
- the WP Plugin Starter version, and whether it came from GitHub or
|
|
||||||
WordPress.org;
|
|
||||||
- the WordPress and PHP versions;
|
|
||||||
- the feature involved and the settings needed;
|
|
||||||
- steps to reproduce it, and what an attacker gains (for example, which
|
|
||||||
role they need and what they can then read or change).
|
|
||||||
|
|
||||||
We reply within 30 days, agree a fix and a date with you, and credit you in
|
|
||||||
the changelog unless you would rather not be named. If it is urgent (for
|
|
||||||
example, it is already being used against sites), report it on GitHub and
|
|
||||||
also email security@evergreen.je with a link to the report. Follow-up
|
|
||||||
emails are welcome.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
In scope: the code in this repository, as installed from a GitHub release
|
|
||||||
or WordPress.org.
|
|
||||||
|
|
||||||
Out of scope: other plugins, themes and services that WP Plugin Starter
|
|
||||||
recommends, links to or works with (report those to their makers), and
|
|
||||||
problems that need an administrator account, since administrators can
|
|
||||||
already run code on their site.
|
|
||||||
-278
@@ -1,278 +0,0 @@
|
|||||||
# Plugin standards
|
|
||||||
|
|
||||||
Rules every plugin made from the wpallstars starter plugin follows. This file
|
|
||||||
is the same in each of them: the starter holds the master copy, so a lesson
|
|
||||||
learned in one plugin goes into the starter's copy and then to every plugin
|
|
||||||
(`scripts/sync-core.sh` shows the differences). Never put rules for one
|
|
||||||
plugin here; they go in its `AGENTS.md`.
|
|
||||||
|
|
||||||
Names below are placeholders. Each plugin's `AGENTS.md` gives its values:
|
|
||||||
|
|
||||||
| Placeholder | Meaning | Example |
|
|
||||||
|---|---|---|
|
|
||||||
| `{slug}` | Folder, main file and text domain | `my-plugin` |
|
|
||||||
| `{prefix}` | Option, hook, function and file prefix: `{PREFIX}` in lower case | `myplugin` |
|
|
||||||
| `{Prefix}` | Class prefix (`@package`) | `MyPlugin` |
|
|
||||||
| `{PREFIX}` | Constant prefix | `MYPLUGIN` |
|
|
||||||
| `{Name}` | Plugin name | My Plugin |
|
|
||||||
| `{css}` | CSS class and data attribute prefix (`{css}-card`, `data-{css}-setting`) | `mp` |
|
|
||||||
|
|
||||||
Minimums: **WordPress 6.2, PHP 7.4** (`readme.txt`, plugin header).
|
|
||||||
How changes are made and checked: `DEVELOPMENT.md`. Releases: `RELEASING.md`.
|
|
||||||
|
|
||||||
## Structure
|
|
||||||
|
|
||||||
- Core files are listed in `scripts/core-files.txt`: the feature registry
|
|
||||||
(`includes/class-{prefix}.php`), the base feature
|
|
||||||
(`includes/class-{prefix}-feature.php`), the settings store
|
|
||||||
(`includes/class-{prefix}-settings.php`), the admin screen and Read Me tab
|
|
||||||
(`admin/`), the shared GitHub updater (`includes/github-updater/`), the
|
|
||||||
scripts, the CI workflow and tool configuration, and the shared docs (this
|
|
||||||
file, `DEVELOPMENT.md`, `RELEASING.md`, `CONTRIBUTING.md`, `SECURITY.md`).
|
|
||||||
A plugin's copy differs from the starter's only in the names above. They
|
|
||||||
hold no code for one plugin: they read `{Prefix}_Setup`
|
|
||||||
(`includes/class-{prefix}-setup.php`: features, settings tabs, header
|
|
||||||
links, settings version and history, the plugin's own helpers and admin
|
|
||||||
parts) or use hooks (`{prefix}_admin_tabs` for tabs,
|
|
||||||
`{prefix}_admin_enqueue` for the plugin's own admin CSS and JS,
|
|
||||||
`scripts/preflight-plugin.sh` for its own release checks). Anything only
|
|
||||||
one plugin needs goes there, in a feature, or in its own file loaded from
|
|
||||||
there. To change a core file, change the starter first, then run
|
|
||||||
`scripts/sync-core.sh` in each plugin; `scripts/sync-core.sh --check` lists
|
|
||||||
core files that differ. A new plugin starts as a copy of the starter
|
|
||||||
renamed with `scripts/rename-plugin.sh`.
|
|
||||||
- One class per feature in `includes/features/`, extending `{Prefix}_Feature`,
|
|
||||||
registered in `{Prefix}_Setup::FEATURES`. Features some builds leave out
|
|
||||||
go in `{Prefix}_Setup::OPTIONAL_FEATURES` and load only when present.
|
|
||||||
- `settings()` declares the schema; the admin screen renders, searches and
|
|
||||||
saves it with no extra code. Field types and keys: `README.md` → Developers.
|
|
||||||
- `boot()` returns early unless `self::enabled()`. Features are **off by
|
|
||||||
default**; the plugin's `AGENTS.md` lists any the owner asked to be on.
|
|
||||||
Turning another feature on by default needs the owner's say.
|
|
||||||
- A feature that replaces another plugin sets `'replaces' => array(slug => name)`
|
|
||||||
and imports that plugin's settings in `migrate()` with
|
|
||||||
`self::import_setting()` (fills only unset keys). It never writes or
|
|
||||||
deletes the other plugin's options. While that plugin is active the
|
|
||||||
feature waits, and the Plugins screen suggests deactivating and deleting
|
|
||||||
it (`admin/includes/class-replaced-plugins.php`) with no extra code.
|
|
||||||
- Migrations run once per `{Prefix}_Setup::DB_VERSION`. After a release, a
|
|
||||||
new or changed import needs a version bump and a line in its docblock.
|
|
||||||
- New options, post meta, user meta, transients, cron hooks and files must be
|
|
||||||
removed in `uninstall.php`.
|
|
||||||
- `README.md` is also the plugin's Read Me tab
|
|
||||||
(`admin/includes/class-readme-manager.php`), which renders headings, lists,
|
|
||||||
tables, bold, italic, inline code, links (http(s) and `#heading` links,
|
|
||||||
with GitHub-style heading IDs) and images from the plugin folder on a line
|
|
||||||
of their own (``). Use only that Markdown,
|
|
||||||
or extend the renderer in the same change.
|
|
||||||
- Update `README.md` (feature section, hooks, changelog), `changelog.txt`
|
|
||||||
(the user-facing changelog entry) and `readme.txt` in the same change.
|
|
||||||
`readme.txt` must stay under 10 KB for WordPress.org: one short line per
|
|
||||||
feature, every service the plugin contacts under External services, and
|
|
||||||
only the newest version's changelog, in short. Details go in `README.md`.
|
|
||||||
- `.distignore` lists files kept out of the release zip. Add new
|
|
||||||
development-only files there (the preflight fails when a known one gets in),
|
|
||||||
then check the build with Plugin Check.
|
|
||||||
|
|
||||||
## Code rules
|
|
||||||
|
|
||||||
- PHP 7.4 syntax and WordPress 6.2 APIs. Guard newer core APIs with
|
|
||||||
`function_exists()` or `method_exists()`.
|
|
||||||
- Capability and nonce checks on every admin action and AJAX handler; escape on
|
|
||||||
output; sanitise through the schema.
|
|
||||||
- Prefix everything global with `{prefix}_`, `{Prefix}_` or `{PREFIX}_`. The
|
|
||||||
shared GitHub updater is the one exception: its `wpallstars_` names are the
|
|
||||||
same in every plugin, so that one copy can stand in for the others.
|
|
||||||
- Admin copy: short, plain words, sentence case, no jargon.
|
|
||||||
- Decide for the user. Within a feature, the plugin makes the choices
|
|
||||||
(which plugins, screens or items it applies to) from what it can detect.
|
|
||||||
Settings are there to bypass something that causes a problem, not choices
|
|
||||||
people need to understand first. A new setting must earn its place;
|
|
||||||
prefer detecting the right behaviour plus a short bypass list.
|
|
||||||
- Site owner in control, performance first: the owner decides what their site
|
|
||||||
sends, contacts and shows. Calls to outside services are opt-in where they
|
|
||||||
are not the point of the feature, made only as often and for as long as
|
|
||||||
needed (cache answers, never on every page load), and never block a
|
|
||||||
visitor's page when they can run later. Features that rein in other
|
|
||||||
plugins hand the choice to the owner instead of deciding for them.
|
|
||||||
WordPress update checks and downloads are the exception: leave them alone
|
|
||||||
(next rule).
|
|
||||||
- Do not change WordPress update behaviour (update transients, `auto_update_*`
|
|
||||||
filters, update checks) outside the shared GitHub updater. Plugin Check
|
|
||||||
reports `plugin_updater_detected` as an error, and WordPress.org asks plugins
|
|
||||||
not to interfere with the updater.
|
|
||||||
- Leave no PHP errors, warnings, notices or deprecations behind. Fix any that
|
|
||||||
the plugin causes as you find them, in the same change when it is small,
|
|
||||||
or as a tracked issue. That includes ones in other plugins that only happen
|
|
||||||
because of this one. Messages that other plugins cause on their own are
|
|
||||||
theirs: mention them, do not hide them.
|
|
||||||
|
|
||||||
## Updates from GitHub
|
|
||||||
|
|
||||||
The one exception to the update rule, at the owner's request (for speed,
|
|
||||||
reliability and site owners' control, and because the plugins are released
|
|
||||||
on GitHub first): the shared GitHub updater in `includes/github-updater/`.
|
|
||||||
It replaces Git Updater.
|
|
||||||
|
|
||||||
- Every plugin made from the starter carries a copy. Each copy registers its
|
|
||||||
version from `load.php` when its plugin loads; on `plugins_loaded` only the
|
|
||||||
newest copy loads, once, and serves every installed plugin with a
|
|
||||||
`GitHub Plugin URI` header. One update check covers them all.
|
|
||||||
- It adds GitHub releases of those plugins to core's own update check and
|
|
||||||
`plugins_api`, and leaves the download, install, auto-updates and rollback
|
|
||||||
to core. It only adds entries for those plugins; it never removes or blocks
|
|
||||||
other updates.
|
|
||||||
- It is the same in every plugin apart from its text domain and `@package`.
|
|
||||||
Change it in the starter, raise the version in its `load.php`, and copy it
|
|
||||||
to each plugin. Plugins change what it does only through its filters
|
|
||||||
(`wpallstars_github_updater_enabled`, `wpallstars_github_updater_early`,
|
|
||||||
`wpallstars_github_plugins`, `wpallstars_github_token`), never by calling
|
|
||||||
its class: another plugin's copy may be the one that runs.
|
|
||||||
- Keep anything that installs or updates code from outside WordPress.org in
|
|
||||||
that folder (and in a feature listed in `.distignore-wporg`, when a plugin
|
|
||||||
has a setting for it), because the WordPress.org build leaves them out.
|
|
||||||
- Never add an `Update URI` header. Tokens for private repositories come only
|
|
||||||
from `wp-config.php` (`WPALLSTARS_GITHUB_TOKEN`) or the filter, go only to
|
|
||||||
api.github.com and are never stored.
|
|
||||||
|
|
||||||
## Releases
|
|
||||||
|
|
||||||
GitHub releases are the early channel; WordPress.org gets settled versions.
|
|
||||||
Sites install the latest GitHub release whose tag is a plain version and the
|
|
||||||
asset whose name starts with the plugin folder (the shared updater; Git
|
|
||||||
Updater, where still active, reads `Version:` on `main` instead), so:
|
|
||||||
|
|
||||||
- Publish the GitHub release (tag `vX.Y.Z`, asset `{slug}-X.Y.Z.zip` with a
|
|
||||||
`{slug}/` folder, built with `.distignore`) straight after the version
|
|
||||||
change reaches `main`.
|
|
||||||
- Never put a pre-release version (`-beta1`, `-rc1`) in `Version:` on `main`;
|
|
||||||
mark test releases as pre-releases on GitHub.
|
|
||||||
- The WordPress.org build is the release build without the files in
|
|
||||||
`.distignore-wporg` (the GitHub updater) and the `GitHub Plugin URI`,
|
|
||||||
`Primary Branch` and `Release Asset` header lines. Its zip is named
|
|
||||||
`wordpress-org-{slug}-X.Y.Z.zip` so no updater picks it; never attach it
|
|
||||||
to a GitHub release.
|
|
||||||
- Any plugin released on GitHub (made from the starter or not) follows the
|
|
||||||
same pattern: a `GitHub Plugin URI: owner/repo` header (and
|
|
||||||
`Release Asset: true`), plain version tags, and a `{folder}-X.Y.Z.zip`
|
|
||||||
asset with a `{folder}/` inside.
|
|
||||||
- Build both zips with `scripts/build-release.sh`, check them with
|
|
||||||
`scripts/preflight-release.sh` and `scripts/plugin-check.sh`. None of them
|
|
||||||
tags, publishes or uploads anything.
|
|
||||||
- Releasing and submitting to WordPress.org need the owner's say. A private
|
|
||||||
repository cannot be read by sites without a token
|
|
||||||
(`WPALLSTARS_GITHUB_TOKEN`).
|
|
||||||
|
|
||||||
Details: `RELEASING.md`; the plugin's own submission state: `LAUNCH.md`.
|
|
||||||
|
|
||||||
## Front-end styling and dark mode
|
|
||||||
|
|
||||||
Block, shortcode and other front-end styles must work with the Kadence Pro
|
|
||||||
dark mode switcher (and themes that switch palettes the same way).
|
|
||||||
|
|
||||||
- How it switches: Kadence adds `color-switch-dark` or `color-switch-light` to
|
|
||||||
`<body>`. The dark class sets `color-scheme: dark` and redefines
|
|
||||||
`--global-palette1`…`15` and `--wp--preset--color--theme-palette-N` **on
|
|
||||||
`<body>`**. `<html>` stays `color-scheme: light`. Palette 3 is the strongest
|
|
||||||
text and palette 9 the page background in light mode; dark mode swaps them.
|
|
||||||
- Use `currentColor`, `inherit`, translucent neutrals (for example
|
|
||||||
`rgba(127, 127, 127, 0.12)`) or palette variables, never fixed light or dark
|
|
||||||
colours for text, backgrounds or borders.
|
|
||||||
- Do not use `@media (prefers-color-scheme)` to follow the site: it tracks the
|
|
||||||
visitor's system, not the switcher.
|
|
||||||
- Do not define custom properties on `:root` from palette variables; they
|
|
||||||
resolve above `<body>` and keep the light values. Read palette variables
|
|
||||||
where they are used, or define derived ones on the block.
|
|
||||||
- Preset references (`var:preset|color|theme-palette3`) become CSS variables
|
|
||||||
with kebab-cased slugs, as core does: `--wp--preset--color--theme-palette-3`.
|
|
||||||
Use `_wp_to_kebab_case()` in PHP and the same rule in editor JS (a hyphen
|
|
||||||
between letters and digits, lower case).
|
|
||||||
- Embedded pages (iframes) do not follow the switcher: they see the visitor's
|
|
||||||
system setting, and the browser paints their own background behind them, so
|
|
||||||
they stay readable in both modes. Do not make iframes transparent or tint them.
|
|
||||||
- Test light and dark with the Kadence theme by toggling the body class (see
|
|
||||||
Testing, step 5).
|
|
||||||
|
|
||||||
## Testing
|
|
||||||
|
|
||||||
CI (`.github/workflows/ci.yml`) runs the code checks, the release preflight,
|
|
||||||
Plugin Check and a smoke test on every pull request; details and local
|
|
||||||
commands: `DEVELOPMENT.md`.
|
|
||||||
|
|
||||||
While a repository is private, CI and review apps only advise: nothing is
|
|
||||||
required to merge, for speed. Fix failures your change causes before merging;
|
|
||||||
open an issue for any other failure and merge anyway. Do not turn on branch
|
|
||||||
protection, required checks or paid reviewers. At public launch (owner's say),
|
|
||||||
run the full sweep in `DEVELOPMENT.md` → At public launch, which makes the
|
|
||||||
checks required.
|
|
||||||
|
|
||||||
The checks catch errors, not wrong behaviour, so also verify on real
|
|
||||||
WordPress:
|
|
||||||
|
|
||||||
1. `scripts/lint.sh` (syntax, ShellCheck, PHPCS, PHPStan; run
|
|
||||||
`composer install` once). Fix findings in the code; never grow
|
|
||||||
`phpstan-baseline.neon` or add a `phpcs:ignore` without a reason.
|
|
||||||
2. The user reviews on one local test site per plugin, shared by every
|
|
||||||
session and worktree. It shows a **combined preview**: `origin/main` plus
|
|
||||||
every open pull request from the repository, merged together. Update it
|
|
||||||
only with the script, from any worktree:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scripts/preview-site.sh # the first run on a clone takes the site: scripts/preview-site.sh "<site>"
|
|
||||||
scripts/preview-site.sh --dry-run # report what would be included, copy nothing
|
|
||||||
```
|
|
||||||
|
|
||||||
It fetches `origin`, merges each open PR's branch onto `origin/main` in PR
|
|
||||||
order without touching any checkout, leaves out branches that conflict
|
|
||||||
(and lists them), copies the result with `.distignore` applied (exactly
|
|
||||||
what a release build contains), and writes
|
|
||||||
`<site>/wp-content/{slug}-synced-from.txt` listing what is included.
|
|
||||||
A lock stops two runs at once. Because every run includes everyone's
|
|
||||||
pushed work, no session hides another's.
|
|
||||||
|
|
||||||
- **Never** `rsync` your worktree into the shared site: it hides every
|
|
||||||
other session's work until the next run. Do not use Git hooks either:
|
|
||||||
they are shared by every worktree and would deploy the wrong checkout.
|
|
||||||
- Only pushed work with an open PR is included. Before asking the user to
|
|
||||||
look at unmerged work, push the branch and open a draft PR, then run the
|
|
||||||
script. It says so if the branch you run it from is missing or has
|
|
||||||
commits that are not pushed.
|
|
||||||
- After merging a PR, run the script again, then check that the stamp
|
|
||||||
lists your merge in `main` before telling the user to look.
|
|
||||||
- Conflicts only in `changelog.txt`, `readme.txt` or `README.md` do not
|
|
||||||
leave a branch out: every PR adds lines at the top of the same
|
|
||||||
changelogs, so each merge to `main` would otherwise drop every other
|
|
||||||
open PR. The preview keeps both sides' lines there and says so in the
|
|
||||||
stamp; still merge `origin/main` into your branch before it merges.
|
|
||||||
- If your branch is left out because it conflicts in other files, merge
|
|
||||||
`origin/main` into it (or wait for the other PR), push and run the
|
|
||||||
script again. Tell the user which PRs are left out.
|
|
||||||
- To check your branch on its own, or for checks the user will not look
|
|
||||||
at, use a throwaway site of your own (step 4's Docker image on a free
|
|
||||||
port), which no one else overwrites:
|
|
||||||
`rsync -a --delete --delete-excluded --exclude-from=.distignore ./ "<site>/wp-content/plugins/{slug}/"`.
|
|
||||||
- Size every test site, shared or throwaway, as `DEVELOPMENT.md` → Test
|
|
||||||
site resources says. PHP's defaults fill up and the slowdowns look like
|
|
||||||
bugs.
|
|
||||||
|
|
||||||
3. Exercise the changed feature through the admin UI or HTTP, and check
|
|
||||||
the debug log for new messages mentioning `{slug}` or a plugin it affects
|
|
||||||
(`wp-content/debug.log`, or the file Debug Log Manager writes in
|
|
||||||
`wp-content/uploads/debug-log-manager/` when it is active). For settings
|
|
||||||
imports, seed the replaced plugin's options and delete `{prefix}_options`
|
|
||||||
and `{prefix}_db_version` while the plugin is inactive, then activate it.
|
|
||||||
4. For changes that touch core APIs, also smoke-test on WordPress 6.2 with
|
|
||||||
PHP 7.4 (`scripts/smoke-test.sh --wp 6.2 --php 7.4`, or the
|
|
||||||
`wordpress:php7.4-apache` Docker image with
|
|
||||||
`wp core download --version=6.2 --force`).
|
|
||||||
5. For front-end styling, view the page with the Kadence theme in light and
|
|
||||||
dark mode. Without Kadence Pro, simulate the switcher: print a
|
|
||||||
`body.color-switch-dark { color-scheme: dark; --global-palette1: …; }`
|
|
||||||
rule with a dark palette (palette 3 light, palette 9 dark, and the matching
|
|
||||||
`--wp--preset--color--theme-palette-N: var(--global-paletteN)` lines), then
|
|
||||||
swap the body class between `color-switch-light` and `color-switch-dark`.
|
|
||||||
Check text, backgrounds, borders and palette colours chosen in block
|
|
||||||
settings in both.
|
|
||||||
|
|
||||||
Note: since WordPress 5.6, posts restored from the Bin become drafts. Republish
|
|
||||||
test posts after bulk-trash tests.
|
|
||||||
@@ -0,0 +1,342 @@
|
|||||||
|
# WARP.md
|
||||||
|
|
||||||
|
This file provides guidance to WARP (warp.dev) when working with code in this repository.
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
**WordPress Plugin Starter Template** - A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.
|
||||||
|
|
||||||
|
* **Plugin Slug**: wp-plugin-starter-template
|
||||||
|
* **Namespace**: `WPALLSTARS\PluginStarterTemplate`
|
||||||
|
* **Text Domain**: wp-plugin-starter-template
|
||||||
|
* **Requirements**: WordPress 5.0+, PHP 7.4+
|
||||||
|
* **License**: GPL-2.0+
|
||||||
|
|
||||||
|
## Common Development Commands
|
||||||
|
|
||||||
|
### Environment Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install dependencies
|
||||||
|
npm install
|
||||||
|
composer install
|
||||||
|
|
||||||
|
# Start local WordPress environment (requires Docker)
|
||||||
|
npm run start
|
||||||
|
|
||||||
|
# Stop WordPress environment
|
||||||
|
npm run stop
|
||||||
|
|
||||||
|
# Setup single-site test environment
|
||||||
|
npm run setup:single
|
||||||
|
|
||||||
|
# Setup multisite test environment
|
||||||
|
npm run setup:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
Local WordPress site runs at: <http://localhost:8888> (admin: admin/password)
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# PHP unit tests
|
||||||
|
npm run test:php
|
||||||
|
composer test
|
||||||
|
|
||||||
|
# E2E tests (Cypress)
|
||||||
|
npm run test:e2e:single
|
||||||
|
npm run test:e2e:multisite
|
||||||
|
|
||||||
|
# Run specific test configurations
|
||||||
|
npm run test:single # Interactive single-site
|
||||||
|
npm run test:multisite # Interactive multisite
|
||||||
|
npm run test:single:headless # Headless single-site
|
||||||
|
npm run test:multisite:headless # Headless multisite
|
||||||
|
|
||||||
|
# Playground tests (no Docker required)
|
||||||
|
npm run test:playground:single
|
||||||
|
npm run test:playground:multisite
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code Quality & Linting
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# PHP linting and fixing
|
||||||
|
npm run lint:php # Run PHPCS
|
||||||
|
npm run fix:php # Run PHPCBF
|
||||||
|
composer run phpcs # Run PHPCS directly
|
||||||
|
composer run phpcbf # Run PHPCBF directly
|
||||||
|
|
||||||
|
# Static analysis
|
||||||
|
npm run lint:phpstan # PHPStan
|
||||||
|
composer run phpstan
|
||||||
|
|
||||||
|
npm run lint:phpmd # PHP Mess Detector
|
||||||
|
composer run phpmd
|
||||||
|
|
||||||
|
# JavaScript linting
|
||||||
|
npm run lint:js
|
||||||
|
|
||||||
|
# Run all linters
|
||||||
|
npm run lint # Runs phpcs, phpstan, phpmd
|
||||||
|
composer run lint
|
||||||
|
|
||||||
|
# Run quality checks and tests
|
||||||
|
npm run quality
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building & Release
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build plugin ZIP for distribution
|
||||||
|
npm run build
|
||||||
|
# or
|
||||||
|
./build.sh {VERSION}
|
||||||
|
|
||||||
|
# Example:
|
||||||
|
./build.sh 1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
The build script creates a deployable ZIP file in the repository root.
|
||||||
|
|
||||||
|
## Architecture Overview
|
||||||
|
|
||||||
|
### Plugin Initialization Flow
|
||||||
|
|
||||||
|
1. **Main Plugin File** (`wp-plugin-starter-template.php`):
|
||||||
|
* Defines constants (`WP_PLUGIN_STARTER_TEMPLATE_FILE`, `_PATH`, `_URL`, `_VERSION`)
|
||||||
|
* Registers custom autoloader for namespaced classes
|
||||||
|
* Instantiates `Plugin` class
|
||||||
|
* Calls `init()` method
|
||||||
|
|
||||||
|
2. **Autoloader**:
|
||||||
|
* Converts namespace `WPALLSTARS\PluginStarterTemplate` to file paths
|
||||||
|
* Looks for class files in `includes/` directory
|
||||||
|
* Uses PSR-4 naming with class file prefix conversion
|
||||||
|
|
||||||
|
3. **Plugin Class** (`includes/class-plugin.php`):
|
||||||
|
* Main orchestration class
|
||||||
|
* Instantiates `Core` and `Admin` classes
|
||||||
|
* Registers hooks and loads text domain
|
||||||
|
* Provides getters for version and admin instance
|
||||||
|
|
||||||
|
4. **Core Class** (`includes/class-core.php`):
|
||||||
|
* Contains core plugin functionality
|
||||||
|
* Provides version management
|
||||||
|
* Houses filter/action methods
|
||||||
|
|
||||||
|
5. **Admin Class** (`includes/Admin/class-admin.php`):
|
||||||
|
* Manages admin-specific functionality
|
||||||
|
* Handles admin menu, pages, and UI
|
||||||
|
|
||||||
|
### Directory Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
wp-plugin-starter-template-for-ai-coding/
|
||||||
|
├── wp-plugin-starter-template.php # Main plugin file with headers
|
||||||
|
├── includes/ # Core plugin classes
|
||||||
|
│ ├── class-plugin.php # Main plugin orchestration
|
||||||
|
│ ├── class-core.php # Core functionality
|
||||||
|
│ ├── updater.php # Update mechanism
|
||||||
|
│ ├── Admin/ # Admin-specific classes
|
||||||
|
│ └── Multisite/ # Multisite-specific functionality
|
||||||
|
├── admin/ # Admin UI resources
|
||||||
|
│ ├── lib/ # Admin classes
|
||||||
|
│ ├── css/ # Admin stylesheets
|
||||||
|
│ ├── js/ # Admin JavaScript
|
||||||
|
│ └── templates/ # Admin template files
|
||||||
|
├── tests/ # PHPUnit and test files
|
||||||
|
├── cypress/ # E2E tests
|
||||||
|
├── .github/workflows/ # CI/CD workflows
|
||||||
|
├── .agents/ # AI assistant documentation
|
||||||
|
├── .wiki/ # Wiki documentation
|
||||||
|
└── languages/ # Translation files
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Architectural Patterns
|
||||||
|
|
||||||
|
* **Object-Oriented**: All functionality in namespaced classes
|
||||||
|
* **PSR-4 Autoloading**: Automatic class loading without require statements
|
||||||
|
* **Dependency Injection**: `Admin` receives `Core` instance via constructor
|
||||||
|
* **Separation of Concerns**: Core functionality, admin UI, and multisite features are isolated
|
||||||
|
* **Hook-Based**: WordPress hooks for extensibility
|
||||||
|
|
||||||
|
## Coding Standards
|
||||||
|
|
||||||
|
### PHP Standards (WordPress Coding Standards)
|
||||||
|
|
||||||
|
* **Indentation**: 4 spaces (project-specific override of WordPress tabs)
|
||||||
|
* **Naming Conventions**:
|
||||||
|
* Classes: `Class_Name`
|
||||||
|
* Functions: `function_name`
|
||||||
|
* Variables: `$variable_name`
|
||||||
|
* **Documentation**: DocBlocks required for all classes, methods, and functions
|
||||||
|
* **Internationalization**: All user-facing strings must be translatable with text domain `wp-plugin-starter-template`
|
||||||
|
|
||||||
|
### Markdown Standards
|
||||||
|
|
||||||
|
* Use asterisks (`*`) for bullet points, never hyphens (`-`)
|
||||||
|
* Add periods to the end of all inline comments
|
||||||
|
|
||||||
|
### Code Quality Tools
|
||||||
|
|
||||||
|
The project uses several automated tools integrated via CI/CD:
|
||||||
|
|
||||||
|
* **PHP_CodeSniffer**: Enforces WordPress Coding Standards
|
||||||
|
* **PHPCBF**: Auto-fixes coding standard violations
|
||||||
|
* **PHPStan**: Static analysis (level 5)
|
||||||
|
* **PHPMD**: Detects code complexity issues
|
||||||
|
* **ESLint**: JavaScript linting
|
||||||
|
* **Stylelint**: CSS linting
|
||||||
|
* **CodeRabbit, CodeFactor, Codacy, SonarCloud**: Continuous quality monitoring
|
||||||
|
|
||||||
|
Always run `npm run lint` or `composer run lint` before committing.
|
||||||
|
|
||||||
|
## Security Requirements
|
||||||
|
|
||||||
|
* Validate and sanitize all inputs (use `sanitize_*()` functions)
|
||||||
|
* Escape all outputs (use `esc_*()` functions)
|
||||||
|
* Use nonces for form submissions
|
||||||
|
* Check user capabilities before allowing actions
|
||||||
|
* Never expose secrets in plain text
|
||||||
|
|
||||||
|
## Release Process
|
||||||
|
|
||||||
|
### Version Numbering
|
||||||
|
|
||||||
|
Follow semantic versioning (MAJOR.MINOR.PATCH):
|
||||||
|
|
||||||
|
* **PATCH**: Bug fixes (1.0.0 → 1.0.1)
|
||||||
|
* **MINOR**: New features, backward-compatible (1.0.0 → 1.1.0)
|
||||||
|
* **MAJOR**: Breaking changes (1.0.0 → 2.0.0)
|
||||||
|
|
||||||
|
### Release Steps
|
||||||
|
|
||||||
|
1. Create version branch from main: `git checkout -b v{MAJOR}.{MINOR}.{PATCH}`
|
||||||
|
2. Update version in:
|
||||||
|
* `wp-plugin-starter-template.php` (header and constant)
|
||||||
|
* `readme.txt` (Stable tag and changelog)
|
||||||
|
* `README.md` (changelog)
|
||||||
|
* `CHANGELOG.md`
|
||||||
|
* `languages/wp-plugin-starter-template.pot`
|
||||||
|
3. Run code quality checks: `npm run quality`
|
||||||
|
4. Build plugin: `./build.sh {VERSION}`
|
||||||
|
5. Test thoroughly (single-site and multisite)
|
||||||
|
6. Commit: `git commit -m "Version {VERSION} - [description]"`
|
||||||
|
7. Tag: `git tag -a v{VERSION} -m "Version {VERSION}"`
|
||||||
|
8. Tag stable: `git tag -a v{VERSION}-stable -m "Stable version {VERSION}"`
|
||||||
|
9. Push to remotes: `git push github main --tags && git push gitea main --tags`
|
||||||
|
|
||||||
|
**Important**: Tags with 'v' prefix trigger GitHub Actions to build and create releases automatically.
|
||||||
|
|
||||||
|
## Git Updater Integration
|
||||||
|
|
||||||
|
This template works with the Git Updater plugin for updates from GitHub and Gitea.
|
||||||
|
|
||||||
|
Required headers in main plugin file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
* GitHub Plugin URI: wpallstars/wp-plugin-starter-template-for-ai-coding
|
||||||
|
* GitHub Branch: main
|
||||||
|
* Gitea Plugin URI: https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding
|
||||||
|
* Gitea Branch: main
|
||||||
|
```
|
||||||
|
|
||||||
|
Users can choose their update source (WordPress.org, GitHub, or Gitea) via plugin settings.
|
||||||
|
|
||||||
|
## Testing Framework
|
||||||
|
|
||||||
|
### WordPress Playground Testing
|
||||||
|
|
||||||
|
Test without Docker using WordPress Playground blueprints:
|
||||||
|
|
||||||
|
* Single-site: <https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json>
|
||||||
|
* Multisite: <https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json>
|
||||||
|
|
||||||
|
### Local Testing with wp-env
|
||||||
|
|
||||||
|
`.wp-env.json` and `.wp-env.multisite.json` configure WordPress environments.
|
||||||
|
|
||||||
|
## AI-Assisted Development
|
||||||
|
|
||||||
|
This repository includes comprehensive AI workflow documentation in `.agents/`:
|
||||||
|
|
||||||
|
* `feature-development.md`: Adding new features
|
||||||
|
* `bug-fixing.md`: Diagnosing and fixing issues
|
||||||
|
* `release-process.md`: Creating releases
|
||||||
|
* `code-quality-checks.md`: Running quality tools
|
||||||
|
* `error-checking-feedback-loops.md`: Monitoring CI/CD
|
||||||
|
* `git-workflow.md`: Git best practices
|
||||||
|
* `wiki-documentation.md`: Maintaining documentation
|
||||||
|
|
||||||
|
Reference these workflows with `@.agents/{filename}` syntax.
|
||||||
|
|
||||||
|
## Multi-Repository Workspace Context
|
||||||
|
|
||||||
|
When working in a workspace with multiple repositories:
|
||||||
|
|
||||||
|
1. Always verify you're in the correct repository: `pwd` and `git remote -v`
|
||||||
|
2. Never assume features from other repositories exist here
|
||||||
|
3. Don't hallucinate functionality from other repositories in the workspace
|
||||||
|
4. Each repository has its own specific purpose and feature set
|
||||||
|
5. Repository-specific documentation reflects only actual features in this repository
|
||||||
|
|
||||||
|
## GitHub Actions Workflows
|
||||||
|
|
||||||
|
* `tests.yml`: PHPUnit tests
|
||||||
|
* `phpunit.yml`: Additional PHPUnit configurations
|
||||||
|
* `code-quality.yml`: Runs PHPCS, PHPStan, PHPMD
|
||||||
|
* `sonarcloud.yml`: SonarCloud analysis
|
||||||
|
* `playground-tests.yml`: Tests in WordPress Playground
|
||||||
|
* `release.yml`: Creates releases when tags are pushed
|
||||||
|
* `sync-wiki.yml`: Syncs `.wiki/` to GitHub wiki
|
||||||
|
|
||||||
|
Workflows run automatically on push and pull requests.
|
||||||
|
|
||||||
|
## Internationalization (i18n)
|
||||||
|
|
||||||
|
All user-facing strings must use translation functions:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Simple strings
|
||||||
|
__('Text', 'wp-plugin-starter-template')
|
||||||
|
|
||||||
|
// Echoed strings
|
||||||
|
_e('Text', 'wp-plugin-starter-template')
|
||||||
|
|
||||||
|
// Escaped strings
|
||||||
|
esc_html__('Text', 'wp-plugin-starter-template')
|
||||||
|
|
||||||
|
// Escaped and echoed
|
||||||
|
esc_html_e('Text', 'wp-plugin-starter-template')
|
||||||
|
```
|
||||||
|
|
||||||
|
Translation files are in `languages/` directory.
|
||||||
|
|
||||||
|
## Multisite Compatibility
|
||||||
|
|
||||||
|
Fully compatible with WordPress multisite. Multisite-specific functionality is in `includes/Multisite/`.
|
||||||
|
|
||||||
|
Test multisite with:
|
||||||
|
|
||||||
|
* `npm run setup:multisite`
|
||||||
|
* `npm run test:e2e:multisite`
|
||||||
|
* WordPress Playground multisite blueprint
|
||||||
|
|
||||||
|
## Documentation Maintenance
|
||||||
|
|
||||||
|
When adding features or making changes:
|
||||||
|
|
||||||
|
1. Update `CHANGELOG.md` and `readme.txt` changelog
|
||||||
|
2. Update `README.md` if user-facing functionality changes
|
||||||
|
3. Update `.wiki/` documentation (syncs to GitHub wiki)
|
||||||
|
4. Update inline code comments and DocBlocks
|
||||||
|
5. Follow markdown standards (asterisks for bullets, periods in comments)
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
* WordPress Coding Standards: <https://developer.wordpress.org/coding-standards/>
|
||||||
|
* Git Updater Headers: <https://git-updater.com/knowledge-base/required-headers/>
|
||||||
|
* Testing Framework: `.wiki/Testing-Framework.md`
|
||||||
|
* Playground Testing: `.wiki/Playground-Testing.md`
|
||||||
|
* Code Quality Setup: `docs/code-quality-setup.md`
|
||||||
@@ -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 rgb(0 0 0 / 10%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.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 rgb(0 0 0 / 10%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.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 (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%;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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: rgb(0 0 0 / 40%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpst-modal-content {
|
||||||
|
position: relative;
|
||||||
|
background-color: #fefefe;
|
||||||
|
margin: 10% auto;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 4px 8px rgb(0 0 0 / 10%);
|
||||||
|
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: 700;
|
||||||
|
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 rgb(0 0 0 / 10%);
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -1,848 +0,0 @@
|
|||||||
/**
|
|
||||||
* WP Plugin Starter admin screen.
|
|
||||||
*
|
|
||||||
* Scoped to .wps-wrap. Uses core admin tokens so the screen follows the
|
|
||||||
* active admin colour scheme; core buttons, notices and plugin cards keep
|
|
||||||
* their native styles. Logical properties keep RTL working without a
|
|
||||||
* separate stylesheet.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.wps-wrap {
|
|
||||||
--wps-accent: var(--wp-admin-theme-color, #2271b1);
|
|
||||||
--wps-accent-dark: var(--wp-admin-theme-color-darker-10, #135e96);
|
|
||||||
--wps-text: #1d2327;
|
|
||||||
--wps-muted: #646970;
|
|
||||||
--wps-border: #dcdcde;
|
|
||||||
--wps-surface: #fff;
|
|
||||||
--wps-subtle: #f6f7f7;
|
|
||||||
--wps-success: #008a20;
|
|
||||||
--wps-error: #d63638;
|
|
||||||
--wps-radius: 8px;
|
|
||||||
--wps-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
||||||
--wps-focus: 0 0 0 2px var(--wps-surface), 0 0 0 4px var(--wps-accent);
|
|
||||||
|
|
||||||
margin-block-start: 0;
|
|
||||||
margin-inline-start: -20px;
|
|
||||||
margin-inline-end: 0;
|
|
||||||
color: var(--wps-text);
|
|
||||||
/* Start below the Screen Options / Notices tabs, so they never narrow the header. */
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap *,
|
|
||||||
.wps-wrap *::before,
|
|
||||||
.wps-wrap *::after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header ------------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-header {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px 24px;
|
|
||||||
padding: 14px 24px;
|
|
||||||
background: var(--wps-surface);
|
|
||||||
border-block-end: 1px solid var(--wps-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-header__brand {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-header__logo {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
font-size: 20px;
|
|
||||||
color: #fff;
|
|
||||||
background: var(--wps-accent);
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-header__title {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 1.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-header__actions {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-inline-start: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-header__support {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* line-height: 1 stops the icon taking the button's taller line height,
|
|
||||||
which draws the glyph below the middle of its box. */
|
|
||||||
.wps-wrap .wps-header__support .dashicons {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Search ------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* Stretch, so the field always matches the button's height, whatever
|
|
||||||
size the admin colour scheme or WordPress version gives buttons. */
|
|
||||||
.wps-search {
|
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-search__field {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__icon {
|
|
||||||
position: absolute;
|
|
||||||
inset-block: 0;
|
|
||||||
inset-inline-start: 9px;
|
|
||||||
margin-block: auto;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__input {
|
|
||||||
width: 260px;
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
min-height: 30px;
|
|
||||||
margin: 0;
|
|
||||||
padding-block: 0;
|
|
||||||
padding-inline: 34px 10px;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: normal;
|
|
||||||
color: var(--wps-text);
|
|
||||||
background: var(--wps-surface);
|
|
||||||
/* Border and corners stay core's, so they match core buttons in each version. */
|
|
||||||
box-shadow: none;
|
|
||||||
transition: border-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__input::placeholder {
|
|
||||||
color: var(--wps-muted);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__input:hover {
|
|
||||||
border-color: var(--wps-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__input:focus {
|
|
||||||
border-color: var(--wps-accent);
|
|
||||||
box-shadow: 0 0 0 1px var(--wps-accent);
|
|
||||||
outline: 2px solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__field:focus-within .wps-search__icon {
|
|
||||||
color: var(--wps-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__button {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__group {
|
|
||||||
margin: 24px 0 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__group:first-of-type {
|
|
||||||
margin-block-start: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Navigation --------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-nav {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: stretch;
|
|
||||||
padding-inline: 12px;
|
|
||||||
background: var(--wps-surface);
|
|
||||||
border-block-end: 1px solid var(--wps-border);
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__group {
|
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__group + .wps-nav__group {
|
|
||||||
margin-inline-start: 8px;
|
|
||||||
padding-inline-start: 8px;
|
|
||||||
border-inline-start: 1px solid var(--wps-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__tab {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 14px 12px 11px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
text-decoration: none;
|
|
||||||
white-space: nowrap;
|
|
||||||
border-block-end: 3px solid transparent;
|
|
||||||
transition: color 0.1s ease, border-color 0.1s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__tab:hover {
|
|
||||||
color: var(--wps-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__tab:focus {
|
|
||||||
outline: none;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__tab:focus-visible {
|
|
||||||
outline: 2px solid var(--wps-accent);
|
|
||||||
outline-offset: -4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav__tab.is-active {
|
|
||||||
color: var(--wps-text);
|
|
||||||
font-weight: 600;
|
|
||||||
border-block-end-color: var(--wps-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Main --------------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-wrap > .notice,
|
|
||||||
.wps-wrap > div.updated,
|
|
||||||
.wps-wrap > div.error {
|
|
||||||
margin: 16px 24px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-main {
|
|
||||||
max-width: 1200px;
|
|
||||||
padding: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-section {
|
|
||||||
max-width: 860px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-section__intro {
|
|
||||||
margin-block-end: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-section__title {
|
|
||||||
margin: 0 0 4px;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-section__desc,
|
|
||||||
.wps-section__hint {
|
|
||||||
margin: 0;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-section__hint {
|
|
||||||
margin-block-start: 4px;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cards -------------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-card {
|
|
||||||
background: var(--wps-surface);
|
|
||||||
border: 1px solid var(--wps-border);
|
|
||||||
border-radius: var(--wps-radius);
|
|
||||||
box-shadow: var(--wps-shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-cards {
|
|
||||||
display: grid;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A settings tab with nothing in it yet. */
|
|
||||||
.wps-empty {
|
|
||||||
padding: 16px 20px;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-empty p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-badge {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 2px 8px;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
vertical-align: middle;
|
|
||||||
background: var(--wps-subtle);
|
|
||||||
border: 1px solid var(--wps-border);
|
|
||||||
border-radius: 999px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-badge--success {
|
|
||||||
color: #00450c;
|
|
||||||
background: #edfaef;
|
|
||||||
border-color: #b8e6bf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setting cards ------------------------------------------------------ */
|
|
||||||
|
|
||||||
/* Clip the header hover and panel backgrounds to the rounded corners. */
|
|
||||||
.wps-setting {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* "On" stripe drawn above the header/panel backgrounds so hover never hides it. */
|
|
||||||
.wps-setting::before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
inset-block: 0;
|
|
||||||
inset-inline-start: 0;
|
|
||||||
width: 3px;
|
|
||||||
background: var(--wps-accent);
|
|
||||||
opacity: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
transition: opacity 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting.is-on::before {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__header {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto 1fr auto;
|
|
||||||
align-items: center;
|
|
||||||
gap: 16px;
|
|
||||||
padding: 16px 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting.has-panel .wps-setting__header {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting.has-panel .wps-setting__header:hover {
|
|
||||||
background: #fcfcfc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__text {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Status sits beside the title so showing/hiding it never reflows the description. */
|
|
||||||
.wps-setting__title-row {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4px 10px;
|
|
||||||
min-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__title {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__desc {
|
|
||||||
margin: 2px 0 0;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-replaces {
|
|
||||||
margin: 4px 0 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-replaces__active {
|
|
||||||
color: #996800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-setting__expand {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4px;
|
|
||||||
padding: 6px 8px;
|
|
||||||
color: var(--wps-accent);
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-setting__expand:hover {
|
|
||||||
background: var(--wps-subtle);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-setting__expand:focus-visible {
|
|
||||||
outline: none;
|
|
||||||
box-shadow: var(--wps-focus);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__expand .dashicons {
|
|
||||||
transition: transform 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__expand[aria-expanded="true"] .dashicons {
|
|
||||||
transform: rotate(180deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__panel {
|
|
||||||
padding: 4px 20px 8px;
|
|
||||||
border-block-start: 1px solid var(--wps-border);
|
|
||||||
background: #fcfcfc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__panel[hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Status a feature prints above its options (wpstarter_setting_panel). */
|
|
||||||
.wps-panel-note {
|
|
||||||
padding: 12px 0;
|
|
||||||
border-block-end: 1px solid #f0f0f1;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-panel-note p {
|
|
||||||
margin: 0 0 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-panel-note p:last-child {
|
|
||||||
margin-block-end: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-panel-note--warning {
|
|
||||||
color: #1d2327;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-panel-note--warning p::before {
|
|
||||||
content: "\f534";
|
|
||||||
margin-inline-end: 6px;
|
|
||||||
font: 16px/1 dashicons;
|
|
||||||
vertical-align: -3px;
|
|
||||||
color: #dba617;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-media__preview {
|
|
||||||
flex: none;
|
|
||||||
width: 64px;
|
|
||||||
height: 64px;
|
|
||||||
object-fit: contain;
|
|
||||||
background: repeating-conic-gradient(#f0f0f1 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
|
|
||||||
border: 1px solid var(--wps-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-code {
|
|
||||||
max-width: 100%;
|
|
||||||
margin: 6px 0 0;
|
|
||||||
padding: 10px 12px;
|
|
||||||
overflow-x: auto;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.5;
|
|
||||||
color: #1d2327;
|
|
||||||
background: #f6f7f7;
|
|
||||||
border: 1px solid var(--wps-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fields ------------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-field {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 200px 1fr;
|
|
||||||
gap: 8px 24px;
|
|
||||||
padding: 16px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field + .wps-field {
|
|
||||||
border-block-start: 1px solid #f0f0f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field__label {
|
|
||||||
padding-block-start: 6px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field__control .description {
|
|
||||||
margin-block-start: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field__unit {
|
|
||||||
color: var(--wps-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field__control textarea.large-text {
|
|
||||||
max-width: 480px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-media {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px 12px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-media__preview[hidden],
|
|
||||||
.wps-media__remove[hidden] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-checkboxes {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px 20px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 6px 0 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-checkbox {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Long lists, such as every active plugin: columns that scroll. */
|
|
||||||
.wps-checkboxes.is-long {
|
|
||||||
display: block;
|
|
||||||
max-height: 320px;
|
|
||||||
overflow-y: auto;
|
|
||||||
columns: 16em auto;
|
|
||||||
column-gap: 20px;
|
|
||||||
padding: 6px 8px;
|
|
||||||
border: 1px solid #dcdcde;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-checkboxes.is-long .wps-checkbox {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
margin-block-end: 6px;
|
|
||||||
break-inside: avoid;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-checkboxes.is-long .wps-checkbox input {
|
|
||||||
margin-block-start: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-checkboxes__all {
|
|
||||||
display: block;
|
|
||||||
margin-block-end: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-tokens {
|
|
||||||
display: block;
|
|
||||||
margin-block-start: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-token {
|
|
||||||
margin: 2px 4px 2px 0;
|
|
||||||
padding: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
background: none;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-token code {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 1px 6px;
|
|
||||||
font-size: 12px;
|
|
||||||
background: var(--wps-subtle);
|
|
||||||
border: 1px solid var(--wps-border);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-token:hover code,
|
|
||||||
.wps-token:focus-visible code {
|
|
||||||
color: var(--wps-accent);
|
|
||||||
border-color: var(--wps-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-token:focus {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Switch ------------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-switch {
|
|
||||||
position: relative;
|
|
||||||
display: inline-block;
|
|
||||||
flex: none;
|
|
||||||
width: 36px;
|
|
||||||
height: 20px;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-switch__input {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 1;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-switch__track {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #1e1e1e;
|
|
||||||
border-radius: 999px;
|
|
||||||
transition: background-color 0.15s ease, border-color 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-switch__track::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
inset-block-start: 3px;
|
|
||||||
inset-inline-start: 3px;
|
|
||||||
width: 12px;
|
|
||||||
height: 12px;
|
|
||||||
background: #1e1e1e;
|
|
||||||
border-radius: 50%;
|
|
||||||
transition: transform 0.15s ease, background-color 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-switch__input:checked + .wps-switch__track {
|
|
||||||
background: var(--wps-accent);
|
|
||||||
border-color: var(--wps-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-switch__input:checked + .wps-switch__track::after {
|
|
||||||
background: #fff;
|
|
||||||
transform: translateX(16px);
|
|
||||||
}
|
|
||||||
|
|
||||||
[dir="rtl"] .wps-switch__input:checked + .wps-switch__track::after {
|
|
||||||
transform: translateX(-16px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-switch__input:focus-visible + .wps-switch__track {
|
|
||||||
box-shadow: var(--wps-focus);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-switch__input:disabled + .wps-switch__track {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save status -------------------------------------------------------- */
|
|
||||||
|
|
||||||
.wps-status {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4px;
|
|
||||||
min-height: 20px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--wps-muted);
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field__control .wps-status {
|
|
||||||
margin-inline-start: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-status.is-saving::before {
|
|
||||||
content: "";
|
|
||||||
width: 12px;
|
|
||||||
height: 12px;
|
|
||||||
border: 2px solid var(--wps-border);
|
|
||||||
border-block-start-color: var(--wps-accent);
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: wps-spin 0.8s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-status.is-saved {
|
|
||||||
color: var(--wps-success);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-status.is-saved::before {
|
|
||||||
content: "\f147";
|
|
||||||
font: normal 18px/1 dashicons;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-status.is-error {
|
|
||||||
color: var(--wps-error);
|
|
||||||
white-space: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes wps-spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read Me ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
.wps-readme {
|
|
||||||
max-width: 820px;
|
|
||||||
padding: 24px 32px;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.65;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme-image {
|
|
||||||
margin: 0 0 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme-image img {
|
|
||||||
display: block;
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
border-radius: var(--wps-radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The banner at the top of README.md fills the top of the card. */
|
|
||||||
.wps-readme > .wps-readme-image:first-child {
|
|
||||||
margin: -24px -32px 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme > .wps-readme-image:first-child img {
|
|
||||||
width: 100%;
|
|
||||||
border-radius: calc(var(--wps-radius) - 1px) calc(var(--wps-radius) - 1px) 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-readme h2 {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
font-size: 22px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-readme h3 {
|
|
||||||
margin: 24px 0 8px;
|
|
||||||
padding-block-start: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
border-block-start: 1px solid #f0f0f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-readme h4 {
|
|
||||||
margin: 16px 0 6px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme ul,
|
|
||||||
.wps-readme ol {
|
|
||||||
margin: 8px 0 12px;
|
|
||||||
padding-inline-start: 22px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme ul {
|
|
||||||
list-style: disc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme ol {
|
|
||||||
list-style: decimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme-table {
|
|
||||||
margin: 8px 0 16px;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme th,
|
|
||||||
.wps-readme td {
|
|
||||||
padding: 6px 10px;
|
|
||||||
text-align: start;
|
|
||||||
vertical-align: top;
|
|
||||||
border: 1px solid rgba(127, 127, 127, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-readme th {
|
|
||||||
background: rgba(127, 127, 127, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Responsive --------------------------------------------------------- */
|
|
||||||
|
|
||||||
@media screen and (max-width: 782px) {
|
|
||||||
.wps-wrap {
|
|
||||||
margin-inline-start: -10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-header,
|
|
||||||
.wps-main {
|
|
||||||
padding-inline: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-nav {
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Brand and website link on the first row, search across the second. */
|
|
||||||
.wps-search {
|
|
||||||
order: 1;
|
|
||||||
flex: 1 1 100%;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-search__field {
|
|
||||||
flex: 1 1 0;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-wrap .wps-search__input {
|
|
||||||
flex: 1 1 0;
|
|
||||||
width: auto;
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 40px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-search .button {
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__header {
|
|
||||||
grid-template-columns: auto 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-setting__expand {
|
|
||||||
grid-column: 2;
|
|
||||||
justify-self: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wps-field {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
.wps-wrap *,
|
|
||||||
.wps-wrap *::before,
|
|
||||||
.wps-wrap *::after {
|
|
||||||
transition: none !important;
|
|
||||||
animation: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Read Me content for the WP Plugin Starter admin tab (from README.md).
|
|
||||||
*
|
|
||||||
* @package WPStarter
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* README.md contents, with a short fallback if the file is missing.
|
|
||||||
*
|
|
||||||
* @return array{title:string,content:string}
|
|
||||||
*/
|
|
||||||
function wpstarter_get_readme_content() {
|
|
||||||
$readme_path = WPSTARTER_DIR . 'README.md';
|
|
||||||
|
|
||||||
if (is_readable($readme_path)) {
|
|
||||||
$content = (string) file_get_contents($readme_path); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- local file.
|
|
||||||
} else {
|
|
||||||
$content = "# WP Plugin Starter\n\nVersion: " . WPSTARTER_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'title' => __('Read Me', 'wp-plugin-starter-template'),
|
|
||||||
'content' => $content,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,434 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!--
|
|
||||||
WP Plugin Starter banner (WordPress.org banners and the Read Me tab).
|
|
||||||
Source: .wordpress-org/banner.svg. Edit that, then run scripts/build-banner.sh.
|
|
||||||
Branding follows wpallstars.com: navy, red and cream, Zilla Slab italic
|
|
||||||
headings, the wpallstars plugin stack in red only, the logo's arc of five stars and its red double stripes (here with cream between).
|
|
||||||
-->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="1544"
|
|
||||||
height="500"
|
|
||||||
viewBox="0 0 1544 500"
|
|
||||||
version="1.1"
|
|
||||||
id="svg51"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<title
|
|
||||||
id="title1">WPALLSTARS WP Plugin Starter: Built with AI</title>
|
|
||||||
<defs
|
|
||||||
id="defs21">
|
|
||||||
<linearGradient
|
|
||||||
id="bg"
|
|
||||||
x1="0"
|
|
||||||
y1="0"
|
|
||||||
x2="1"
|
|
||||||
y2="1">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#000c1f"
|
|
||||||
id="stop1" />
|
|
||||||
<stop
|
|
||||||
offset="0.55"
|
|
||||||
stop-color="#001537"
|
|
||||||
id="stop2" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#0d264d"
|
|
||||||
id="stop3" />
|
|
||||||
</linearGradient>
|
|
||||||
<radialGradient
|
|
||||||
id="glow-blue"
|
|
||||||
cx="1214"
|
|
||||||
cy="270"
|
|
||||||
r="440"
|
|
||||||
gradientUnits="userSpaceOnUse">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#bb0000"
|
|
||||||
stop-opacity="0.45"
|
|
||||||
id="stop4" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#bb0000"
|
|
||||||
stop-opacity="0"
|
|
||||||
id="stop5" />
|
|
||||||
</radialGradient>
|
|
||||||
<radialGradient
|
|
||||||
id="glow-red"
|
|
||||||
cx="200"
|
|
||||||
cy="580"
|
|
||||||
r="520"
|
|
||||||
gradientUnits="userSpaceOnUse">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#bb0000"
|
|
||||||
stop-opacity="0.2"
|
|
||||||
id="stop6" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#bb0000"
|
|
||||||
stop-opacity="0"
|
|
||||||
id="stop7" />
|
|
||||||
</radialGradient>
|
|
||||||
<radialGradient
|
|
||||||
id="glow-gold"
|
|
||||||
cx="1214"
|
|
||||||
cy="76"
|
|
||||||
r="120"
|
|
||||||
gradientUnits="userSpaceOnUse">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#ffc94d"
|
|
||||||
stop-opacity="0.45"
|
|
||||||
id="stop8" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#ffc94d"
|
|
||||||
stop-opacity="0"
|
|
||||||
id="stop9" />
|
|
||||||
</radialGradient>
|
|
||||||
<radialGradient
|
|
||||||
id="dots-fade"
|
|
||||||
cx="1214"
|
|
||||||
cy="260"
|
|
||||||
r="560"
|
|
||||||
gradientUnits="userSpaceOnUse">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#fff"
|
|
||||||
stop-opacity="1"
|
|
||||||
id="stop10" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#fff"
|
|
||||||
stop-opacity="0"
|
|
||||||
id="stop11" />
|
|
||||||
</radialGradient>
|
|
||||||
<pattern
|
|
||||||
id="dots"
|
|
||||||
width="28"
|
|
||||||
height="28"
|
|
||||||
patternUnits="userSpaceOnUse">
|
|
||||||
<circle
|
|
||||||
cx="14"
|
|
||||||
cy="14"
|
|
||||||
r="1.5"
|
|
||||||
fill="#ffffea"
|
|
||||||
fill-opacity="0.12"
|
|
||||||
id="circle11" />
|
|
||||||
</pattern>
|
|
||||||
<mask
|
|
||||||
id="dots-mask">
|
|
||||||
<rect
|
|
||||||
width="1544"
|
|
||||||
height="500"
|
|
||||||
fill="url(#dots-fade)"
|
|
||||||
id="rect11" />
|
|
||||||
</mask>
|
|
||||||
<linearGradient
|
|
||||||
id="gold"
|
|
||||||
x1="0"
|
|
||||||
y1="0"
|
|
||||||
x2="0"
|
|
||||||
y2="1">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#ffe08a"
|
|
||||||
id="stop12" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#f5a524"
|
|
||||||
id="stop13" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
id="gold-text"
|
|
||||||
x1="96"
|
|
||||||
y1="280"
|
|
||||||
x2="700"
|
|
||||||
y2="340"
|
|
||||||
gradientUnits="userSpaceOnUse">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#ffd970"
|
|
||||||
id="stop14" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#f5a524"
|
|
||||||
id="stop15" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
id="top-red"
|
|
||||||
x1="0"
|
|
||||||
y1="0"
|
|
||||||
x2="1"
|
|
||||||
y2="1">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#ef4444"
|
|
||||||
id="stop16" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#bb0000"
|
|
||||||
id="stop17" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
id="top-cream"
|
|
||||||
x1="0"
|
|
||||||
y1="0"
|
|
||||||
x2="1"
|
|
||||||
y2="1">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#ff8a8a"
|
|
||||||
id="stop18" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#e03131"
|
|
||||||
id="stop19" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
id="top-blue"
|
|
||||||
x1="0"
|
|
||||||
y1="0"
|
|
||||||
x2="1"
|
|
||||||
y2="1">
|
|
||||||
<stop
|
|
||||||
offset="0"
|
|
||||||
stop-color="#c81e1e"
|
|
||||||
id="stop20" />
|
|
||||||
<stop
|
|
||||||
offset="1"
|
|
||||||
stop-color="#7a0000"
|
|
||||||
id="stop21" />
|
|
||||||
</linearGradient>
|
|
||||||
<!-- A five-pointed star, radius 1, centred on 0,0 -->
|
|
||||||
<polygon
|
|
||||||
id="star"
|
|
||||||
points="0,-1 0.2245,-0.309 0.9511,-0.309 0.3633,0.118 0.5878,0.809 0,0.382 -0.5878,0.809 -0.3633,0.118 -0.9511,-0.309 -0.2245,-0.309" />
|
|
||||||
</defs>
|
|
||||||
<!-- Background -->
|
|
||||||
<rect
|
|
||||||
width="1544"
|
|
||||||
height="500"
|
|
||||||
fill="url(#bg)"
|
|
||||||
id="rect21" />
|
|
||||||
<rect
|
|
||||||
width="1544"
|
|
||||||
height="500"
|
|
||||||
fill="url(#glow-red)"
|
|
||||||
id="rect22" />
|
|
||||||
<rect
|
|
||||||
width="1544"
|
|
||||||
height="500"
|
|
||||||
fill="url(#glow-blue)"
|
|
||||||
id="rect23" />
|
|
||||||
<rect
|
|
||||||
width="1544"
|
|
||||||
height="500"
|
|
||||||
fill="url(#dots)"
|
|
||||||
mask="url(#dots-mask)"
|
|
||||||
id="rect24" />
|
|
||||||
<!-- wpallstars.com's red double lines, with a cream line between them. -->
|
|
||||||
<g
|
|
||||||
id="g30">
|
|
||||||
<rect
|
|
||||||
y="0"
|
|
||||||
width="1544"
|
|
||||||
height="6"
|
|
||||||
fill="#bb0000"
|
|
||||||
id="rect25" />
|
|
||||||
<rect
|
|
||||||
y="6"
|
|
||||||
width="1544"
|
|
||||||
height="5"
|
|
||||||
fill="#ffffea"
|
|
||||||
id="rect26" />
|
|
||||||
<rect
|
|
||||||
y="11"
|
|
||||||
width="1544"
|
|
||||||
height="6"
|
|
||||||
fill="#bb0000"
|
|
||||||
id="rect27" />
|
|
||||||
<rect
|
|
||||||
y="483"
|
|
||||||
width="1544"
|
|
||||||
height="6"
|
|
||||||
fill="#bb0000"
|
|
||||||
id="rect28" />
|
|
||||||
<rect
|
|
||||||
y="489"
|
|
||||||
width="1544"
|
|
||||||
height="5"
|
|
||||||
fill="#ffffea"
|
|
||||||
id="rect29" />
|
|
||||||
<rect
|
|
||||||
y="494"
|
|
||||||
width="1544"
|
|
||||||
height="6"
|
|
||||||
fill="#bb0000"
|
|
||||||
id="rect30" />
|
|
||||||
</g>
|
|
||||||
<!-- The picture: scaled down a little so it keeps clear of the stripes -->
|
|
||||||
<g
|
|
||||||
transform="translate(1214 248) scale(0.86) translate(-1214 -248)"
|
|
||||||
id="g48">
|
|
||||||
<!-- The stack: red, cream and blue layers, each with a top face and two sides -->
|
|
||||||
<g
|
|
||||||
stroke-linejoin="round"
|
|
||||||
id="g43">
|
|
||||||
<g
|
|
||||||
transform="translate(0 350)"
|
|
||||||
id="g33">
|
|
||||||
<polygon
|
|
||||||
points="1064,0 1214,87 1214,117 1064,30"
|
|
||||||
fill="#5c0000"
|
|
||||||
id="polygon30" />
|
|
||||||
<polygon
|
|
||||||
points="1214,87 1364,0 1364,30 1214,117"
|
|
||||||
fill="#420000"
|
|
||||||
id="polygon31" />
|
|
||||||
<polygon
|
|
||||||
points="1214,-87 1364,0 1214,87 1064,0"
|
|
||||||
fill="url(#top-blue)"
|
|
||||||
id="polygon32" />
|
|
||||||
<polygon
|
|
||||||
points="1214,-61 1319,0 1214,61 1109,0"
|
|
||||||
fill="none"
|
|
||||||
stroke="#ffffff"
|
|
||||||
stroke-opacity="0.3"
|
|
||||||
stroke-width="2"
|
|
||||||
id="polygon33" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
transform="translate(0 294)"
|
|
||||||
id="g37">
|
|
||||||
<polygon
|
|
||||||
points="1064,0 1214,87 1214,117 1064,30"
|
|
||||||
fill="#c22424"
|
|
||||||
id="polygon34" />
|
|
||||||
<polygon
|
|
||||||
points="1214,87 1364,0 1364,30 1214,117"
|
|
||||||
fill="#9e1414"
|
|
||||||
id="polygon35" />
|
|
||||||
<polygon
|
|
||||||
points="1214,-87 1364,0 1214,87 1064,0"
|
|
||||||
fill="url(#top-cream)"
|
|
||||||
id="polygon36" />
|
|
||||||
<polygon
|
|
||||||
points="1214,-61 1319,0 1214,61 1109,0"
|
|
||||||
fill="none"
|
|
||||||
stroke="#001537"
|
|
||||||
stroke-opacity="0.18"
|
|
||||||
stroke-width="2"
|
|
||||||
id="polygon37" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
transform="translate(0 238)"
|
|
||||||
id="g42">
|
|
||||||
<polygon
|
|
||||||
points="1064,0 1214,87 1214,117 1064,30"
|
|
||||||
fill="#940000"
|
|
||||||
id="polygon38" />
|
|
||||||
<polygon
|
|
||||||
points="1214,87 1364,0 1364,30 1214,117"
|
|
||||||
fill="#700000"
|
|
||||||
id="polygon39" />
|
|
||||||
<polygon
|
|
||||||
points="1214,-87 1364,0 1214,87 1064,0"
|
|
||||||
fill="url(#top-red)"
|
|
||||||
id="polygon40" />
|
|
||||||
<!-- The WordPress Plugins icon (Dashicons admin-plugins, GPLv2 or later),
|
|
||||||
laid flat on the top face: icon x runs along the top-right edge and
|
|
||||||
icon y along the top-left edge, each 20-unit side 66% of the face.
|
|
||||||
Turned 45 degrees so the plug points along the back-left edge. -->
|
|
||||||
<g
|
|
||||||
transform="matrix(4.95 2.871 -4.95 2.871 1214 -57.42)"
|
|
||||||
id="g41">
|
|
||||||
<path
|
|
||||||
fill="#5c0000"
|
|
||||||
fill-opacity="0.55"
|
|
||||||
transform="translate(0.3 0.3) rotate(-45 10 10)"
|
|
||||||
d="M13.11 4.36L9.87 7.6 8 5.73l3.24-3.24c.35-.34 1.05-.2 1.56.32.52.51.66 1.21.31 1.55zm-8 1.77l.91-1.12 9.01 9.01-1.19.84c-.71.71-2.63 1.16-3.82 1.16H6.14L4.9 17.26c-.59.59-1.54.59-2.12 0-.59-.58-.59-1.53 0-2.12l1.24-1.24v-3.88c0-1.13.4-3.19 1.09-3.89zm7.26 3.97l3.24-3.24c.34-.35 1.04-.21 1.55.31.52.51.66 1.21.31 1.55l-3.24 3.25z"
|
|
||||||
id="path40" />
|
|
||||||
<path
|
|
||||||
fill="#ffffea"
|
|
||||||
transform="rotate(-45 10 10)"
|
|
||||||
d="M13.11 4.36L9.87 7.6 8 5.73l3.24-3.24c.35-.34 1.05-.2 1.56.32.52.51.66 1.21.31 1.55zm-8 1.77l.91-1.12 9.01 9.01-1.19.84c-.71.71-2.63 1.16-3.82 1.16H6.14L4.9 17.26c-.59.59-1.54.59-2.12 0-.59-.58-.59-1.53 0-2.12l1.24-1.24v-3.88c0-1.13.4-3.19 1.09-3.89zm7.26 3.97l3.24-3.24c.34-.35 1.04-.21 1.55.31.52.51.66 1.21.31 1.55l-3.24 3.25z"
|
|
||||||
id="path41" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<!-- The logo's arc of five stars: gold in the middle, floating above the stack -->
|
|
||||||
<circle
|
|
||||||
cx="1214"
|
|
||||||
cy="76"
|
|
||||||
r="120"
|
|
||||||
fill="url(#glow-gold)"
|
|
||||||
id="circle43" />
|
|
||||||
<g
|
|
||||||
stroke-linejoin="round"
|
|
||||||
id="g47">
|
|
||||||
<g
|
|
||||||
fill="#bb0000"
|
|
||||||
stroke="#ffffea"
|
|
||||||
stroke-width="5"
|
|
||||||
id="g46">
|
|
||||||
<use
|
|
||||||
xlink:href="#star"
|
|
||||||
transform="translate(1043 150) scale(17)"
|
|
||||||
stroke-width="0.3"
|
|
||||||
id="use43" />
|
|
||||||
<use
|
|
||||||
xlink:href="#star"
|
|
||||||
transform="translate(1110 100) scale(26)"
|
|
||||||
stroke-width="0.2"
|
|
||||||
id="use44" />
|
|
||||||
<use
|
|
||||||
xlink:href="#star"
|
|
||||||
transform="translate(1318 100) scale(26)"
|
|
||||||
stroke-width="0.2"
|
|
||||||
id="use45" />
|
|
||||||
<use
|
|
||||||
xlink:href="#star"
|
|
||||||
transform="translate(1385 150) scale(17)"
|
|
||||||
stroke-width="0.3"
|
|
||||||
id="use46" />
|
|
||||||
</g>
|
|
||||||
<use
|
|
||||||
xlink:href="#star"
|
|
||||||
transform="translate(1214 78) scale(54)"
|
|
||||||
fill="url(#gold)"
|
|
||||||
stroke="#ffffea"
|
|
||||||
stroke-width="0.11"
|
|
||||||
id="use47" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<!-- Words -->
|
|
||||||
<g
|
|
||||||
font-family="Zilla Slab"
|
|
||||||
text-rendering="geometricPrecision"
|
|
||||||
id="g51">
|
|
||||||
<path
|
|
||||||
d="m 123.893,113.015 h -1.431 L 117.683,128 h -2.214 l -4.293,-12.366 h -0.135 L 106.883,128 h -2.241 l -5.076,-14.985 h -1.512 v -2.565 h 6.669 v 2.565 h -1.944 l 3.024,10.044 h 0.135 l 3.483,-10.044 h -1.539 v -2.565 h 6.642 v 2.565 h -1.431 l 3.483,10.179 h 0.135 l 2.754,-10.179 h -2.16 v -2.565 h 6.588 z m 20.60601,3.024 q 0,2.889 -1.863,4.374 -1.836,1.458 -4.428,1.458 h -2.97 v 3.564 h 2.808 V 128 h -7.83 v -2.565 h 2.025 v -12.42 h -2.025 v -2.565 h 7.83 q 3.267,0 4.86,1.566 1.593,1.566 1.593,4.023 z m -3.213,0.054 q 0,-1.458 -0.837,-2.268 -0.81,-0.81 -2.754,-0.81 h -2.457 v 6.318 h 2.457 q 1.917,0 2.754,-0.864 0.837,-0.891 0.837,-2.376 z M 166.72505,128 h -6.723 v -2.565 h 1.782 l -0.891,-2.403 h -6.561 l -0.945,2.403 h 1.971 V 128 h -6.642 v -2.565 h 1.62 l 5.292,-12.42 h -2.565 v -2.565 h 5.643 l 6.318,14.985 h 1.701 z m -6.642,-7.155 -2.295,-6.102 h -0.162 l -2.43,6.102 z M 185.71107,128 h -12.987 v -2.565 h 2.025 v -12.42 h -2.025 v -2.565 h 7.641 v 2.565 h -2.619 v 12.42 h 5.4 l 0.54,-3.645 2.565,0.216 z m 19.93099,0 h -12.987 v -2.565 h 2.025 v -12.42 h -2.025 v -2.565 h 7.641 v 2.565 h -2.619 v 12.42 h 5.4 l 0.54,-3.645 2.565,0.216 z m 19.68799,-5.157 q 0,2.619 -1.836,4.023 -1.809,1.404 -4.806,1.404 -1.782,0 -3.456,-0.432 -1.647,-0.432 -2.619,-1.242 l 0.486,-4.023 2.403,0.243 -0.054,2.16 q 0.891,0.459 1.62,0.594 0.756,0.108 1.404,0.108 1.566,0 2.592,-0.486 1.053,-0.513 1.053,-2.025 0,-1.647 -1.188,-2.187 -1.188,-0.567 -2.727,-0.864 -1.242,-0.243 -2.511,-0.648 -1.269,-0.405 -2.106,-1.35 -0.837,-0.945 -0.837,-2.781 0,-2.754 1.863,-3.942 1.89,-1.215 4.212,-1.215 1.62,0 3.132,0.486 1.539,0.486 2.403,1.269 l 0.162,3.699 -2.403,0.216 -0.243,-2.268 q -0.756,-0.432 -1.512,-0.594 -0.756,-0.162 -1.458,-0.162 -1.269,0 -2.106,0.513 -0.837,0.513 -0.837,1.647 0,1.323 1.026,1.809 1.053,0.459 2.349,0.756 1.107,0.243 2.511,0.648 1.404,0.405 2.43,1.458 1.053,1.026 1.053,3.186 z m 22.65801,-6.669 -2.592,0.216 -0.54,-3.375 h -3.429 v 12.42 h 2.943 V 128 h -8.775 v -2.565 h 2.835 v -12.42 h -3.456 l -0.54,3.375 -2.565,-0.216 0.54,-5.724 h 15.039 z M 270.18705,128 h -6.723 v -2.565 h 1.782 l -0.891,-2.403 h -6.561 l -0.945,2.403 h 1.971 V 128 h -6.642 v -2.565 h 1.62 l 5.292,-12.42 h -2.565 v -2.565 h 5.643 l 6.318,14.985 h 1.701 z m -6.642,-7.155 -2.295,-6.102 h -0.162 l -2.43,6.102 z M 291.81908,128 h -4.104 l -3.618,-6.939 h -2.889 v 4.374 h 2.052 V 128 h -7.074 v -2.565 h 2.025 v -12.42 h -2.025 v -2.565 h 7.803 q 3.267,0 4.887,1.377 1.62,1.35 1.62,3.807 0,1.755 -0.945,3.024 -0.918,1.242 -2.565,1.782 l 2.673,4.995 h 2.16 z m -4.509,-12.285 q 0,-1.485 -0.864,-2.079 -0.864,-0.621 -2.943,-0.621 h -2.295 v 5.643 h 2.268 q 2.16,0 2.997,-0.756 0.837,-0.783 0.837,-2.187 z m 23.62998,7.128 q 0,2.619 -1.836,4.023 -1.809,1.404 -4.806,1.404 -1.782,0 -3.456,-0.432 -1.647,-0.432 -2.619,-1.242 l 0.486,-4.023 2.403,0.243 -0.054,2.16 q 0.891,0.459 1.62,0.594 0.756,0.108 1.404,0.108 1.566,0 2.592,-0.486 1.053,-0.513 1.053,-2.025 0,-1.647 -1.188,-2.187 -1.188,-0.567 -2.727,-0.864 -1.242,-0.243 -2.511,-0.648 -1.269,-0.405 -2.106,-1.35 -0.837,-0.945 -0.837,-2.781 0,-2.754 1.863,-3.942 1.89,-1.215 4.212,-1.215 1.62,0 3.132,0.486 1.539,0.486 2.403,1.269 l 0.162,3.699 -2.403,0.216 -0.243,-2.268 q -0.756,-0.432 -1.512,-0.594 -0.756,-0.162 -1.458,-0.162 -1.269,0 -2.106,0.513 -0.837,0.513 -0.837,1.647 0,1.323 1.026,1.809 1.053,0.459 2.349,0.756 1.107,0.243 2.511,0.648 1.404,0.405 2.43,1.458 1.053,1.026 1.053,3.186 z"
|
|
||||||
id="text48"
|
|
||||||
style="font-weight:600;font-size:27px;letter-spacing:5;fill:#ff999b"
|
|
||||||
aria-label="WPALLSTARS" />
|
|
||||||
<path
|
|
||||||
d="M 192.464,184.256 H 187.16 L 163.552,240 h -9.464 l -10.712,-43.68 h -0.52 L 123.72,240 h -9.672 L 100.944,184.256 H 95.328 L 96.576,172.4 h 25.792 l -1.248,11.856 h -5.928 l 6.24,32.656 h 0.624 l 14.976,-32.656 h -5.096 l 1.248,-11.856 h 25.896 l -1.248,11.856 h -4.68 l 8.008,33.28 h 0.624 l 11.96,-33.28 h -6.864 l 1.248,-11.856 h 25.584 z m -0.37598,43.888 h 6.968 l 4.576,-43.888 h -6.968 l 1.248,-11.856 h 29.744 q 11.128,0 16.848,5.616 5.72,5.512 5.72,14.976 0,12.272 -8.216,18.304 -8.112,6.032 -18.408,6.032 h -9.984 l -1.144,10.816 h 9.984 l -1.248,11.856 h -30.368 z m 30.264,-22.568 q 7.696,0 10.504,-3.432 2.912,-3.536 2.912,-8.528 0,-4.576 -2.392,-6.968 -2.392,-2.392 -8.632,-2.392 h -7.696 l -2.184,21.32 z m 46.464,22.568 h 6.968 l 4.576,-43.888 h -6.968 l 1.248,-11.856 h 29.744 q 11.128,0 16.848,5.616 5.72,5.512 5.72,14.976 0,12.272 -8.216,18.304 -8.112,6.032 -18.408,6.032 h -9.984 l -1.144,10.816 h 9.984 l -1.248,11.856 h -30.368 z m 30.264,-22.568 q 7.696,0 10.504,-3.432 2.912,-3.536 2.912,-8.528 0,-4.576 -2.392,-6.968 -2.392,-2.392 -8.632,-2.392 h -7.696 l -2.184,21.32 z m 31.55191,-34.32 3.224,-2.808 h 16.432 l -7.488,61.36 h 6.032 l -0.936,7.592 -3.12,2.6 h -16.12 l 7.488,-61.36 h -6.448 z m 73.98399,58.552 -0.936,7.384 -3.224,2.808 h -14.456 l -0.52,-9.048 q -2.392,4.472 -6.136,7.28 -3.744,2.704 -8.944,2.704 -6.344,0 -10.608,-3.952 -4.16,-3.952 -3.12,-12.272 l 2.6,-21.424 h -6.032 l 0.936,-7.592 3.12,-2.6 h 16.016 l -3.224,26.416 q -0.728,6.136 0.832,8.736 1.664,2.496 5.512,2.496 4.68,0 6.968,-3.12 2.392,-3.12 3.016,-8.008 v 0.104 l 3.224,-26.624 h 12.896 l -4.472,36.712 z m 41.32793,-36.712 h 16.952 l -0.936,7.592 -3.12,2.6 h -3.328 l -4.264,34.32 q -1.248,9.984 -6.864,17.68 -5.616,7.8 -18.616,7.8 -6.656,0 -12.584,-3.328 -5.824,-3.224 -7.592,-11.336 l 9.152,-5.2 q 3.432,8.736 11.856,8.736 9.984,0 11.752,-14.352 l 0.728,-6.448 q -2.392,4.056 -6.24,6.968 -3.848,2.912 -9.36,2.912 -7.696,0 -11.336,-5.824 -3.64,-5.824 -3.64,-13.936 0,-6.552 2.392,-13.208 2.392,-6.76 7.176,-11.336 4.888,-4.576 12.48,-4.576 10.088,0 13.104,8.32 z m -13.312,9.256 q -4.992,0 -7.592,5.2 -2.6,5.2 -2.6,12.272 0,4.888 1.456,8.008 1.456,3.016 4.888,3.016 4.16,0 7.488,-3.952 3.328,-3.952 4.368,-8.424 l 0.624,-4.992 q 0.208,-5.408 -2.496,-8.216 -2.704,-2.912 -6.136,-2.912 z m 39.5601,-17.576 1.456,-13.936 h 12.48 l -1.456,13.936 z m -8.216,11.128 3.224,-2.808 h 16.536 l -4.472,36.712 h 5.928 l -0.936,7.592 -3.12,2.6 h -16.016 l 4.472,-36.712 h -6.552 z m 30.51203,-2.808 h 14.456 l 0.52,8.944 q 2.392,-4.472 6.136,-7.176 3.744,-2.704 8.944,-2.704 6.344,0 10.504,3.952 4.264,3.952 3.224,12.272 l -2.6,21.424 h 6.032 l -0.936,7.592 -3.12,2.6 h -16.016 l 3.224,-26.416 q 0.728,-6.032 -0.936,-8.632 -1.56,-2.6 -5.408,-2.6 -4.368,0 -6.76,2.704 -2.392,2.704 -3.12,7.176 l -3.328,27.768 h -12.896 l 4.472,-36.712 h -6.552 l 0.936,-7.384 z m 118.53613,25.688 q 0,10.816 -7.176,16.536 -7.072,5.72 -19.76,5.72 -6.968,0 -13.52,-1.768 -6.448,-1.768 -9.984,-5.304 l 3.848,-16.744 10.816,1.04 -0.936,8.216 q 3.224,1.872 5.616,2.288 2.392,0.312 3.744,0.312 5.824,0 9.152,-1.768 3.432,-1.872 3.432,-7.488 0,-5.096 -2.912,-6.552 -2.912,-1.56 -8.632,-2.6 -4.576,-0.832 -9.048,-2.496 -4.368,-1.768 -7.28,-5.304 -2.912,-3.64 -2.912,-10.4 0,-7.8 3.848,-12.376 3.952,-4.68 9.88,-6.656 6.032,-2.08 12.272,-2.08 6.864,0 12.48,2.08 5.72,1.976 8.632,5.408 l -0.936,14.664 -11.024,1.04 -0.104,-7.904 q -2.392,-1.768 -4.888,-2.392 -2.496,-0.624 -4.992,-0.624 -4.368,0 -7.488,1.664 -3.12,1.56 -3.12,5.408 0,4.056 3.328,5.616 3.328,1.56 7.696,2.496 4.368,0.936 8.944,2.704 4.68,1.664 7.8,5.616 3.224,3.952 3.224,11.648 z m 5.44796,-22.464 3.536,-3.224 h 3.016 l 1.248,-10.088 4.056,-4.16 h 9.36 l -1.768,14.248 h 14.04 l -0.936,6.864 -3.536,3.328 h -10.816 l -2.6,21.424 q -0.728,6.136 3.12,6.136 1.664,0 3.224,-1.456 1.664,-1.56 3.016,-6.968 l 9.048,3.016 q -1.976,8.112 -5.824,11.856 -3.848,3.744 -10.816,3.744 -7.488,0 -11.648,-3.848 -4.056,-3.952 -3.224,-11.232 l 2.808,-22.672 h -6.24 z m 85.11207,-3.224 q -1.352,4.264 -2.392,8.32 -0.936,4.056 -1.456,8.32 l -2.496,20.072 h 6.032 l -0.936,7.592 -3.12,2.6 h -14.04 l -0.416,-9.568 q -2.184,4.368 -5.928,7.488 -3.744,3.12 -9.464,3.12 -7.696,0 -11.544,-5.824 -3.848,-5.824 -3.848,-14.248 0,-6.344 2.288,-13 2.288,-6.656 6.968,-11.232 4.784,-4.576 12.376,-4.576 10.192,0 13.312,8.736 0.52,-1.976 0.936,-3.848 0.52,-1.976 1.248,-3.952 z m -25.896,9.256 q -4.992,0 -7.384,5.304 -2.392,5.2 -2.392,11.752 0,11.44 6.656,11.44 4.264,0 7.28,-4.056 3.016,-4.056 3.952,-8.632 l 0.416,-3.536 q 0.624,-5.824 -2.184,-9.048 -2.704,-3.224 -6.344,-3.224 z m 35.50396,-9.256 h 13.416 l 0.728,12.896 q 1.56,-4.888 4.264,-9.36 2.808,-4.472 7.072,-4.472 2.912,0 5.096,1.872 l -2.08,13.832 q -2.912,-1.56 -5.408,-1.56 -7.072,0 -8.736,7.28 l -2.288,16.224 h 8.944 l -0.936,7.384 -3.224,2.808 h -25.064 l 0.936,-7.384 3.224,-2.808 h 3.12 l 3.224,-26.52 h -6.448 l 0.936,-7.384 z m 31.13605,3.224 3.536,-3.224 h 3.016 l 1.248,-10.088 4.056,-4.16 h 9.36 l -1.768,14.2Line truncated
|
|
||||||
id="text49"
|
|
||||||
style="font-style:italic;font-weight:700;font-size:104px;letter-spacing:-1;fill:#ffffea"
|
|
||||||
aria-label="WP Plugin Starter" />
|
|
||||||
<path
|
|
||||||
d="m 124.944,279.2 q 5.76,0 9.144,2.736 3.456,2.664 3.456,7.272 0,3.816 -2.448,6.912 -2.376,3.096 -6.768,3.816 v 0.288 q 4.248,0.72 6.408,3.528 2.16,2.808 2.16,7.056 0,5.904 -4.104,10.584 Q 128.688,326 120.336,326 H 96.648 l 0.864,-8.208 h 4.824 l 3.168,-30.384 h -4.824 l 0.864,-8.208 z m -5.112,19.152 q 4.392,0 5.904,-1.944 1.584,-1.944 1.584,-4.248 0,-2.88 -1.656,-3.816 -1.584,-0.936 -4.032,-0.936 h -6.84 l -1.152,10.944 z m -1.08,19.44 q 8.208,0 8.208,-6.624 0,-5.328 -6.336,-5.328 h -7.776 l -1.224,11.952 z m 57.24003,1.152 -0.648,5.112 -2.232,1.944 h -10.008 l -0.36,-6.264 q -1.656,3.096 -4.248,5.04 -2.592,1.872 -6.192,1.872 -4.392,0 -7.344,-2.736 -2.88,-2.736 -2.16,-8.496 l 1.8,-14.832 h -4.176 l 0.648,-5.256 2.16,-1.8 h 11.088 l -2.232,18.288 q -0.504,4.248 0.576,6.048 1.152,1.728 3.816,1.728 3.24,0 4.824,-2.16 1.656,-2.16 2.088,-5.544 v 0.072 l 2.232,-18.432 h 8.928 l -3.096,25.416 z m 10.29594,-31.176 1.008,-9.648 h 8.64 l -1.008,9.648 z m -5.688,7.704 2.232,-1.944 h 11.448 l -3.096,25.416 h 4.104 l -0.648,5.256 -2.16,1.8 h -11.088 l 3.096,-25.416 h -4.536 z m 20.80802,-17.064 2.232,-1.944 h 11.376 l -5.184,42.48 h 4.176 l -0.648,5.256 -2.16,1.8 h -11.16 l 5.184,-42.48 h -4.464 z m 16.84799,17.352 2.448,-2.232 h 2.088 l 0.864,-6.984 2.808,-2.88 h 6.48 l -1.224,9.864 h 9.72 l -0.648,4.752 -2.448,2.304 h -7.488 l -1.8,14.832 q -0.504,4.248 2.16,4.248 1.152,0 2.232,-1.008 1.152,-1.08 2.088,-4.824 l 6.264,2.088 q -1.368,5.616 -4.032,8.208 -2.664,2.592 -7.488,2.592 -5.184,0 -8.064,-2.664 -2.808,-2.736 -2.232,-7.776 l 1.944,-15.696 h -4.32 z m 72.21606,19.584 h 0.36 q 3.312,-4.608 4.68,-7.92 1.44,-3.384 1.44,-6.912 0,-3.456 -1.44,-6.984 h 10.008 q 0.792,4.392 -0.216,9.072 -1.008,4.68 -4.824,9.792 -1.872,2.448 -5.328,6.48 -3.456,4.032 -6.624,7.128 h -3.744 l -4.752,-18.72 h -0.432 l -10.512,18.72 h -4.752 l -6.912,-25.416 h -3.168 l 0.648,-5.112 2.232,-1.944 h 14.616 l -0.648,5.112 -2.232,1.944 h -2.232 l 2.52,12.816 h 0.432 l 10.368,-19.872 h 5.328 z m 24.04794,-27.576 1.008,-9.648 h 8.64 l -1.008,9.648 z m -5.688,7.704 2.232,-1.944 h 11.448 l -3.096,25.416 h 4.104 l -0.648,5.256 -2.16,1.8 h -11.088 l 3.096,-25.416 h -4.536 z m 19.15202,0.288 2.448,-2.232 h 2.088 l 0.864,-6.984 2.808,-2.88 h 6.48 l -1.224,9.864 h 9.72 l -0.648,4.752 -2.448,2.304 h -7.488 l -1.8,14.832 q -0.504,4.248 2.16,4.248 1.152,0 2.232,-1.008 1.152,-1.08 2.088,-4.824 l 6.264,2.088 q -1.368,5.616 -4.032,8.208 -2.664,2.592 -7.488,2.592 -5.184,0 -8.064,-2.664 -2.808,-2.736 -2.232,-7.776 l 1.944,-15.696 h -4.32 z m 27.28803,-17.352 2.232,-1.944 h 11.088 l -2.736,22.536 q 1.584,-2.736 4.104,-4.392 2.52,-1.728 5.904,-1.728 4.392,0 7.272,2.736 2.952,2.736 2.232,8.496 l -1.8,14.832 h 4.176 l -0.648,5.256 -2.16,1.8 h -11.088 l 2.232,-18.288 q 0.576,-4.176 -0.576,-5.976 -1.152,-1.8 -3.816,-1.8 -3.096,0 -4.68,1.944 -1.584,1.944 -2.16,5.112 l -2.304,19.008 h -8.928 l 5.184,-42.48 h -4.176 z m 45.14409,39.384 h 4.104 l 15.984,-30.384 h -6.192 l 0.864,-8.208 h 15.408 l 12.168,38.592 h 4.248 l -0.864,8.208 h -17.856 l 0.864,-8.208 h 3.6 l -1.224,-4.752 h -15.264 l -2.304,4.752 h 4.176 l -0.864,8.208 h -17.712 z m 25.632,-24.84 -6.408,13.176 h 10.152 l -3.312,-13.176 z m 23.75999,24.84 h 4.824 l 3.168,-30.384 h -4.824 l 0.864,-8.208 h 18.936 l -0.864,8.208 h -4.896 l -3.168,30.384 h 4.896 l -0.864,8.208 h -18.936 z"
|
|
||||||
id="text50"
|
|
||||||
style="font-style:italic;font-weight:700;font-size:72px;fill:url(#gold-text)"
|
|
||||||
aria-label="Built with AI" />
|
|
||||||
<path
|
|
||||||
d="m 119.912,396 h -7.887 v -2.607 h 2.541 l -1.32,-3.564 H 104.6 l -1.419,3.564 h 2.805 V 396 h -7.821 v -2.607 h 1.98 l 6.765,-16.236 h -3.3 v -2.607 h 6.468 l 7.722,18.843 h 2.112 z m -7.524,-8.415 -3.267,-8.712 h -0.198 l -3.432,8.712 z m 27.852,3.3 q -0.264,1.947 -1.749,3.696 -1.452,1.749 -4.653,1.749 -3.102,0 -5.016,-1.914 -1.881,-1.947 -1.881,-5.544 0,-3.333 1.881,-5.61 1.881,-2.31 5.247,-2.31 1.386,0 2.673,0.33 1.287,0.33 2.442,1.155 l 0.594,3.828 -2.343,0.264 -0.528,-2.475 q -1.254,-0.726 -2.871,-0.726 -2.079,0 -3.069,1.518 -0.99,1.485 -0.99,3.861 0,2.475 1.056,3.861 1.056,1.386 3.102,1.386 3.069,0 3.663,-3.564 z m 9.24002,5.115 h -7.656 v -2.244 h 2.376 v -18.183 h -2.475 v -2.277 h 5.379 v 20.46 h 2.376 z m 15.27898,-4.356 q -0.231,1.914 -1.881,3.3 -1.65,1.386 -4.488,1.386 -3.201,0 -5.181,-1.914 -1.98,-1.914 -1.98,-5.544 0,-3.432 1.848,-5.676 1.848,-2.244 5.115,-2.244 3.036,0 4.719,1.881 1.683,1.881 1.716,4.554 0,0.891 -0.198,1.881 h -10.164 q 0.198,4.686 4.323,4.686 1.716,0 2.574,-0.825 0.891,-0.825 1.188,-1.98 z m -3.135,-4.323 q 0.132,-1.452 -0.726,-2.772 -0.825,-1.353 -2.772,-1.353 -1.815,0 -2.739,1.221 -0.891,1.188 -1.089,2.904 z m 6.73203,-4.95 q 1.353,-0.792 2.64,-1.089 1.32,-0.33 2.871,-0.33 2.508,0 3.96,1.221 1.485,1.221 1.485,3.762 v 6.831 q 0,1.452 1.155,1.452 0.462,0 0.891,-0.165 l 0.033,1.716 q -0.924,0.561 -2.145,0.561 -2.673,0 -2.838,-2.97 v -0.033 q -0.66,1.155 -1.914,2.079 -1.221,0.924 -3.003,0.924 -1.518,0 -3.036,-0.924 -1.485,-0.924 -1.485,-3.234 0,-2.772 2.178,-3.63 2.211,-0.891 4.719,-0.891 1.518,0 2.541,0.132 v -1.089 q 0,-1.452 -0.561,-2.475 -0.561,-1.023 -2.508,-1.023 -1.584,0 -2.673,0.561 l -0.561,2.409 -2.343,-0.264 z m 8.052,7.953 v -0.858 q -0.594,-0.066 -1.254,-0.099 -0.627,-0.066 -1.287,-0.066 -1.518,0 -2.706,0.495 -1.188,0.495 -1.188,2.046 0,1.188 0.726,1.716 0.759,0.528 1.716,0.528 1.419,0 2.64,-0.99 1.221,-0.99 1.353,-2.772 z M 200.72902,396 h -7.656 v -2.244 h 2.376 v -6.369 q 0,-2.244 -0.858,-3.168 -0.858,-0.957 -2.277,-0.957 -1.848,0 -2.937,1.221 -1.089,1.221 -1.155,2.838 v 6.435 h 2.376 V 396 h -7.656 v -2.244 h 2.376 v -10.23 h -2.475 v -2.277 h 5.379 v 2.508 q 1.551,-2.805 5.016,-2.805 2.145,0 3.63,1.32 1.485,1.32 1.485,4.125 v 7.359 h 2.376 z m 20.95501,-4.323 q 0,2.211 -1.848,3.432 -1.815,1.221 -4.62,1.221 -3.399,0 -5.775,-1.452 l 0.462,-3.564 2.277,0.231 -0.066,1.914 q 0.66,0.33 1.419,0.462 0.792,0.132 1.551,0.132 1.419,0 2.541,-0.528 1.155,-0.528 1.155,-1.65 0,-1.089 -0.924,-1.518 -0.924,-0.462 -2.31,-0.693 -1.353,-0.231 -2.706,-0.561 -1.353,-0.363 -2.277,-1.188 -0.924,-0.858 -0.924,-2.574 0,-2.475 1.815,-3.432 1.848,-0.957 3.927,-0.957 1.518,0 2.838,0.396 1.353,0.363 2.442,0.957 l 0.33,3.564 -2.31,0.264 -0.33,-2.31 q -1.353,-0.627 -2.838,-0.627 -1.221,0 -2.013,0.462 -0.792,0.462 -0.792,1.518 0,1.023 0.891,1.452 0.924,0.429 2.244,0.66 1.353,0.198 2.673,0.561 1.353,0.363 2.244,1.221 0.924,0.858 0.924,2.607 z m 13.62901,0.165 q -0.627,4.488 -4.95,4.488 -2.277,0 -3.564,-1.221 -1.254,-1.254 -1.254,-3.465 v -8.184 h -2.277 v -2.211 h 2.277 v -4.653 h 2.871 v 4.653 h 5.643 v 2.211 h -5.643 v 7.755 q 0,2.64 2.277,2.64 0.726,0 1.452,-0.462 0.726,-0.495 1.023,-2.244 z m 2.60698,-9.471 q 1.353,-0.792 2.64,-1.089 1.32,-0.33 2.871,-0.33 2.508,0 3.96,1.221 1.485,1.221 1.485,3.762 v 6.831 q 0,1.452 1.155,1.452 0.462,0 0.891,-0.165 l 0.033,1.716 q -0.924,0.561 -2.145,0.561 -2.673,0 -2.838,-2.97 v -0.033 q -0.66,1.155 -1.914,2.079 -1.221,0.924 -3.003,0.924 -1.518,0 -3.036,-0.924 -1.485,-0.924 -1.485,-3.234 0,-2.772 2.178,-3.63 2.211,-0.891 4.719,-0.891 1.518,0 2.541,0.132 v -1.089 q 0,-1.452 -0.561,-2.475 -0.561,-1.023 -2.508,-1.023 -1.584,0 -2.673,0.561 l -0.561,2.409 -2.343,-0.264 z m 8.052,7.953 v -0.858 q -0.594,-0.066 -1.254,-0.099 -0.627,-0.066 -1.287,-0.066 -1.518,0 -2.706,0.495 -1.188,0.495 -1.188,2.046 0,1.188 0.726,1.716 0.759,0.528 1.716,0.528 1.419,0 2.64,-0.99 1.221,-0.99 1.353,-2.772 z m 15.213,-9.306 q 1.551,0 2.64,0.792 l 0.594,4.125 -2.277,0.264 -0.561,-2.541 q -0.561,-0.231 -1.155,-0.231 -1.122,0 -1.881,0.957 -0.759,0.924 -0.759,2.442 v 6.93 h 3.168 V 396 h -8.448 v -2.244 h 2.376 v -10.23 h -2.475 v -2.277 h 5.181 v 2.706 q 0.429,-1.254 1.32,-2.079 0.924,-0.858 2.277,-0.858 z m 16.86302,10.824 q -0.627,4.488 -4.95,4.488 -2.277,0 -3.564,-1.221 -1.254,-1.254 -1.254,-3.465 v -8.184 h -2.277 v -2.211 h 2.277 v -4.653 h 2.871 v 4.653 h 5.643 v 2.211 h -5.643 v 7.755 q 0,2.64 2.277,2.64 0.726,0 1.452,-0.462 0.726,-0.495 1.023,-2.244 z m 15.80697,-18.876 q 1.023,0 1.947,0.231 0.957,0.231 1.782,0.891 l 0.594,3.597 -2.31,0.297 -0.627,-2.475 q -0.693,-0.231 -1.551,-0.231 -2.343,0 -2.343,3.036 v 2.937 h 3.795 v 2.211 h -3.795 v 10.296 h 3.102 V 396 h -8.382 v -2.244 h 2.409 V 383.46 h -2.046 v -2.211 h 2.046 v -2.607 q 0,-2.508 1.518,-4.092 1.518,-1.584 3.861,-1.584 z m 17.88599,15.675 q 0,3.399 -2.112,5.544 -2.079,2.145 -5.511,2.145 -3.366,0 -5.346,-2.079 -1.947,-2.079 -1.947,-5.478 0,-3.234 1.881,-5.544 1.881,-2.31 5.61,-2.31 3.729,0 5.577,2.31 1.848,2Line truncated
|
|
||||||
id="text51"
|
|
||||||
style="font-weight:500;font-size:33px;fill:#c2cad6"
|
|
||||||
aria-label="A clean start for WordPress plugins, made with aidevops." />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 42 KiB |
@@ -1,360 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* WP Plugin Starter admin screen.
|
|
||||||
*
|
|
||||||
* Owns the Settings → WP Plugin Starter page: tab registry, page chrome and the
|
|
||||||
* single admin script/stylesheet. Tab content is delegated to the manager
|
|
||||||
* classes. Settings tabs and header links come from WPStarter_Setup; add
|
|
||||||
* other tabs with the `wpstarter_admin_tabs` filter.
|
|
||||||
*
|
|
||||||
* @package WPStarter
|
|
||||||
* @since 0.2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
class WPStarter_Admin_Manager {
|
|
||||||
|
|
||||||
/** Menu/page slug. */
|
|
||||||
const PAGE = 'wp-plugin-starter-template';
|
|
||||||
|
|
||||||
/** Hook suffix returned by add_options_page(). */
|
|
||||||
const HOOK = 'settings_page_' . self::PAGE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register hooks (once).
|
|
||||||
*/
|
|
||||||
public static function init() {
|
|
||||||
add_action('admin_menu', array(__CLASS__, 'register_admin_menu'));
|
|
||||||
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_assets'));
|
|
||||||
add_filter('plugin_action_links_' . plugin_basename(WPSTARTER_FILE), array(__CLASS__, 'plugin_action_links'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Slug of the search results screen (not shown in the navigation). */
|
|
||||||
const SEARCH = 'search';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings tabs, in navigation order (WPStarter_Setup::settings_tabs()).
|
|
||||||
*
|
|
||||||
* @return array<string,array{label:string,description:string}>
|
|
||||||
*/
|
|
||||||
public static function settings_tabs() {
|
|
||||||
return WPStarter_Setup::settings_tabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registered tabs.
|
|
||||||
*
|
|
||||||
* @return array<string,array{label:string,group:string,render:callable}>
|
|
||||||
*/
|
|
||||||
public static function get_tabs() {
|
|
||||||
$tabs = array();
|
|
||||||
|
|
||||||
// Settings tabs without settings are hidden (they can be filled via
|
|
||||||
// the schema filter). With no settings at all, the first tab shows
|
|
||||||
// and says so, so a new plugin still has a settings screen.
|
|
||||||
$settings_tabs = self::settings_tabs();
|
|
||||||
$has_settings = false;
|
|
||||||
foreach (array_keys($settings_tabs) as $slug) {
|
|
||||||
if (WPStarter_Settings::fields_for_tab($slug)) {
|
|
||||||
$has_settings = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($settings_tabs as $slug => $tab) {
|
|
||||||
if ($has_settings && !WPStarter_Settings::fields_for_tab($slug)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!$has_settings && $tabs) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$tabs[$slug] = array(
|
|
||||||
'label' => $tab['label'],
|
|
||||||
'group' => 'settings',
|
|
||||||
'render' => function () use ($slug, $tab) {
|
|
||||||
WPStarter_Settings_Manager::render_tab($slug, $tab['label'], $tab['description']);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tabs += array(
|
|
||||||
'readme' => array(
|
|
||||||
'label' => __('Read Me', 'wp-plugin-starter-template'),
|
|
||||||
'group' => 'about',
|
|
||||||
'render' => array('WPStarter_Readme_Manager', 'display_tab_content'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter the admin tabs.
|
|
||||||
*
|
|
||||||
* @param array $tabs Tabs keyed by slug: label, group (settings|discover|about),
|
|
||||||
* render callback, optional capability.
|
|
||||||
*/
|
|
||||||
$tabs = (array) apply_filters('wpstarter_admin_tabs', $tabs);
|
|
||||||
|
|
||||||
// Hide tabs the current user cannot use.
|
|
||||||
return array_filter($tabs, function ($tab) {
|
|
||||||
return empty($tab['capability']) || current_user_can($tab['capability']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Active tab slug, falling back to the first registered tab.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function get_active_tab() {
|
|
||||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only navigation.
|
|
||||||
$tab = isset($_GET['tab']) ? sanitize_key(wp_unslash($_GET['tab'])) : '';
|
|
||||||
if (self::SEARCH === $tab && '' !== self::search_query()) {
|
|
||||||
return $tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tabs = self::get_tabs();
|
|
||||||
$tab = WPStarter_Settings::resolve_tab($tab);
|
|
||||||
if (!isset($tabs[$tab])) {
|
|
||||||
$tab = (string) key($tabs);
|
|
||||||
}
|
|
||||||
return $tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current settings search text.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function search_query() {
|
|
||||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only search.
|
|
||||||
$query = isset($_GET['s']) ? sanitize_text_field(wp_unslash($_GET['s'])) : '';
|
|
||||||
return trim(function_exists('mb_substr') ? mb_substr($query, 0, 100) : substr($query, 0, 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of a tab.
|
|
||||||
*
|
|
||||||
* @param string $tab Tab slug.
|
|
||||||
* @param array $args Extra query args.
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function tab_url($tab, array $args = array()) {
|
|
||||||
return add_query_arg(array_merge(array('page' => self::PAGE, 'tab' => $tab), $args), admin_url('options-general.php'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the Settings link on the Plugins screen.
|
|
||||||
*
|
|
||||||
* @param array $links Action links.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function plugin_action_links($links) {
|
|
||||||
array_unshift($links, sprintf('<a href="%s">%s</a>', esc_url(add_query_arg('page', self::PAGE, admin_url('options-general.php'))), esc_html__('Settings', 'wp-plugin-starter-template')));
|
|
||||||
return $links;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register Settings → WP Plugin Starter.
|
|
||||||
*/
|
|
||||||
public static function register_admin_menu() {
|
|
||||||
add_options_page(
|
|
||||||
__('WP Plugin Starter', 'wp-plugin-starter-template'),
|
|
||||||
__('WP Plugin Starter', 'wp-plugin-starter-template'),
|
|
||||||
'manage_options',
|
|
||||||
self::PAGE,
|
|
||||||
array(__CLASS__, 'render_settings_page')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enqueue the admin stylesheet and script on our screen only.
|
|
||||||
*
|
|
||||||
* @param string $hook Current admin page hook.
|
|
||||||
*/
|
|
||||||
public static function enqueue_assets($hook) {
|
|
||||||
if (self::HOOK !== $hook) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tab = self::get_active_tab();
|
|
||||||
$css = file_exists(WPSTARTER_DIR . 'admin/css/wpstarter-admin.css') ? filemtime(WPSTARTER_DIR . 'admin/css/wpstarter-admin.css') : WPSTARTER_VERSION;
|
|
||||||
$js = file_exists(WPSTARTER_DIR . 'admin/js/wpstarter-admin.js') ? filemtime(WPSTARTER_DIR . 'admin/js/wpstarter-admin.js') : WPSTARTER_VERSION;
|
|
||||||
|
|
||||||
wp_enqueue_style('wpstarter-admin', WPSTARTER_URL . 'admin/css/wpstarter-admin.css', array('dashicons'), $css);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter the admin script's dependencies; enqueue what a tab needs.
|
|
||||||
*
|
|
||||||
* @param string[] $deps Script handles.
|
|
||||||
* @param string $tab Active tab.
|
|
||||||
*/
|
|
||||||
$deps = (array) apply_filters('wpstarter_admin_script_deps', array('jquery', 'wp-a11y', 'wp-i18n'), $tab);
|
|
||||||
|
|
||||||
if (self::shows_media_field($tab)) {
|
|
||||||
wp_enqueue_media();
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_enqueue_script('wpstarter-admin', WPSTARTER_URL . 'admin/js/wpstarter-admin.js', $deps, $js, true);
|
|
||||||
wp_set_script_translations('wpstarter-admin', 'wp-plugin-starter-template');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter the data the admin script reads (wpstarterAdmin).
|
|
||||||
*
|
|
||||||
* @param array $data Script data.
|
|
||||||
* @param string $tab Active tab.
|
|
||||||
*/
|
|
||||||
wp_localize_script('wpstarter-admin', 'wpstarterAdmin', (array) apply_filters('wpstarter_admin_script_data', array(
|
|
||||||
'ajaxUrl' => admin_url('admin-ajax.php'),
|
|
||||||
'nonce' => wp_create_nonce(WPStarter_Settings::NONCE),
|
|
||||||
'tab' => $tab,
|
|
||||||
'i18n' => array(
|
|
||||||
'saving' => __('Saving…', 'wp-plugin-starter-template'),
|
|
||||||
'saved' => __('Saved', 'wp-plugin-starter-template'),
|
|
||||||
'saveFailed' => __('Could not save. Please try again.', 'wp-plugin-starter-template'),
|
|
||||||
'chooseImage' => __('Choose a picture', 'wp-plugin-starter-template'),
|
|
||||||
'useImage' => __('Use this picture', 'wp-plugin-starter-template'),
|
|
||||||
),
|
|
||||||
), $tab));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fires after the admin stylesheet and script are enqueued: enqueue
|
|
||||||
* the plugin's own, depending on 'wpstarter-admin'.
|
|
||||||
*
|
|
||||||
* @param string $tab Active tab.
|
|
||||||
*/
|
|
||||||
do_action('wpstarter_admin_enqueue', $tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether a tab (or the search results) may show a media field, which
|
|
||||||
* needs the media dialog.
|
|
||||||
*
|
|
||||||
* @param string $tab Tab slug.
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private static function shows_media_field($tab) {
|
|
||||||
$schema = WPStarter_Settings::schema();
|
|
||||||
foreach ($schema as $field) {
|
|
||||||
if (!isset($field['type']) || 'media' !== $field['type']) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (self::SEARCH === $tab) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$field_tab = isset($field['tab']) ? $field['tab'] : '';
|
|
||||||
if (!$field_tab && isset($field['parent'], $schema[$field['parent']]['tab'])) {
|
|
||||||
$field_tab = $schema[$field['parent']]['tab'];
|
|
||||||
}
|
|
||||||
if ($field_tab === $tab) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the page chrome and the active tab.
|
|
||||||
*/
|
|
||||||
public static function render_settings_page() {
|
|
||||||
if (!current_user_can('manage_options')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tabs = self::get_tabs();
|
|
||||||
$active = self::get_active_tab();
|
|
||||||
$links = WPStarter_Setup::header_links();
|
|
||||||
$groups = array(
|
|
||||||
'settings' => __('Settings', 'wp-plugin-starter-template'),
|
|
||||||
'discover' => __('Discover', 'wp-plugin-starter-template'),
|
|
||||||
'about' => __('About', 'wp-plugin-starter-template'),
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
<div class="wrap wps-wrap">
|
|
||||||
<header class="wps-header">
|
|
||||||
<div class="wps-header__brand">
|
|
||||||
<span class="wps-header__logo dashicons dashicons-star-filled" aria-hidden="true"></span>
|
|
||||||
<h1 class="wps-header__title"><?php esc_html_e('WP Plugin Starter', 'wp-plugin-starter-template'); ?></h1>
|
|
||||||
<span class="wps-badge"><?php echo esc_html('v' . WPSTARTER_VERSION); ?></span>
|
|
||||||
</div>
|
|
||||||
<form class="wps-search" role="search" method="get" action="<?php echo esc_url(admin_url('options-general.php')); ?>">
|
|
||||||
<input type="hidden" name="page" value="<?php echo esc_attr(self::PAGE); ?>" />
|
|
||||||
<input type="hidden" name="tab" value="<?php echo esc_attr(self::SEARCH); ?>" />
|
|
||||||
<label class="screen-reader-text" for="wps-search-input"><?php esc_html_e('Search features', 'wp-plugin-starter-template'); ?></label>
|
|
||||||
<span class="wps-search__field">
|
|
||||||
<span class="wps-search__icon dashicons dashicons-search" aria-hidden="true"></span>
|
|
||||||
<input type="search"
|
|
||||||
id="wps-search-input"
|
|
||||||
class="wps-search__input"
|
|
||||||
name="s"
|
|
||||||
maxlength="100"
|
|
||||||
value="<?php echo esc_attr(self::search_query()); ?>"
|
|
||||||
placeholder="<?php esc_attr_e('Search features', 'wp-plugin-starter-template'); ?>" />
|
|
||||||
</span>
|
|
||||||
<button type="submit" class="button wps-search__button"><?php esc_html_e('Search', 'wp-plugin-starter-template'); ?></button>
|
|
||||||
</form>
|
|
||||||
<div class="wps-header__actions">
|
|
||||||
<?php if (!empty($links['website'])) : ?>
|
|
||||||
<a class="button" href="<?php echo esc_url($links['website']); ?>" target="_blank" rel="noopener noreferrer">
|
|
||||||
<?php esc_html_e('Visit website', 'wp-plugin-starter-template'); ?>
|
|
||||||
<span class="screen-reader-text"><?php esc_html_e('(opens in a new tab)', 'wp-plugin-starter-template'); ?></span>
|
|
||||||
</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (!empty($links['support'])) : ?>
|
|
||||||
<a class="button wps-header__support" href="<?php echo esc_url($links['support']); ?>" target="_blank" rel="noopener noreferrer">
|
|
||||||
<span class="dashicons dashicons-sos" aria-hidden="true"></span>
|
|
||||||
<?php esc_html_e('Report a problem', 'wp-plugin-starter-template'); ?>
|
|
||||||
<span class="screen-reader-text"><?php esc_html_e('(opens in a new tab)', 'wp-plugin-starter-template'); ?></span>
|
|
||||||
</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if (!empty($links['donate'])) : ?>
|
|
||||||
<a class="button wps-header__support wps-header__donate" href="<?php echo esc_url($links['donate']); ?>" target="_blank" rel="noopener noreferrer">
|
|
||||||
<span class="dashicons dashicons-coffee" aria-hidden="true"></span>
|
|
||||||
<?php esc_html_e('Buy me a coffee', 'wp-plugin-starter-template'); ?>
|
|
||||||
<span class="screen-reader-text"><?php esc_html_e('(opens in a new tab)', 'wp-plugin-starter-template'); ?></span>
|
|
||||||
</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<nav class="wps-nav" aria-label="<?php esc_attr_e('WP Plugin Starter sections', 'wp-plugin-starter-template'); ?>">
|
|
||||||
<?php foreach ($groups as $group => $group_label) : ?>
|
|
||||||
<?php
|
|
||||||
$group_tabs = array_filter($tabs, function ($tab) use ($group) {
|
|
||||||
return isset($tab['group']) && $tab['group'] === $group;
|
|
||||||
});
|
|
||||||
if (!$group_tabs) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wps-nav__group" role="group" aria-label="<?php echo esc_attr($group_label); ?>">
|
|
||||||
<?php foreach ($group_tabs as $slug => $tab) : ?>
|
|
||||||
<a href="<?php echo esc_url(self::tab_url($slug)); ?>"
|
|
||||||
class="wps-nav__tab<?php echo $slug === $active ? ' is-active' : ''; ?>"
|
|
||||||
<?php echo $slug === $active ? 'aria-current="page"' : ''; ?>>
|
|
||||||
<?php echo esc_html($tab['label']); ?>
|
|
||||||
</a>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<?php // Core moves admin notices after this marker instead of into the header. ?>
|
|
||||||
<hr class="wp-header-end" />
|
|
||||||
|
|
||||||
<?php settings_errors(); ?>
|
|
||||||
|
|
||||||
<?php // Not <main>: core's #wpbody already carries role="main". ?>
|
|
||||||
<div class="wps-main wps-tab-<?php echo esc_attr($active); ?>" id="wps-tab-<?php echo esc_attr($active); ?>">
|
|
||||||
<?php
|
|
||||||
if (self::SEARCH === $active) {
|
|
||||||
WPStarter_Settings_Manager::render_search(self::search_query(), $tabs);
|
|
||||||
} elseif (isset($tabs[$active]['render']) && is_callable($tabs[$active]['render'])) {
|
|
||||||
call_user_func($tabs[$active]['render']);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* WP Plugin Starter Read Me tab.
|
|
||||||
*
|
|
||||||
* Renders README.md with a small, escaping Markdown subset
|
|
||||||
* (headings with GitHub-style IDs, lists, tables, bold, italic, inline code,
|
|
||||||
* http(s) links, links to headings and images from the plugin's folder).
|
|
||||||
*
|
|
||||||
* @package WPStarter
|
|
||||||
* @since 0.2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
class WPStarter_Readme_Manager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the tab.
|
|
||||||
*/
|
|
||||||
public static function display_tab_content() {
|
|
||||||
$readme = wpstarter_get_readme_content();
|
|
||||||
?>
|
|
||||||
<article class="wps-card wps-readme">
|
|
||||||
<?php echo self::parse_markdown($readme['content']); // phpcs:ignore WordPress.Security.EscapeOutput -- built from escaped text. ?>
|
|
||||||
</article>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert Markdown to HTML. Input is escaped first; only the generated
|
|
||||||
* tags and validated http(s) links are emitted.
|
|
||||||
*
|
|
||||||
* @param string $markdown Markdown.
|
|
||||||
* @return string HTML.
|
|
||||||
*/
|
|
||||||
public static function parse_markdown($markdown) {
|
|
||||||
$markdown = str_replace('{WPSTARTER_VERSION}', WPSTARTER_VERSION, $markdown);
|
|
||||||
$lines = preg_split('/\r\n|\r|\n/', $markdown);
|
|
||||||
$html = '';
|
|
||||||
$list = '';
|
|
||||||
$table = ''; // '', 'head' (header row written) or 'body'.
|
|
||||||
$ids = array();
|
|
||||||
|
|
||||||
$close_list = function () use (&$html, &$list, &$table) {
|
|
||||||
if ($list) {
|
|
||||||
$html .= '</' . $list . '>';
|
|
||||||
$list = '';
|
|
||||||
}
|
|
||||||
if ($table) {
|
|
||||||
$html .= ('head' === $table ? '</thead>' : '</tbody>') . '</table></div>';
|
|
||||||
$table = '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
|
||||||
$trim = trim($line);
|
|
||||||
|
|
||||||
if ('' === $trim || '#' === $trim) {
|
|
||||||
$close_list();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// An image on a line of its own, from the plugin's own folder.
|
|
||||||
if (preg_match('/^!\[([^\]]*)\]\(([^)\s]+)\)$/', $trim, $m)) {
|
|
||||||
$close_list();
|
|
||||||
$html .= self::image($m[2], $m[1]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preg_match('/^(#{1,4})\s+(.+)$/', $trim, $m)) {
|
|
||||||
$close_list();
|
|
||||||
$level = min(4, strlen($m[1]) + 1); // h1 is reserved for the page title.
|
|
||||||
$html .= sprintf('<h%1$d id="%2$s">%3$s</h%1$d>', $level, esc_attr(self::anchor($m[2], $ids)), self::inline($m[2]));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tables: a header row, a |---| separator, then body rows.
|
|
||||||
if (strlen($trim) > 1 && '|' === $trim[0] && '|' === substr($trim, -1)) {
|
|
||||||
if ('head' === $table && preg_match('/^\|[\s:|-]+\|$/', $trim)) {
|
|
||||||
$html .= '</thead><tbody>';
|
|
||||||
$table = 'body';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!$table) {
|
|
||||||
$close_list();
|
|
||||||
$html .= '<div class="wps-readme-table"><table><thead>';
|
|
||||||
$table = 'head';
|
|
||||||
}
|
|
||||||
$tag = 'head' === $table ? 'th' : 'td';
|
|
||||||
$html .= '<tr>';
|
|
||||||
foreach (explode('|', substr($trim, 1, -1)) as $cell) {
|
|
||||||
$html .= '<' . $tag . '>' . self::inline(trim($cell)) . '</' . $tag . '>';
|
|
||||||
}
|
|
||||||
$html .= '</tr>';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preg_match('/^[-*]\s+(.+)$/', $trim, $m) || preg_match('/^\d+\.\s+(.+)$/', $trim, $n)) {
|
|
||||||
$type = isset($n[1]) ? 'ol' : 'ul';
|
|
||||||
$text = isset($n[1]) ? $n[1] : $m[1];
|
|
||||||
if ($list !== $type) {
|
|
||||||
$close_list();
|
|
||||||
$html .= '<' . $type . '>';
|
|
||||||
$list = $type;
|
|
||||||
}
|
|
||||||
$html .= '<li>' . self::inline($text) . '</li>';
|
|
||||||
unset($n);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$close_list();
|
|
||||||
$html .= '<p>' . self::inline($trim) . '</p>';
|
|
||||||
}
|
|
||||||
$close_list();
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Heading ID as GitHub makes it, so README links such as
|
|
||||||
* `[Credits](#credits)` work in the tab too. Repeats get -1, -2...
|
|
||||||
*
|
|
||||||
* @param string $text Heading Markdown.
|
|
||||||
* @param array $ids IDs used so far (updated).
|
|
||||||
* @return string ID.
|
|
||||||
*/
|
|
||||||
private static function anchor($text, array &$ids) {
|
|
||||||
$text = preg_replace('/\[([^\]]+)\]\([^)]*\)/', '$1', $text);
|
|
||||||
$text = str_replace(array('`', '*'), '', $text);
|
|
||||||
$id = function_exists('mb_strtolower') ? mb_strtolower($text, 'UTF-8') : strtolower($text);
|
|
||||||
$id = preg_replace('/[^\p{L}\p{N}\s_-]/u', '', $id);
|
|
||||||
$id = preg_replace('/\s/u', '-', trim($id));
|
|
||||||
$base = '' === $id ? 'section' : $id;
|
|
||||||
$id = $base;
|
|
||||||
$n = 0;
|
|
||||||
while (isset($ids[$id])) {
|
|
||||||
$id = $base . '-' . (++$n);
|
|
||||||
}
|
|
||||||
$ids[$id] = true;
|
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An image from the plugin's folder, such as the banner at the top of
|
|
||||||
* README.md. Only relative paths to image files that exist are shown, so
|
|
||||||
* the tab never loads anything from another site.
|
|
||||||
*
|
|
||||||
* @param string $path Path relative to the plugin folder.
|
|
||||||
* @param string $alt Alternative text.
|
|
||||||
* @return string HTML, or '' for anything else.
|
|
||||||
*/
|
|
||||||
private static function image($path, $alt) {
|
|
||||||
if (!preg_match('#^[A-Za-z0-9_-]+(?:/[A-Za-z0-9_-]+)*\.(?:svg|png|jpe?g|gif|webp)$#i', $path)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
$file = WPSTARTER_DIR . $path;
|
|
||||||
if (!is_file($file)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Width and height stop the page jumping while the image loads.
|
|
||||||
$size = '';
|
|
||||||
if ('svg' === strtolower(pathinfo($path, PATHINFO_EXTENSION))) {
|
|
||||||
$head = (string) file_get_contents($file, false, null, 0, 2048); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- local file.
|
|
||||||
if (preg_match('/<svg\b[^>]*?\swidth="(\d+)"[^>]*?\sheight="(\d+)"/', $head, $m)) {
|
|
||||||
$size = array((int) $m[1], (int) $m[2]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$size = wp_getimagesize($file);
|
|
||||||
}
|
|
||||||
$dims = is_array($size) && !empty($size[0]) && !empty($size[1])
|
|
||||||
? sprintf(' width="%d" height="%d"', $size[0], $size[1])
|
|
||||||
: '';
|
|
||||||
|
|
||||||
// The file's time in the address, so browsers fetch a changed image
|
|
||||||
// (such as a new banner after an update) instead of a cached one.
|
|
||||||
$url = add_query_arg('ver', (string) filemtime($file), WPSTARTER_URL . $path);
|
|
||||||
|
|
||||||
return sprintf(
|
|
||||||
'<p class="wps-readme-image"><img src="%1$s" alt="%2$s"%3$s decoding="async" /></p>',
|
|
||||||
esc_url($url),
|
|
||||||
esc_attr($alt),
|
|
||||||
$dims
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inline Markdown on escaped text.
|
|
||||||
*
|
|
||||||
* @param string $text Raw text.
|
|
||||||
* @return string HTML.
|
|
||||||
*/
|
|
||||||
private static function inline($text) {
|
|
||||||
$text = esc_html($text);
|
|
||||||
$text = preg_replace('/`([^`]+)`/', '<code>$1</code>', $text);
|
|
||||||
$text = preg_replace('/\*\*(.+?)\*\*/', '<strong>$1</strong>', $text);
|
|
||||||
$text = preg_replace('/(?<![*\w])\*(?!\s)(.+?)(?<!\s)\*(?![*\w])/', '<em>$1</em>', $text);
|
|
||||||
|
|
||||||
return preg_replace_callback('/\[([^\]]+)\]\(([^)\s]+)\)/', function ($m) {
|
|
||||||
$url = esc_url(html_entity_decode($m[2]), array('http', 'https'));
|
|
||||||
if ('#' === $m[2][0]) {
|
|
||||||
return sprintf('<a href="#%1$s">%2$s</a>', esc_attr(substr($m[2], 1)), $m[1]);
|
|
||||||
}
|
|
||||||
if ('' === $url) {
|
|
||||||
return $m[1];
|
|
||||||
}
|
|
||||||
return sprintf('<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>', $url, $m[1]);
|
|
||||||
}, $text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,431 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Plugins screen: plugins WP Plugin Starter can replace.
|
|
||||||
*
|
|
||||||
* Lists installed plugins that a setting's `replaces` names:
|
|
||||||
* - active, with every setting that replaces it on: the plugin can go, with a
|
|
||||||
* Deactivate link (the settings wait until it is deactivated);
|
|
||||||
* - active, with a replacing setting off: WP Plugin Starter can do this job, with
|
|
||||||
* a link to the settings (only for people who can change them);
|
|
||||||
* - installed but inactive, with every replacing setting on: no longer
|
|
||||||
* needed, with a Delete link (single sites; on multisite a plugin may be
|
|
||||||
* active on another site).
|
|
||||||
* While an active plugin does things here that WP Plugin Starter does not (the
|
|
||||||
* `wpstarter_replaced_plugin_extras` filter), the notice names them
|
|
||||||
* instead of saying the plugin can go.
|
|
||||||
*
|
|
||||||
* Each of those plugins, and inactive ones whose replacing setting is off,
|
|
||||||
* also gets a note under its own row with the same step.
|
|
||||||
*
|
|
||||||
* Shown on the Plugins screen to people who can activate plugins. "Hide"
|
|
||||||
* hides the plugins listed at the time for that person; a plugin that needs
|
|
||||||
* a different step later shows again.
|
|
||||||
*
|
|
||||||
* @package WPStarter
|
|
||||||
* @since 0.7.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
class WPStarter_Replaced_Plugins {
|
|
||||||
|
|
||||||
/** admin-post action, also the nonce action. */
|
|
||||||
const HIDE = 'wpstarter_hide_replaced_plugins';
|
|
||||||
|
|
||||||
/** User meta: list of "slug:step" items the person hid. */
|
|
||||||
const HIDDEN = 'wpstarter_replaced_plugins_hidden';
|
|
||||||
|
|
||||||
/** admin-post action that deactivates a replaced plugin and comes back. */
|
|
||||||
const DEACTIVATE = 'wpstarter_deactivate_replaced';
|
|
||||||
|
|
||||||
/** Query argument on the page it comes back to. */
|
|
||||||
const DONE = 'wpstarter-deactivated';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register hooks.
|
|
||||||
*/
|
|
||||||
public static function init() {
|
|
||||||
add_action('load-plugins.php', array(__CLASS__, 'load_screen'));
|
|
||||||
add_action('admin_post_' . self::HIDE, array(__CLASS__, 'hide'));
|
|
||||||
add_action('admin_post_' . self::DEACTIVATE, array(__CLASS__, 'deactivate'));
|
|
||||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only shows a message.
|
|
||||||
if (isset($_GET[self::DONE])) {
|
|
||||||
add_action('admin_notices', array(__CLASS__, 'deactivated_notice'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugins screen: add the notice and the notes on each plugin's row.
|
|
||||||
*/
|
|
||||||
public static function load_screen() {
|
|
||||||
if (!current_user_can('activate_plugins')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
add_action(is_network_admin() ? 'network_admin_notices' : 'admin_notices', array(__CLASS__, 'notice'));
|
|
||||||
add_action('after_plugin_row', array(__CLASS__, 'row_note'), 10, 1);
|
|
||||||
add_action('admin_head', array(__CLASS__, 'row_note_style'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Join a row note to its plugin's row, as core does for update notes.
|
|
||||||
*/
|
|
||||||
public static function row_note_style() {
|
|
||||||
echo '<style>.plugins tr:has(+ tr.wps-replaced-row) th, .plugins tr:has(+ tr.wps-replaced-row) td { box-shadow: none; }</style>' . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Link that deactivates a replaced plugin on this site and comes back to
|
|
||||||
* the page it was clicked on.
|
|
||||||
*
|
|
||||||
* @param string $file Plugin file.
|
|
||||||
* @return string Unescaped URL.
|
|
||||||
*/
|
|
||||||
public static function deactivate_url($file) {
|
|
||||||
return wp_nonce_url(add_query_arg(array(
|
|
||||||
'action' => self::DEACTIVATE,
|
|
||||||
'plugin' => rawurlencode($file),
|
|
||||||
'_wp_http_referer' => rawurlencode(remove_query_arg(array(self::DONE, 'deactivate', 'activate'))),
|
|
||||||
), admin_url('admin-post.php')), self::DEACTIVATE . '_' . $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Core's deactivate link on the Plugins screen, keeping the list's
|
|
||||||
* status, page and search, so it comes back to the same list.
|
|
||||||
*
|
|
||||||
* @param string $file Plugin file.
|
|
||||||
* @return string Unescaped URL.
|
|
||||||
*/
|
|
||||||
private static function plugins_deactivate_url($file) {
|
|
||||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- the list being shown.
|
|
||||||
$args = array(
|
|
||||||
'action' => 'deactivate',
|
|
||||||
'plugin' => rawurlencode($file),
|
|
||||||
'plugin_status' => isset($_GET['plugin_status']) ? sanitize_key(wp_unslash($_GET['plugin_status'])) : 'all',
|
|
||||||
'paged' => isset($_GET['paged']) ? absint($_GET['paged']) : 1,
|
|
||||||
's' => isset($_GET['s']) ? rawurlencode(sanitize_text_field(wp_unslash($_GET['s']))) : '',
|
|
||||||
);
|
|
||||||
// phpcs:enable
|
|
||||||
return wp_nonce_url(add_query_arg($args, self_admin_url('plugins.php')), 'deactivate-plugin_' . $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* admin-post: deactivate a replaced plugin on this site, then go back.
|
|
||||||
*/
|
|
||||||
public static function deactivate() {
|
|
||||||
$file = isset($_GET['plugin']) ? sanitize_text_field(wp_unslash($_GET['plugin'])) : '';
|
|
||||||
check_admin_referer(self::DEACTIVATE . '_' . $file);
|
|
||||||
if ('' === $file || validate_file($file) || !current_user_can('deactivate_plugin', $file)) {
|
|
||||||
wp_die(esc_html__('You are not allowed to deactivate this plugin.', 'wp-plugin-starter-template'), '', array('response' => 403));
|
|
||||||
}
|
|
||||||
if (!isset(self::replaced()[dirname($file)])) {
|
|
||||||
wp_die(esc_html__('WP Plugin Starter only deactivates plugins it replaces.', 'wp-plugin-starter-template'), '', array('response' => 400));
|
|
||||||
}
|
|
||||||
if (!function_exists('is_plugin_active')) {
|
|
||||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
||||||
}
|
|
||||||
$back = wp_get_referer();
|
|
||||||
$back = $back ? $back : admin_url('plugins.php');
|
|
||||||
// Network-wide plugins are deactivated in the network admin.
|
|
||||||
if (is_plugin_active($file) && !is_plugin_active_for_network($file)) {
|
|
||||||
deactivate_plugins($file);
|
|
||||||
update_option('recently_activated', array($file => time()) + (array) get_option('recently_activated'), false);
|
|
||||||
$back = add_query_arg(self::DONE, 1, $back);
|
|
||||||
}
|
|
||||||
wp_safe_redirect($back);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* "Plugin deactivated." on the page the link came back to.
|
|
||||||
*/
|
|
||||||
public static function deactivated_notice() {
|
|
||||||
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__('Plugin deactivated.', 'wp-plugin-starter-template') . '</p></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A note under a replaced plugin's row on the Plugins screen: which
|
|
||||||
* setting does its job and what to do next.
|
|
||||||
*
|
|
||||||
* @param string $file Plugin file.
|
|
||||||
*/
|
|
||||||
public static function row_note($file) {
|
|
||||||
global $wp_list_table;
|
|
||||||
$states = self::states();
|
|
||||||
if (!isset($states[$file])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$item = $states[$file];
|
|
||||||
$labels = esc_html(implode(', ', array_map(function ($label) {
|
|
||||||
return '‘' . $label . '’';
|
|
||||||
}, $item['settings'])));
|
|
||||||
$setting = '';
|
|
||||||
if (WPStarter_Settings::can_change()) {
|
|
||||||
$setting = sprintf(' <a href="%1$s">%2$s</a>', esc_url(WPStarter_Admin_Manager::tab_url(WPStarter_Admin_Manager::SEARCH, array('s' => $item['name']))), esc_html__('Show the setting', 'wp-plugin-starter-template'));
|
|
||||||
}
|
|
||||||
$extras = esc_html(implode(', ', $item['extras']));
|
|
||||||
|
|
||||||
switch ($item['step']) {
|
|
||||||
case 'deactivate':
|
|
||||||
/* translators: %s: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('WP Plugin Starter makes this plugin redundant: %s is on and takes over once you deactivate this plugin. Then you can delete it.', 'wp-plugin-starter-template'), $labels);
|
|
||||||
break;
|
|
||||||
case 'partial':
|
|
||||||
/* translators: 1: WP Plugin Starter setting names, 2: the plugin's settings WP Plugin Starter does not have */
|
|
||||||
$text = sprintf(esc_html__('WP Plugin Starter can do this plugin\'s job: %1$s is on and takes over once you deactivate it, except for these, which WP Plugin Starter does not do: %2$s.', 'wp-plugin-starter-template'), $labels, $extras);
|
|
||||||
break;
|
|
||||||
case 'switch_on':
|
|
||||||
/* translators: %s: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('WP Plugin Starter makes this plugin redundant: turn on %s in WP Plugin Starter, then deactivate and delete this plugin.', 'wp-plugin-starter-template'), $labels) . $setting;
|
|
||||||
break;
|
|
||||||
case 'switch_on_partial':
|
|
||||||
/* translators: 1: WP Plugin Starter setting names, 2: the plugin's settings WP Plugin Starter does not have */
|
|
||||||
$text = sprintf(esc_html__('WP Plugin Starter can do part of this plugin\'s job with %1$s. It does not do these, which this plugin has on: %2$s.', 'wp-plugin-starter-template'), $labels, $extras) . $setting;
|
|
||||||
break;
|
|
||||||
case 'switch_on_inactive':
|
|
||||||
/* translators: %s: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('WP Plugin Starter makes this plugin redundant: turn on %s in WP Plugin Starter, then you can delete this plugin.', 'wp-plugin-starter-template'), $labels) . $setting;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* translators: %s: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('No longer needed: %s in WP Plugin Starter does this plugin\'s job. You can delete it.', 'wp-plugin-starter-template'), $labels);
|
|
||||||
}
|
|
||||||
$columns = ($wp_list_table instanceof WP_List_Table) ? $wp_list_table->get_column_count() : 4;
|
|
||||||
$active = in_array($item['step'], array('deactivate', 'partial', 'switch_on', 'switch_on_partial'), true) ? ' active' : ' inactive';
|
|
||||||
printf(
|
|
||||||
'<tr class="plugin-update-tr wps-replaced-row%1$s"><td colspan="%2$d" class="plugin-update colspanchange"><div class="notice inline notice-info notice-alt"><p>%3$s</p></div></td></tr>',
|
|
||||||
esc_attr($active),
|
|
||||||
(int) $columns,
|
|
||||||
$text // phpcs:ignore WordPress.Security.EscapeOutput -- built from escaped parts above.
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaced plugins, keyed by folder name, with the settings that replace
|
|
||||||
* them.
|
|
||||||
*
|
|
||||||
* @return array<string,array{name:string,settings:array<string,string>}> slug => name and setting key => label.
|
|
||||||
*/
|
|
||||||
private static function replaced() {
|
|
||||||
$replaced = array();
|
|
||||||
foreach (WPStarter_Settings::schema() as $key => $field) {
|
|
||||||
if (empty($field['replaces']) || !is_array($field['replaces']) || !empty($field['parent'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
foreach ($field['replaces'] as $slug => $name) {
|
|
||||||
if (!isset($replaced[$slug])) {
|
|
||||||
$replaced[$slug] = array('name' => (string) $name, 'settings' => array());
|
|
||||||
}
|
|
||||||
$replaced[$slug]['settings'][$key] = isset($field['label']) ? (string) $field['label'] : (string) $key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $replaced;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* What to show in the notice: one item per installed replaced plugin that
|
|
||||||
* needs a step, leaving out what the person hid.
|
|
||||||
*
|
|
||||||
* @return array<int,array{slug:string,file:string,name:string,step:string,settings:array<string,string>}>
|
|
||||||
*/
|
|
||||||
private static function items() {
|
|
||||||
$items = array_filter(self::states(), function ($item) {
|
|
||||||
// Inactive with the setting off: only a note on its row.
|
|
||||||
return 'switch_on_inactive' !== $item['step']
|
|
||||||
&& ('switch_on' !== $item['step'] || WPStarter_Settings::can_change());
|
|
||||||
});
|
|
||||||
$hidden = (array) get_user_meta(get_current_user_id(), self::HIDDEN, true);
|
|
||||||
return array_values(array_filter($items, function ($item) use ($hidden) {
|
|
||||||
return !in_array($item['slug'] . ':' . $item['step'], $hidden, true);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Every installed replaced plugin that needs a step, keyed by plugin file.
|
|
||||||
*
|
|
||||||
* Steps: deactivate, partial (active, setting on, it does more),
|
|
||||||
* switch_on, switch_on_partial, delete (inactive, setting on) and
|
|
||||||
* switch_on_inactive (inactive, setting off; single sites only).
|
|
||||||
*
|
|
||||||
* @return array<string,array{slug:string,file:string,name:string,step:string,settings:array<string,string>,extras:string[]}>
|
|
||||||
*/
|
|
||||||
private static function states() {
|
|
||||||
static $states = null;
|
|
||||||
if (null !== $states) {
|
|
||||||
return $states;
|
|
||||||
}
|
|
||||||
if (!function_exists('get_plugins')) {
|
|
||||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
||||||
}
|
|
||||||
$installed = array();
|
|
||||||
foreach (array_keys(get_plugins()) as $file) {
|
|
||||||
$slug = dirname($file);
|
|
||||||
if ('.' !== $slug) {
|
|
||||||
$installed[$slug] = $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$network = is_multisite() && is_network_admin();
|
|
||||||
// Active where this screen can deactivate it: network-wide in the
|
|
||||||
// network admin, on this site otherwise. Stored lists, so plugins
|
|
||||||
// skipped on this screen still count.
|
|
||||||
$here = $network
|
|
||||||
? array_keys((array) get_site_option('active_sitewide_plugins', array()))
|
|
||||||
: WPStarter_Feature::stored_active_plugins();
|
|
||||||
$all = WPStarter_Feature::active_plugins();
|
|
||||||
|
|
||||||
$items = array();
|
|
||||||
foreach (self::replaced() as $slug => $plugin) {
|
|
||||||
if (!isset($installed[$slug])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$file = $installed[$slug];
|
|
||||||
$all_on = true;
|
|
||||||
foreach (array_keys($plugin['settings']) as $key) {
|
|
||||||
$all_on = $all_on && (bool) WPStarter_Settings::get($key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array($file, $here, true)) {
|
|
||||||
$step = $all_on ? 'deactivate' : 'switch_on';
|
|
||||||
} elseif (!isset($all[$slug]) && !is_multisite()) {
|
|
||||||
$step = $all_on ? 'delete' : 'switch_on_inactive';
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$extras = array();
|
|
||||||
if ('deactivate' === $step || 'switch_on' === $step) {
|
|
||||||
/**
|
|
||||||
* What a replaced plugin does on this site that WP Plugin Starter,
|
|
||||||
* as set up, does not. When there is any, the notice lists it
|
|
||||||
* instead of saying the plugin can go.
|
|
||||||
*
|
|
||||||
* @param string[] $extras Plain names.
|
|
||||||
* @param string $slug Plugin folder.
|
|
||||||
*/
|
|
||||||
$extras = array_values(array_filter(array_map('strval', (array) apply_filters('wpstarter_replaced_plugin_extras', array(), (string) $slug))));
|
|
||||||
}
|
|
||||||
if ($extras) {
|
|
||||||
$step = 'deactivate' === $step ? 'partial' : 'switch_on_partial';
|
|
||||||
}
|
|
||||||
$items[$file] = array(
|
|
||||||
'slug' => (string) $slug,
|
|
||||||
'file' => $file,
|
|
||||||
'name' => $plugin['name'],
|
|
||||||
'step' => $step,
|
|
||||||
'settings' => $plugin['settings'],
|
|
||||||
'extras' => $extras,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$states = $items;
|
|
||||||
return $states;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The notice.
|
|
||||||
*/
|
|
||||||
public static function notice() {
|
|
||||||
$items = self::items();
|
|
||||||
if (!$items) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$rows = array();
|
|
||||||
foreach ($items as $item) {
|
|
||||||
$rows[] = self::row($item);
|
|
||||||
}
|
|
||||||
$keys = array_map(function ($item) {
|
|
||||||
return $item['slug'] . ':' . $item['step'];
|
|
||||||
}, $items);
|
|
||||||
$hide = wp_nonce_url(add_query_arg(array('action' => self::HIDE, 'items' => implode(',', $keys)), admin_url('admin-post.php')), self::HIDE);
|
|
||||||
?>
|
|
||||||
<div class="notice notice-info wps-replaced-plugins">
|
|
||||||
<p><strong><?php esc_html_e('WP Plugin Starter can do the job of these plugins:', 'wp-plugin-starter-template'); ?></strong></p>
|
|
||||||
<ul class="ul-disc">
|
|
||||||
<?php foreach ($rows as $row) : ?>
|
|
||||||
<li><?php echo $row; // phpcs:ignore WordPress.Security.EscapeOutput -- built from escaped parts in row(). ?></li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
<p><a href="<?php echo esc_url($hide); ?>"><?php esc_html_e('Hide', 'wp-plugin-starter-template'); ?></a></p>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One line of the notice.
|
|
||||||
*
|
|
||||||
* @param array $item Item from items().
|
|
||||||
* @return string HTML.
|
|
||||||
*/
|
|
||||||
private static function row(array $item) {
|
|
||||||
$labels = implode(', ', array_map(function ($label) {
|
|
||||||
return '‘' . $label . '’';
|
|
||||||
}, $item['settings']));
|
|
||||||
$name = '<strong>' . esc_html($item['name']) . '</strong>';
|
|
||||||
$base = self_admin_url('plugins.php');
|
|
||||||
|
|
||||||
if ('deactivate' === $item['step']) {
|
|
||||||
/* translators: 1: plugin name, 2: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('%1$s: %2$s is on and takes over once you deactivate it. Then you can delete it.', 'wp-plugin-starter-template'), $name, esc_html($labels));
|
|
||||||
if (current_user_can('deactivate_plugin', $item['file'])) {
|
|
||||||
$url = self::plugins_deactivate_url($item['file']);
|
|
||||||
/* translators: %s: plugin name */
|
|
||||||
$text .= sprintf(' <a href="%1$s">%2$s</a>', esc_url($url), esc_html(sprintf(__('Deactivate %s', 'wp-plugin-starter-template'), $item['name'])));
|
|
||||||
}
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('partial' === $item['step'] || 'switch_on_partial' === $item['step']) {
|
|
||||||
$extras = esc_html(implode(', ', $item['extras']));
|
|
||||||
if ('partial' === $item['step']) {
|
|
||||||
/* translators: 1: plugin name, 2: WP Plugin Starter setting names, 3: the plugin's settings WP Plugin Starter does not have */
|
|
||||||
$text = sprintf(esc_html__('%1$s: %2$s is on and takes over once you deactivate it, except for these, which WP Plugin Starter does not do: %3$s. Deactivate it only if you no longer need them.', 'wp-plugin-starter-template'), $name, esc_html($labels), $extras);
|
|
||||||
if (current_user_can('deactivate_plugin', $item['file'])) {
|
|
||||||
$url = self::plugins_deactivate_url($item['file']);
|
|
||||||
/* translators: %s: plugin name */
|
|
||||||
$text .= sprintf(' <a href="%1$s">%2$s</a>', esc_url($url), esc_html(sprintf(__('Deactivate %s', 'wp-plugin-starter-template'), $item['name'])));
|
|
||||||
}
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
/* translators: 1: plugin name, 2: WP Plugin Starter setting names, 3: the plugin's settings WP Plugin Starter does not have */
|
|
||||||
$text = sprintf(esc_html__('%1$s: %2$s can do part of its job. WP Plugin Starter does not do these, which it has on: %3$s.', 'wp-plugin-starter-template'), $name, esc_html($labels), $extras);
|
|
||||||
$url = WPStarter_Admin_Manager::tab_url(WPStarter_Admin_Manager::SEARCH, array('s' => $item['name']));
|
|
||||||
return $text . sprintf(' <a href="%1$s">%2$s</a>', esc_url($url), esc_html__('Show the setting', 'wp-plugin-starter-template'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('delete' === $item['step']) {
|
|
||||||
/* translators: 1: plugin name, 2: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('%1$s is inactive and no longer needed: %2$s does its job.', 'wp-plugin-starter-template'), $name, esc_html($labels));
|
|
||||||
if (current_user_can('delete_plugins')) {
|
|
||||||
$url = wp_nonce_url(add_query_arg(array('action' => 'delete-selected', 'checked[]' => $item['file'], 'plugin_status' => 'all'), $base), 'bulk-plugins');
|
|
||||||
/* translators: %s: plugin name */
|
|
||||||
$text .= sprintf(' <a href="%1$s">%2$s</a>', esc_url($url), esc_html(sprintf(__('Delete %s', 'wp-plugin-starter-template'), $item['name'])));
|
|
||||||
}
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* translators: 1: plugin name, 2: WP Plugin Starter setting names */
|
|
||||||
$text = sprintf(esc_html__('%1$s: switch on %2$s, then deactivate and delete it.', 'wp-plugin-starter-template'), $name, esc_html($labels));
|
|
||||||
$url = WPStarter_Admin_Manager::tab_url(WPStarter_Admin_Manager::SEARCH, array('s' => $item['name']));
|
|
||||||
return $text . sprintf(' <a href="%1$s">%2$s</a>', esc_url($url), esc_html__('Show the setting', 'wp-plugin-starter-template'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* admin-post: hide the listed items for this person.
|
|
||||||
*/
|
|
||||||
public static function hide() {
|
|
||||||
check_admin_referer(self::HIDE);
|
|
||||||
if (!current_user_can('activate_plugins')) {
|
|
||||||
wp_die(esc_html__('You are not allowed to manage plugins on this site.', 'wp-plugin-starter-template'), '', array('response' => 403));
|
|
||||||
}
|
|
||||||
$items = isset($_GET['items']) ? explode(',', sanitize_text_field(wp_unslash($_GET['items']))) : array();
|
|
||||||
$items = array_filter($items, function ($item) {
|
|
||||||
return (bool) preg_match('/^[A-Za-z0-9._-]+:(deactivate|switch_on|delete|partial|switch_on_partial)$/', $item);
|
|
||||||
});
|
|
||||||
$hidden = (array) get_user_meta(get_current_user_id(), self::HIDDEN, true);
|
|
||||||
update_user_meta(get_current_user_id(), self::HIDDEN, array_values(array_unique(array_filter(array_merge($hidden, $items)))));
|
|
||||||
|
|
||||||
$back = wp_get_referer();
|
|
||||||
wp_safe_redirect($back ? $back : self_admin_url('plugins.php'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,449 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* WP Plugin Starter settings tabs.
|
|
||||||
*
|
|
||||||
* Renders setting cards from WPStarter_Settings::schema(). Each top-level
|
|
||||||
* setting is a card with a switch; child settings appear in an expandable
|
|
||||||
* panel. Controls save instantly via AJAX (see admin/js/wpstarter-admin.js).
|
|
||||||
*
|
|
||||||
* @package WPStarter
|
|
||||||
* @since 0.2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
class WPStarter_Settings_Manager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render matching settings from every tab, grouped by tab.
|
|
||||||
*
|
|
||||||
* Cards are the same as on their own tab, so they can be switched on
|
|
||||||
* and changed here.
|
|
||||||
*
|
|
||||||
* @param string $query Search text.
|
|
||||||
* @param array $tabs Registered tabs (see WPStarter_Admin_Manager::get_tabs()).
|
|
||||||
*/
|
|
||||||
public static function render_search($query, array $tabs) {
|
|
||||||
$groups = array();
|
|
||||||
foreach (WPStarter_Settings::search($query) as $key => $field) {
|
|
||||||
if (isset($tabs[$field['tab']])) {
|
|
||||||
$groups[$field['tab']][$key] = $field;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$count = array_sum(array_map('count', $groups));
|
|
||||||
?>
|
|
||||||
<div class="wps-section">
|
|
||||||
<div class="wps-section__intro">
|
|
||||||
<h2 class="wps-section__title">
|
|
||||||
<?php
|
|
||||||
/* translators: %s: search text */
|
|
||||||
echo esc_html(sprintf(__('Results for “%s”', 'wp-plugin-starter-template'), $query));
|
|
||||||
?>
|
|
||||||
</h2>
|
|
||||||
<p class="wps-section__desc" role="status">
|
|
||||||
<?php
|
|
||||||
echo esc_html($count
|
|
||||||
/* translators: %d: number of matching features */
|
|
||||||
? sprintf(_n('%d feature found.', '%d features found.', $count, 'wp-plugin-starter-template'), $count)
|
|
||||||
: __('No features match. Try another word.', 'wp-plugin-starter-template'));
|
|
||||||
?>
|
|
||||||
</p>
|
|
||||||
<?php if ($count) : ?>
|
|
||||||
<p class="wps-section__hint"><?php esc_html_e('Changes are saved automatically.', 'wp-plugin-starter-template'); ?></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php foreach ($groups as $tab => $fields) : ?>
|
|
||||||
<h3 class="wps-search__group">
|
|
||||||
<a href="<?php echo esc_url(WPStarter_Admin_Manager::tab_url($tab)); ?>"><?php echo esc_html($tabs[$tab]['label']); ?></a>
|
|
||||||
</h3>
|
|
||||||
<div class="wps-cards">
|
|
||||||
<?php
|
|
||||||
foreach ($fields as $key => $field) {
|
|
||||||
self::render_card($key, $field);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render every top-level setting for a tab.
|
|
||||||
*
|
|
||||||
* @param string $tab Tab slug.
|
|
||||||
* @param string $title Section heading.
|
|
||||||
* @param string $description Section intro.
|
|
||||||
*/
|
|
||||||
public static function render_tab($tab, $title, $description) {
|
|
||||||
$fields = WPStarter_Settings::fields_for_tab($tab);
|
|
||||||
?>
|
|
||||||
<div class="wps-section">
|
|
||||||
<div class="wps-section__intro">
|
|
||||||
<h2 class="wps-section__title"><?php echo esc_html($title); ?></h2>
|
|
||||||
<?php if ($description) : ?>
|
|
||||||
<p class="wps-section__desc"><?php echo esc_html($description); ?></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($fields) : ?>
|
|
||||||
<p class="wps-section__hint"><?php esc_html_e('Changes are saved automatically.', 'wp-plugin-starter-template'); ?></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php if ($fields) : ?>
|
|
||||||
<div class="wps-cards">
|
|
||||||
<?php
|
|
||||||
foreach ($fields as $key => $field) {
|
|
||||||
self::render_card($key, $field);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php else : ?>
|
|
||||||
<div class="wps-card wps-empty">
|
|
||||||
<p><?php esc_html_e('No settings yet.', 'wp-plugin-starter-template'); ?></p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Fires after a settings tab's cards, for sections that are not
|
|
||||||
* settings (such as example data).
|
|
||||||
*
|
|
||||||
* @param string $tab Tab slug.
|
|
||||||
*/
|
|
||||||
do_action('wpstarter_settings_tab_after', $tab);
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render a setting card.
|
|
||||||
*
|
|
||||||
* @param string $key Setting key.
|
|
||||||
* @param array $field Schema entry.
|
|
||||||
*/
|
|
||||||
public static function render_card($key, array $field) {
|
|
||||||
// Hidden options are wiring set by starter data or code, not choices.
|
|
||||||
$children = array_filter(WPStarter_Settings::children_of($key), function ($child) {
|
|
||||||
return empty($child['hidden']);
|
|
||||||
});
|
|
||||||
$value = WPStarter_Settings::get($key);
|
|
||||||
$id = 'wps-' . $key;
|
|
||||||
$panel_id = $id . '-panel';
|
|
||||||
$is_bool = 'bool' === $field['type'];
|
|
||||||
?>
|
|
||||||
<section class="wps-card wps-setting<?php echo ($is_bool && $value) ? ' is-on' : ''; ?><?php echo $children ? ' has-panel' : ''; ?>" data-setting-card="<?php echo esc_attr($key); ?>">
|
|
||||||
<?php // Clicking the header (outside the switch) opens the options; only the switch changes the value. ?>
|
|
||||||
<div class="wps-setting__header"<?php echo $children ? ' data-wps-panel-toggle' : ''; ?>>
|
|
||||||
<?php if ($is_bool) : ?>
|
|
||||||
<span class="wps-switch">
|
|
||||||
<input type="checkbox"
|
|
||||||
role="switch"
|
|
||||||
class="wps-switch__input"
|
|
||||||
id="<?php echo esc_attr($id); ?>"
|
|
||||||
data-wps-setting="<?php echo esc_attr($key); ?>"
|
|
||||||
aria-labelledby="<?php echo esc_attr($id); ?>-title"
|
|
||||||
aria-describedby="<?php echo esc_attr($id); ?>-desc"
|
|
||||||
<?php checked((bool) $value); ?> />
|
|
||||||
<span class="wps-switch__track" aria-hidden="true"></span>
|
|
||||||
</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="wps-setting__text">
|
|
||||||
<div class="wps-setting__title-row">
|
|
||||||
<span class="wps-setting__title" id="<?php echo esc_attr($id); ?>-title"><?php echo esc_html($field['label']); ?></span>
|
|
||||||
<span class="wps-status" data-wps-status="<?php echo esc_attr($key); ?>" aria-hidden="true"></span>
|
|
||||||
</div>
|
|
||||||
<?php if (!empty($field['description'])) : ?>
|
|
||||||
<p class="wps-setting__desc" id="<?php echo esc_attr($id); ?>-desc"><?php echo esc_html($field['description']); ?></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php self::render_replaces($field); ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if ($children) : ?>
|
|
||||||
<button type="button"
|
|
||||||
class="wps-setting__expand button-link"
|
|
||||||
aria-expanded="false"
|
|
||||||
aria-controls="<?php echo esc_attr($panel_id); ?>">
|
|
||||||
<span class="wps-setting__expand-label"><?php esc_html_e('Options', 'wp-plugin-starter-template'); ?></span>
|
|
||||||
<span class="dashicons dashicons-arrow-down-alt2" aria-hidden="true"></span>
|
|
||||||
<span class="screen-reader-text"><?php echo esc_html(sprintf(/* translators: %s: setting name */ __('for %s', 'wp-plugin-starter-template'), $field['label'])); ?></span>
|
|
||||||
</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if ($children) : ?>
|
|
||||||
<div class="wps-setting__panel" id="<?php echo esc_attr($panel_id); ?>" hidden>
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Fires at the top of a setting's options panel, for status
|
|
||||||
* such as progress (wrap output in .wps-panel-note).
|
|
||||||
*
|
|
||||||
* @param string $key Setting key.
|
|
||||||
* @param array $field Schema entry.
|
|
||||||
*/
|
|
||||||
do_action('wpstarter_setting_panel', $key, $field);
|
|
||||||
foreach ($children as $child_key => $child) {
|
|
||||||
self::render_field($child_key, $child);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</section>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note which plugins a setting replaces. While one is active the setting
|
|
||||||
* waits (WPStarter_Feature::replaced_active()); say so, with a
|
|
||||||
* deactivate link where the user can deactivate it here.
|
|
||||||
*
|
|
||||||
* @param array $field Schema entry.
|
|
||||||
*/
|
|
||||||
private static function render_replaces(array $field) {
|
|
||||||
if (empty($field['replaces']) || !is_array($field['replaces'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$active = WPStarter_Feature::active_plugins();
|
|
||||||
$site = self::active_plugins_by_slug();
|
|
||||||
$items = array();
|
|
||||||
$links = array();
|
|
||||||
$busy = array();
|
|
||||||
foreach ($field['replaces'] as $slug => $name) {
|
|
||||||
$items[] = esc_html($name);
|
|
||||||
if (!isset($active[$slug])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$busy[] = (string) $name;
|
|
||||||
if (isset($site[$slug]) && current_user_can('deactivate_plugin', $site[$slug])) {
|
|
||||||
// Comes back to this tab, where the setting then takes over.
|
|
||||||
$url = WPStarter_Replaced_Plugins::deactivate_url($site[$slug]);
|
|
||||||
/* translators: %s: plugin name */
|
|
||||||
$links[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($url), esc_html(sprintf(__('Deactivate %s', 'wp-plugin-starter-template'), $name)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf(
|
|
||||||
'<p class="wps-replaces">%1$s %2$s</p>',
|
|
||||||
esc_html__('Replaces:', 'wp-plugin-starter-template'),
|
|
||||||
implode(', ', $items) // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
);
|
|
||||||
if ($busy) {
|
|
||||||
printf(
|
|
||||||
'<p class="wps-replaces wps-replaces__active">%1$s %2$s</p>',
|
|
||||||
/* translators: %s: plugin names */
|
|
||||||
esc_html(sprintf(__('%s is still active, so it does this job and this setting waits until it is deactivated.', 'wp-plugin-starter-template'), implode(', ', $busy))),
|
|
||||||
implode(' · ', $links) // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugins active on this site (not network-wide) keyed by directory slug.
|
|
||||||
*
|
|
||||||
* @return array<string,string> slug => plugin file
|
|
||||||
*/
|
|
||||||
private static function active_plugins_by_slug() {
|
|
||||||
static $active = null;
|
|
||||||
if (null === $active) {
|
|
||||||
$active = array();
|
|
||||||
foreach (WPStarter_Feature::stored_active_plugins() as $file) {
|
|
||||||
$slug = dirname((string) $file);
|
|
||||||
if ('.' !== $slug) {
|
|
||||||
$active[$slug] = (string) $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render a child field row.
|
|
||||||
*
|
|
||||||
* @param string $key Setting key.
|
|
||||||
* @param array $field Schema entry.
|
|
||||||
*/
|
|
||||||
public static function render_field($key, array $field) {
|
|
||||||
$value = WPStarter_Settings::get($key);
|
|
||||||
$id = 'wps-' . $key;
|
|
||||||
$desc_id = $id . '-desc';
|
|
||||||
$attrs = sprintf('id="%1$s" data-wps-setting="%2$s" aria-describedby="%3$s"', esc_attr($id), esc_attr($key), esc_attr($desc_id));
|
|
||||||
$is_multi = 'multi' === $field['type'];
|
|
||||||
?>
|
|
||||||
<div class="wps-field">
|
|
||||||
<?php if ($is_multi) : ?>
|
|
||||||
<span class="wps-field__label" id="<?php echo esc_attr($id); ?>-label"><?php echo esc_html($field['label']); ?></span>
|
|
||||||
<?php else : ?>
|
|
||||||
<label class="wps-field__label" for="<?php echo esc_attr($id); ?>"><?php echo esc_html($field['label']); ?></label>
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="wps-field__control">
|
|
||||||
<?php
|
|
||||||
switch ($field['type']) {
|
|
||||||
case 'select':
|
|
||||||
printf('<select %s>', $attrs); // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
$choices = WPStarter_Settings::options_for($field);
|
|
||||||
if (!empty($field['open']) && '' !== (string) $value && !array_key_exists((string) $value, $choices)) {
|
|
||||||
// A saved choice whose plugin is not loaded here stays shown.
|
|
||||||
$choices[(string) $value] = (string) $value;
|
|
||||||
}
|
|
||||||
foreach ($choices as $option_value => $option_label) {
|
|
||||||
printf(
|
|
||||||
'<option value="%1$s"%2$s>%3$s</option>',
|
|
||||||
esc_attr((string) $option_value),
|
|
||||||
selected((string) $value, (string) $option_value, false),
|
|
||||||
esc_html($option_label)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
echo '</select>';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'multi':
|
|
||||||
$chosen = array_map('strval', (array) $value);
|
|
||||||
$choices = WPStarter_Settings::options_for($field);
|
|
||||||
// With some plugins skipped on this request, a saved
|
|
||||||
// choice may belong to one of them; keep it too.
|
|
||||||
if (!empty($field['open']) || WPStarter_Feature::plugins_skipped()) {
|
|
||||||
// Saved items that are not registered right now stay visible so they can be unticked.
|
|
||||||
foreach (array_diff($chosen, array_map('strval', array_keys($choices))) as $missing) {
|
|
||||||
$choices[$missing] = $missing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$long = count($choices) > 12;
|
|
||||||
if ($long) {
|
|
||||||
// Long lists (such as every active plugin) scroll, with quick choices.
|
|
||||||
printf(
|
|
||||||
'<span class="wps-checkboxes__all"><button type="button" class="button-link" data-wps-check-all="%1$s">%2$s</button> · <button type="button" class="button-link" data-wps-check-none="%1$s">%3$s</button></span>',
|
|
||||||
esc_attr($id),
|
|
||||||
esc_html__('Select all', 'wp-plugin-starter-template'),
|
|
||||||
esc_html__('Clear', 'wp-plugin-starter-template')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// The group carries data-wps-setting; the JS saves every checked value.
|
|
||||||
printf(
|
|
||||||
'<fieldset class="wps-checkboxes%3$s" data-wps-multi %1$s aria-labelledby="%2$s">',
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
esc_attr($id . '-label'),
|
|
||||||
$long ? ' is-long' : ''
|
|
||||||
);
|
|
||||||
foreach ($choices as $option_value => $option_label) {
|
|
||||||
printf(
|
|
||||||
'<label class="wps-checkbox"><input type="checkbox" value="%1$s"%2$s /> %3$s</label>',
|
|
||||||
esc_attr((string) $option_value),
|
|
||||||
checked(in_array((string) $option_value, $chosen, true), true, false),
|
|
||||||
esc_html($option_label)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
echo '</fieldset>';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'url':
|
|
||||||
printf(
|
|
||||||
'<input type="text" class="regular-text code" inputmode="url" %1$s value="%2$s" placeholder="%3$s" />',
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
esc_attr((string) $value),
|
|
||||||
esc_attr(isset($field['placeholder']) ? $field['placeholder'] : '')
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'times':
|
|
||||||
printf(
|
|
||||||
'<input type="text" class="regular-text" %1$s value="%2$s" placeholder="%3$s" autocomplete="off" />',
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
esc_attr((string) $value),
|
|
||||||
esc_attr(isset($field['placeholder']) ? $field['placeholder'] : '')
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'int':
|
|
||||||
printf(
|
|
||||||
'<input type="number" class="small-text" %1$s value="%2$s" min="%3$s" max="%4$s" step="1" inputmode="numeric" />',
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
esc_attr((string) $value),
|
|
||||||
esc_attr(isset($field['min']) ? (string) $field['min'] : ''),
|
|
||||||
esc_attr(isset($field['max']) ? (string) $field['max'] : '')
|
|
||||||
);
|
|
||||||
if (!empty($field['unit'])) {
|
|
||||||
echo ' <span class="wps-field__unit">' . esc_html($field['unit']) . '</span>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'lines':
|
|
||||||
case 'domains':
|
|
||||||
printf(
|
|
||||||
'<textarea class="large-text code" rows="%1$d" %2$s placeholder="%3$s">%4$s</textarea>',
|
|
||||||
isset($field['rows']) ? (int) $field['rows'] : 3,
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
esc_attr(isset($field['placeholder']) ? $field['placeholder'] : ''),
|
|
||||||
esc_textarea((string) $value)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'media':
|
|
||||||
// The hidden input carries data-wps-setting; the JS sets it
|
|
||||||
// from the media dialog and saves it.
|
|
||||||
$image_id = (int) $value;
|
|
||||||
$preview = $image_id ? wp_get_attachment_image_url($image_id, 'thumbnail') : '';
|
|
||||||
echo '<div class="wps-media" data-wps-media>';
|
|
||||||
printf(
|
|
||||||
'<input type="hidden" data-wps-setting="%1$s" value="%2$s" />',
|
|
||||||
esc_attr($key),
|
|
||||||
esc_attr((string) $image_id)
|
|
||||||
);
|
|
||||||
if ($preview) {
|
|
||||||
printf('<img class="wps-media__preview" src="%s" alt="" />', esc_url($preview));
|
|
||||||
} else {
|
|
||||||
echo '<img class="wps-media__preview" alt="" hidden />';
|
|
||||||
}
|
|
||||||
printf(
|
|
||||||
'<button type="button" class="button wps-media__choose" id="%1$s" aria-describedby="%2$s">%3$s</button>',
|
|
||||||
esc_attr($id),
|
|
||||||
esc_attr($desc_id),
|
|
||||||
esc_html__('Choose picture', 'wp-plugin-starter-template')
|
|
||||||
);
|
|
||||||
printf(
|
|
||||||
'<button type="button" class="button-link wps-media__remove"%1$s>%2$s</button>',
|
|
||||||
$image_id ? '' : ' hidden',
|
|
||||||
esc_html__('Remove', 'wp-plugin-starter-template')
|
|
||||||
);
|
|
||||||
echo '</div>';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'bool':
|
|
||||||
printf(
|
|
||||||
'<span class="wps-switch"><input type="checkbox" role="switch" class="wps-switch__input" %1$s %2$s /><span class="wps-switch__track" aria-hidden="true"></span></span>',
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
checked((bool) $value, true, false)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'text':
|
|
||||||
default:
|
|
||||||
printf(
|
|
||||||
'<input type="text" class="regular-text" %1$s value="%2$s" placeholder="%3$s" />',
|
|
||||||
$attrs, // phpcs:ignore WordPress.Security.EscapeOutput -- escaped above.
|
|
||||||
esc_attr((string) $value),
|
|
||||||
esc_attr(isset($field['placeholder']) ? $field['placeholder'] : '')
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<span class="wps-status" data-wps-status="<?php echo esc_attr($key); ?>" aria-hidden="true"></span>
|
|
||||||
<?php if (!empty($field['description']) || !empty($field['tokens'])) : ?>
|
|
||||||
<p class="description" id="<?php echo esc_attr($desc_id); ?>">
|
|
||||||
<?php echo esc_html(isset($field['description']) ? $field['description'] : ''); ?>
|
|
||||||
<?php if (!empty($field['tokens'])) : ?>
|
|
||||||
<span class="wps-tokens">
|
|
||||||
<?php esc_html_e('Tokens:', 'wp-plugin-starter-template'); ?>
|
|
||||||
<?php foreach ($field['tokens'] as $token) : ?>
|
|
||||||
<button type="button" class="wps-token" data-token="<?php echo esc_attr($token); ?>" data-target="<?php echo esc_attr($id); ?>" title="<?php esc_attr_e('Insert token', 'wp-plugin-starter-template'); ?>"><code><?php echo esc_html($token); ?></code></button>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
/**
|
||||||
|
* 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 = $( '<div class="wpst-notice ' + type + '"><p>' + message + '</p></div>' );
|
||||||
|
|
||||||
|
// 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 );
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/**
|
||||||
|
* 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( '<span class="wpst-loading"></span> Saving...' );
|
||||||
|
|
||||||
|
// Send AJAX request.
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
url: wpstModalData.ajaxUrl, // WordPress AJAX URL.
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
action: 'wpst_set_update_source', // AJAX action hook.
|
||||||
|
nonce: wpstModalData.nonce, // Security 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 );
|
||||||
@@ -1,322 +0,0 @@
|
|||||||
/**
|
|
||||||
* WP Plugin Starter admin screen.
|
|
||||||
*
|
|
||||||
* One delegated controller per concern:
|
|
||||||
* - Settings: instant save for [data-wps-setting] controls.
|
|
||||||
* - Panels: expandable setting options.
|
|
||||||
* - Tokens: insert pattern tokens into text fields.
|
|
||||||
* - Media fields: choose a Media Library picture with the media dialog.
|
|
||||||
*
|
|
||||||
* The plugin's own tabs bring their own script (wpstarter_admin_enqueue),
|
|
||||||
* which can use window.wpstarterAdmin.api.
|
|
||||||
*
|
|
||||||
* Localized data: window.wpstarterAdmin (see WPStarter_Admin_Manager::enqueue_assets()).
|
|
||||||
*/
|
|
||||||
(function ($, wp, cfg) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
if (!cfg) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var i18n = cfg.i18n || {};
|
|
||||||
|
|
||||||
function speak(message, politeness) {
|
|
||||||
if (wp && wp.a11y && wp.a11y.speak) {
|
|
||||||
wp.a11y.speak(message, politeness || 'polite');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some plugins redirect the first admin request after activation to a
|
|
||||||
// welcome screen, and admin-ajax.php runs admin_init too. The redirect
|
|
||||||
// happens once, so a reply that is a page instead of JSON is retried
|
|
||||||
// once. Every action here is safe to repeat.
|
|
||||||
function post(action, data) {
|
|
||||||
var deferred = $.Deferred();
|
|
||||||
var current;
|
|
||||||
var send = function (retry) {
|
|
||||||
current = $.ajax({
|
|
||||||
url: cfg.ajaxUrl,
|
|
||||||
type: 'POST',
|
|
||||||
dataType: 'json',
|
|
||||||
data: $.extend({ action: action, nonce: cfg.nonce }, data)
|
|
||||||
})
|
|
||||||
.done(deferred.resolve)
|
|
||||||
.fail(function (xhr, status, error) {
|
|
||||||
if (status === 'parsererror' && retry) {
|
|
||||||
send(false);
|
|
||||||
} else {
|
|
||||||
deferred.reject(xhr, status, error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
send(true);
|
|
||||||
|
|
||||||
var promise = deferred.promise();
|
|
||||||
promise.abort = function () {
|
|
||||||
current.abort();
|
|
||||||
};
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
function errorMessage(xhr, fallback) {
|
|
||||||
var json = xhr && xhr.responseJSON;
|
|
||||||
if (json && json.data && json.data.message) {
|
|
||||||
return json.data.message;
|
|
||||||
}
|
|
||||||
return fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
/* Settings */
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
var Settings = {
|
|
||||||
pending: {},
|
|
||||||
sequence: 0,
|
|
||||||
// Saves run one at a time so each reads the settings the last one wrote.
|
|
||||||
queue: $.Deferred().resolve().promise(),
|
|
||||||
|
|
||||||
init: function () {
|
|
||||||
$(document).on('change', '[data-wps-setting]', function () {
|
|
||||||
Settings.save($(this));
|
|
||||||
});
|
|
||||||
// "Select all" and "Clear" for long checkbox lists: one save for the lot.
|
|
||||||
$(document).on('click', '[data-wps-check-all], [data-wps-check-none]', function () {
|
|
||||||
var all = this.hasAttribute('data-wps-check-all');
|
|
||||||
var $group = $('#' + $(this).attr(all ? 'data-wps-check-all' : 'data-wps-check-none'));
|
|
||||||
$group.find(':checkbox').prop('checked', all);
|
|
||||||
Settings.save($group);
|
|
||||||
});
|
|
||||||
// Forms that change data elsewhere ask first.
|
|
||||||
$(document).on('submit', 'form[data-wps-confirm]', function (event) {
|
|
||||||
if (!window.confirm($(this).attr('data-wps-confirm'))) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
valueOf: function ($input) {
|
|
||||||
if ($input.is('[data-wps-multi]')) {
|
|
||||||
return $input.find(':checkbox:checked').map(function () {
|
|
||||||
return this.value;
|
|
||||||
}).get();
|
|
||||||
}
|
|
||||||
if ($input.is(':checkbox')) {
|
|
||||||
return $input.is(':checked') ? '1' : '0';
|
|
||||||
}
|
|
||||||
return $input.val();
|
|
||||||
},
|
|
||||||
|
|
||||||
status: function (key, state, text, keep) {
|
|
||||||
var $status = $('[data-wps-status="' + key + '"]');
|
|
||||||
$status.removeClass('is-saving is-saved is-error').addClass(state ? 'is-' + state : '').text(text || '');
|
|
||||||
clearTimeout($status.data('timer'));
|
|
||||||
// "Reload the page" stays until the next change.
|
|
||||||
if (state === 'saved' && !keep) {
|
|
||||||
$status.data('timer', setTimeout(function () {
|
|
||||||
$status.removeClass('is-saved').text('');
|
|
||||||
}, 2000));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
save: function ($input) {
|
|
||||||
var key = $input.data('wps-setting');
|
|
||||||
var value = this.valueOf($input);
|
|
||||||
var previous = $input.data('wps-saved');
|
|
||||||
var seq = ++this.sequence;
|
|
||||||
|
|
||||||
if (previous === undefined) {
|
|
||||||
previous = $input.is(':checkbox') ? ($input.is(':checked') ? '0' : '1') : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pending[key] = seq;
|
|
||||||
this.status(key, 'saving', i18n.saving);
|
|
||||||
|
|
||||||
var run = function () {
|
|
||||||
return post('wpstarter_save_setting', { key: key, value: value })
|
|
||||||
.done(done)
|
|
||||||
.fail(failed);
|
|
||||||
};
|
|
||||||
var done = function (response) {
|
|
||||||
if (Settings.pending[key] !== seq) {
|
|
||||||
return; // A newer save for this key is queued.
|
|
||||||
}
|
|
||||||
if (!response || !response.success) {
|
|
||||||
Settings.fail($input, key, previous, i18n.saveFailed);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var saved = response.data.value;
|
|
||||||
if ($input.is('[data-wps-multi]')) {
|
|
||||||
var chosen = $.map(saved || [], String);
|
|
||||||
$input.find(':checkbox').each(function () {
|
|
||||||
this.checked = $.inArray(this.value, chosen) !== -1;
|
|
||||||
});
|
|
||||||
} else if ($input.is(':checkbox')) {
|
|
||||||
$input.data('wps-saved', saved ? '1' : '0');
|
|
||||||
} else if (saved !== undefined && String(saved) !== String($input.val())) {
|
|
||||||
$input.val(saved); // Show the sanitized value.
|
|
||||||
}
|
|
||||||
if (!$input.is(':checkbox')) {
|
|
||||||
$input.data('wps-saved', $input.val());
|
|
||||||
}
|
|
||||||
var reload = !!response.data.reload;
|
|
||||||
var message = reload && response.data.message ? response.data.message : i18n.saved;
|
|
||||||
Settings.status(key, 'saved', message, reload);
|
|
||||||
speak(message);
|
|
||||||
$(document).trigger('wpstarter:setting-saved', [key, saved]);
|
|
||||||
};
|
|
||||||
var failed = function (xhr) {
|
|
||||||
if (Settings.pending[key] === seq) {
|
|
||||||
Settings.fail($input, key, previous, errorMessage(xhr, i18n.saveFailed));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// A failed save must not block the ones after it.
|
|
||||||
this.queue = this.queue.then(run, run);
|
|
||||||
|
|
||||||
if ($input.is(':checkbox')) {
|
|
||||||
$input.closest('[data-setting-card]').filter(function () {
|
|
||||||
return $(this).data('setting-card') === key;
|
|
||||||
}).toggleClass('is-on', $input.is(':checked'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fail: function ($input, key, previous, message) {
|
|
||||||
if ($input.is(':checkbox')) {
|
|
||||||
var on = previous === '1' || previous === true;
|
|
||||||
$input.prop('checked', on);
|
|
||||||
$input.closest('[data-setting-card]').toggleClass('is-on', on);
|
|
||||||
}
|
|
||||||
this.status(key, 'error', message);
|
|
||||||
speak(message, 'assertive');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
/* Expandable panels and tokens */
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
var Panels = {
|
|
||||||
toggle: function ($button) {
|
|
||||||
if (!$button.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var expanded = $button.attr('aria-expanded') === 'true';
|
|
||||||
var panel = document.getElementById($button.attr('aria-controls'));
|
|
||||||
$button.attr('aria-expanded', expanded ? 'false' : 'true');
|
|
||||||
if (panel) {
|
|
||||||
panel.hidden = expanded;
|
|
||||||
}
|
|
||||||
$button.closest('.wps-setting').toggleClass('is-expanded', !expanded);
|
|
||||||
},
|
|
||||||
|
|
||||||
init: function () {
|
|
||||||
$(document).on('click', '.wps-setting__expand', function (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
Panels.toggle($(this));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Mouse convenience: clicking anywhere on the header opens/closes the
|
|
||||||
// options. The switch (and any other control) keeps its own behaviour;
|
|
||||||
// keyboard users use the Options button.
|
|
||||||
$(document).on('click', '[data-wps-panel-toggle]', function (event) {
|
|
||||||
if ($(event.target).closest('input, button, a, label, select, textarea, .wps-switch').length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (window.getSelection && String(window.getSelection()).length) {
|
|
||||||
return; // Let people select text.
|
|
||||||
}
|
|
||||||
Panels.toggle($(this).find('.wps-setting__expand').first());
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '.wps-token', function () {
|
|
||||||
var input = document.getElementById($(this).data('target'));
|
|
||||||
var token = String($(this).data('token'));
|
|
||||||
if (!input) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var start = typeof input.selectionStart === 'number' ? input.selectionStart : input.value.length;
|
|
||||||
var end = typeof input.selectionEnd === 'number' ? input.selectionEnd : input.value.length;
|
|
||||||
input.value = input.value.slice(0, start) + token + input.value.slice(end);
|
|
||||||
input.focus();
|
|
||||||
input.setSelectionRange(start + token.length, start + token.length);
|
|
||||||
$(input).trigger('change');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
/* Media fields: choose a Media Library picture */
|
|
||||||
/* ------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
var MediaField = {
|
|
||||||
init: function () {
|
|
||||||
$(document).on('click', '.wps-media__choose', function () {
|
|
||||||
MediaField.open($(this).closest('[data-wps-media]'));
|
|
||||||
});
|
|
||||||
$(document).on('click', '.wps-media__remove', function () {
|
|
||||||
MediaField.set($(this).closest('[data-wps-media]'), 0, '');
|
|
||||||
$(this).siblings('.wps-media__choose').trigger('focus');
|
|
||||||
});
|
|
||||||
// A saved 0 means the choice was not a picture.
|
|
||||||
$(document).on('wpstarter:setting-saved', function (event, key, value) {
|
|
||||||
var $field = $('[data-wps-media]').has('[data-wps-setting="' + key + '"]');
|
|
||||||
if ($field.length && !parseInt(value, 10)) {
|
|
||||||
MediaField.preview($field, '');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
open: function ($field) {
|
|
||||||
if (!wp || !wp.media) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frame = $field.data('wps-frame');
|
|
||||||
if (!frame) {
|
|
||||||
frame = wp.media({
|
|
||||||
title: i18n.chooseImage,
|
|
||||||
library: { type: 'image' },
|
|
||||||
multiple: false,
|
|
||||||
button: { text: i18n.useImage }
|
|
||||||
});
|
|
||||||
frame.on('select', function () {
|
|
||||||
var item = frame.state().get('selection').first();
|
|
||||||
if (!item) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var data = item.toJSON();
|
|
||||||
var url = data.sizes && data.sizes.thumbnail ? data.sizes.thumbnail.url : data.url;
|
|
||||||
MediaField.set($field, data.id, url);
|
|
||||||
});
|
|
||||||
$field.data('wps-frame', frame);
|
|
||||||
}
|
|
||||||
frame.open();
|
|
||||||
},
|
|
||||||
|
|
||||||
set: function ($field, id, url) {
|
|
||||||
this.preview($field, url);
|
|
||||||
$field.find('[data-wps-setting]').val(String(id || 0)).trigger('change');
|
|
||||||
},
|
|
||||||
|
|
||||||
preview: function ($field, url) {
|
|
||||||
var $img = $field.find('.wps-media__preview');
|
|
||||||
if (url) {
|
|
||||||
$img.attr('src', url).prop('hidden', false);
|
|
||||||
} else {
|
|
||||||
$img.removeAttr('src').prop('hidden', true);
|
|
||||||
}
|
|
||||||
$field.find('.wps-media__remove').prop('hidden', !url);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// For the plugin's own admin scripts, which load after this one
|
|
||||||
// (wpstarter_admin_enqueue): the same AJAX, screen reader and error helpers.
|
|
||||||
cfg.api = { post: post, speak: speak, errorMessage: errorMessage };
|
|
||||||
|
|
||||||
$(function () {
|
|
||||||
Settings.init();
|
|
||||||
Panels.init();
|
|
||||||
MediaField.init();
|
|
||||||
});
|
|
||||||
})(jQuery, window.wp, window.wpstarterAdmin);
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin area specific functions.
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate\Admin\Lib
|
||||||
|
* @file
|
||||||
|
*/
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Modal related functions for the admin area.
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate\Admin\Lib
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File: modal.php
|
||||||
|
* Description: Modal related functions for the admin area.
|
||||||
|
* Version: 1.0
|
||||||
|
* Author: Your Name
|
||||||
|
* Author URI: https://yourwebsite.com
|
||||||
|
*/
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* WP Plugin Starter admin loader.
|
|
||||||
*
|
|
||||||
* Loads the settings screen, the Read Me tab and the Plugins screen notes
|
|
||||||
* for replaced plugins, then the plugin's own admin parts
|
|
||||||
* (WPStarter_Setup::admin()). Included from the main plugin file for
|
|
||||||
* admin requests only.
|
|
||||||
*
|
|
||||||
* @package WPStarter
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH')) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpstarter_admin_files = array(
|
|
||||||
'admin/data/readme.php',
|
|
||||||
'admin/includes/class-settings-manager.php',
|
|
||||||
'admin/includes/class-readme-manager.php',
|
|
||||||
'admin/includes/class-admin-manager.php',
|
|
||||||
'admin/includes/class-replaced-plugins.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($wpstarter_admin_files as $wpstarter_file) {
|
|
||||||
require_once WPSTARTER_DIR . $wpstarter_file;
|
|
||||||
}
|
|
||||||
unset($wpstarter_admin_files, $wpstarter_file);
|
|
||||||
|
|
||||||
WPStarter_Admin_Manager::init();
|
|
||||||
WPStarter_Replaced_Plugins::init();
|
|
||||||
WPStarter_Setup::admin();
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Modal Template
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate\Admin\Templates
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Ensure this file is loaded within WordPress.
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!-- Update Source Modal -->
|
||||||
|
<div id="wpst-update-source-modal" class="wpst-modal">
|
||||||
|
<div class="wpst-modal-content">
|
||||||
|
<div class="wpst-modal-header">
|
||||||
|
<h2 class="wpst-modal-title"><?php esc_html_e( 'Select Update Source', 'wp-plugin-starter-template' ); ?></h2>
|
||||||
|
<span class="wpst-modal-close">×</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wpst-modal-body">
|
||||||
|
<p><?php esc_html_e( 'Choose your preferred source for plugin updates:', 'wp-plugin-starter-template' ); ?></p>
|
||||||
|
|
||||||
|
<div class="wpst-modal-message"></div>
|
||||||
|
|
||||||
|
<div class="wpst-source-options">
|
||||||
|
<?php
|
||||||
|
// Get current update source.
|
||||||
|
$current_source = get_option( 'wpst_update_source', 'wordpress.org' );
|
||||||
|
?>
|
||||||
|
|
||||||
|
<label class="wpst-source-option <?php echo 'wordpress.org' === $current_source ? 'selected' : ''; ?>">
|
||||||
|
<input type="radio" name="update_source" value="wordpress.org" <?php checked( $current_source, 'wordpress.org' ); ?>>
|
||||||
|
<span class="wpst-source-option-label"><?php esc_html_e( 'WordPress.org', 'wp-plugin-starter-template' ); ?></span>
|
||||||
|
<div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the official WordPress.org repository. Recommended for most users.', 'wp-plugin-starter-template' ); ?></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label class="wpst-source-option <?php echo 'github' === $current_source ? 'selected' : ''; ?>">
|
||||||
|
<input type="radio" name="update_source" value="github" <?php checked( $current_source, 'github' ); ?>>
|
||||||
|
<span class="wpst-source-option-label"><?php esc_html_e( 'GitHub', 'wp-plugin-starter-template' ); ?></span>
|
||||||
|
<div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the GitHub repository. May include pre-release versions.', 'wp-plugin-starter-template' ); ?></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label class="wpst-source-option <?php echo 'gitea' === $current_source ? 'selected' : ''; ?>">
|
||||||
|
<input type="radio" name="update_source" value="gitea" <?php checked( $current_source, 'gitea' ); ?>>
|
||||||
|
<span class="wpst-source-option-label"><?php esc_html_e( 'Gitea', 'wp-plugin-starter-template' ); ?></span>
|
||||||
|
<div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the Gitea repository. May include pre-release versions.', 'wp-plugin-starter-template' ); ?></div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wpst-modal-footer">
|
||||||
|
<button type="button" id="wpst-save-source" class="button button-primary"><?php esc_html_e( 'Save', 'wp-plugin-starter-template' ); ?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loaded 100 of 183 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user