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 / hubspot-form-a11y-polyfill.js
Created August 14, 2024 17:23 — forked from derekcavaliero/hubspot-form-a11y-polyfill.js
HubSpot Embedded Form Accessibility Polyfills
/**
* HubSpot Embedded Form Accessibility Pollyfills
*
* This script fixes the HubSpot HTML blunders that make their embedded forms inaccessible for assistive technology.
* - Replaces/removes improper use of <fieldset>, <legend>, <label>, and role attributes.
* - Note - this can cause forms configured for mulitple column field layouts to break - you will need to adjust your CSS accordingly.
**/
hubspotFormA11y = {
@undfine
undfine / arrayToObject.js
Created August 10, 2024 16:41
Convert array of objects to a single object
function arrayToObject(arr) {
return arr.reduce((acc, curr) => {
acc[curr.name] = curr.value;
return acc;
}, {});
}
// Example usage:
const inputArray = [
{ name: "firstName", value: "John" },
@undfine
undfine / elementor_password_form_page.php
Created June 6, 2024 23:13
Custom Password Protected page with Elementor Template
function elementor_password_form_page() {
// Elementor Template ID
$template_id = 3785; // Replace with your Elementor template ID
// Check if Elementor is active and the template exists
if (defined('ELEMENTOR_VERSION') && \Elementor\Plugin::$instance->templates_manager->get_source('local')->get_item($template_id)) {
// Render the Elementor template
return \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($template_id, true);
}
@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 cliffseal/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);