Skip to main content

PHP Cheatsheet

Scope

This cheatsheet is a lookup reference for PHP used in real WordPress work. It covers core PHP language features, common standard-library functions, security boundaries, and the WordPress APIs most frequently used in themes, plugins, REST routes, AJAX handlers, admin screens, WooCommerce extensions, and production maintenance.

Sections​

Golden Rules​

RuleWhy It Matters
Validate inputReject values your feature should never accept
Sanitize before storageNormalize values before they become durable data
Escape outputPrevent broken markup and cross-site scripting
Check capabilitiesPrevent unauthorized reads and writes
Use prepared SQLPrevent SQL injection
Avoid editing coreKeep updates safe and reversible
Log safelyDebug without exposing secrets