Setting the file. One moment.
Skill 14 · Wp Plugin Development
Subchapter 14.4
references/security.mdMarkdown2 KBView on GitHub
Use this file when making security fixes or when handling any input/output.
current_user_can() or a more specific capability).Upstream reference:
Golden rule:
Practical rules:
$_POST / $_GET array; read explicit keyswp_unslash() before sanitizing when neededEscape at output, using the function that matches the context:
esc_html()esc_attr()esc_url()esc_textarea()esc_js()For JSON data, prefer wp_json_encode() and pass data through WordPress script APIs such as wp_add_inline_script() or wp_localize_script().
For user-provided HTML, restrict allowed markup with wp_kses_post() or wp_kses() before output.
wp_ajax_*, verify nonce and check capabilities.wp_ajax_nopriv_*, assume unauthenticated attacker-controlled traffic.wp_send_json_success() or wp_send_json_error().Common review guidance: