Skip to content

Instantly share code, notes, and snippets.

View undfine's full-sized avatar

Dustin W undfine

  • Wilmington, NC
View GitHub Profile
@undfine
undfine / pods-admin-gallery-styles.css
Created January 18, 2024 16:38
Image Gallery Field Styles for the PODS plugin for Wordpress
@undfine
undfine / extended-spam-query.sql
Last active December 28, 2023 01:02
SQL to remove spam entries from Gravity Forms entries
-- 1) Create a temporary table to store rows to delete
CREATE TEMPORARY TABLE `gf_spam_entries` AS
SELECT `entry_id`
FROM `wp_gf_entry_meta`
WHERE (
LENGTH(meta_value) > 700
OR LOWER(`meta_value`) REGEXP '^(http|\\<a href)'
OR `meta_value` REGEXP '[\\p{Cyrillic}]'
OR `meta_value` REGEXP 'http.+\\.(ru|cz|de|jp|bz|bx|php|asp|xyz|ua|tk|icu|bit\\.ly)'
OR LOWER(`meta_value`) REGEXP '([a-z0-9._%+-]+)@(.*\\.)?(ru|xy|xx|xv|cz|cc|de|xyz|bagat|[a-z]maill)'
/* Create underline effect */
.animated-underlines a{
position: relative;
}
.animated-underlines a::after {
content: '';
display: block;
width: 100%;
height: 1px;
@undfine
undfine / roundLargeNumbers.php
Last active December 11, 2023 21:44
a function to round large numbers (in millions and thousands) to decimals and add suffix "M" or "K"
<?php
function roundLargeNumber($number) {
if ($number >= 1000000) {
// If the number is in millions, round to 2 decimal points and append "M" suffix
return number_format($number / 1000000, 2) . 'M';
} elseif ($number >= 1000) {
// If the number is in thousands, round to 0 decimal points and append "K" suffix
return number_format($number / 1000, 0) . 'K';
} else {
// For smaller values, round to 2 decimal points without any suffix
@undfine
undfine / cf7-submit-event.js
Created December 7, 2023 22:48
GA4 event for successful Contact Form 7 submit
document.addEventListener( 'wpcf7mailsent', function( event ) {
// GA4 event with recommended standard dimensions
if ( 'detail' in event && typeof gtag !== 'undefined') {
var form_id = event.detail.contactFormId;
var form_name = '';
switch (form_id) {
case 1 : form_name = 'Form 1'; break; // change form_name to match use case of each cf7 id
case 8 : form_name = 'Form 8'; break;
@undfine
undfine / do_not_render_hidden_sections.php
Last active December 15, 2023 17:45
Prevent Elementor sections and containers from rendering on frontend if they are set to hide in all 3 responsive settings
<?php
/**
* prevent Elementor sections and containers from rendering on frontend if they are set to hide in all 3 responsive settings
*/
function do_not_render_hidden_sections( $should_render, $section ) {
// skip check if we are and editing
if ( is_admin() ) { return $should_render; }
$settings = $section->get_settings_for_display();
@undfine
undfine / woocommerce_filter_checkout_fields.php
Created September 26, 2023 20:02
Pre-populate Woocommerce checkout fields with info from URL parameters, stored in WC session
<?php
if ( !defined( 'ABSPATH' ) ) exit;
/** Store URL params as WC session data to later pre-fill checkout fields
*
* reference: https://www.businessbloomer.com/woocommerce-populate-checkout-from-url/
* https://stackoverflow.com/questions/50356459/pre-fill-woocommerce-checkout-fields-with-url-variables-saved-in-session/50357363#50357363
*/
add_action( 'template_redirect', 'PREFIX_wc_session__store_url_params' );
function PREFIX_wc_session__store_url_params() {
@undfine
undfine / multi_array_filter.php
Created August 11, 2023 18:45
Filter Multidimensional array to remove empty items
// remove any empty items in multidimensional array
function multi_array_filter($arr){
if ( is_array($arr) ){
$arr = array_map('multi_array_filter', $arr);
$arr = array_filter($arr);
}
return $arr;
}
@undfine
undfine / fluentform-submit-success-event.js
Last active July 1, 2026 17:44
Fluentforms Submit Success event for GA4 / GTM + Meta
jQuery(document).ready(function() {
jQuery(document).on('fluentform_submission_success', function( event ) {
if (typeof gtag !== 'undefined') {
gtag('event', 'form_submit_success', {
'form_name': 'Contact Form',
'form_id': event.target.name
});
} else {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
@undfine
undfine / simpleparallax-elementor.html
Last active May 19, 2023 13:27
SimpleParallax for Elementor
<script src="https://cdn.jsdelivr.net/npm/simple-parallax-js@5.6.2/dist/simpleParallax.min.js"></script>
<script>
var parallaxBg = document.querySelectorAll('.parallax-bg img');
new simpleParallax(parallaxBg, {
customWrapper: '.elementor-widget-container',
orientation: 'down',
scale: 1.25,
delay: 0.3,
transition: 'cubic-bezier(0,0,0,1)',
});