WordPress Code Snippets
A collection of WordPress PHP snippets. Every page documents one snippet: what it does, its version, its type, and its status.
The snippets were originally written for WP Codebox, but each one works the same as a mu-plugin, a plugin, or an entry in any snippet manager. Start with installing a snippet if you are new here, and read the header contract if you are adding one.
50 snippets in 21 categories. Each page lists the version, type and status, and links to the source file.
ACF
| Snippet | Version | Type | Status |
|---|---|---|---|
| ACF Pull Contact Form Name IDs into Select Field | 1.0.0 | snippet | ✅ |
Admin
| Snippet | Version | Type | Status |
|---|---|---|---|
| Change Admin Email | 1.0.0 | mu-plugin | ✅ |
| Disable WooCommerce Checkout & Restrict Logins to Admins | 1.0.0 | mu-plugin | ✅ |
| Log Admin Notices | 1.0.0 | snippet | ✅ |
| Menu Shortcode | 1.0.0 | snippet | 🚧 |
| WP Admin Login Message | 1.0.0 | mu-plugin | ✅ |
Ajax Log
| Snippet | Version | Type | Status |
|---|---|---|---|
| Ajax Logger | 1.0.0 | mu-plugin | ✅ |
Blocks
| Snippet | Version | Type | Status |
|---|---|---|---|
| Email Subscribe Block | 1.0 | plugin | ✅ |
| Footer Navigation Block | 1.0.0 | plugin | ✅ |
BuddyBoss
| Snippet | Version | Type | Status |
|---|---|---|---|
| BBP WPAL Filters | 1.0.1 | mu-plugin | ✅ |
Caching
| Snippet | Version | Type | Status |
|---|---|---|---|
| disable-lscache-notice.php | 1.0.0 | snippet | 🚧 |
| disable-plugin-updates.php | 1.0.0 | snippet | ✅ |
| Disable WP Rocket Cache when Litespeed Cache is enabled. | 0.2.0 | mu-plugin | ✅ |
| Disable WP Rocket Cache Preload | 0.1.0 | mu-plugin | ✅ |
| nginx-gravity-forms-stripe-cache-exclude.php | 1.0.0 | snippet | ✅ |
| nginx-helper-purge-schedule.php | 1.0.0 | snippet | ✅ |
Core
| Snippet | Version | Type | Status |
|---|---|---|---|
| Block HTTP Requests to a list of URLs | 0.1.0 | snippet | ✅ |
| enable-core-updates-version-control.php | 1.0.0 | mu-plugin | ✅ |
Debug
| Snippet | Version | Type | Status |
|---|---|---|---|
| log-hook-calls.php | 1.0.0 | mu-plugin | ✅ |
| PHP Memory Info | 1.0 | mu-plugin | ✅ |
| show-browser-cookies.php | 1.0.0 | snippet | ✅ |
| Application Logs | 1.0 | snippet | ✅ |
| Show Server IP in Admin | 1.0.0 | snippet | ✅ |
| WP Redirect Log | 1.0.1 | mu-plugin | ✅ |
Development
| Snippet | Version | Type | Status |
|---|---|---|---|
| staging-environment.php | 1.0.0 | Snippet | ✅ |
General
| Snippet | Version | Type | Status |
|---|---|---|---|
| MU Shortcode: SVG QR for Current URL | 1.0.0 | Snippet | ✅ |
| Updated Content Report | 1.0.0 | mu-plugin | ✅ |
Mail
| Snippet | Version | Type | Status |
|---|---|---|---|
| wp-mail-log-to-file.php | 1.0.0 | Snippet | ✅ |
| wp-mail-test.php | 1.0.0 | mu-plugin | ✅ |
Maintenance
| Snippet | Version | Type | Status |
|---|---|---|---|
| wp-maintenance-major.php | 1.0.0 | mu-plugin | ✅ |
| wp-maintenance-mode.php | 1.0.0 | mu-plugin | ✅ |
| wp-maintenance-mode2.php | 1.0.0 | mu-plugin | ✅ |
Monitoring
| Snippet | Version | Type | Status |
|---|---|---|---|
| betteruptime-heartbeat.php | 1.0.0 | mu-plugin | ✅ |
Multisite
| Snippet | Version | Type | Status |
|---|---|---|---|
| sunrise-subdomain-to-subdirectory-mapping.php | 1.0.0 | mu-plugin | ✅ |
Plugins
| Snippet | Version | Type | Status |
|---|---|---|---|
| Gravity Forms Notifications as Text not HTML | 0.1.0 | snippet | ✅ |
| Podcast Download Canonical Guard | 0.1.0 | snippet | ✅ |
| PowerKit SVG Lazyload Fix | 1.0.0 | mu-plugin | ✅ |
| redirection-search-replace.php | 1.0.0 | script | ✅ |
| Simple Membership Members Per Page | 1.0 | script | ✅ |
| Ultimo Custom Domain Edits | 1.0 | snippet | ✅ |
Shortcodes
| Snippet | Version | Type | Status |
|---|---|---|---|
| Prayer Times | 1.0.2 | mu-plugin | ✅ |
Tests
| Snippet | Version | Type | Status |
|---|---|---|---|
| test-open-tcp-ports.php | 1.0.0 | mu-plugin | ✅ |
Theme
| Snippet | Version | Type | Status |
|---|---|---|---|
| SAL.js Scroll Animations | 1.0.0 | Snippet | ✅ |
| post-title-permalink.php | 1.0.0 | Snippet | ✅ |
Ultimo
| Snippet | Version | Type | Status |
|---|---|---|---|
| WP Ultimo API Fix | 0.1.0 | snippet | ✅ |
WooCommerce
| Snippet | Version | Type | Status |
|---|---|---|---|
| WooCommerce Gateway ID Column | 2.1.0 | mu-plugin | ✅ |
| woo-commerce-hide-costofgoodssold-metadata.php | 1.0.0 | snippet | ✅ |
| woocommerce-order-search-in-admin-bar.php | 1.0.0 | Snippet | ✅ |
| woocommerce-wc_product_loop_transient-expiration-to-1-day.php | 1.0.0 | snippet | ✅ |
WP Failover
| Snippet | Version | Type | Status |
|---|---|---|---|
| Failover Status Monitor | 1.1.0 | mu-plugin | ✅ |