Code Snippets
Recent Code Snippets
Stop WordPress sending anything but essential data during the update check
The code snippet defines a PHP function called wp_update_privacy that modifies the query by unsetting specific elements. It then uses the add_action function to connect wp_update_privacy to the core_version_check_query_args action hook. This allows for privacy-related updates within the WordPress platform.
January 30, 2023
Get all Metakeys
PHPfunction get_all_meta_keys(){ global $wpdb; $table = $wpdb->prefix . 'postmeta'; $results = $wpdb->get_results("SELECT DISTINCT meta_key FROM $table;"); var_dump($results); }
January 30, 2023
PostmarkApp Headers for Gravity Forms
PHP/** * Postmark Headers for Gravity Forms. * * @param [type] $email Email. * @param [type] $message_format Message Format. *…
January 30, 2023
WP Config Constants
The given PHP content includes various WordPress configuration settings, including memory limits, database repair, URLs, file paths, cookies, debugging, SSL, cron, updates, languages, trash, developer tools, and recovery mode. It also addresses themes, fatal error handling, and email notifications. These settings help in fine-tuning WordPress for optimal performance, security, and customization.
January 30, 2023
Add Woff Support to Divi
The code snippet adds custom MIME type support to WordPress using PHP. It includes functions to modify the array of MIME types, add custom font type support to Divi, and ensures PHPCS compliance. New MIME types such as OTF, WOFF, and WOFF2 are added with their respective MIME type declarations.
January 26, 2023
Optimizing dynamically-generated CSS
Source: http://aristath.github.io/blog/optimize-inline-css
January 26, 2023
Selectively Enable Gutenberg
This code snippet demonstrates how to enable or disable the Gutenberg editor in WordPress based on various conditions such as post IDs, post meta, categories, tags, and post types. Filters are used to control the editor’s availability, ensuring a customized editing experience in line with specific criteria.
January 20, 2023
Allow JSON Uploads to WordPress Media Library
Source: https://koop.sh/software/allow-json-uploads-to-wordpress-media-library/
October 4, 2022
WooCommerce – Custom Order Status
PHPadd_action( 'init', function() { register_post_status( 'wc-backorder', [ 'label' => 'On backorder', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true,…
September 26, 2022
Breadcrumbs
Start with Yoast SEO Breadcrumbs, but fallback to Jetpack. WooCommerce: Rename Home:
September 13, 2022