25% off ProSNIPC25OFF

Snippet library

PHP snippets for WordPress.

467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.

PHP

Remove PHP and Server Version Headers

Strips X-Powered-By, Server, and WordPress generator headers to reduce server fingerprinting exposure.

#fingerprinting#hardening#headers
PHP

Add Permissions-Policy Header

Sends a Permissions-Policy HTTP header to disable browser features (camera, microphone, geolocation, etc.) that the site does not need.

#browser#hardening#headers
PHP

Force HTTPS Redirect Site-Wide

Permanently redirects all non-HTTPS requests to their secure equivalent and adds an HSTS header.

#https#redirect#security
PHPPro

Change Login URL Slug

Moves the login form to a custom URL slug and blocks direct access to wp-login.php to reduce credential-stuffing exposure.

#hardening#login#security
PHPPro

Email-Code Two-Factor for Admins

After a successful password login, administrator accounts receive a one-time email code that must be entered before the session is granted.

#2fa#admin#authentication
PHPPro

Restrict Admin Access by Country

Geo-blocks wp-admin access, allowing only logins from a configurable list of country codes, with a transient-cached IP lookup.

#access-control#admin#geo-blocking
PHPPro

Restrict wp-admin by IP Allowlist

Blocks access to the WordPress admin dashboard from any IP address not in the configured allowlist.

#access-control#admin#ip-allowlist
PHPPro

Lock Account After Failed Logins

Temporarily blocks a username/IP combination after a configurable number of failed logins and emails the site admin.

#brute-force#lockout#login
PHPPro

Enforce Strong Password Policy

Requires passwords to contain uppercase, lowercase, a digit, and a special character before the profile can be saved.

#complexity#passwords#security
PHPPro

Force Minimum Password Length

Rejects passwords shorter than a configurable minimum when a user saves their profile.

#authentication#passwords#security
PHP

Disable Application Passwords

Turns off WordPress's built-in application password feature to reduce the API attack surface.

#authentication#hardening#rest-api
PHP

Recent Posts With Thumbnails Shortcode

Shortcode [recent_posts_thumbs] that outputs a configurable list of recent posts with featured image thumbnails and dates.

#posts#recent-posts#shortcode
PHP

Register a Custom Sidebar Widget Area

Registers a new named widget area that can be displayed anywhere via dynamic_sidebar() or a shortcode.

#admin#customization#sidebar
PHP

Disable Remote Pattern Directory

Prevents WordPress from loading block patterns from the remote WordPress.org pattern directory, improving editor load time.

#admin#gutenberg#patterns
PHPPro

Register a Custom Block Pattern

Registers a reusable block pattern category and a hero CTA layout pattern available in the block inserter.

#admin#editor#gutenberg
PHPPro

Show Custom Fonts in Block Editor

Loads a custom font from Google Fonts into the block editor and applies it to the editor canvas to match frontend typography.

#admin#editor#fonts
PHPPro

Register a Block Style Variation

Registers additional style variations for core blocks so editors can pick alternate visual treatments in the block toolbar.

#admin#block-styles#customization
PHPPro

Add Custom Editor Font Sizes

Defines a typographic scale in the block editor and disables arbitrary font-size input to keep sizing consistent.

#admin#editor#font-sizes
PHPPro

Add Custom Editor Color Palette

Registers a brand color palette in the block editor and disables the free-form color picker to enforce consistency.

#admin#branding#colors
PHPPro

Disable Specific Gutenberg Blocks

Removes a configurable list of core blocks from the block inserter so editors cannot add them.

#admin#blocks#customization
PHP

Enable Classic Widgets

Restores the legacy Widgets screen and Customizer widget panel, disabling the block-based widget editor.

#admin#classic-editor#gutenberg
PHP

Custom Admin Dashboard Notice

Displays a custom information notice on the Dashboard page for editors so they see a welcome message on login.

#admin#dashboard#editors
PHP

Hide Admin Notices for Non-Admins

Suppresses all admin notice banners for non-administrator users to keep the dashboard clean for clients.

#admin#client#notices
PHP

Hide Screen Options and Help Tabs

Removes the Screen Options dropdown and all Help tab panels from wp-admin for non-administrator users.

#admin#cleanup#help