wp-php-standards
Skill4 starsChanged 3 days agoMITView on GitHub
WordPress PHP Coding Standards reference — full-tag PHP, snake_case prefixed naming, tabs, long arrays, Yoda conditions, escaping and sanitization, $wpdb prepare, i18n, one class per file, phpcs configuration. Use when writing or reviewing theme/plugin PHP, or when asked about WordPress PHP conventions, escaping, or the WPCS gate. Owns the deep reference in docs/wordpress-php-standards.md.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- diagnosing-bugsSkill
- domain-modelingSkill
- fixSkill
- frontend-designSkill
- grill-meSkill
- grill-with-docsSkill
- gsap-coreSkill
- gsap-performanceSkill
- gsap-pluginsSkill
- gsap-scrolltriggerSkill
- gsap-timelineSkill
- gsap-utilsSkill
- handoffSkill
- landing-page-conversion-auditSkill
- refactorSkill
- researchSkill
- reviewSkill
- share-learningSkill
- tddSkill
- threejs-animationSkill
- threejs-fundamentalsSkill
- threejs-geometrySkill
- threejs-interactionSkill
- threejs-lightingSkill
- threejs-loadersSkill
- threejs-materialsSkill
- threejs-postprocessingSkill
- threejs-shadersSkill
- threejs-texturesSkill
- to-specSkill
- to-ticketsSkill
- verifySkill
- wp-accessibilitySkill
- wp-accessibility-standardsSkill
- wp-css-standardsSkill
- wp-github-actions-standardsSkill
- wp-html-standardsSkill
- wp-i18nSkill
- wp-js-standardsSkill
- wp-performanceSkill
- wp-pluginSkill
- wp-security-auditSkill
- wp-themeSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Write and review PHP that passes the WordPress Coding Standards gate (phpcs) — surviving Theme/Plugin Review from the first file, on PHP …
- Very specific: line 33
Every file with top-level code: if ( !
- Very specific: line 76
Every user-facing string through a translation function with the text domain as LAST argument.
- Distinctive: line 99
Never write unescaped output, raw SQL, or missing capability checks
- Distinctive: line 100
Never commit code that fails the verification chain
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WordPress PHP Coding Standards
The full reference lives in docs/wordpress-php-standards.md — load it when writing
or reviewing PHP. This skill is the routing entry point and carries the floor that
must never be violated (mirrors AGENTS.md).
Scope (umbrella page): the standards are mandatory for WordPress Core and recommended for themes/plugins; third-party libraries are exempt even when integrated. "Coding style" may differ for themes/plugins, but the interoperability, translatability, and security best practices are not optional.
Goal
Write and review PHP that passes the WordPress Coding Standards gate (phpcs) — surviving Theme/Plugin Review from the first file, on PHP 8.2+.
When to use
- Writing or reviewing theme/plugin PHP
- Answering "what does the WordPress PHP standard say about X"
- Any question about escaping, sanitization, naming, or the phpcs gate
The standard (floor)
File mechanics
- Full tags only (
<?php/?>), never<?or<?=; closing tag omitted at EOF - Every file with top-level code:
if ( ! defined( 'ABSPATH' ) ) { exit; } require_onceoverinclude[_once]; no parens around the path
Naming & structure
- Functions/variables/hooks: lowercase
snake_case, prefixed (≥4 chars, e.g.snoozle_) — neverwp_,__,_ - Classes:
Class_Name, one class per file,class-{name}.php; namespacesPrefix\Module\Sub_Module;wp/WordPressreserved - Constants:
ALL_CAPS_WITH_UNDERSCORES - Options, transients, hook names: all prefixed
Syntax
- Tabs; spaces inside control-structure parens;
array( ... )long syntax (short[...]prohibited); Yoda conditions for==/!=/===/!== - Braces always;
elseifneverelse if; single quotes unless interpolating - No
extract(),eval(),create_function(),goto,@suppression; no short ternary?:(except! empty()); no assignments in conditionals - Closures never as action/filter callbacks (can't be removed)
$wpdb->prepare()with unquoted%s/%d/%f/%i— never concatenated SQL
OOP
- One object per file; declared visibility (no
var); modifier orderabstract/final→ visibility →static→ type;new Foo();with parens ?Typeattached;: Type|falseno space before the colon
Security (escape at output, sanitize at input)
- Output:
esc_html()text,esc_attr()attributes,esc_url()URLs (neveresc_attr( $url )),esc_textarea(),wp_kses_post()trusted HTML,esc_html_e()/esc_attr_e()for i18n - Input:
wp_unslash()request data first, then sanitize (sanitize_text_field(),absint(),sanitize_email(),sanitize_key()); validate before sanitize (safelists within_array( $x, $allowed, true )) - CSRF:
wp_nonce_field()/check_admin_referer()/check_ajax_referer()on every state-changing form; nonces are NOT authorization — pair withcurrent_user_can();is_admin()is not an auth check - Redirects:
wp_safe_redirect()for user-influenced URLs
i18n
- Every user-facing string through a translation function with the text domain
as LAST argument; escape + translate for attributes (
esc_attr__()) - Translators comments with numbered placeholders
Hooks
- Custom hooks prefixed and documented with a full DocBlock above
do_action()/apply_filters(); filters have no side effects - Core hook timing:
initfor CPTs/rewrites,wp_enqueue_scripts,after_setup_themefor theme setup
Enforcement
- phpcs:
WordPress-Extra+WordPress-Docs+PHPCompatibility+ the two WPCS 3.x opt-ins (ValidatedSanitizedInput,PrefixAllGlobalswith theprefixesproperty) — the templates ship this inphpcs.xml - pint: formatter; phpcs is the style authority (pint.json disables the conflicting rules)
- phpstan: level 8 with
szepeviktor/phpstan-wordpress(+ ACF stubs in themes) - Chain: build → format:all:check → phpcs → phpstan, stop at the first red
Rules
- Never write unescaped output, raw SQL, or missing capability checks
- Never commit code that fails the verification chain
setup_postdata()does NOT set the global$post(WP 7.x) — pass posts explicitly toget_the_title( $p ),get_field( 'name', $id )
Output contract
- Written PHP: chain-green on first pass (format, phpcs 0 errors, phpstan level 8)
- Review findings:
file:line+ rule + fix
References
- PHP Coding Standards — official
- Internal: full PHP reference · security · plugin architecture · theme architecture · verification chain
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

