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 / observeElementAddedToDOM.js
Created April 30, 2024 18:02
JS - Observer for Elements added to the DOM
function observeElementAddedToDOM(elementId, callback) {
// Select the target node
var targetNode = document;
// Options for the observer (which mutations to observe)
var config = { childList: true, subtree: true };
// Callback function to execute when mutations are observed
var observerCallback = function(mutationsList, observer) {
for(var mutation of mutationsList) {
@undfine
undfine / pods_orderby_meta_value_num.php
Last active April 19, 2024 14:55 — forked from logoscreative/functions.php
Pods Shortcode orderby 'meta_value_num'
<?php
/**
* WordPress stores all meta fields as strings, which causes problems for ordering by numbers. When using Pods::find() directly, this issue can be addressed by casting the field as a decimal, as shown here: https://github.com/pods-framework/pods-code-library/blob/master/example/classes/Pods/find/examples/orderby-number.php
*
* In shortcodes, this strategy is not possible, as MySQL functions can not be used in the WordPress post editor. Instead, you can use the "pods_shortcode_findrecords_params" params filter, as shown below:
*/
/**
* Example to order by a price field properly.
*/
<?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; }
@undfine
undfine / custom-animations.css
Created February 29, 2024 16:07
Simplified Animations.css for Elementor
/*** Override default Animations.css ***/
@keyframes fadeInDown {
from { opacity: 0;transform: translate3d(0,-20px,0)}
to { opacity: 1; transform: none }
}
@keyframes fadeInLeft {
from { opacity: 0; transform: translate3d(-30%,0,0)}
@undfine
undfine / elementor-utilities.css
Created February 29, 2024 16:06
A few additional utility classes for Elementor elements
/*** .vh100 ***
* add this class to any elemtent to make it full-height
* (excluding address bar on mobile)
*/
.vh100{
height: 100vh;
max-height: 100svh;
}
@undfine
undfine / load-script.js
Created February 1, 2024 21:15
inject external script using JS
var script = document.createElement('script');
script.src = 'https://example.com/external-script.js';
script.async = true; // or script.defer = true; for defer attribute
document.body.appendChild(script);
@undfine
undfine / wp-admin-inline-styles.php
Last active January 18, 2024 16:41
Add Inline styles to admin backend on Wordpress
<?php
function custom_admin_styles() {
echo '<style> /*...*/ </style>';
}
add_action('admin_head', 'custom_admin_styles', 99);
// Alternate to hook in post-edit screen
//add_action('admin_head-post.php', 'custom_admin_styles', 99);
@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;