WPCodeBox2 — Code Snippets
Overview
WPCodeBox2 manages custom PHP, CSS, JavaScript, and HTML snippets outside the theme's functions.php. Snippets are stored in the wp_wpcb_snippets database table.
Active Snippets
Opshell Contact Form Shortcode
ID: 1 | Type: PHP | Hook: Custom Root
Registers the [opshell_contact_form] shortcode. Handles the full contact form lifecycle: rendering, honeypot spam detection, Turnstile verification, Reoon email verification, CSV storage, and email notifications.
Code Management
- Snippets run at
custom_root(loaded on every page) - PHP snippets are stored as
longtextin the database - Conditional execution via WPCodeBox2 conditions (page URL, user role, etc.)
- Snippets can be enabled/disabled individually
- Revisions are stored in
wp_wpcb_snippets_ai_backup
Best Practices
- Use custom root for site-wide PHP functionality
- Use hook-specific snippets for targeted execution (e.g.,
wp_enqueue_scriptsfor assets) - Keep snippets focused on a single responsibility
- Test snippet changes in staging before enabling on production
- Document snippet purpose, dependencies, and modification history