Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.

Latest commit

 

History

History
72 lines (62 loc) · 4.47 KB

AGENTS.md

File metadata and controls

72 lines (62 loc) · 4.47 KB

AGENTS.md

Overview

  • This repository contains the WPVulnerability WordPress plugin. Treat every change as production-grade code for a widely distributed plugin.
  • Maintain compatibility with WordPress 4.7 – 6.9 and PHP 5.6 – 8.4. Test new logic against modern PHP (8.x) while ensuring legacy behaviour remains intact.
  • Keep plugin headers, translation domains (wpvulnerability), and public APIs stable. Preserve backward compatibility for filters, actions, and CLI commands.

Repository Map

  • wpvulnerability.php is the loader; feature-specific logic is split across wpvulnerability-*.php files and supporting classes in the root directory.
  • CLI tooling lives in class-wpvulnerability-cli.php and class-wpvulnerability-config-cli.php.
  • Assets (JS/CSS) reside in assets/; language files live in languages/.
  • Automated tests are under tests/ (PHPUnit). Supporting scripts live in bin/.

Environment Setup

  1. Install PHP dependencies:
    composer install
  2. Ensure the PHP interpreter used locally supports all required extensions (curl, json, mbstring, xml, zip) to mirror typical WordPress hosting.
  3. Activate the plugin inside a WordPress installation by symlinking or copying the repository folder into wp-content/plugins/.

Required Checks

Run all commands from the repository root after making changes:

  1. Static analysis:
    vendor/bin/phpstan analyse --memory-limit=1G
  2. Unit tests:
    vendor/bin/phpunit
  3. Coding standards (WordPress Coding Standards via PHPCS):
    vendor/bin/phpcs
    Target PHP files must follow PHPCS + WPCS with tab indentation. Use vendor/bin/phpcbf only when confident it will not introduce breaking formatting.

Coding & Documentation Standards

  • Follow WordPress Coding Standards for PHP, JS, and CSS. Use tabs for indentation; align multi-line arrays or arguments with spaces only where WPCS allows.
  • PHPDoc blocks are mandatory for classes, interfaces, traits, properties, and methods/functions. Include summaries, @since, @param, @return, and @throws when relevant.
  • Prefer early returns, strict comparisons, and guard clauses to keep functions readable.
  • Do not introduce new global functions/constants unless required. Extend existing classes or create prefixed classes (e.g., WPVulnerability_*).
  • All user-facing strings must be translatable with the wpvulnerability text domain and properly escaped (esc_html__, esc_attr__, wp_kses_post, etc.).
  • Keep array syntax compatible with PHP 5.6 (no trailing commas in function calls, no short array destructuring).
  • When modifying database or HTTP interactions, leverage WordPress APIs (e.g., $wpdb, wp_remote_get()). Avoid blocking synchronous calls inside hooks that run on every request.

Security Expectations

  • Sanitize, validate, and escape all input and output. Use the most specific helper (sanitize_text_field, absint, wp_kses_post, etc.).
  • Use capability checks before mutating data (e.g., current_user_can( 'manage_options' )).
  • All mutating requests (forms, AJAX, REST) must include a nonce and verify it with wp_verify_nonce().
  • Never store secrets or credentials in the repository. Read them from environment variables or WordPress options stored securely.
  • Review each change for potential privilege escalation, CSRF, and XSS vectors.

Testing Guidance

  • Add or update PHPUnit tests in tests/ for new behaviour. Structure tests to run independently of a full WordPress install when possible.
  • Use data providers for coverage across multiple WordPress/PHP versions when logic diverges.
  • For regression fixes, include tests that reproduce the previous bug.

Release Checklist

  • Code formatted and PHPCS/WPCS clean.
  • PHPStan and PHPUnit pass locally; document any pre-existing failures.
  • Added/updated tests covering new logic.
  • Documentation (README, docblocks, inline comments) updated.
  • Security review completed (nonces, sanitization, escaping, capability checks).
  • Confirm backwards compatibility for public hooks, filters, and CLI commands.

Commit & PR Guidelines

  • Write commit messages in English using <type>: <description> where <type> might be fix, feat, docs, etc.
  • Do not amend or squash existing commits; keep history linear and descriptive.
  • Summaries and PR descriptions must be in English and highlight testing performed.
  • After committing, use the make_pr tool to draft the PR message once all work is complete.