From bbd0a31795ec21b27fcc87d23ea087cc33125919 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Wed, 22 Oct 2025 13:06:56 +0200 Subject: [PATCH 1/4] Documenation added --- .distignore | 3 ++- .gitignore | 3 ++- AGENTS.md | 34 ++++++++++++++++++++++++++++++++++ README.md | 18 ++++++++++++++++-- composer.json | 1 + 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 AGENTS.md diff --git a/.distignore b/.distignore index 83b15fe..c9f99d2 100644 --- a/.distignore +++ b/.distignore @@ -10,10 +10,10 @@ coverage.xml .distignore .gitattributes .gitignore +.phpcs.cache .phpunit.result.cache .scrutinizer.yml Changelog.md -composer.json composer.lock mslsmenu.zip package.json @@ -22,3 +22,4 @@ phpdoc.xml phpstan.neon phpunit.xml README.md +AGENTS.md diff --git a/.gitignore b/.gitignore index 1bac2c0..a4078a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ .DS_Store .phpunit.result.cache .idea/ +.phpcs.cache vendor/ reports/ mslsmenu/ composer.lock mslsmenu.zip -coverage.xml \ No newline at end of file +coverage.xml diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..628b423 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,34 @@ +# Repository Guidelines + +## Project Structure & Module Organization +- `MslsMenu.php` is the WordPress bootstrap; add hooks here or split helpers into new subdirectories under `mslsmenu/` as needed. +- `mslsmenu/` mirrors the shipping bundle; keep source and bundle in sync before release. +- `languages/` stores translation assets; regenerate via `wp i18n make-pot` when strings move. +- `tests/` houses Pest specs with Brain Monkey shims in `tests/Pest.php`; colocate fixtures with their specs. +- `bin/` contains release tooling (`bin/git-release.sh`); prefer extending scripts over one-off commands. + +## Build, Test, and Development Commands +- Run `composer install` after cloning to pull dev dependencies. +- `composer test` executes the Pest suite with mocked WordPress APIs. +- `composer analyze` runs PHPStan (level 5) against `MslsMenu.php`; keep it passing before pushing. +- `composer coverage` enables Xdebug coverage for pull request evidence. +- `composer build` triggers `bin/git-release.sh`, refreshing `mslsmenu/` and `mslsmenu.zip` for distribution. + +## Coding Style & Naming Conventions +- Follow WordPress PHP standards: tabs for indentation, braces on new lines, no trailing commas. +- Include `declare(strict_types=1);` in new entry points and document public APIs with PHPDoc. +- Use `snake_case` for hook callbacks, `PascalCase` for classes, and `camelCase` for internal helpers unless a hook signature dictates otherwise. + +## Testing Guidelines +- Place new specs in `tests/YourFeatureTest.php`; keep case names descriptive (`it('renders menu item')`). +- Stub external WP functions with Brain Monkey setup blocks to keep tests deterministic. +- Run `composer coverage` for behavioral changes and share the summary when coverage changes noticeably. + +## Commit & Pull Request Guidelines +- Write short imperative subjects (≈50 chars) such as `Clean menu walker output`; batch related edits together. +- Reference GitHub issues in the body (`Refs #123`) and list the commands you ran. +- PRs should explain the problem, outline the fix, attach UI evidence when relevant, and confirm `composer test` plus `composer analyze`. + +## Release Packaging Tips +- Bump the plugin header version in `MslsMenu.php` and sync the same value into `readme.txt` before building. +- Run `composer build`, inspect the refreshed `mslsmenu/` contents, and spot-check the generated `mslsmenu.zip` before tagging. diff --git a/README.md b/README.md index e3a2bbf..8d84617 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,20 @@ MslsMenu [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lloc/MslsMenu/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lloc/MslsMenu/?branch=master) [![codecov](https://codecov.io/gh/lloc/MslsMenu/graph/badge.svg?token=902NM9H2BW)](https://codecov.io/gh/lloc/MslsMenu) -Adds the output of the Multisite Language Switcher to the one (or more) of your navigation menus(s) +MslsMenu extends the Multisite Language Switcher by injecting a language picker into any registered WordPress navigation menu. Install it when you want users to toggle sites and languages without custom walkers. -[Latest stable](https://wordpress.org/plugins/mslsmenu/) \ No newline at end of file +## Install +- From WordPress: search for “MslsMenu” under Plugins → Add New and activate it. +- Manual: copy the `mslsmenu/` directory to `wp-content/plugins/` and activate the plugin. + +## Usage +- Head to Appearance → Menus, add the “MslsMenu” item to your chosen menu, and arrange it like any other menu entry. +- Configure Multisite Language Switcher as usual; MslsMenu reuses its site mappings automatically. + +## Develop +- `composer install` pulls dev tools (Pest, PHPStan, Brain Monkey). +- `composer test` runs the Pest suite; `composer analyze` performs static analysis. + +## Contribute +- Review `AGENTS.md` for project conventions and release steps. +- Latest release: https://wordpress.org/plugins/mslsmenu/ diff --git a/composer.json b/composer.json index 9325441..3a61e45 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "analyze": "vendor/bin/phpstan analyze", "git-release": "bin/git-release.sh", "build": [ + "@composer update --no-dev", "@git-release" ] }, From 7a269988c5f8d6a389d0277f103161373c53fa82 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Wed, 22 Oct 2025 13:12:47 +0200 Subject: [PATCH 2/4] Update composer.json Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f832f97..e40d0a3 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "coverage": "php -d xdebug.mode=coverage vendor/bin/pest --coverage", "phpstan": "vendor/bin/phpstan analyze", "git-release": "bin/git-release.sh", - "build": [ +@composer install --no-dev --no-interaction --prefer-dist "@composer update --no-dev", "@git-release" ], From d4e70189681cd8dc75a2be6cfe147c8153467cfc Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Wed, 22 Oct 2025 13:15:04 +0200 Subject: [PATCH 3/4] Remove redundant composer install command --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index e40d0a3..63648e9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "coverage": "php -d xdebug.mode=coverage vendor/bin/pest --coverage", "phpstan": "vendor/bin/phpstan analyze", "git-release": "bin/git-release.sh", -@composer install --no-dev --no-interaction --prefer-dist "@composer update --no-dev", "@git-release" ], From abd72769429416f5e5b647370f3e05bd08b27070 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Wed, 22 Oct 2025 13:16:47 +0200 Subject: [PATCH 4/4] Refactor composer.json scripts and dependencies --- composer.json | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 63648e9..3a61e45 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,7 @@ "brain/monkey": "2.*", "phpstan/phpstan": "^1.8", "szepeviktor/phpstan-wordpress": "^1.1", - "phpstan/extension-installer": "^1.1", - "wp-coding-standards/wpcs": "^3.0" + "phpstan/extension-installer": "^1.1" }, "autoload-dev": { "files": [ "MslsMenu.php" ] @@ -22,20 +21,11 @@ "scripts": { "test": "vendor/bin/pest", "coverage": "php -d xdebug.mode=coverage vendor/bin/pest --coverage", - "phpstan": "vendor/bin/phpstan analyze", + "analyze": "vendor/bin/phpstan analyze", "git-release": "bin/git-release.sh", + "build": [ "@composer update --no-dev", "@git-release" - ], - "githooks": [ - "if [ -e bin/githooks/pre-commit ]; then cp bin/githooks/pre-commit ./.git/hooks/; fi", - "if [ -e .git/hooks/pre-commit ]; then chmod 0755 .git/hooks/pre-commit; fi" - ], - "post-install-cmd": [ - "@githooks" - ], - "post-update-cmd": [ - "@githooks" ] }, "authors": [ @@ -56,8 +46,7 @@ "allow-plugins": { "composer/installers": true, "phpstan/extension-installer": true, - "pestphp/pest-plugin": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "pestphp/pest-plugin": true } } }