Skip to content

managingwp/wordpress-code-snippets

Repository files navigation

wordpress-code-snippets

A collection of WordPress PHP code snippets.

The original intent was for use in WP Codebox, but they can be used in any WordPress theme, plugin or as a mu-plugin.

Status Field

The status field is used to indicate the current status of the snippet. This is useful for tracking the progress of a snippet. The following statuses are used:

  • Complete - ✔️
  • WIP - 🚧
  • Unknown - ❓
  • Broken - ❌

Minor Snippets

Title Type Status Description
acf-pull-contact-form-name-ids.php snippet Pull Contact Form 6 form name and ID's into a select field called form_id dynamically.
Title Type Status Description
Change Admin Email mu-plugin Changes the admin email address if it hasn't been changed already without triggering email validation.
log-admin-notices.php snippet Log's admin notices on admin_init, great for finding admin_notices to hide.
mu-dashboard-shortcode.php snippet 🚧 Unsure what the usage of this snippet is.
Title Type Status Description
Ajax Logger Plugin Record all admin_init requests to troubleshoot high admin-ajax.php requests.
Title Type Status Description
BBP WPAL Filters Plugin BuddyBoss Platform Filters to improve page speed.
Title Type Status Description
disable-lscache-notice.php snippet 🚧 Disables the admin notice Litespeeds LSCache generates about conflicting plugins installed
disable-plugin-updates.php snippet Remove plugin update notices
nginx-gravity-forms-stripe-cache-exclude.php snippet Exclude Gravity Forms or Stripe from caching
Title Type Status Description
enable-core-updates-version-control.php Plugin Filters whether the automatic updater should consider a filesystem location to be potentially managed by a version control system.
Title Type Status Description
log-hook-calls.php Plugin Log all hook calls to a file
show-browser-cookies.php snippet * Description Shows your browsers cookies
Application Logs Plugin Displays top 10 lines from a log file in the WordPress admin section.
Title Type Status Description
staging-environment.php Snippet This snippet will enable and disable plugins based on the WP_ENVIRONMENT_TYPE
Title Type Status Description
wp-mail-log-to-file.php Plugin Log wp_mail function to a file
wp-mail-test.php Plugin Used to send a test email to test the wp_mail function.
Title Type Status Description
wp-maintenance-mode.php Plugin Maintenance mode for WordPress - Originally from https://wordpress.stackexchange.com/questions/398037/maintenance-mode-excluding-site-administrators
wp-maintenance-mode2.php Plugin This plugin displays a maintenance message for non-administrative users.
Title Type Status Description
betteruptime-heartbeat.php Plugin Monitor WordPress cron via Better Uptime heartbeat checks. Originally from https://www.sprucely.net/knowledge-base/monitoring-wordpress-cron-via-heartbeat-checks/
Title Type Status Description
sunrise-subdomain-to-subdirectory-mapping.php Plugin Redirect domain names to multisite subdirectories and include query arguments in the redirect.
Title Type Status Description
redirection-search-replace.php script This script has two objectives, replace redirection_items and update
Ultimo Custom Domain Edits Plugin Custom Domain Edits for Ultimo
Title Type Status Description
check-ports.php Plugin Original created to test if ports are open outbound on hosting providers to be able to send tranational email
Title Type Status Description
post-title-permalink.php Snippet This code will add a link to the title of the post, so that the title is clickable.
Title Type Status Description
woocommerce-hide-costofgoodssold-metadata.php snippet Hides item metadata for the WooCommerce Costs of Goods Sold on specific Booster for WooCommerce plugin shortcodes
woocommerce-order-search-in-admin-bar.php Snippet Add shop order search in the admin bar
woocommerce-wc_product_loop_transient-expiration-to-1-day.php snippet Change wc_product_loop transient expiration to 1 day
Title Type Status Description
Failover Status Monitor Plugin Monitors failover status and provides notifications.